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 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 53 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 54 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 55 | GLsizei numPaths, |
| 56 | const void *paths, |
| 57 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 58 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 59 | std::vector<Path *> ret; |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 60 | ret.reserve(numPaths); |
| 61 | |
| 62 | const auto *nameArray = static_cast<const T *>(paths); |
| 63 | |
| 64 | for (GLsizei i = 0; i < numPaths; ++i) |
| 65 | { |
| 66 | const GLuint pathName = nameArray[i] + pathBase; |
| 67 | |
| 68 | ret.push_back(resourceManager.getPath(pathName)); |
| 69 | } |
| 70 | |
| 71 | return ret; |
| 72 | } |
| 73 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 74 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 75 | GLsizei numPaths, |
| 76 | GLenum pathNameType, |
| 77 | const void *paths, |
| 78 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 79 | { |
| 80 | switch (pathNameType) |
| 81 | { |
| 82 | case GL_UNSIGNED_BYTE: |
| 83 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 84 | |
| 85 | case GL_BYTE: |
| 86 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 87 | |
| 88 | case GL_UNSIGNED_SHORT: |
| 89 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 90 | |
| 91 | case GL_SHORT: |
| 92 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 93 | |
| 94 | case GL_UNSIGNED_INT: |
| 95 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 96 | |
| 97 | case GL_INT: |
| 98 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 99 | } |
| 100 | |
| 101 | UNREACHABLE(); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 102 | return std::vector<Path *>(); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 106 | angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 107 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 108 | ASSERT(query != nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 109 | |
| 110 | switch (pname) |
| 111 | { |
| 112 | case GL_QUERY_RESULT_EXT: |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 113 | return query->getResult(context, params); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 114 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 115 | { |
| 116 | bool available; |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 117 | ANGLE_TRY(query->isResultAvailable(context, &available)); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 118 | *params = CastFromStateValue<T>(pname, static_cast<GLuint>(available)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 119 | return angle::Result::Continue; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 120 | } |
| 121 | default: |
| 122 | UNREACHABLE(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 123 | return angle::Result::Stop; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 127 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 128 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 129 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 130 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 131 | } |
| 132 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 133 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 134 | { |
| 135 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 136 | } |
| 137 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 138 | Version GetClientVersion(const egl::AttributeMap &attribs) |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 139 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 140 | return Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 141 | } |
| 142 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 143 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 144 | { |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 145 | EGLAttrib attrib = |
| 146 | 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] | 147 | switch (attrib) |
| 148 | { |
| 149 | case EGL_NO_RESET_NOTIFICATION: |
| 150 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 151 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 152 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 153 | default: |
| 154 | UNREACHABLE(); |
| 155 | return GL_NONE; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 160 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 161 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || |
| 162 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != |
| 163 | 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | bool GetDebug(const egl::AttributeMap &attribs) |
| 167 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 168 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || |
| 169 | ((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] | 170 | } |
| 171 | |
| 172 | bool GetNoError(const egl::AttributeMap &attribs) |
| 173 | { |
| 174 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 175 | } |
| 176 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 177 | bool GetWebGLContext(const egl::AttributeMap &attribs) |
| 178 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 179 | return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 180 | } |
| 181 | |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 182 | bool GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext) |
| 183 | { |
| 184 | // If the context is WebGL, extensions are disabled by default |
| 185 | EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE; |
| 186 | return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE); |
| 187 | } |
| 188 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 189 | bool GetBindGeneratesResource(const egl::AttributeMap &attribs) |
| 190 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 191 | 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] | 192 | } |
| 193 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 194 | bool GetClientArraysEnabled(const egl::AttributeMap &attribs) |
| 195 | { |
| 196 | return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE); |
| 197 | } |
| 198 | |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 199 | bool GetRobustResourceInit(const egl::AttributeMap &attribs) |
| 200 | { |
| 201 | return (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE); |
| 202 | } |
| 203 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 204 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 205 | { |
| 206 | std::string labelName; |
| 207 | if (label != nullptr) |
| 208 | { |
| 209 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 210 | labelName = std::string(label, labelLength); |
| 211 | } |
| 212 | return labelName; |
| 213 | } |
| 214 | |
| 215 | void GetObjectLabelBase(const std::string &objectLabel, |
| 216 | GLsizei bufSize, |
| 217 | GLsizei *length, |
| 218 | GLchar *label) |
| 219 | { |
| 220 | size_t writeLength = objectLabel.length(); |
| 221 | if (label != nullptr && bufSize > 0) |
| 222 | { |
| 223 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 224 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 225 | label[writeLength] = '\0'; |
| 226 | } |
| 227 | |
| 228 | if (length != nullptr) |
| 229 | { |
| 230 | *length = static_cast<GLsizei>(writeLength); |
| 231 | } |
| 232 | } |
| 233 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 234 | template <typename CapT, typename MaxT> |
| 235 | void LimitCap(CapT *cap, MaxT maximum) |
| 236 | { |
| 237 | *cap = std::min(*cap, static_cast<CapT>(maximum)); |
| 238 | } |
| 239 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 240 | // The rest default to false. |
| 241 | constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMode>() + 1> |
| 242 | kValidBasicDrawModes = {{ |
| 243 | {PrimitiveMode::Points, true}, |
| 244 | {PrimitiveMode::Lines, true}, |
| 245 | {PrimitiveMode::LineLoop, true}, |
| 246 | {PrimitiveMode::LineStrip, true}, |
| 247 | {PrimitiveMode::Triangles, true}, |
| 248 | {PrimitiveMode::TriangleStrip, true}, |
| 249 | {PrimitiveMode::TriangleFan, true}, |
| 250 | }}; |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 251 | |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 252 | enum SubjectIndexes : angle::SubjectIndex |
| 253 | { |
| 254 | kTexture0SubjectIndex = 0, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 255 | kTextureMaxSubjectIndex = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
Qin Jiajia | 3f01f53 | 2018-12-11 15:13:51 +0800 | [diff] [blame] | 256 | kUniformBuffer0SubjectIndex = kTextureMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 257 | kUniformBufferMaxSubjectIndex = |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 258 | kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 259 | kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 260 | kSamplerMaxSubjectIndex = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 261 | kVertexArraySubjectIndex = kSamplerMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 262 | kReadFramebufferSubjectIndex, |
| 263 | kDrawFramebufferSubjectIndex |
| 264 | }; |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 265 | } // anonymous namespace |
| 266 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 267 | Context::Context(rx::EGLImplFactory *implFactory, |
| 268 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 269 | const Context *shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 270 | TextureManager *shareTextures, |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 271 | MemoryProgramCache *memoryProgramCache, |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 272 | const egl::AttributeMap &attribs, |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 273 | const egl::DisplayExtensions &displayExtensions, |
| 274 | const egl::ClientExtensions &clientExtensions) |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 275 | : mState(reinterpret_cast<ContextID>(this), |
| 276 | shareContext ? &shareContext->mState : nullptr, |
| 277 | shareTextures, |
| 278 | GetClientVersion(attribs), |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 279 | GetDebug(attribs), |
| 280 | GetBindGeneratesResource(attribs), |
| 281 | GetClientArraysEnabled(attribs), |
| 282 | GetRobustResourceInit(attribs), |
| 283 | memoryProgramCache != nullptr), |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 284 | mSkipValidation(GetNoError(attribs)), |
| 285 | mDisplayTextureShareGroup(shareTextures != nullptr), |
Jamie Madill | 0c66721 | 2019-01-01 14:40:36 -0500 | [diff] [blame] | 286 | mErrors(this), |
| 287 | mImplementation(implFactory->createContext(mState, &mErrors, config, shareContext, attribs)), |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 288 | mLabel(nullptr), |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 289 | mCompiler(), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 290 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 291 | mClientType(EGL_OPENGL_ES_API), |
| 292 | mHasBeenCurrent(false), |
| 293 | mContextLost(false), |
| 294 | mResetStatus(GL_NO_ERROR), |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 295 | mContextLostForced(false), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 296 | mResetStrategy(GetResetStrategy(attribs)), |
| 297 | mRobustAccess(GetRobustAccess(attribs)), |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 298 | mSurfacelessSupported(displayExtensions.surfacelessContext), |
| 299 | mExplicitContextAvailable(clientExtensions.explicitContext), |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 300 | mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), |
| 301 | mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 302 | mWebGLContext(GetWebGLContext(attribs)), |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame] | 303 | mBufferAccessValidationEnabled(false), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 304 | mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 305 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 306 | mVertexArrayObserverBinding(this, kVertexArraySubjectIndex), |
| 307 | mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex), |
| 308 | mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 309 | mScratchBuffer(1000u), |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 310 | mZeroFilledBuffer(1000u), |
| 311 | mThreadPool(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 312 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 313 | for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; |
| 314 | uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) |
| 315 | { |
| 316 | mUniformBufferObserverBindings.emplace_back(this, uboIndex); |
| 317 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 318 | |
| 319 | for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex; |
| 320 | samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex) |
| 321 | { |
| 322 | mSamplerObserverBindings.emplace_back(this, samplerIndex); |
| 323 | } |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 324 | } |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 325 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 326 | void Context::initialize() |
| 327 | { |
| 328 | mImplementation->setMemoryProgramCache(mMemoryProgramCache); |
Jamie Madill | 14bbb3f | 2017-09-12 15:23:01 -0400 | [diff] [blame] | 329 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 330 | initCaps(); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 331 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 332 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 333 | mState.initialize(this); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 334 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 335 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 336 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 337 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 338 | // 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] | 339 | // and cube map texture state vectors respectively associated with them. |
| 340 | // In order that access to these initial textures not be lost, they are treated as texture |
| 341 | // objects all of whose names are 0. |
| 342 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 343 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, TextureType::_2D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 344 | mZeroTextures[TextureType::_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 345 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 346 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, TextureType::CubeMap); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 347 | mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 348 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 349 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 350 | { |
| 351 | // TODO: These could also be enabled via extension |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 352 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, TextureType::_3D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 353 | mZeroTextures[TextureType::_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 354 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 355 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, TextureType::_2DArray); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 356 | mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 357 | } |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 358 | if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample) |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 359 | { |
| 360 | Texture *zeroTexture2DMultisample = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 361 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisample); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 362 | mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample); |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 363 | } |
| 364 | if (getClientVersion() >= Version(3, 1)) |
| 365 | { |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 366 | Texture *zeroTexture2DMultisampleArray = |
| 367 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisampleArray); |
| 368 | mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 369 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 370 | for (unsigned int i = 0; i < mState.mCaps.maxAtomicCounterBufferBindings; i++) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 371 | { |
Qin Jiajia | 339f65b | 2018-02-27 12:52:48 +0800 | [diff] [blame] | 372 | bindBufferRange(BufferBinding::AtomicCounter, i, 0, 0, 0); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 373 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 374 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 375 | for (unsigned int i = 0; i < mState.mCaps.maxShaderStorageBufferBindings; i++) |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 376 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 377 | bindBufferRange(BufferBinding::ShaderStorage, i, 0, 0, 0); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 378 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 379 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 380 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 381 | if (mSupportedExtensions.textureRectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 382 | { |
| 383 | Texture *zeroTextureRectangle = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 384 | new Texture(mImplementation.get(), 0, TextureType::Rectangle); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 385 | mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 386 | } |
| 387 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 388 | if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal) |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 389 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 390 | Texture *zeroTextureExternal = new Texture(mImplementation.get(), 0, TextureType::External); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 391 | mZeroTextures[TextureType::External].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 392 | } |
| 393 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 394 | mState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 395 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 396 | bindVertexArray(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 397 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 398 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 399 | { |
| 400 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 401 | // In the initial state, a default transform feedback object is bound and treated as |
| 402 | // a transform feedback object with a name of zero. That object is bound any time |
| 403 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 404 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 405 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 406 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 407 | for (auto type : angle::AllEnums<BufferBinding>()) |
| 408 | { |
| 409 | bindBuffer(type, 0); |
| 410 | } |
| 411 | |
| 412 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 413 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 414 | for (unsigned int i = 0; i < mState.mCaps.maxUniformBufferBindings; i++) |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 415 | { |
| 416 | bindBufferRange(BufferBinding::Uniform, i, 0, 0, -1); |
| 417 | } |
| 418 | |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 419 | // Initialize GLES1 renderer if appropriate. |
| 420 | if (getClientVersion() < Version(2, 0)) |
| 421 | { |
| 422 | mGLES1Renderer.reset(new GLES1Renderer()); |
| 423 | } |
| 424 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 425 | // Initialize dirty bit masks |
Jamie Madill | 9d0bb3d | 2018-10-09 20:29:13 -0400 | [diff] [blame] | 426 | mAllDirtyBits.set(); |
| 427 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 428 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 429 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 430 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 431 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 432 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 433 | |
| 434 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 435 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 436 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 437 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 438 | |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 439 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 440 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 441 | // No dirty objects. |
| 442 | |
| 443 | // Readpixels uses the pack state and read FBO |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 444 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 445 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 446 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 447 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 448 | |
| 449 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 450 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 451 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 452 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 453 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 454 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 455 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 456 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 457 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 458 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 459 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 460 | mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 461 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 462 | |
| 463 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 464 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 465 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 466 | mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 467 | mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 468 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 469 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 470 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 471 | mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 472 | mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS); |
| 473 | mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 474 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING); |
| 475 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 476 | mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS); |
| 477 | mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 478 | mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 479 | mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 480 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 481 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 482 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 483 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 484 | ANGLE_CONTEXT_TRY(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 485 | } |
| 486 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 487 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 488 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 489 | if (mGLES1Renderer) |
| 490 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 491 | mGLES1Renderer->onDestroy(this, &mState); |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Jamie Madill | e7b3fe2 | 2018-04-05 09:42:46 -0400 | [diff] [blame] | 494 | ANGLE_TRY(releaseSurface(display)); |
| 495 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 496 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 497 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 498 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 499 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 500 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 501 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 502 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 503 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 504 | if (query.second != nullptr) |
| 505 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 506 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 507 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 508 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 509 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 510 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 511 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 512 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 513 | if (vertexArray.second) |
| 514 | { |
| 515 | vertexArray.second->onDestroy(this); |
| 516 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 517 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 518 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 519 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 520 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 521 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 522 | if (transformFeedback.second != nullptr) |
| 523 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 524 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 525 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 526 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 527 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 528 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 529 | for (BindingPointer<Texture> &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 530 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 531 | if (zeroTexture.get() != nullptr) |
| 532 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 533 | zeroTexture.set(this, nullptr); |
| 534 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 535 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 536 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 537 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 538 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 539 | mState.reset(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 540 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 541 | mState.mBufferManager->release(this); |
| 542 | mState.mShaderProgramManager->release(this); |
| 543 | mState.mTextureManager->release(this); |
| 544 | mState.mRenderbufferManager->release(this); |
| 545 | mState.mSamplerManager->release(this); |
| 546 | mState.mSyncManager->release(this); |
| 547 | mState.mPathManager->release(this); |
| 548 | mState.mFramebufferManager->release(this); |
| 549 | mState.mProgramPipelineManager->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 550 | |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 551 | mThreadPool.reset(); |
| 552 | |
Jamie Madill | 76e471e | 2017-10-21 09:56:01 -0400 | [diff] [blame] | 553 | mImplementation->onDestroy(this); |
| 554 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 555 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 558 | Context::~Context() {} |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 559 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 560 | void Context::setLabel(EGLLabelKHR label) |
| 561 | { |
| 562 | mLabel = label; |
| 563 | } |
| 564 | |
| 565 | EGLLabelKHR Context::getLabel() const |
| 566 | { |
| 567 | return mLabel; |
| 568 | } |
| 569 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 570 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 571 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 572 | mCurrentDisplay = display; |
| 573 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 574 | if (!mHasBeenCurrent) |
| 575 | { |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 576 | initialize(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 577 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 578 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 579 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 580 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 581 | int width = 0; |
| 582 | int height = 0; |
| 583 | if (surface != nullptr) |
| 584 | { |
| 585 | width = surface->getWidth(); |
| 586 | height = surface->getHeight(); |
| 587 | } |
| 588 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 589 | mState.setViewportParams(0, 0, width, height); |
| 590 | mState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 591 | |
| 592 | mHasBeenCurrent = true; |
| 593 | } |
| 594 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 595 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 596 | mState.setAllDirtyBits(); |
| 597 | mState.setAllDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 598 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 599 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 600 | |
| 601 | Framebuffer *newDefault = nullptr; |
| 602 | if (surface != nullptr) |
| 603 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 604 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 605 | mCurrentSurface = surface; |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 606 | newDefault = surface->createDefaultFramebuffer(this); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 607 | } |
| 608 | else |
| 609 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 610 | newDefault = new Framebuffer(mImplementation.get()); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 611 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 612 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 613 | // Update default framebuffer, the binding of the previous default |
| 614 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 615 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 616 | mState.mFramebufferManager->setDefaultFramebuffer(newDefault); |
| 617 | if (mState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 618 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 619 | bindReadFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 620 | } |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 621 | if (mState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 622 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 623 | bindDrawFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 624 | } |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 625 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 626 | |
Jamie Madill | 32643ce | 2018-10-19 11:38:03 -0400 | [diff] [blame] | 627 | // Notify the renderer of a context switch. |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 628 | return angle::ResultToEGL(mImplementation->onMakeCurrent(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 629 | } |
| 630 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 631 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 632 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 633 | gl::Framebuffer *defaultFramebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 634 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 635 | // Remove the default framebuffer |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 636 | if (mState.getReadFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 637 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 638 | mState.setReadFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 639 | mReadFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 640 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 641 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 642 | if (mState.getDrawFramebuffer() == 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.setDrawFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 645 | mDrawFramebufferObserverBinding.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 | |
| 648 | if (defaultFramebuffer) |
| 649 | { |
| 650 | defaultFramebuffer->onDestroy(this); |
| 651 | delete defaultFramebuffer; |
| 652 | } |
| 653 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 654 | mState.mFramebufferManager->setDefaultFramebuffer(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 655 | |
| 656 | if (mCurrentSurface) |
| 657 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 658 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 659 | mCurrentSurface = nullptr; |
| 660 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 661 | |
| 662 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 663 | } |
| 664 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 665 | GLuint Context::createBuffer() |
| 666 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 667 | return mState.mBufferManager->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | GLuint Context::createProgram() |
| 671 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 672 | return mState.mShaderProgramManager->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 673 | } |
| 674 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 675 | GLuint Context::createShader(ShaderType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 676 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 677 | return mState.mShaderProgramManager->createShader(mImplementation.get(), mState.mLimitations, |
| 678 | type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | GLuint Context::createTexture() |
| 682 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 683 | return mState.mTextureManager->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | GLuint Context::createRenderbuffer() |
| 687 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 688 | return mState.mRenderbufferManager->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 689 | } |
| 690 | |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 691 | void Context::tryGenPaths(GLsizei range, GLuint *createdOut) |
| 692 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 693 | ANGLE_CONTEXT_TRY(mState.mPathManager->createPaths(this, range, createdOut)); |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 694 | } |
| 695 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 696 | GLuint Context::genPaths(GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 697 | { |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 698 | GLuint created = 0; |
| 699 | tryGenPaths(range, &created); |
| 700 | return created; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 701 | } |
| 702 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 703 | // Returns an unused framebuffer name |
| 704 | GLuint Context::createFramebuffer() |
| 705 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 706 | return mState.mFramebufferManager->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 707 | } |
| 708 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 709 | void Context::genFencesNV(GLsizei n, GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 710 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 711 | for (int i = 0; i < n; i++) |
| 712 | { |
| 713 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
| 714 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
| 715 | fences[i] = handle; |
| 716 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 717 | } |
| 718 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 719 | GLuint Context::createProgramPipeline() |
| 720 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 721 | return mState.mProgramPipelineManager->createProgramPipeline(); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 722 | } |
| 723 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 724 | GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 725 | { |
| 726 | UNIMPLEMENTED(); |
| 727 | return 0u; |
| 728 | } |
| 729 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 730 | void Context::deleteBuffer(GLuint bufferName) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 731 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 732 | Buffer *buffer = mState.mBufferManager->getBuffer(bufferName); |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 733 | if (buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 734 | { |
| 735 | detachBuffer(buffer); |
| 736 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 737 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 738 | mState.mBufferManager->deleteObject(this, bufferName); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | void Context::deleteShader(GLuint shader) |
| 742 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 743 | mState.mShaderProgramManager->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | void Context::deleteProgram(GLuint program) |
| 747 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 748 | mState.mShaderProgramManager->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | void Context::deleteTexture(GLuint texture) |
| 752 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 753 | if (mState.mTextureManager->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 754 | { |
| 755 | detachTexture(texture); |
| 756 | } |
| 757 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 758 | mState.mTextureManager->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 762 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 763 | if (mState.mRenderbufferManager->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 764 | { |
| 765 | detachRenderbuffer(renderbuffer); |
| 766 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 767 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 768 | mState.mRenderbufferManager->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 769 | } |
| 770 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 771 | void Context::deleteSync(GLsync sync) |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 772 | { |
| 773 | // The spec specifies the underlying Fence object is not deleted until all current |
| 774 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 775 | // and since our API is currently designed for being called from a single thread, we can delete |
| 776 | // the fence immediately. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 777 | mState.mSyncManager->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 778 | } |
| 779 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 780 | void Context::deleteProgramPipeline(GLuint pipeline) |
| 781 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 782 | if (mState.mProgramPipelineManager->getProgramPipeline(pipeline)) |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 783 | { |
| 784 | detachProgramPipeline(pipeline); |
| 785 | } |
| 786 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 787 | mState.mProgramPipelineManager->deleteObject(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 788 | } |
| 789 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 790 | void Context::deletePaths(GLuint first, GLsizei range) |
| 791 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 792 | mState.mPathManager->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 793 | } |
| 794 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 795 | bool Context::isPath(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 796 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 797 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 798 | if (pathObj == nullptr) |
| 799 | return false; |
| 800 | |
| 801 | return pathObj->hasPathData(); |
| 802 | } |
| 803 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 804 | bool Context::isPathGenerated(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 805 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 806 | return mState.mPathManager->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 807 | } |
| 808 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 809 | void Context::pathCommands(GLuint path, |
| 810 | GLsizei numCommands, |
| 811 | const GLubyte *commands, |
| 812 | GLsizei numCoords, |
| 813 | GLenum coordType, |
| 814 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 815 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 816 | auto *pathObject = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 817 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 818 | ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 819 | } |
| 820 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 821 | void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 822 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 823 | Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 824 | |
| 825 | switch (pname) |
| 826 | { |
| 827 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 828 | pathObj->setStrokeWidth(value); |
| 829 | break; |
| 830 | case GL_PATH_END_CAPS_CHROMIUM: |
| 831 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 832 | break; |
| 833 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 834 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 835 | break; |
| 836 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 837 | pathObj->setMiterLimit(value); |
| 838 | break; |
| 839 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 840 | pathObj->setStrokeBound(value); |
| 841 | break; |
| 842 | default: |
| 843 | UNREACHABLE(); |
| 844 | break; |
| 845 | } |
| 846 | } |
| 847 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 848 | void Context::pathParameteri(GLuint path, GLenum pname, GLint value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 849 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 850 | // TODO(jmadill): Should use proper clamping/casting. |
| 851 | pathParameterf(path, pname, static_cast<GLfloat>(value)); |
| 852 | } |
| 853 | |
| 854 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) |
| 855 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 856 | const Path *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 857 | |
| 858 | switch (pname) |
| 859 | { |
| 860 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 861 | *value = pathObj->getStrokeWidth(); |
| 862 | break; |
| 863 | case GL_PATH_END_CAPS_CHROMIUM: |
| 864 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 865 | break; |
| 866 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 867 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 868 | break; |
| 869 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 870 | *value = pathObj->getMiterLimit(); |
| 871 | break; |
| 872 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 873 | *value = pathObj->getStrokeBound(); |
| 874 | break; |
| 875 | default: |
| 876 | UNREACHABLE(); |
| 877 | break; |
| 878 | } |
| 879 | } |
| 880 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 881 | void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value) |
| 882 | { |
| 883 | GLfloat val = 0.0f; |
| 884 | getPathParameterfv(path, pname, value != nullptr ? &val : nullptr); |
| 885 | if (value) |
| 886 | *value = static_cast<GLint>(val); |
| 887 | } |
| 888 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 889 | void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 890 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 891 | mState.setPathStencilFunc(func, ref, mask); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 892 | } |
| 893 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 894 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 895 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 896 | if (mState.mFramebufferManager->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 897 | { |
| 898 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 899 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 900 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 901 | mState.mFramebufferManager->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 904 | void Context::deleteFencesNV(GLsizei n, const GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 905 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 906 | for (int i = 0; i < n; i++) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 907 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 908 | GLuint fence = fences[i]; |
| 909 | |
| 910 | FenceNV *fenceObject = nullptr; |
| 911 | if (mFenceNVMap.erase(fence, &fenceObject)) |
| 912 | { |
| 913 | mFenceNVHandleAllocator.release(fence); |
| 914 | delete fenceObject; |
| 915 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 916 | } |
| 917 | } |
| 918 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 919 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 920 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 921 | return mState.mBufferManager->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 922 | } |
| 923 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 924 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 925 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 926 | return mState.mRenderbufferManager->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 929 | Sync *Context::getSync(GLsync handle) const |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 930 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 931 | return mState.mSyncManager->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 932 | } |
| 933 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 934 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 935 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 936 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 937 | } |
| 938 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 939 | Sampler *Context::getSampler(GLuint handle) const |
| 940 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 941 | return mState.mSamplerManager->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 942 | } |
| 943 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 944 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 945 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 946 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 947 | } |
| 948 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 949 | ProgramPipeline *Context::getProgramPipeline(GLuint handle) const |
| 950 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 951 | return mState.mProgramPipelineManager->getProgramPipeline(handle); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 952 | } |
| 953 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 954 | gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 955 | { |
| 956 | switch (identifier) |
| 957 | { |
| 958 | case GL_BUFFER: |
| 959 | return getBuffer(name); |
| 960 | case GL_SHADER: |
| 961 | return getShader(name); |
| 962 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 963 | return getProgramNoResolveLink(name); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 964 | case GL_VERTEX_ARRAY: |
| 965 | return getVertexArray(name); |
| 966 | case GL_QUERY: |
| 967 | return getQuery(name); |
| 968 | case GL_TRANSFORM_FEEDBACK: |
| 969 | return getTransformFeedback(name); |
| 970 | case GL_SAMPLER: |
| 971 | return getSampler(name); |
| 972 | case GL_TEXTURE: |
| 973 | return getTexture(name); |
| 974 | case GL_RENDERBUFFER: |
| 975 | return getRenderbuffer(name); |
| 976 | case GL_FRAMEBUFFER: |
| 977 | return getFramebuffer(name); |
| 978 | default: |
| 979 | UNREACHABLE(); |
| 980 | return nullptr; |
| 981 | } |
| 982 | } |
| 983 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 984 | gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 985 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 986 | return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 987 | } |
| 988 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 989 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 990 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 991 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 992 | ASSERT(object != nullptr); |
| 993 | |
| 994 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 995 | object->setLabel(this, labelName); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 996 | |
| 997 | // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the |
| 998 | // specified object is active until we do this. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 999 | mState.setObjectDirty(identifier); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 1003 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1004 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1005 | ASSERT(object != nullptr); |
| 1006 | |
| 1007 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1008 | object->setLabel(this, labelName); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | void Context::getObjectLabel(GLenum identifier, |
| 1012 | GLuint name, |
| 1013 | GLsizei bufSize, |
| 1014 | GLsizei *length, |
| 1015 | GLchar *label) const |
| 1016 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1017 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1018 | ASSERT(object != nullptr); |
| 1019 | |
| 1020 | const std::string &objectLabel = object->getLabel(); |
| 1021 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1022 | } |
| 1023 | |
| 1024 | void Context::getObjectPtrLabel(const void *ptr, |
| 1025 | GLsizei bufSize, |
| 1026 | GLsizei *length, |
| 1027 | GLchar *label) const |
| 1028 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1029 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1030 | ASSERT(object != nullptr); |
| 1031 | |
| 1032 | const std::string &objectLabel = object->getLabel(); |
| 1033 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1034 | } |
| 1035 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1036 | bool Context::isSampler(GLuint samplerName) const |
| 1037 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1038 | return mState.mSamplerManager->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1039 | } |
| 1040 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1041 | void Context::bindTexture(TextureType target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1042 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1043 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1044 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1045 | if (handle == 0) |
| 1046 | { |
| 1047 | texture = mZeroTextures[target].get(); |
| 1048 | } |
| 1049 | else |
| 1050 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1051 | texture = |
| 1052 | mState.mTextureManager->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | ASSERT(texture); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1056 | mState.setSamplerTexture(this, target, texture); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1057 | mStateCache.onActiveTextureChange(this); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1058 | } |
| 1059 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1060 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1061 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1062 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1063 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1064 | mState.setReadFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1065 | mReadFramebufferObserverBinding.bind(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1068 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1069 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1070 | Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation( |
| 1071 | mImplementation.get(), mState.mCaps, framebufferHandle); |
| 1072 | mState.setDrawFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1073 | mDrawFramebufferObserverBinding.bind(framebuffer); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1074 | mStateCache.onDrawFramebufferChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1077 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1078 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1079 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1080 | mState.setVertexArrayBinding(this, vertexArray); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1081 | mVertexArrayObserverBinding.bind(vertexArray); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1082 | mStateCache.onVertexArrayBindingChange(this); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1083 | } |
| 1084 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1085 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 1086 | GLuint bufferHandle, |
| 1087 | GLintptr offset, |
| 1088 | GLsizei stride) |
| 1089 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1090 | Buffer *buffer = |
| 1091 | mState.mBufferManager->checkBufferAllocation(mImplementation.get(), bufferHandle); |
| 1092 | mState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1093 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1094 | } |
| 1095 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1096 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1097 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1098 | ASSERT(textureUnit < mState.mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1099 | Sampler *sampler = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1100 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
| 1101 | mState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 1102 | mSamplerObserverBindings[textureUnit].bind(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1103 | } |
| 1104 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1105 | void Context::bindImageTexture(GLuint unit, |
| 1106 | GLuint texture, |
| 1107 | GLint level, |
| 1108 | GLboolean layered, |
| 1109 | GLint layer, |
| 1110 | GLenum access, |
| 1111 | GLenum format) |
| 1112 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1113 | Texture *tex = mState.mTextureManager->getTexture(texture); |
| 1114 | mState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1115 | } |
| 1116 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1117 | void Context::useProgram(GLuint program) |
| 1118 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1119 | ANGLE_CONTEXT_TRY(mState.setProgram(this, getProgramResolveLink(program))); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1120 | mStateCache.onProgramExecutableChange(this); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1121 | } |
| 1122 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 1123 | void Context::useProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) |
| 1124 | { |
| 1125 | UNIMPLEMENTED(); |
| 1126 | } |
| 1127 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1128 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1129 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1130 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1131 | TransformFeedback *transformFeedback = |
| 1132 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1133 | mState.setTransformFeedbackBinding(this, transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1134 | } |
| 1135 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1136 | void Context::bindProgramPipeline(GLuint pipelineHandle) |
| 1137 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1138 | ProgramPipeline *pipeline = mState.mProgramPipelineManager->checkProgramPipelineAllocation( |
| 1139 | mImplementation.get(), pipelineHandle); |
| 1140 | mState.setProgramPipelineBinding(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1141 | } |
| 1142 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1143 | void Context::beginQuery(QueryType target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1144 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1145 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1146 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1147 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1148 | // begin query |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 1149 | ANGLE_CONTEXT_TRY(queryObject->begin(this)); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1150 | |
| 1151 | // set query as active for specified target only if begin succeeded |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1152 | mState.setActiveQuery(this, target, queryObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1153 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1154 | } |
| 1155 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1156 | void Context::endQuery(QueryType target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1157 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1158 | Query *queryObject = mState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1159 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1160 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1161 | // Intentionally don't call try here. We don't want an early return. |
| 1162 | (void)(queryObject->end(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1163 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1164 | // 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] | 1165 | mState.setActiveQuery(this, target, nullptr); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1166 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1167 | } |
| 1168 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1169 | void Context::queryCounter(GLuint id, QueryType target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1170 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1171 | ASSERT(target == QueryType::Timestamp); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1172 | |
| 1173 | Query *queryObject = getQuery(id, true, target); |
| 1174 | ASSERT(queryObject); |
| 1175 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1176 | ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1177 | } |
| 1178 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1179 | void Context::getQueryiv(QueryType target, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1180 | { |
| 1181 | switch (pname) |
| 1182 | { |
| 1183 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1184 | params[0] = mState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1185 | break; |
| 1186 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1187 | switch (target) |
| 1188 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1189 | case QueryType::TimeElapsed: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1190 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1191 | break; |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1192 | case QueryType::Timestamp: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1193 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1194 | break; |
| 1195 | default: |
| 1196 | UNREACHABLE(); |
| 1197 | params[0] = 0; |
| 1198 | break; |
| 1199 | } |
| 1200 | break; |
| 1201 | default: |
| 1202 | UNREACHABLE(); |
| 1203 | return; |
| 1204 | } |
| 1205 | } |
| 1206 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1207 | void Context::getQueryivRobust(QueryType target, |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1208 | GLenum pname, |
| 1209 | GLsizei bufSize, |
| 1210 | GLsizei *length, |
| 1211 | GLint *params) |
| 1212 | { |
| 1213 | getQueryiv(target, pname, params); |
| 1214 | } |
| 1215 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1216 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1217 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1218 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1219 | } |
| 1220 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1221 | void Context::getQueryObjectivRobust(GLuint id, |
| 1222 | GLenum pname, |
| 1223 | GLsizei bufSize, |
| 1224 | GLsizei *length, |
| 1225 | GLint *params) |
| 1226 | { |
| 1227 | getQueryObjectiv(id, pname, params); |
| 1228 | } |
| 1229 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1230 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1231 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1232 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1233 | } |
| 1234 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1235 | void Context::getQueryObjectuivRobust(GLuint id, |
| 1236 | GLenum pname, |
| 1237 | GLsizei bufSize, |
| 1238 | GLsizei *length, |
| 1239 | GLuint *params) |
| 1240 | { |
| 1241 | getQueryObjectuiv(id, pname, params); |
| 1242 | } |
| 1243 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1244 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1245 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1246 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1247 | } |
| 1248 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1249 | void Context::getQueryObjecti64vRobust(GLuint id, |
| 1250 | GLenum pname, |
| 1251 | GLsizei bufSize, |
| 1252 | GLsizei *length, |
| 1253 | GLint64 *params) |
| 1254 | { |
| 1255 | getQueryObjecti64v(id, pname, params); |
| 1256 | } |
| 1257 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1258 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1259 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1260 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1261 | } |
| 1262 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1263 | void Context::getQueryObjectui64vRobust(GLuint id, |
| 1264 | GLenum pname, |
| 1265 | GLsizei bufSize, |
| 1266 | GLsizei *length, |
| 1267 | GLuint64 *params) |
| 1268 | { |
| 1269 | getQueryObjectui64v(id, pname, params); |
| 1270 | } |
| 1271 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1272 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1273 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1274 | return mState.mFramebufferManager->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1277 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1278 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1279 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1280 | } |
| 1281 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1282 | Query *Context::getQuery(GLuint handle, bool create, QueryType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1283 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1284 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1285 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1286 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1287 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1288 | |
| 1289 | Query *query = mQueryMap.query(handle); |
| 1290 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1291 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1292 | ASSERT(type != QueryType::InvalidEnum); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1293 | query = new Query(mImplementation->createQuery(type), handle); |
| 1294 | query->addRef(); |
| 1295 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1296 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1297 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1298 | } |
| 1299 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1300 | Query *Context::getQuery(GLuint handle) const |
| 1301 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1302 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1303 | } |
| 1304 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1305 | Texture *Context::getTargetTexture(TextureType type) const |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1306 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1307 | ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1308 | return mState.getTargetTexture(type); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1311 | Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1312 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1313 | return mState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1314 | } |
| 1315 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1316 | Compiler *Context::getCompiler() const |
| 1317 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1318 | if (mCompiler.get() == nullptr) |
| 1319 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1320 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1321 | } |
| 1322 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1323 | } |
| 1324 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1325 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1326 | { |
| 1327 | switch (pname) |
| 1328 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1329 | case GL_SHADER_COMPILER: |
| 1330 | *params = GL_TRUE; |
| 1331 | break; |
| 1332 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1333 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1334 | break; |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 1335 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1336 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1337 | mState.getBooleanv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1338 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1339 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1340 | } |
| 1341 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1342 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1343 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1344 | // Queries about context capabilities and maximums are answered by Context. |
| 1345 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1346 | switch (pname) |
| 1347 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1348 | case GL_ALIASED_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1349 | params[0] = mState.mCaps.minAliasedLineWidth; |
| 1350 | params[1] = mState.mCaps.maxAliasedLineWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1351 | break; |
| 1352 | case GL_ALIASED_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1353 | params[0] = mState.mCaps.minAliasedPointSize; |
| 1354 | params[1] = mState.mCaps.maxAliasedPointSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1355 | break; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1356 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1357 | params[0] = mState.mCaps.minSmoothPointSize; |
| 1358 | params[1] = mState.mCaps.maxSmoothPointSize; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1359 | break; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1360 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1361 | params[0] = mState.mCaps.minSmoothLineWidth; |
| 1362 | params[1] = mState.mCaps.maxSmoothLineWidth; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1363 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1364 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1365 | ASSERT(mState.mExtensions.textureFilterAnisotropic); |
| 1366 | *params = mState.mExtensions.maxTextureAnisotropy; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1367 | break; |
| 1368 | case GL_MAX_TEXTURE_LOD_BIAS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1369 | *params = mState.mCaps.maxLODBias; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1370 | break; |
| 1371 | |
| 1372 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1373 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1374 | { |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1375 | // GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the |
| 1376 | // GLES1 constants for modelview/projection matrix. |
| 1377 | if (getClientVersion() < Version(2, 0)) |
| 1378 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1379 | mState.getFloatv(pname, params); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1380 | } |
| 1381 | else |
| 1382 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1383 | ASSERT(mState.mExtensions.pathRendering); |
| 1384 | const GLfloat *m = mState.getPathRenderingMatrix(pname); |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1385 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1386 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1387 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1388 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1389 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1390 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1391 | mState.getFloatv(pname, params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1392 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1393 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1394 | } |
| 1395 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1396 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1397 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1398 | // Queries about context capabilities and maximums are answered by Context. |
| 1399 | // 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] | 1400 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1401 | switch (pname) |
| 1402 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1403 | case GL_MAX_VERTEX_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1404 | *params = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1405 | break; |
| 1406 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1407 | *params = mState.mCaps.maxVertexUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1408 | break; |
| 1409 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1410 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1411 | break; |
| 1412 | case GL_MAX_VARYING_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1413 | *params = mState.mCaps.maxVaryingVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1414 | break; |
| 1415 | case GL_MAX_VARYING_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1416 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1417 | break; |
| 1418 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1419 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1420 | break; |
| 1421 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1422 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1423 | break; |
| 1424 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1425 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1426 | break; |
| 1427 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1428 | *params = mState.mCaps.maxFragmentUniformVectors; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1429 | break; |
| 1430 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1431 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1432 | break; |
| 1433 | case GL_MAX_RENDERBUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1434 | *params = mState.mCaps.maxRenderbufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1435 | break; |
| 1436 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1437 | *params = mState.mCaps.maxColorAttachments; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1438 | break; |
| 1439 | case GL_MAX_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1440 | *params = mState.mCaps.maxDrawBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1441 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1442 | case GL_SUBPIXEL_BITS: |
| 1443 | *params = 4; |
| 1444 | break; |
| 1445 | case GL_MAX_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1446 | *params = mState.mCaps.max2DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1447 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1448 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1449 | *params = mState.mCaps.maxRectangleTextureSize; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1450 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1451 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1452 | *params = mState.mCaps.maxCubeMapTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1453 | break; |
| 1454 | case GL_MAX_3D_TEXTURE_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1455 | *params = mState.mCaps.max3DTextureSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1456 | break; |
| 1457 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1458 | *params = mState.mCaps.maxArrayTextureLayers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1459 | break; |
| 1460 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1461 | *params = mState.mCaps.uniformBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1462 | break; |
| 1463 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1464 | *params = mState.mCaps.maxUniformBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1465 | break; |
| 1466 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1467 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1468 | break; |
| 1469 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1470 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1471 | break; |
| 1472 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1473 | *params = mState.mCaps.maxCombinedTextureImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1474 | break; |
| 1475 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1476 | *params = mState.mCaps.maxVertexOutputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1477 | break; |
| 1478 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1479 | *params = mState.mCaps.maxFragmentInputComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1480 | break; |
| 1481 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1482 | *params = mState.mCaps.minProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1483 | break; |
| 1484 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1485 | *params = mState.mCaps.maxProgramTexelOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1486 | break; |
| 1487 | case GL_MAJOR_VERSION: |
| 1488 | *params = getClientVersion().major; |
| 1489 | break; |
| 1490 | case GL_MINOR_VERSION: |
| 1491 | *params = getClientVersion().minor; |
| 1492 | break; |
| 1493 | case GL_MAX_ELEMENTS_INDICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1494 | *params = mState.mCaps.maxElementsIndices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1495 | break; |
| 1496 | case GL_MAX_ELEMENTS_VERTICES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1497 | *params = mState.mCaps.maxElementsVertices; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1498 | break; |
| 1499 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1500 | *params = mState.mCaps.maxTransformFeedbackInterleavedComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1501 | break; |
| 1502 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1503 | *params = mState.mCaps.maxTransformFeedbackSeparateAttributes; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1504 | break; |
| 1505 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1506 | *params = mState.mCaps.maxTransformFeedbackSeparateComponents; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1507 | break; |
| 1508 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1509 | *params = static_cast<GLint>(mState.mCaps.compressedTextureFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1510 | break; |
| 1511 | case GL_MAX_SAMPLES_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1512 | *params = mState.mCaps.maxSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1513 | break; |
| 1514 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1515 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1516 | params[0] = mState.mCaps.maxViewportWidth; |
| 1517 | params[1] = mState.mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1518 | } |
| 1519 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1520 | case GL_COMPRESSED_TEXTURE_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1521 | std::copy(mState.mCaps.compressedTextureFormats.begin(), |
| 1522 | mState.mCaps.compressedTextureFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1523 | break; |
| 1524 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1525 | *params = mResetStrategy; |
| 1526 | break; |
| 1527 | case GL_NUM_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1528 | *params = static_cast<GLint>(mState.mCaps.shaderBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1529 | break; |
| 1530 | case GL_SHADER_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1531 | std::copy(mState.mCaps.shaderBinaryFormats.begin(), |
| 1532 | mState.mCaps.shaderBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1533 | break; |
| 1534 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1535 | *params = static_cast<GLint>(mState.mCaps.programBinaryFormats.size()); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1536 | break; |
| 1537 | case GL_PROGRAM_BINARY_FORMATS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1538 | std::copy(mState.mCaps.programBinaryFormats.begin(), |
| 1539 | mState.mCaps.programBinaryFormats.end(), params); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1540 | break; |
| 1541 | case GL_NUM_EXTENSIONS: |
| 1542 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1543 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1544 | |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame] | 1545 | // GL_ANGLE_request_extension |
| 1546 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 1547 | *params = static_cast<GLint>(mRequestableExtensionStrings.size()); |
| 1548 | break; |
| 1549 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1550 | // GL_KHR_debug |
| 1551 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1552 | *params = mState.mExtensions.maxDebugMessageLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1553 | break; |
| 1554 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1555 | *params = mState.mExtensions.maxDebugLoggedMessages; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1556 | break; |
| 1557 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1558 | *params = mState.mExtensions.maxDebugGroupStackDepth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1559 | break; |
| 1560 | case GL_MAX_LABEL_LENGTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1561 | *params = mState.mExtensions.maxLabelLength; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1562 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1563 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1564 | // GL_ANGLE_multiview |
| 1565 | case GL_MAX_VIEWS_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1566 | *params = mState.mExtensions.maxViews; |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1567 | break; |
| 1568 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1569 | // GL_EXT_disjoint_timer_query |
| 1570 | case GL_GPU_DISJOINT_EXT: |
| 1571 | *params = mImplementation->getGPUDisjoint(); |
| 1572 | break; |
| 1573 | case GL_MAX_FRAMEBUFFER_WIDTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1574 | *params = mState.mCaps.maxFramebufferWidth; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1575 | break; |
| 1576 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1577 | *params = mState.mCaps.maxFramebufferHeight; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1578 | break; |
| 1579 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1580 | *params = mState.mCaps.maxFramebufferSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1581 | break; |
| 1582 | case GL_MAX_SAMPLE_MASK_WORDS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1583 | *params = mState.mCaps.maxSampleMaskWords; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1584 | break; |
| 1585 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1586 | *params = mState.mCaps.maxColorTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1587 | break; |
| 1588 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1589 | *params = mState.mCaps.maxDepthTextureSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1590 | break; |
| 1591 | case GL_MAX_INTEGER_SAMPLES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1592 | *params = mState.mCaps.maxIntegerSamples; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1593 | break; |
| 1594 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1595 | *params = mState.mCaps.maxVertexAttribRelativeOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1596 | break; |
| 1597 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1598 | *params = mState.mCaps.maxVertexAttribBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1599 | break; |
| 1600 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1601 | *params = mState.mCaps.maxVertexAttribStride; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1602 | break; |
| 1603 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1604 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1605 | break; |
| 1606 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1607 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1608 | break; |
| 1609 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1610 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1611 | break; |
| 1612 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1613 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1614 | break; |
| 1615 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1616 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1617 | break; |
| 1618 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1619 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1620 | break; |
| 1621 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1622 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1623 | break; |
| 1624 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1625 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1626 | break; |
| 1627 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1628 | *params = mState.mCaps.minProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1629 | break; |
| 1630 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1631 | *params = mState.mCaps.maxProgramTextureGatherOffset; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1632 | break; |
| 1633 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1634 | *params = mState.mCaps.maxComputeWorkGroupInvocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1635 | break; |
| 1636 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1637 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1638 | break; |
| 1639 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1640 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1641 | break; |
| 1642 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1643 | *params = mState.mCaps.maxComputeSharedMemorySize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1644 | break; |
| 1645 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1646 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1647 | break; |
| 1648 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1649 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1650 | break; |
| 1651 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1652 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1653 | break; |
| 1654 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1655 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1656 | break; |
| 1657 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1658 | *params = static_cast<GLint>( |
| 1659 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1660 | break; |
| 1661 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1662 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1663 | break; |
| 1664 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1665 | *params = mState.mCaps.maxCombinedShaderOutputResources; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1666 | break; |
| 1667 | case GL_MAX_UNIFORM_LOCATIONS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1668 | *params = mState.mCaps.maxUniformLocations; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1669 | break; |
| 1670 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1671 | *params = mState.mCaps.maxAtomicCounterBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1672 | break; |
| 1673 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1674 | *params = mState.mCaps.maxAtomicCounterBufferSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1675 | break; |
| 1676 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1677 | *params = mState.mCaps.maxCombinedAtomicCounterBuffers; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1678 | break; |
| 1679 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1680 | *params = mState.mCaps.maxCombinedAtomicCounters; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1681 | break; |
| 1682 | case GL_MAX_IMAGE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1683 | *params = mState.mCaps.maxImageUnits; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1684 | break; |
| 1685 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1686 | *params = mState.mCaps.maxCombinedImageUniforms; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1687 | break; |
| 1688 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1689 | *params = mState.mCaps.maxShaderStorageBufferBindings; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1690 | break; |
| 1691 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1692 | *params = mState.mCaps.maxCombinedShaderStorageBlocks; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1693 | break; |
| 1694 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1695 | *params = mState.mCaps.shaderStorageBufferOffsetAlignment; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1696 | break; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1697 | |
| 1698 | // GL_EXT_geometry_shader |
| 1699 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1700 | *params = mState.mCaps.maxFramebufferLayers; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1701 | break; |
| 1702 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1703 | *params = mState.mCaps.layerProvokingVertex; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1704 | break; |
| 1705 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1706 | *params = mState.mCaps.maxShaderUniformComponents[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1707 | break; |
| 1708 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1709 | *params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1710 | break; |
| 1711 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1712 | *params = static_cast<GLint>( |
| 1713 | mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]); |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1714 | break; |
| 1715 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1716 | *params = mState.mCaps.maxGeometryInputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1717 | break; |
| 1718 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1719 | *params = mState.mCaps.maxGeometryOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1720 | break; |
| 1721 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1722 | *params = mState.mCaps.maxGeometryOutputVertices; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1723 | break; |
| 1724 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1725 | *params = mState.mCaps.maxGeometryTotalOutputComponents; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1726 | break; |
| 1727 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1728 | *params = mState.mCaps.maxGeometryShaderInvocations; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1729 | break; |
| 1730 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1731 | *params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1732 | break; |
| 1733 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1734 | *params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1735 | break; |
| 1736 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1737 | *params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1738 | break; |
| 1739 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1740 | *params = mState.mCaps.maxShaderImageUniforms[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1741 | break; |
| 1742 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1743 | *params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1744 | break; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1745 | // GLES1 emulation: Caps queries |
| 1746 | case GL_MAX_TEXTURE_UNITS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1747 | *params = mState.mCaps.maxMultitextureUnits; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1748 | break; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1749 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1750 | *params = mState.mCaps.maxModelviewMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1751 | break; |
| 1752 | case GL_MAX_PROJECTION_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1753 | *params = mState.mCaps.maxProjectionMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1754 | break; |
| 1755 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1756 | *params = mState.mCaps.maxTextureMatrixStackDepth; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1757 | break; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1758 | case GL_MAX_LIGHTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1759 | *params = mState.mCaps.maxLights; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1760 | break; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1761 | case GL_MAX_CLIP_PLANES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1762 | *params = mState.mCaps.maxClipPlanes; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1763 | break; |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1764 | // GLES1 emulation: Vertex attribute queries |
| 1765 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 1766 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 1767 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 1768 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
| 1769 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 1770 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1771 | GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params); |
| 1772 | break; |
| 1773 | case GL_VERTEX_ARRAY_STRIDE: |
| 1774 | case GL_NORMAL_ARRAY_STRIDE: |
| 1775 | case GL_COLOR_ARRAY_STRIDE: |
| 1776 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 1777 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 1778 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1779 | GL_VERTEX_ATTRIB_ARRAY_STRIDE, params); |
| 1780 | break; |
| 1781 | case GL_VERTEX_ARRAY_SIZE: |
| 1782 | case GL_COLOR_ARRAY_SIZE: |
| 1783 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 1784 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1785 | GL_VERTEX_ATTRIB_ARRAY_SIZE, params); |
| 1786 | break; |
| 1787 | case GL_VERTEX_ARRAY_TYPE: |
| 1788 | case GL_COLOR_ARRAY_TYPE: |
| 1789 | case GL_NORMAL_ARRAY_TYPE: |
| 1790 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 1791 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 1792 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1793 | GL_VERTEX_ATTRIB_ARRAY_TYPE, params); |
| 1794 | break; |
| 1795 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1796 | // GL_KHR_parallel_shader_compile |
| 1797 | case GL_MAX_SHADER_COMPILER_THREADS_KHR: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1798 | *params = mState.getMaxShaderCompilerThreads(); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1799 | break; |
| 1800 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1801 | // GL_EXT_blend_func_extended |
| 1802 | case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1803 | *params = mState.mExtensions.maxDualSourceDrawBuffers; |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1804 | break; |
| 1805 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1806 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1807 | ANGLE_CONTEXT_TRY(mState.getIntegerv(this, pname, params)); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1808 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1809 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1810 | } |
| 1811 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 1812 | void Context::getInteger64vImpl(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1813 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1814 | // Queries about context capabilities and maximums are answered by Context. |
| 1815 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1816 | switch (pname) |
| 1817 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1818 | case GL_MAX_ELEMENT_INDEX: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1819 | *params = mState.mCaps.maxElementIndex; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1820 | break; |
| 1821 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1822 | *params = mState.mCaps.maxUniformBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1823 | break; |
| 1824 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1825 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1826 | break; |
| 1827 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1828 | *params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1829 | break; |
| 1830 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1831 | *params = mState.mCaps.maxServerWaitTimeout; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1832 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1833 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1834 | // GL_EXT_disjoint_timer_query |
| 1835 | case GL_TIMESTAMP_EXT: |
| 1836 | *params = mImplementation->getTimestamp(); |
| 1837 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1838 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1839 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1840 | *params = mState.mCaps.maxShaderStorageBlockSize; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1841 | break; |
| 1842 | default: |
| 1843 | UNREACHABLE(); |
| 1844 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1845 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1846 | } |
| 1847 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1848 | void Context::getPointerv(GLenum pname, void **params) const |
| 1849 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1850 | mState.getPointerv(this, pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1851 | } |
| 1852 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 1853 | void Context::getPointervRobustANGLERobust(GLenum pname, |
| 1854 | GLsizei bufSize, |
| 1855 | GLsizei *length, |
| 1856 | void **params) |
| 1857 | { |
| 1858 | UNIMPLEMENTED(); |
| 1859 | } |
| 1860 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1861 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1862 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1863 | // Queries about context capabilities and maximums are answered by Context. |
| 1864 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1865 | |
| 1866 | GLenum nativeType; |
| 1867 | unsigned int numParams; |
| 1868 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1869 | ASSERT(queryStatus); |
| 1870 | |
| 1871 | if (nativeType == GL_INT) |
| 1872 | { |
| 1873 | switch (target) |
| 1874 | { |
| 1875 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1876 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1877 | *data = mState.mCaps.maxComputeWorkGroupCount[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1878 | break; |
| 1879 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1880 | ASSERT(index < 3u); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1881 | *data = mState.mCaps.maxComputeWorkGroupSize[index]; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1882 | break; |
| 1883 | default: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1884 | mState.getIntegeri_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1885 | } |
| 1886 | } |
| 1887 | else |
| 1888 | { |
| 1889 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1890 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1891 | } |
| 1892 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1893 | void Context::getIntegeri_vRobust(GLenum target, |
| 1894 | GLuint index, |
| 1895 | GLsizei bufSize, |
| 1896 | GLsizei *length, |
| 1897 | GLint *data) |
| 1898 | { |
| 1899 | getIntegeri_v(target, index, data); |
| 1900 | } |
| 1901 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1902 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1903 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1904 | // Queries about context capabilities and maximums are answered by Context. |
| 1905 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1906 | |
| 1907 | GLenum nativeType; |
| 1908 | unsigned int numParams; |
| 1909 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1910 | ASSERT(queryStatus); |
| 1911 | |
| 1912 | if (nativeType == GL_INT_64_ANGLEX) |
| 1913 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1914 | mState.getInteger64i_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1915 | } |
| 1916 | else |
| 1917 | { |
| 1918 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1919 | } |
| 1920 | } |
| 1921 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1922 | void Context::getInteger64i_vRobust(GLenum target, |
| 1923 | GLuint index, |
| 1924 | GLsizei bufSize, |
| 1925 | GLsizei *length, |
| 1926 | GLint64 *data) |
| 1927 | { |
| 1928 | getInteger64i_v(target, index, data); |
| 1929 | } |
| 1930 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1931 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1932 | { |
| 1933 | // Queries about context capabilities and maximums are answered by Context. |
| 1934 | // Queries about current GL state values are answered by State. |
| 1935 | |
| 1936 | GLenum nativeType; |
| 1937 | unsigned int numParams; |
| 1938 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1939 | ASSERT(queryStatus); |
| 1940 | |
| 1941 | if (nativeType == GL_BOOL) |
| 1942 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1943 | mState.getBooleani_v(target, index, data); |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1944 | } |
| 1945 | else |
| 1946 | { |
| 1947 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1948 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1949 | } |
| 1950 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1951 | void Context::getBooleani_vRobust(GLenum target, |
| 1952 | GLuint index, |
| 1953 | GLsizei bufSize, |
| 1954 | GLsizei *length, |
| 1955 | GLboolean *data) |
| 1956 | { |
| 1957 | getBooleani_v(target, index, data); |
| 1958 | } |
| 1959 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 1960 | void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1961 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1962 | Buffer *buffer = mState.getTargetBuffer(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1963 | QueryBufferParameteriv(buffer, pname, params); |
| 1964 | } |
| 1965 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1966 | void Context::getBufferParameterivRobust(BufferBinding target, |
| 1967 | GLenum pname, |
| 1968 | GLsizei bufSize, |
| 1969 | GLsizei *length, |
| 1970 | GLint *params) |
| 1971 | { |
| 1972 | getBufferParameteriv(target, pname, params); |
| 1973 | } |
| 1974 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1975 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 1976 | GLenum attachment, |
| 1977 | GLenum pname, |
| 1978 | GLint *params) |
| 1979 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1980 | const Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 1981 | QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1982 | } |
| 1983 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1984 | void Context::getFramebufferAttachmentParameterivRobust(GLenum target, |
| 1985 | GLenum attachment, |
| 1986 | GLenum pname, |
| 1987 | GLsizei bufSize, |
| 1988 | GLsizei *length, |
| 1989 | GLint *params) |
| 1990 | { |
| 1991 | getFramebufferAttachmentParameteriv(target, attachment, pname, params); |
| 1992 | } |
| 1993 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1994 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 1995 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 1996 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1997 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 1998 | } |
| 1999 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2000 | void Context::getRenderbufferParameterivRobust(GLenum target, |
| 2001 | GLenum pname, |
| 2002 | GLsizei bufSize, |
| 2003 | GLsizei *length, |
| 2004 | GLint *params) |
| 2005 | { |
| 2006 | getRenderbufferParameteriv(target, pname, params); |
| 2007 | } |
| 2008 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2009 | void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2010 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2011 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2012 | QueryTexParameterfv(texture, pname, params); |
| 2013 | } |
| 2014 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2015 | void Context::getTexParameterfvRobust(TextureType target, |
| 2016 | GLenum pname, |
| 2017 | GLsizei bufSize, |
| 2018 | GLsizei *length, |
| 2019 | GLfloat *params) |
| 2020 | { |
| 2021 | getTexParameterfv(target, pname, params); |
| 2022 | } |
| 2023 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2024 | void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2025 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2026 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2027 | QueryTexParameteriv(texture, pname, params); |
| 2028 | } |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2029 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2030 | void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params) |
| 2031 | { |
| 2032 | const Texture *const texture = getTargetTexture(target); |
| 2033 | QueryTexParameterIiv(texture, pname, params); |
| 2034 | } |
| 2035 | |
| 2036 | void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params) |
| 2037 | { |
| 2038 | const Texture *const texture = getTargetTexture(target); |
| 2039 | QueryTexParameterIuiv(texture, pname, params); |
| 2040 | } |
| 2041 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2042 | void Context::getTexParameterivRobust(TextureType target, |
| 2043 | GLenum pname, |
| 2044 | GLsizei bufSize, |
| 2045 | GLsizei *length, |
| 2046 | GLint *params) |
| 2047 | { |
| 2048 | getTexParameteriv(target, pname, params); |
| 2049 | } |
| 2050 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2051 | void Context::getTexParameterIivRobust(TextureType target, |
| 2052 | GLenum pname, |
| 2053 | GLsizei bufSize, |
| 2054 | GLsizei *length, |
| 2055 | GLint *params) |
| 2056 | { |
| 2057 | UNIMPLEMENTED(); |
| 2058 | } |
| 2059 | |
| 2060 | void Context::getTexParameterIuivRobust(TextureType target, |
| 2061 | GLenum pname, |
| 2062 | GLsizei bufSize, |
| 2063 | GLsizei *length, |
| 2064 | GLuint *params) |
| 2065 | { |
| 2066 | UNIMPLEMENTED(); |
| 2067 | } |
| 2068 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2069 | void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2070 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2071 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2072 | QueryTexLevelParameteriv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2073 | } |
| 2074 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2075 | void Context::getTexLevelParameterivRobust(TextureTarget target, |
| 2076 | GLint level, |
| 2077 | GLenum pname, |
| 2078 | GLsizei bufSize, |
| 2079 | GLsizei *length, |
| 2080 | GLint *params) |
| 2081 | { |
| 2082 | UNIMPLEMENTED(); |
| 2083 | } |
| 2084 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2085 | void Context::getTexLevelParameterfv(TextureTarget target, |
| 2086 | GLint level, |
| 2087 | GLenum pname, |
| 2088 | GLfloat *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2089 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2090 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2091 | QueryTexLevelParameterfv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2092 | } |
| 2093 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2094 | void Context::getTexLevelParameterfvRobust(TextureTarget target, |
| 2095 | GLint level, |
| 2096 | GLenum pname, |
| 2097 | GLsizei bufSize, |
| 2098 | GLsizei *length, |
| 2099 | GLfloat *params) |
| 2100 | { |
| 2101 | UNIMPLEMENTED(); |
| 2102 | } |
| 2103 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2104 | void Context::texParameterf(TextureType target, GLenum pname, GLfloat param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2105 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2106 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2107 | SetTexParameterf(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2108 | } |
| 2109 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2110 | void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params) |
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 | SetTexParameterfv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2114 | } |
| 2115 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2116 | void Context::texParameterfvRobust(TextureType target, |
| 2117 | GLenum pname, |
| 2118 | GLsizei bufSize, |
| 2119 | const GLfloat *params) |
| 2120 | { |
| 2121 | texParameterfv(target, pname, params); |
| 2122 | } |
| 2123 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2124 | void Context::texParameteri(TextureType target, GLenum pname, GLint param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2125 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2126 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2127 | SetTexParameteri(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2128 | } |
| 2129 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2130 | void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params) |
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 | SetTexParameteriv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2134 | } |
| 2135 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2136 | void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params) |
| 2137 | { |
| 2138 | Texture *const texture = getTargetTexture(target); |
| 2139 | SetTexParameterIiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2140 | } |
| 2141 | |
| 2142 | void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params) |
| 2143 | { |
| 2144 | Texture *const texture = getTargetTexture(target); |
| 2145 | SetTexParameterIuiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2146 | } |
| 2147 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2148 | void Context::texParameterivRobust(TextureType target, |
| 2149 | GLenum pname, |
| 2150 | GLsizei bufSize, |
| 2151 | const GLint *params) |
| 2152 | { |
| 2153 | texParameteriv(target, pname, params); |
| 2154 | } |
| 2155 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2156 | void Context::texParameterIivRobust(TextureType target, |
| 2157 | GLenum pname, |
| 2158 | GLsizei bufSize, |
| 2159 | const GLint *params) |
| 2160 | { |
| 2161 | UNIMPLEMENTED(); |
| 2162 | } |
| 2163 | |
| 2164 | void Context::texParameterIuivRobust(TextureType target, |
| 2165 | GLenum pname, |
| 2166 | GLsizei bufSize, |
| 2167 | const GLuint *params) |
| 2168 | { |
| 2169 | UNIMPLEMENTED(); |
| 2170 | } |
| 2171 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2172 | void Context::drawArraysInstanced(PrimitiveMode mode, |
| 2173 | GLint first, |
| 2174 | GLsizei count, |
| 2175 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2176 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2177 | // No-op if count draws no primitives for given mode |
| 2178 | if (noopDrawInstanced(mode, count, instanceCount)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2179 | { |
| 2180 | return; |
| 2181 | } |
| 2182 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2183 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2184 | ANGLE_CONTEXT_TRY( |
| 2185 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 2186 | MarkTransformFeedbackBufferUsage(this, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2187 | } |
| 2188 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2189 | void Context::drawElementsInstanced(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2190 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2191 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2192 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2193 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2194 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2195 | // No-op if count draws no primitives for given mode |
| 2196 | if (noopDrawInstanced(mode, count, instances)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2197 | { |
| 2198 | return; |
| 2199 | } |
| 2200 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2201 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2202 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 2203 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2204 | } |
| 2205 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2206 | void Context::drawRangeElements(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2207 | GLuint start, |
| 2208 | GLuint end, |
| 2209 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2210 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2211 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2212 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2213 | // No-op if count draws no primitives for given mode |
| 2214 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2215 | { |
| 2216 | return; |
| 2217 | } |
| 2218 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2219 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2220 | ANGLE_CONTEXT_TRY( |
| 2221 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2222 | } |
| 2223 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2224 | void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2225 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2226 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2227 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2228 | } |
| 2229 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2230 | void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, 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->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2234 | } |
| 2235 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2236 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2237 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2238 | ANGLE_CONTEXT_TRY(mImplementation->flush(this)); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2239 | } |
| 2240 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2241 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2242 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2243 | ANGLE_CONTEXT_TRY(mImplementation->finish(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2244 | } |
| 2245 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2246 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 2247 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2248 | ASSERT(mImplementation); |
| 2249 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 2253 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2254 | ASSERT(mImplementation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 2255 | |
| 2256 | if (marker == nullptr) |
| 2257 | { |
| 2258 | // From the EXT_debug_marker spec, |
| 2259 | // "If <marker> is null then an empty string is pushed on the stack." |
| 2260 | mImplementation->pushGroupMarker(length, ""); |
| 2261 | } |
| 2262 | else |
| 2263 | { |
| 2264 | mImplementation->pushGroupMarker(length, marker); |
| 2265 | } |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | void Context::popGroupMarker() |
| 2269 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2270 | ASSERT(mImplementation); |
| 2271 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2272 | } |
| 2273 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2274 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 2275 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2276 | Program *programObject = getProgramResolveLink(program); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2277 | ASSERT(programObject); |
| 2278 | |
| 2279 | programObject->bindUniformLocation(location, name); |
| 2280 | } |
| 2281 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2282 | void Context::coverageModulation(GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2283 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2284 | mState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2285 | } |
| 2286 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2287 | void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2288 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2289 | mState.loadPathRenderingMatrix(matrixMode, matrix); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2290 | } |
| 2291 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2292 | void Context::matrixLoadIdentity(GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2293 | { |
| 2294 | GLfloat I[16]; |
| 2295 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 2296 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2297 | mState.loadPathRenderingMatrix(matrixMode, I); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 2301 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2302 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2303 | if (!pathObj) |
| 2304 | return; |
| 2305 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2306 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2307 | |
| 2308 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 2309 | } |
| 2310 | |
| 2311 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 2312 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2313 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2314 | if (!pathObj) |
| 2315 | return; |
| 2316 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2317 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2318 | |
| 2319 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 2320 | } |
| 2321 | |
| 2322 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 2323 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2324 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2325 | if (!pathObj) |
| 2326 | return; |
| 2327 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2328 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2329 | |
| 2330 | mImplementation->coverFillPath(pathObj, coverMode); |
| 2331 | } |
| 2332 | |
| 2333 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 2334 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2335 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2336 | if (!pathObj) |
| 2337 | return; |
| 2338 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2339 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2340 | |
| 2341 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 2342 | } |
| 2343 | |
| 2344 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 2345 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2346 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2347 | if (!pathObj) |
| 2348 | return; |
| 2349 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2350 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2351 | |
| 2352 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 2353 | } |
| 2354 | |
| 2355 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 2356 | GLint reference, |
| 2357 | GLuint mask, |
| 2358 | GLenum coverMode) |
| 2359 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2360 | const auto *pathObj = mState.mPathManager->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2361 | if (!pathObj) |
| 2362 | return; |
| 2363 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2364 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2365 | |
| 2366 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 2367 | } |
| 2368 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2369 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 2370 | GLenum pathNameType, |
| 2371 | const void *paths, |
| 2372 | GLuint pathBase, |
| 2373 | GLenum coverMode, |
| 2374 | GLenum transformType, |
| 2375 | const GLfloat *transformValues) |
| 2376 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2377 | const auto &pathObjects = |
| 2378 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2379 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2380 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2381 | |
| 2382 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 2383 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2384 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2385 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 2386 | GLenum pathNameType, |
| 2387 | const void *paths, |
| 2388 | GLuint pathBase, |
| 2389 | GLenum coverMode, |
| 2390 | GLenum transformType, |
| 2391 | const GLfloat *transformValues) |
| 2392 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2393 | const auto &pathObjects = |
| 2394 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2395 | |
| 2396 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2397 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2398 | |
| 2399 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 2400 | transformValues); |
| 2401 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2402 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2403 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 2404 | GLenum pathNameType, |
| 2405 | const void *paths, |
| 2406 | GLuint pathBase, |
| 2407 | GLenum fillMode, |
| 2408 | GLuint mask, |
| 2409 | GLenum transformType, |
| 2410 | const GLfloat *transformValues) |
| 2411 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2412 | const auto &pathObjects = |
| 2413 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2414 | |
| 2415 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2416 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2417 | |
| 2418 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2419 | transformValues); |
| 2420 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2421 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2422 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2423 | GLenum pathNameType, |
| 2424 | const void *paths, |
| 2425 | GLuint pathBase, |
| 2426 | GLint reference, |
| 2427 | GLuint mask, |
| 2428 | GLenum transformType, |
| 2429 | const GLfloat *transformValues) |
| 2430 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2431 | const auto &pathObjects = |
| 2432 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2433 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2434 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2435 | |
| 2436 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2437 | transformValues); |
| 2438 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2439 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2440 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2441 | GLenum pathNameType, |
| 2442 | const void *paths, |
| 2443 | GLuint pathBase, |
| 2444 | GLenum fillMode, |
| 2445 | GLuint mask, |
| 2446 | GLenum coverMode, |
| 2447 | GLenum transformType, |
| 2448 | const GLfloat *transformValues) |
| 2449 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2450 | const auto &pathObjects = |
| 2451 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2452 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2453 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2454 | |
| 2455 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2456 | transformType, transformValues); |
| 2457 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2458 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2459 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2460 | GLenum pathNameType, |
| 2461 | const void *paths, |
| 2462 | GLuint pathBase, |
| 2463 | GLint reference, |
| 2464 | GLuint mask, |
| 2465 | GLenum coverMode, |
| 2466 | GLenum transformType, |
| 2467 | const GLfloat *transformValues) |
| 2468 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2469 | const auto &pathObjects = |
| 2470 | GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2471 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2472 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2473 | |
| 2474 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2475 | transformType, transformValues); |
| 2476 | } |
| 2477 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2478 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2479 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2480 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2481 | |
| 2482 | programObject->bindFragmentInputLocation(location, name); |
| 2483 | } |
| 2484 | |
| 2485 | void Context::programPathFragmentInputGen(GLuint program, |
| 2486 | GLint location, |
| 2487 | GLenum genMode, |
| 2488 | GLint components, |
| 2489 | const GLfloat *coeffs) |
| 2490 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2491 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2492 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 2493 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2494 | } |
| 2495 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2496 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2497 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2498 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2499 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2500 | } |
| 2501 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2502 | void Context::getProgramResourceName(GLuint program, |
| 2503 | GLenum programInterface, |
| 2504 | GLuint index, |
| 2505 | GLsizei bufSize, |
| 2506 | GLsizei *length, |
| 2507 | GLchar *name) |
| 2508 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2509 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2510 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2511 | } |
| 2512 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2513 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2514 | GLenum programInterface, |
| 2515 | const GLchar *name) |
| 2516 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2517 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2518 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2519 | } |
| 2520 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2521 | void Context::getProgramResourceiv(GLuint program, |
| 2522 | GLenum programInterface, |
| 2523 | GLuint index, |
| 2524 | GLsizei propCount, |
| 2525 | const GLenum *props, |
| 2526 | GLsizei bufSize, |
| 2527 | GLsizei *length, |
| 2528 | GLint *params) |
| 2529 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2530 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2531 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2532 | length, params); |
| 2533 | } |
| 2534 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2535 | void Context::getProgramInterfaceiv(GLuint program, |
| 2536 | GLenum programInterface, |
| 2537 | GLenum pname, |
| 2538 | GLint *params) |
| 2539 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2540 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2541 | QueryProgramInterfaceiv(programObject, programInterface, pname, params); |
| 2542 | } |
| 2543 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2544 | void Context::getProgramInterfaceivRobust(GLuint program, |
| 2545 | GLenum programInterface, |
| 2546 | GLenum pname, |
| 2547 | GLsizei bufSize, |
| 2548 | GLsizei *length, |
| 2549 | GLint *params) |
| 2550 | { |
| 2551 | UNIMPLEMENTED(); |
| 2552 | } |
| 2553 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 2554 | void Context::handleError(GLenum errorCode, |
| 2555 | const char *message, |
| 2556 | const char *file, |
| 2557 | const char *function, |
| 2558 | unsigned int line) |
| 2559 | { |
| 2560 | mErrors.handleError(errorCode, message, file, function, line); |
| 2561 | } |
| 2562 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 2563 | void Context::validationError(GLenum errorCode, const char *message) |
| 2564 | { |
| 2565 | mErrors.validationError(errorCode, message); |
| 2566 | } |
| 2567 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2568 | // Get one of the recorded errors and clear its flag, if any. |
| 2569 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2570 | GLenum Context::getError() |
| 2571 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2572 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2573 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2574 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2575 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2576 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2577 | { |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2578 | return mErrors.popError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2579 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2580 | } |
| 2581 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2582 | // NOTE: this function should not assume that this context is current! |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2583 | void Context::markContextLost() |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2584 | { |
| 2585 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2586 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2587 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2588 | mContextLostForced = true; |
| 2589 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2590 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2591 | } |
| 2592 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 2593 | GLenum Context::getGraphicsResetStatus() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2594 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2595 | // Even if the application doesn't want to know about resets, we want to know |
| 2596 | // as it will allow us to skip all the calls. |
| 2597 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2598 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2599 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2600 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2601 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2602 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2603 | |
| 2604 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2605 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2606 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2607 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2608 | } |
| 2609 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2610 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2611 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2612 | // once the device has finished resetting. |
| 2613 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2614 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2615 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2616 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2617 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2618 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2619 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2620 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2621 | } |
| 2622 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2623 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2624 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2625 | // If markContextLost was used to mark the context lost then |
| 2626 | // assume that is not recoverable, and continue to report the |
| 2627 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2628 | mResetStatus = mImplementation->getResetStatus(); |
| 2629 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2630 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2631 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2632 | } |
| 2633 | |
| 2634 | bool Context::isResetNotificationEnabled() |
| 2635 | { |
| 2636 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2637 | } |
| 2638 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2639 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2640 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2641 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2642 | } |
| 2643 | |
| 2644 | EGLenum Context::getClientType() const |
| 2645 | { |
| 2646 | return mClientType; |
| 2647 | } |
| 2648 | |
| 2649 | EGLenum Context::getRenderBuffer() const |
| 2650 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2651 | const Framebuffer *framebuffer = mState.mFramebufferManager->getFramebuffer(0); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2652 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2653 | { |
| 2654 | return EGL_NONE; |
| 2655 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2656 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2657 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2658 | ASSERT(backAttachment != nullptr); |
| 2659 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2660 | } |
| 2661 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2662 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2663 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2664 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2665 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2666 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2667 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2668 | vertexArray = |
| 2669 | new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2670 | mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2671 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2672 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2673 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2674 | |
| 2675 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2676 | } |
| 2677 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2678 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2679 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2680 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2681 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2682 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2683 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2684 | transformFeedback = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2685 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mState.mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2686 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2687 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2688 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2689 | |
| 2690 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2691 | } |
| 2692 | |
| 2693 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2694 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2695 | ASSERT(mVertexArrayMap.contains(0)); |
| 2696 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2697 | } |
| 2698 | |
| 2699 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2700 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2701 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2702 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2703 | } |
| 2704 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2705 | void Context::detachTexture(GLuint texture) |
| 2706 | { |
| 2707 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2708 | // allocation map management either here or in the resource manager at detach time. |
| 2709 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2710 | // the State. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2711 | mState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2712 | } |
| 2713 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 2714 | void Context::detachBuffer(Buffer *buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2715 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2716 | // Simple pass-through to State's detachBuffer method, since |
| 2717 | // only buffer attachments to container objects that are bound to the current context |
| 2718 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2719 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2720 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2721 | // Attachments to unbound container objects, such as |
| 2722 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2723 | // 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] | 2724 | ANGLE_CONTEXT_TRY(mState.detachBuffer(this, buffer)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2725 | } |
| 2726 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2727 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2728 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2729 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2730 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2731 | // to State at binding time. |
| 2732 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2733 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2734 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2735 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2736 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2737 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2738 | if (mState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2739 | { |
| 2740 | bindReadFramebuffer(0); |
| 2741 | } |
| 2742 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2743 | if (mState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2744 | { |
| 2745 | bindDrawFramebuffer(0); |
| 2746 | } |
| 2747 | } |
| 2748 | |
| 2749 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2750 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2751 | mState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2752 | } |
| 2753 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2754 | void Context::detachVertexArray(GLuint vertexArray) |
| 2755 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2756 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2757 | // 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] | 2758 | // binding time. |
| 2759 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2760 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2761 | // If a vertex array object that is currently bound is deleted, the binding |
| 2762 | // 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] | 2763 | if (mState.removeVertexArrayBinding(this, vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2764 | { |
| 2765 | bindVertexArray(0); |
| 2766 | } |
| 2767 | } |
| 2768 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2769 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2770 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2771 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2772 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2773 | // binding time. |
| 2774 | |
| 2775 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2776 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2777 | // 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] | 2778 | if (mState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2779 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2780 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2781 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2782 | } |
| 2783 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2784 | void Context::detachSampler(GLuint sampler) |
| 2785 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2786 | mState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2787 | } |
| 2788 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2789 | void Context::detachProgramPipeline(GLuint pipeline) |
| 2790 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2791 | mState.detachProgramPipeline(this, pipeline); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2792 | } |
| 2793 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 2794 | void Context::vertexAttribDivisor(GLuint index, GLuint divisor) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2795 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2796 | mState.setVertexAttribDivisor(this, index, divisor); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 2797 | mStateCache.onVertexArrayStateChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2798 | } |
| 2799 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2800 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2801 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2802 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2803 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2804 | SetSamplerParameteri(this, samplerObject, pname, param); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2805 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2806 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2807 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2808 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2809 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2810 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2811 | SetSamplerParameteriv(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2812 | } |
| 2813 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2814 | void Context::samplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) |
| 2815 | { |
| 2816 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2817 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2818 | SetSamplerParameterIiv(this, samplerObject, pname, param); |
| 2819 | } |
| 2820 | |
| 2821 | void Context::samplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param) |
| 2822 | { |
| 2823 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2824 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2825 | SetSamplerParameterIuiv(this, samplerObject, pname, param); |
| 2826 | } |
| 2827 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2828 | void Context::samplerParameterivRobust(GLuint sampler, |
| 2829 | GLenum pname, |
| 2830 | GLsizei bufSize, |
| 2831 | const GLint *param) |
| 2832 | { |
| 2833 | samplerParameteriv(sampler, pname, param); |
| 2834 | } |
| 2835 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2836 | void Context::samplerParameterIivRobust(GLuint sampler, |
| 2837 | GLenum pname, |
| 2838 | GLsizei bufSize, |
| 2839 | const GLint *param) |
| 2840 | { |
| 2841 | UNIMPLEMENTED(); |
| 2842 | } |
| 2843 | |
| 2844 | void Context::samplerParameterIuivRobust(GLuint sampler, |
| 2845 | GLenum pname, |
| 2846 | GLsizei bufSize, |
| 2847 | const GLuint *param) |
| 2848 | { |
| 2849 | UNIMPLEMENTED(); |
| 2850 | } |
| 2851 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2852 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2853 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2854 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2855 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2856 | SetSamplerParameterf(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2857 | } |
| 2858 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2859 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2860 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2861 | Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2862 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2863 | SetSamplerParameterfv(this, samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2864 | } |
| 2865 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2866 | void Context::samplerParameterfvRobust(GLuint sampler, |
| 2867 | GLenum pname, |
| 2868 | GLsizei bufSize, |
| 2869 | const GLfloat *param) |
| 2870 | { |
| 2871 | samplerParameterfv(sampler, pname, param); |
| 2872 | } |
| 2873 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2874 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2875 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2876 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2877 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2878 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2879 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2880 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2881 | void Context::getSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) |
| 2882 | { |
| 2883 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2884 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2885 | QuerySamplerParameterIiv(samplerObject, pname, params); |
| 2886 | } |
| 2887 | |
| 2888 | void Context::getSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) |
| 2889 | { |
| 2890 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2891 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2892 | QuerySamplerParameterIuiv(samplerObject, pname, params); |
| 2893 | } |
| 2894 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2895 | void Context::getSamplerParameterivRobust(GLuint sampler, |
| 2896 | GLenum pname, |
| 2897 | GLsizei bufSize, |
| 2898 | GLsizei *length, |
| 2899 | GLint *params) |
| 2900 | { |
| 2901 | getSamplerParameteriv(sampler, pname, params); |
| 2902 | } |
| 2903 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2904 | void Context::getSamplerParameterIivRobust(GLuint sampler, |
| 2905 | GLenum pname, |
| 2906 | GLsizei bufSize, |
| 2907 | GLsizei *length, |
| 2908 | GLint *params) |
| 2909 | { |
| 2910 | UNIMPLEMENTED(); |
| 2911 | } |
| 2912 | |
| 2913 | void Context::getSamplerParameterIuivRobust(GLuint sampler, |
| 2914 | GLenum pname, |
| 2915 | GLsizei bufSize, |
| 2916 | GLsizei *length, |
| 2917 | GLuint *params) |
| 2918 | { |
| 2919 | UNIMPLEMENTED(); |
| 2920 | } |
| 2921 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2922 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2923 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2924 | const Sampler *const samplerObject = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2925 | mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2926 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2927 | } |
| 2928 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2929 | void Context::getSamplerParameterfvRobust(GLuint sampler, |
| 2930 | GLenum pname, |
| 2931 | GLsizei bufSize, |
| 2932 | GLsizei *length, |
| 2933 | GLfloat *params) |
| 2934 | { |
| 2935 | getSamplerParameterfv(sampler, pname, params); |
| 2936 | } |
| 2937 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2938 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2939 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2940 | gl::Program *programObject = getProgramResolveLink(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 2941 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2942 | } |
| 2943 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2944 | void Context::initRendererString() |
| 2945 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2946 | std::ostringstream rendererString; |
| 2947 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2948 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2949 | rendererString << ")"; |
| 2950 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2951 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2952 | } |
| 2953 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2954 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2955 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2956 | const Version &clientVersion = getClientVersion(); |
| 2957 | |
| 2958 | std::ostringstream versionString; |
| 2959 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 2960 | << ANGLE_VERSION_STRING << ")"; |
| 2961 | mVersionString = MakeStaticString(versionString.str()); |
| 2962 | |
| 2963 | std::ostringstream shadingLanguageVersionString; |
| 2964 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 2965 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 2966 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 2967 | << ")"; |
| 2968 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2969 | } |
| 2970 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2971 | void Context::initExtensionStrings() |
| 2972 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2973 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 2974 | std::ostringstream combinedStringStream; |
| 2975 | std::copy(strings.begin(), strings.end(), |
| 2976 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 2977 | return MakeStaticString(combinedStringStream.str()); |
| 2978 | }; |
| 2979 | |
| 2980 | mExtensionStrings.clear(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2981 | for (const auto &extensionString : mState.mExtensions.getStrings()) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 2982 | { |
| 2983 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 2984 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2985 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2986 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2987 | mRequestableExtensionStrings.clear(); |
| 2988 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 2989 | { |
| 2990 | if (extensionInfo.second.Requestable && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 2991 | !(mState.mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 2992 | mSupportedExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 2993 | { |
| 2994 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 2995 | } |
| 2996 | } |
| 2997 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2998 | } |
| 2999 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3000 | const GLubyte *Context::getString(GLenum name) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3001 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3002 | switch (name) |
| 3003 | { |
| 3004 | case GL_VENDOR: |
| 3005 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 3006 | |
| 3007 | case GL_RENDERER: |
| 3008 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 3009 | |
| 3010 | case GL_VERSION: |
| 3011 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 3012 | |
| 3013 | case GL_SHADING_LANGUAGE_VERSION: |
| 3014 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 3015 | |
| 3016 | case GL_EXTENSIONS: |
| 3017 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 3018 | |
| 3019 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3020 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 3021 | |
| 3022 | default: |
| 3023 | UNREACHABLE(); |
| 3024 | return nullptr; |
| 3025 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3026 | } |
| 3027 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3028 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3029 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3030 | switch (name) |
| 3031 | { |
| 3032 | case GL_EXTENSIONS: |
| 3033 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 3034 | |
| 3035 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3036 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 3037 | |
| 3038 | default: |
| 3039 | UNREACHABLE(); |
| 3040 | return nullptr; |
| 3041 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3042 | } |
| 3043 | |
| 3044 | size_t Context::getExtensionStringCount() const |
| 3045 | { |
| 3046 | return mExtensionStrings.size(); |
| 3047 | } |
| 3048 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3049 | bool Context::isExtensionRequestable(const char *name) |
| 3050 | { |
| 3051 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3052 | auto extension = extensionInfos.find(name); |
| 3053 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3054 | return extension != extensionInfos.end() && extension->second.Requestable && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3055 | mSupportedExtensions.*(extension->second.ExtensionsMember); |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3056 | } |
| 3057 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3058 | void Context::requestExtension(const char *name) |
| 3059 | { |
| 3060 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3061 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 3062 | const auto &extension = extensionInfos.at(name); |
| 3063 | ASSERT(extension.Requestable); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3064 | ASSERT(isExtensionRequestable(name)); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3065 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3066 | if (mState.mExtensions.*(extension.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3067 | { |
| 3068 | // Extension already enabled |
| 3069 | return; |
| 3070 | } |
| 3071 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3072 | mState.mExtensions.*(extension.ExtensionsMember) = true; |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3073 | updateCaps(); |
| 3074 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3075 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 3076 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 3077 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3078 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 3079 | // Invalidate all textures and framebuffer. Some extensions make new formats renderable or |
| 3080 | // sampleable. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3081 | mState.mTextureManager->signalAllTexturesDirty(this); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3082 | for (auto &zeroTexture : mZeroTextures) |
| 3083 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3084 | if (zeroTexture.get() != nullptr) |
| 3085 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3086 | zeroTexture->signalDirtyStorage(this, InitState::Initialized); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3087 | } |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3088 | } |
| 3089 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3090 | mState.mFramebufferManager->invalidateFramebufferComplenessCache(this); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3091 | } |
| 3092 | |
| 3093 | size_t Context::getRequestableExtensionStringCount() const |
| 3094 | { |
| 3095 | return mRequestableExtensionStrings.size(); |
| 3096 | } |
| 3097 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 3098 | void Context::beginTransformFeedback(PrimitiveMode primitiveMode) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3099 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3100 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3101 | ASSERT(transformFeedback != nullptr); |
| 3102 | ASSERT(!transformFeedback->isPaused()); |
| 3103 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3104 | ANGLE_CONTEXT_TRY(transformFeedback->begin(this, primitiveMode, mState.getProgram())); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 3105 | mStateCache.onActiveTransformFeedbackChange(this); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3106 | } |
| 3107 | |
| 3108 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 3109 | { |
| 3110 | for (auto pair : mTransformFeedbackMap) |
| 3111 | { |
| 3112 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 3113 | { |
| 3114 | return true; |
| 3115 | } |
| 3116 | } |
| 3117 | return false; |
| 3118 | } |
| 3119 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3120 | Extensions Context::generateSupportedExtensions() const |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3121 | { |
| 3122 | Extensions supportedExtensions = mImplementation->getNativeExtensions(); |
| 3123 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3124 | // Explicitly enable GL_KHR_parallel_shader_compile |
| 3125 | supportedExtensions.parallelShaderCompile = true; |
| 3126 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3127 | if (getClientVersion() < ES_2_0) |
| 3128 | { |
| 3129 | // Default extensions for GLES1 |
Lingfeng Yang | 0df813c | 2018-07-12 12:52:06 -0700 | [diff] [blame] | 3130 | supportedExtensions.pointSizeArray = true; |
| 3131 | supportedExtensions.textureCubeMap = true; |
| 3132 | supportedExtensions.pointSprite = true; |
| 3133 | supportedExtensions.drawTexture = true; |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3134 | supportedExtensions.parallelShaderCompile = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3135 | } |
| 3136 | |
| 3137 | if (getClientVersion() < ES_3_0) |
| 3138 | { |
| 3139 | // Disable ES3+ extensions |
| 3140 | supportedExtensions.colorBufferFloat = false; |
| 3141 | supportedExtensions.eglImageExternalEssl3 = false; |
| 3142 | supportedExtensions.textureNorm16 = false; |
| 3143 | supportedExtensions.multiview = false; |
| 3144 | supportedExtensions.maxViews = 1u; |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 3145 | supportedExtensions.copyTexture3d = false; |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 3146 | supportedExtensions.textureMultisample = false; |
Geoff Lang | 7198ebc | 2018-11-22 14:36:06 -0500 | [diff] [blame] | 3147 | |
| 3148 | // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support |
| 3149 | if (!supportedExtensions.sRGB) |
| 3150 | { |
| 3151 | supportedExtensions.textureSRGBDecode = false; |
| 3152 | } |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | if (getClientVersion() < ES_3_1) |
| 3156 | { |
| 3157 | // Disable ES3.1+ extensions |
| 3158 | supportedExtensions.geometryShader = false; |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 3159 | |
| 3160 | // TODO(http://anglebug.com/2775): Multisample arrays could be supported on ES 3.0 as well |
| 3161 | // once 2D multisample texture extension is exposed there. |
Olli Etuaho | 064458a | 2018-08-30 14:02:02 +0300 | [diff] [blame] | 3162 | supportedExtensions.textureStorageMultisample2DArray = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | if (getClientVersion() > ES_2_0) |
| 3166 | { |
| 3167 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 3168 | // supportedExtensions.sRGB = false; |
| 3169 | } |
| 3170 | |
| 3171 | // Some extensions are always available because they are implemented in the GL layer. |
| 3172 | supportedExtensions.bindUniformLocation = true; |
| 3173 | supportedExtensions.vertexArrayObject = true; |
| 3174 | supportedExtensions.bindGeneratesResource = true; |
| 3175 | supportedExtensions.clientArrays = true; |
| 3176 | supportedExtensions.requestExtension = true; |
Austin Eng | 7cf9cd2 | 2018-10-09 15:27:32 -0700 | [diff] [blame] | 3177 | supportedExtensions.multiDraw = true; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3178 | |
| 3179 | // Enable the no error extension if the context was created with the flag. |
| 3180 | supportedExtensions.noError = mSkipValidation; |
| 3181 | |
| 3182 | // 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] | 3183 | supportedExtensions.surfacelessContext = mSurfacelessSupported; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3184 | |
| 3185 | // Explicitly enable GL_KHR_debug |
| 3186 | supportedExtensions.debug = true; |
| 3187 | supportedExtensions.maxDebugMessageLength = 1024; |
| 3188 | supportedExtensions.maxDebugLoggedMessages = 1024; |
| 3189 | supportedExtensions.maxDebugGroupStackDepth = 1024; |
| 3190 | supportedExtensions.maxLabelLength = 1024; |
| 3191 | |
| 3192 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 3193 | supportedExtensions.robustClientMemory = true; |
| 3194 | |
| 3195 | // Determine robust resource init availability from EGL. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3196 | supportedExtensions.robustResourceInitialization = mState.isRobustResourceInitEnabled(); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3197 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3198 | // mState.mExtensions.robustBufferAccessBehavior is true only if robust access is true and the |
| 3199 | // backend supports it. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3200 | supportedExtensions.robustBufferAccessBehavior = |
| 3201 | mRobustAccess && supportedExtensions.robustBufferAccessBehavior; |
| 3202 | |
| 3203 | // Enable the cache control query unconditionally. |
| 3204 | supportedExtensions.programCacheControl = true; |
| 3205 | |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3206 | // Enable EGL_ANGLE_explicit_context subextensions |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3207 | if (mExplicitContextAvailable) |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3208 | { |
| 3209 | // GL_ANGLE_explicit_context_gles1 |
| 3210 | supportedExtensions.explicitContextGles1 = true; |
| 3211 | // GL_ANGLE_explicit_context |
| 3212 | supportedExtensions.explicitContext = true; |
| 3213 | } |
| 3214 | |
Shahbaz Youssefi | 5313c8a | 2019-01-14 17:02:52 -0500 | [diff] [blame] | 3215 | // If EGL_KHR_fence_sync is not enabled, don't expose GL_OES_EGL_sync. |
| 3216 | ASSERT(mCurrentDisplay); |
| 3217 | if (!mCurrentDisplay->getExtensions().fenceSync) |
| 3218 | { |
| 3219 | supportedExtensions.eglSync = false; |
| 3220 | } |
| 3221 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3222 | supportedExtensions.memorySize = true; |
| 3223 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3224 | return supportedExtensions; |
| 3225 | } |
| 3226 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3227 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3228 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3229 | mState.mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3230 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3231 | mSupportedExtensions = generateSupportedExtensions(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3232 | mState.mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3233 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3234 | mState.mLimitations = mImplementation->getNativeLimitations(); |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3235 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3236 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3237 | if (getClientVersion() < Version(2, 0)) |
| 3238 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3239 | mState.mCaps.maxMultitextureUnits = 4; |
| 3240 | mState.mCaps.maxClipPlanes = 6; |
| 3241 | mState.mCaps.maxLights = 8; |
| 3242 | mState.mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3243 | mState.mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3244 | mState.mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3245 | mState.mCaps.minSmoothPointSize = 1.0f; |
| 3246 | mState.mCaps.maxSmoothPointSize = 1.0f; |
| 3247 | mState.mCaps.minSmoothLineWidth = 1.0f; |
| 3248 | mState.mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3249 | } |
| 3250 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3251 | // Apply/Verify implementation limits |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3252 | LimitCap(&mState.mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3253 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3254 | ASSERT(mState.mCaps.minAliasedPointSize >= 1.0f); |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3255 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3256 | if (getClientVersion() < ES_3_1) |
| 3257 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3258 | mState.mCaps.maxVertexAttribBindings = mState.mCaps.maxVertexAttributes; |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3259 | } |
| 3260 | else |
| 3261 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3262 | LimitCap(&mState.mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3263 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3264 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3265 | LimitCap(&mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3266 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3267 | LimitCap(&mState.mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3268 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3269 | LimitCap(&mState.mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3270 | LimitCap(&mState.mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3271 | |
| 3272 | // 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] | 3273 | LimitCap(&mState.mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
| 3274 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3275 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3276 | LimitCap(&mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3277 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3278 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3279 | LimitCap(&mState.mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3280 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3281 | mState.mCaps.maxSampleMaskWords = |
| 3282 | std::min<GLuint>(mState.mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3283 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3284 | // WebGL compatibility |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3285 | mState.mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3286 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3287 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3288 | // If the user has requested that extensions start disabled and they are requestable, |
| 3289 | // disable them. |
| 3290 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3291 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3292 | mState.mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3293 | } |
| 3294 | } |
| 3295 | |
| 3296 | // Generate texture caps |
| 3297 | updateCaps(); |
| 3298 | } |
| 3299 | |
| 3300 | void Context::updateCaps() |
| 3301 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3302 | mState.mCaps.compressedTextureFormats.clear(); |
| 3303 | mState.mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3304 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3305 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3306 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3307 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3308 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3309 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3310 | // Update the format caps based on the client version and extensions. |
| 3311 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3312 | // ES3. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3313 | formatCaps.texturable = formatCaps.texturable && |
| 3314 | formatInfo.textureSupport(getClientVersion(), mState.mExtensions); |
| 3315 | formatCaps.filterable = formatCaps.filterable && |
| 3316 | formatInfo.filterSupport(getClientVersion(), mState.mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3317 | formatCaps.textureAttachment = |
| 3318 | formatCaps.textureAttachment && |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3319 | formatInfo.textureAttachmentSupport(getClientVersion(), mState.mExtensions); |
| 3320 | formatCaps.renderbuffer = |
| 3321 | formatCaps.renderbuffer && |
| 3322 | formatInfo.renderbufferSupport(getClientVersion(), mState.mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3323 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3324 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3325 | // 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] | 3326 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3327 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3328 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3329 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3330 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3331 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3332 | else |
| 3333 | { |
| 3334 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3335 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3336 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3337 | |
| 3338 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3339 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3340 | // exception of signed and unsigned integer formats." |
| 3341 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3342 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3343 | { |
| 3344 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3345 | mState.mCaps.maxSamples = std::min(mState.mCaps.maxSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3346 | } |
| 3347 | |
| 3348 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3349 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3350 | { |
| 3351 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3352 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3353 | // the exception that the signed and unsigned integer formats are required only to |
| 3354 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3355 | // multisamples, which must be at least one." |
| 3356 | if (formatInfo.componentType == GL_INT || |
| 3357 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3358 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3359 | mState.mCaps.maxIntegerSamples = |
| 3360 | std::min(mState.mCaps.maxIntegerSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | // GLES 3.1 section 19.3.1. |
| 3364 | if (formatCaps.texturable) |
| 3365 | { |
| 3366 | if (formatInfo.depthBits > 0) |
| 3367 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3368 | mState.mCaps.maxDepthTextureSamples = |
| 3369 | std::min(mState.mCaps.maxDepthTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3370 | } |
| 3371 | else if (formatInfo.redBits > 0) |
| 3372 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3373 | mState.mCaps.maxColorTextureSamples = |
| 3374 | std::min(mState.mCaps.maxColorTextureSamples, formatMaxSamples); |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3375 | } |
| 3376 | } |
| 3377 | } |
| 3378 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3379 | |
| 3380 | if (formatCaps.texturable && formatInfo.compressed) |
| 3381 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3382 | mState.mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3383 | } |
| 3384 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3385 | mState.mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3386 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3387 | |
| 3388 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3389 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3390 | { |
| 3391 | mMemoryProgramCache = nullptr; |
| 3392 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3393 | |
| 3394 | // Compute which buffer types are allowed |
| 3395 | mValidBufferBindings.reset(); |
| 3396 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3397 | mValidBufferBindings.set(BufferBinding::Array); |
| 3398 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3399 | if (mState.mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3400 | { |
| 3401 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3402 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3403 | } |
| 3404 | |
| 3405 | if (getClientVersion() >= ES_3_0) |
| 3406 | { |
| 3407 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3408 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3409 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3410 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3411 | } |
| 3412 | |
| 3413 | if (getClientVersion() >= ES_3_1) |
| 3414 | { |
| 3415 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3416 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3417 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3418 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3419 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3420 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3421 | mThreadPool = angle::WorkerThreadPool::Create(mState.mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3422 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3423 | // Reinitialize some dirty bits that depend on extensions. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3424 | bool robustInit = mState.isRobustResourceInitEnabled(); |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3425 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3426 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3427 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
| 3428 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3429 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3430 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3431 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame] | 3432 | // We need to validate buffer bounds if we are in a WebGL or robust access context and the |
| 3433 | // back-end does not support robust buffer access behaviour. |
| 3434 | if (!mSupportedExtensions.robustBufferAccessBehavior && (mState.isWebGL() || mRobustAccess)) |
| 3435 | { |
| 3436 | mBufferAccessValidationEnabled = true; |
| 3437 | } |
| 3438 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3439 | // Reinitialize state cache after extension changes. |
| 3440 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3441 | } |
| 3442 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3443 | void Context::initWorkarounds() |
| 3444 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3445 | // Apply back-end workarounds. |
| 3446 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3447 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3448 | // Lose the context upon out of memory error if the application is |
| 3449 | // expecting to watch for those events. |
| 3450 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3451 | |
| 3452 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3453 | { |
| 3454 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3455 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3456 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3457 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3458 | } |
| 3459 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3460 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3461 | { |
| 3462 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3463 | } |
| 3464 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3465 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3466 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3467 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3468 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3469 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3470 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3471 | } |
| 3472 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3473 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3474 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3475 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3476 | ANGLE_TRY(mState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3477 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3478 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3479 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3480 | } |
| 3481 | |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3482 | ANGLE_INLINE angle::Result Context::prepareForDispatch() |
| 3483 | { |
| 3484 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
| 3485 | return syncDirtyBits(mComputeDirtyBits); |
| 3486 | } |
| 3487 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3488 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3489 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3490 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3491 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3492 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3493 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3494 | } |
| 3495 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3496 | void Context::blitFramebuffer(GLint srcX0, |
| 3497 | GLint srcY0, |
| 3498 | GLint srcX1, |
| 3499 | GLint srcY1, |
| 3500 | GLint dstX0, |
| 3501 | GLint dstY0, |
| 3502 | GLint dstX1, |
| 3503 | GLint dstY1, |
| 3504 | GLbitfield mask, |
| 3505 | GLenum filter) |
| 3506 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3507 | if (mask == 0) |
| 3508 | { |
| 3509 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3510 | // buffers are copied. |
| 3511 | return; |
| 3512 | } |
| 3513 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3514 | Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3515 | ASSERT(drawFramebuffer); |
| 3516 | |
| 3517 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3518 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3519 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3520 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3521 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3522 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3523 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3524 | |
| 3525 | void Context::clear(GLbitfield mask) |
| 3526 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3527 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3528 | ANGLE_CONTEXT_TRY(mState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3529 | } |
| 3530 | |
| 3531 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3532 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3533 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3534 | const FramebufferAttachment *attachment = nullptr; |
| 3535 | if (buffer == GL_DEPTH) |
| 3536 | { |
| 3537 | attachment = framebufferObject->getDepthbuffer(); |
| 3538 | } |
| 3539 | if (buffer == GL_COLOR && |
| 3540 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3541 | { |
| 3542 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3543 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3544 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3545 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3546 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3547 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3548 | return; |
| 3549 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3550 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3551 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3552 | } |
| 3553 | |
| 3554 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3555 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3556 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3557 | const FramebufferAttachment *attachment = nullptr; |
| 3558 | if (buffer == GL_COLOR && |
| 3559 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3560 | { |
| 3561 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3562 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3563 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3564 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3565 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3566 | { |
| 3567 | return; |
| 3568 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3569 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3570 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3571 | } |
| 3572 | |
| 3573 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3574 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3575 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3576 | const FramebufferAttachment *attachment = nullptr; |
| 3577 | if (buffer == GL_STENCIL) |
| 3578 | { |
| 3579 | attachment = framebufferObject->getStencilbuffer(); |
| 3580 | } |
| 3581 | if (buffer == GL_COLOR && |
| 3582 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3583 | { |
| 3584 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3585 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3586 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3587 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3588 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3589 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3590 | return; |
| 3591 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3592 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3593 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3594 | } |
| 3595 | |
| 3596 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3597 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3598 | Framebuffer *framebufferObject = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3599 | ASSERT(framebufferObject); |
| 3600 | |
| 3601 | // If a buffer is not present, the clear has no effect |
| 3602 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3603 | framebufferObject->getStencilbuffer() == nullptr) |
| 3604 | { |
| 3605 | return; |
| 3606 | } |
| 3607 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3608 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3609 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3610 | } |
| 3611 | |
| 3612 | void Context::readPixels(GLint x, |
| 3613 | GLint y, |
| 3614 | GLsizei width, |
| 3615 | GLsizei height, |
| 3616 | GLenum format, |
| 3617 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3618 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3619 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3620 | if (width == 0 || height == 0) |
| 3621 | { |
| 3622 | return; |
| 3623 | } |
| 3624 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3625 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3626 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3627 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3628 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3629 | |
| 3630 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3631 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3632 | } |
| 3633 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3634 | void Context::readPixelsRobust(GLint x, |
| 3635 | GLint y, |
| 3636 | GLsizei width, |
| 3637 | GLsizei height, |
| 3638 | GLenum format, |
| 3639 | GLenum type, |
| 3640 | GLsizei bufSize, |
| 3641 | GLsizei *length, |
| 3642 | GLsizei *columns, |
| 3643 | GLsizei *rows, |
| 3644 | void *pixels) |
| 3645 | { |
| 3646 | readPixels(x, y, width, height, format, type, pixels); |
| 3647 | } |
| 3648 | |
| 3649 | void Context::readnPixelsRobust(GLint x, |
| 3650 | GLint y, |
| 3651 | GLsizei width, |
| 3652 | GLsizei height, |
| 3653 | GLenum format, |
| 3654 | GLenum type, |
| 3655 | GLsizei bufSize, |
| 3656 | GLsizei *length, |
| 3657 | GLsizei *columns, |
| 3658 | GLsizei *rows, |
| 3659 | void *data) |
| 3660 | { |
| 3661 | readPixels(x, y, width, height, format, type, data); |
| 3662 | } |
| 3663 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3664 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3665 | GLint level, |
| 3666 | GLenum internalformat, |
| 3667 | GLint x, |
| 3668 | GLint y, |
| 3669 | GLsizei width, |
| 3670 | GLsizei height, |
| 3671 | GLint border) |
| 3672 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3673 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3674 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3675 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3676 | Rectangle sourceArea(x, y, width, height); |
| 3677 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3678 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3679 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3680 | ANGLE_CONTEXT_TRY( |
| 3681 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3682 | } |
| 3683 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3684 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3685 | GLint level, |
| 3686 | GLint xoffset, |
| 3687 | GLint yoffset, |
| 3688 | GLint x, |
| 3689 | GLint y, |
| 3690 | GLsizei width, |
| 3691 | GLsizei height) |
| 3692 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3693 | if (width == 0 || height == 0) |
| 3694 | { |
| 3695 | return; |
| 3696 | } |
| 3697 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3698 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3699 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3700 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3701 | Offset destOffset(xoffset, yoffset, 0); |
| 3702 | Rectangle sourceArea(x, y, width, height); |
| 3703 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3704 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3705 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3706 | ANGLE_CONTEXT_TRY( |
| 3707 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3708 | } |
| 3709 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3710 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3711 | GLint level, |
| 3712 | GLint xoffset, |
| 3713 | GLint yoffset, |
| 3714 | GLint zoffset, |
| 3715 | GLint x, |
| 3716 | GLint y, |
| 3717 | GLsizei width, |
| 3718 | GLsizei height) |
| 3719 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3720 | if (width == 0 || height == 0) |
| 3721 | { |
| 3722 | return; |
| 3723 | } |
| 3724 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3725 | // Only sync the read FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3726 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3727 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3728 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3729 | Rectangle sourceArea(x, y, width, height); |
| 3730 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3731 | Framebuffer *framebuffer = mState.getReadFramebuffer(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3732 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3733 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3734 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3735 | } |
| 3736 | |
| 3737 | void Context::framebufferTexture2D(GLenum target, |
| 3738 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3739 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3740 | GLuint texture, |
| 3741 | GLint level) |
| 3742 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3743 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3744 | ASSERT(framebuffer); |
| 3745 | |
| 3746 | if (texture != 0) |
| 3747 | { |
| 3748 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3749 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3750 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3751 | } |
| 3752 | else |
| 3753 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3754 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3755 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3756 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3757 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3758 | } |
| 3759 | |
| 3760 | void Context::framebufferRenderbuffer(GLenum target, |
| 3761 | GLenum attachment, |
| 3762 | GLenum renderbuffertarget, |
| 3763 | GLuint renderbuffer) |
| 3764 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3765 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3766 | ASSERT(framebuffer); |
| 3767 | |
| 3768 | if (renderbuffer != 0) |
| 3769 | { |
| 3770 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3771 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3772 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3773 | renderbufferObject); |
| 3774 | } |
| 3775 | else |
| 3776 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3777 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3778 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3779 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3780 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3781 | } |
| 3782 | |
| 3783 | void Context::framebufferTextureLayer(GLenum target, |
| 3784 | GLenum attachment, |
| 3785 | GLuint texture, |
| 3786 | GLint level, |
| 3787 | GLint layer) |
| 3788 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3789 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3790 | ASSERT(framebuffer); |
| 3791 | |
| 3792 | if (texture != 0) |
| 3793 | { |
| 3794 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3795 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3796 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3797 | } |
| 3798 | else |
| 3799 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3800 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3801 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3802 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3803 | mState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3804 | } |
| 3805 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3806 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3807 | GLenum attachment, |
| 3808 | GLuint texture, |
| 3809 | GLint level, |
| 3810 | GLint baseViewIndex, |
| 3811 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3812 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3813 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3814 | ASSERT(framebuffer); |
| 3815 | |
| 3816 | if (texture != 0) |
| 3817 | { |
| 3818 | Texture *textureObj = getTexture(texture); |
| 3819 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3820 | ImageIndex index; |
| 3821 | if (textureObj->getType() == TextureType::_2DArray) |
| 3822 | { |
| 3823 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3824 | } |
| 3825 | else |
| 3826 | { |
| 3827 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3828 | ASSERT(level == 0); |
| 3829 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3830 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3831 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3832 | numViews, baseViewIndex); |
| 3833 | } |
| 3834 | else |
| 3835 | { |
| 3836 | framebuffer->resetAttachment(this, attachment); |
| 3837 | } |
| 3838 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3839 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3840 | } |
| 3841 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3842 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3843 | GLenum attachment, |
| 3844 | GLuint texture, |
| 3845 | GLint level, |
| 3846 | GLsizei numViews, |
| 3847 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3848 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3849 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3850 | ASSERT(framebuffer); |
| 3851 | |
| 3852 | if (texture != 0) |
| 3853 | { |
| 3854 | Texture *textureObj = getTexture(texture); |
| 3855 | |
| 3856 | ImageIndex index = ImageIndex::Make2D(level); |
| 3857 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3858 | textureObj, numViews, viewportOffsets); |
| 3859 | } |
| 3860 | else |
| 3861 | { |
| 3862 | framebuffer->resetAttachment(this, attachment); |
| 3863 | } |
| 3864 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3865 | mState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3866 | } |
| 3867 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3868 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3869 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3870 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3871 | ASSERT(framebuffer); |
| 3872 | |
| 3873 | if (texture != 0) |
| 3874 | { |
| 3875 | Texture *textureObj = getTexture(texture); |
| 3876 | |
| 3877 | ImageIndex index = ImageIndex::MakeFromType( |
| 3878 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3879 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3880 | } |
| 3881 | else |
| 3882 | { |
| 3883 | framebuffer->resetAttachment(this, attachment); |
| 3884 | } |
| 3885 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3886 | mState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3887 | } |
| 3888 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3889 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3890 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3891 | Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3892 | ASSERT(framebuffer); |
| 3893 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3894 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3895 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3896 | } |
| 3897 | |
| 3898 | void Context::readBuffer(GLenum mode) |
| 3899 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3900 | Framebuffer *readFBO = mState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3901 | readFBO->setReadBuffer(mode); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3902 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3903 | } |
| 3904 | |
| 3905 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3906 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3907 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3908 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3909 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3910 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3911 | ASSERT(framebuffer); |
| 3912 | |
| 3913 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3914 | // 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] | 3915 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3916 | } |
| 3917 | |
| 3918 | void Context::invalidateFramebuffer(GLenum target, |
| 3919 | GLsizei numAttachments, |
| 3920 | const GLenum *attachments) |
| 3921 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3922 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3923 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3924 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3925 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3926 | ASSERT(framebuffer); |
| 3927 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3928 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3929 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3930 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3931 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3932 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3933 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3934 | } |
| 3935 | |
| 3936 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3937 | GLsizei numAttachments, |
| 3938 | const GLenum *attachments, |
| 3939 | GLint x, |
| 3940 | GLint y, |
| 3941 | GLsizei width, |
| 3942 | GLsizei height) |
| 3943 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3944 | // Only sync the FBO |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3945 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3946 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3947 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3948 | ASSERT(framebuffer); |
| 3949 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3950 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3951 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3952 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3953 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3954 | |
| 3955 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3956 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3957 | } |
| 3958 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3959 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3960 | GLint level, |
| 3961 | GLint internalformat, |
| 3962 | GLsizei width, |
| 3963 | GLsizei height, |
| 3964 | GLint border, |
| 3965 | GLenum format, |
| 3966 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3967 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3968 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3969 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3970 | |
| 3971 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3972 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 3973 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3974 | internalformat, size, format, type, |
| 3975 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3976 | } |
| 3977 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3978 | void Context::texImage2DRobust(TextureTarget target, |
| 3979 | GLint level, |
| 3980 | GLint internalformat, |
| 3981 | GLsizei width, |
| 3982 | GLsizei height, |
| 3983 | GLint border, |
| 3984 | GLenum format, |
| 3985 | GLenum type, |
| 3986 | GLsizei bufSize, |
| 3987 | const void *pixels) |
| 3988 | { |
| 3989 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 3990 | } |
| 3991 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3992 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3993 | GLint level, |
| 3994 | GLint internalformat, |
| 3995 | GLsizei width, |
| 3996 | GLsizei height, |
| 3997 | GLsizei depth, |
| 3998 | GLint border, |
| 3999 | GLenum format, |
| 4000 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4001 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4002 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4003 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4004 | |
| 4005 | Extents size(width, height, depth); |
| 4006 | Texture *texture = getTargetTexture(target); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4007 | ANGLE_CONTEXT_TRY(texture->setImage(this, mState.getUnpackState(), |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4008 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4009 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4010 | } |
| 4011 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4012 | void Context::texImage3DRobust(TextureType target, |
| 4013 | GLint level, |
| 4014 | GLint internalformat, |
| 4015 | GLsizei width, |
| 4016 | GLsizei height, |
| 4017 | GLsizei depth, |
| 4018 | GLint border, |
| 4019 | GLenum format, |
| 4020 | GLenum type, |
| 4021 | GLsizei bufSize, |
| 4022 | const void *pixels) |
| 4023 | { |
| 4024 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4025 | } |
| 4026 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4027 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4028 | GLint level, |
| 4029 | GLint xoffset, |
| 4030 | GLint yoffset, |
| 4031 | GLsizei width, |
| 4032 | GLsizei height, |
| 4033 | GLenum format, |
| 4034 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4035 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4036 | { |
| 4037 | // Zero sized uploads are valid but no-ops |
| 4038 | if (width == 0 || height == 0) |
| 4039 | { |
| 4040 | return; |
| 4041 | } |
| 4042 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4043 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4044 | |
| 4045 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4046 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4047 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4048 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4049 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4050 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, target, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4051 | level, area, format, type, |
| 4052 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4053 | } |
| 4054 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4055 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4056 | GLint level, |
| 4057 | GLint xoffset, |
| 4058 | GLint yoffset, |
| 4059 | GLsizei width, |
| 4060 | GLsizei height, |
| 4061 | GLenum format, |
| 4062 | GLenum type, |
| 4063 | GLsizei bufSize, |
| 4064 | const void *pixels) |
| 4065 | { |
| 4066 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4067 | } |
| 4068 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4069 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4070 | GLint level, |
| 4071 | GLint xoffset, |
| 4072 | GLint yoffset, |
| 4073 | GLint zoffset, |
| 4074 | GLsizei width, |
| 4075 | GLsizei height, |
| 4076 | GLsizei depth, |
| 4077 | GLenum format, |
| 4078 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4079 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4080 | { |
| 4081 | // Zero sized uploads are valid but no-ops |
| 4082 | if (width == 0 || height == 0 || depth == 0) |
| 4083 | { |
| 4084 | return; |
| 4085 | } |
| 4086 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4087 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4088 | |
| 4089 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4090 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4091 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4092 | gl::Buffer *unpackBuffer = mState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4093 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4094 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mState.getUnpackState(), unpackBuffer, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4095 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4096 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4097 | } |
| 4098 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4099 | void Context::texSubImage3DRobust(TextureType target, |
| 4100 | GLint level, |
| 4101 | GLint xoffset, |
| 4102 | GLint yoffset, |
| 4103 | GLint zoffset, |
| 4104 | GLsizei width, |
| 4105 | GLsizei height, |
| 4106 | GLsizei depth, |
| 4107 | GLenum format, |
| 4108 | GLenum type, |
| 4109 | GLsizei bufSize, |
| 4110 | const void *pixels) |
| 4111 | { |
| 4112 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4113 | pixels); |
| 4114 | } |
| 4115 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4116 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4117 | GLint level, |
| 4118 | GLenum internalformat, |
| 4119 | GLsizei width, |
| 4120 | GLsizei height, |
| 4121 | GLint border, |
| 4122 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4123 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4124 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4125 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4126 | |
| 4127 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4128 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4129 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4130 | internalformat, size, imageSize, |
| 4131 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4132 | } |
| 4133 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4134 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4135 | GLint level, |
| 4136 | GLenum internalformat, |
| 4137 | GLsizei width, |
| 4138 | GLsizei height, |
| 4139 | GLint border, |
| 4140 | GLsizei imageSize, |
| 4141 | GLsizei dataSize, |
| 4142 | const GLvoid *data) |
| 4143 | { |
| 4144 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4145 | } |
| 4146 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4147 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4148 | GLint level, |
| 4149 | GLenum internalformat, |
| 4150 | GLsizei width, |
| 4151 | GLsizei height, |
| 4152 | GLsizei depth, |
| 4153 | GLint border, |
| 4154 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4155 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4156 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4157 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4158 | |
| 4159 | Extents size(width, height, depth); |
| 4160 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4161 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4162 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4163 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4164 | } |
| 4165 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4166 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4167 | GLint level, |
| 4168 | GLenum internalformat, |
| 4169 | GLsizei width, |
| 4170 | GLsizei height, |
| 4171 | GLsizei depth, |
| 4172 | GLint border, |
| 4173 | GLsizei imageSize, |
| 4174 | GLsizei dataSize, |
| 4175 | const GLvoid *data) |
| 4176 | { |
| 4177 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4178 | data); |
| 4179 | } |
| 4180 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4181 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4182 | GLint level, |
| 4183 | GLint xoffset, |
| 4184 | GLint yoffset, |
| 4185 | GLsizei width, |
| 4186 | GLsizei height, |
| 4187 | GLenum format, |
| 4188 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4189 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4190 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4191 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4192 | |
| 4193 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4194 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4195 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4196 | area, format, imageSize, |
| 4197 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4198 | } |
| 4199 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4200 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4201 | GLint level, |
| 4202 | GLint xoffset, |
| 4203 | GLint yoffset, |
| 4204 | GLsizei width, |
| 4205 | GLsizei height, |
| 4206 | GLenum format, |
| 4207 | GLsizei imageSize, |
| 4208 | GLsizei dataSize, |
| 4209 | const GLvoid *data) |
| 4210 | { |
| 4211 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4212 | data); |
| 4213 | } |
| 4214 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4215 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4216 | GLint level, |
| 4217 | GLint xoffset, |
| 4218 | GLint yoffset, |
| 4219 | GLint zoffset, |
| 4220 | GLsizei width, |
| 4221 | GLsizei height, |
| 4222 | GLsizei depth, |
| 4223 | GLenum format, |
| 4224 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4225 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4226 | { |
| 4227 | // Zero sized uploads are valid but no-ops |
| 4228 | if (width == 0 || height == 0) |
| 4229 | { |
| 4230 | return; |
| 4231 | } |
| 4232 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4233 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4234 | |
| 4235 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4236 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4237 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4238 | this, mState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4239 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4240 | } |
| 4241 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4242 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4243 | GLint level, |
| 4244 | GLint xoffset, |
| 4245 | GLint yoffset, |
| 4246 | GLint zoffset, |
| 4247 | GLsizei width, |
| 4248 | GLsizei height, |
| 4249 | GLsizei depth, |
| 4250 | GLenum format, |
| 4251 | GLsizei imageSize, |
| 4252 | GLsizei dataSize, |
| 4253 | const GLvoid *data) |
| 4254 | { |
| 4255 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4256 | imageSize, data); |
| 4257 | } |
| 4258 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4259 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4260 | { |
| 4261 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4262 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4263 | } |
| 4264 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4265 | void Context::copyTexture(GLuint sourceId, |
| 4266 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4267 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4268 | GLuint destId, |
| 4269 | GLint destLevel, |
| 4270 | GLint internalFormat, |
| 4271 | GLenum destType, |
| 4272 | GLboolean unpackFlipY, |
| 4273 | GLboolean unpackPremultiplyAlpha, |
| 4274 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4275 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4276 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4277 | |
| 4278 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4279 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4280 | ANGLE_CONTEXT_TRY( |
| 4281 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4282 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4283 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4284 | } |
| 4285 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4286 | void Context::copySubTexture(GLuint sourceId, |
| 4287 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4288 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4289 | GLuint destId, |
| 4290 | GLint destLevel, |
| 4291 | GLint xoffset, |
| 4292 | GLint yoffset, |
| 4293 | GLint x, |
| 4294 | GLint y, |
| 4295 | GLsizei width, |
| 4296 | GLsizei height, |
| 4297 | GLboolean unpackFlipY, |
| 4298 | GLboolean unpackPremultiplyAlpha, |
| 4299 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4300 | { |
| 4301 | // Zero sized copies are valid but no-ops |
| 4302 | if (width == 0 || height == 0) |
| 4303 | { |
| 4304 | return; |
| 4305 | } |
| 4306 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4307 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4308 | |
| 4309 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4310 | gl::Texture *destTexture = getTexture(destId); |
| 4311 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4312 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4313 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4314 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4315 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4316 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4317 | } |
| 4318 | |
| 4319 | void Context::copyTexture3D(GLuint sourceId, |
| 4320 | GLint sourceLevel, |
| 4321 | TextureTarget destTarget, |
| 4322 | GLuint destId, |
| 4323 | GLint destLevel, |
| 4324 | GLint internalFormat, |
| 4325 | GLenum destType, |
| 4326 | GLboolean unpackFlipY, |
| 4327 | GLboolean unpackPremultiplyAlpha, |
| 4328 | GLboolean unpackUnmultiplyAlpha) |
| 4329 | { |
| 4330 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4331 | |
| 4332 | Texture *sourceTexture = getTexture(sourceId); |
| 4333 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4334 | ANGLE_CONTEXT_TRY( |
| 4335 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4336 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4337 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4338 | } |
| 4339 | |
| 4340 | void Context::copySubTexture3D(GLuint sourceId, |
| 4341 | GLint sourceLevel, |
| 4342 | TextureTarget destTarget, |
| 4343 | GLuint destId, |
| 4344 | GLint destLevel, |
| 4345 | GLint xoffset, |
| 4346 | GLint yoffset, |
| 4347 | GLint zoffset, |
| 4348 | GLint x, |
| 4349 | GLint y, |
| 4350 | GLint z, |
| 4351 | GLsizei width, |
| 4352 | GLsizei height, |
| 4353 | GLsizei depth, |
| 4354 | GLboolean unpackFlipY, |
| 4355 | GLboolean unpackPremultiplyAlpha, |
| 4356 | GLboolean unpackUnmultiplyAlpha) |
| 4357 | { |
| 4358 | // Zero sized copies are valid but no-ops |
| 4359 | if (width == 0 || height == 0 || depth == 0) |
| 4360 | { |
| 4361 | return; |
| 4362 | } |
| 4363 | |
| 4364 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4365 | |
| 4366 | Texture *sourceTexture = getTexture(sourceId); |
| 4367 | Texture *destTexture = getTexture(destId); |
| 4368 | Offset offset(xoffset, yoffset, zoffset); |
| 4369 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4370 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4371 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4372 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4373 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4374 | } |
| 4375 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4376 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4377 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4378 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4379 | |
| 4380 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4381 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4382 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4383 | } |
| 4384 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4385 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4386 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4387 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4388 | ASSERT(buffer); |
| 4389 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4390 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4391 | } |
| 4392 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4393 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4394 | GLenum pname, |
| 4395 | GLsizei bufSize, |
| 4396 | GLsizei *length, |
| 4397 | void **params) |
| 4398 | { |
| 4399 | getBufferPointerv(target, pname, params); |
| 4400 | } |
| 4401 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4402 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4403 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4404 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4405 | ASSERT(buffer); |
| 4406 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4407 | if (buffer->map(this, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4408 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4409 | return nullptr; |
| 4410 | } |
| 4411 | |
| 4412 | return buffer->getMapPointer(); |
| 4413 | } |
| 4414 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4415 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4416 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4417 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4418 | ASSERT(buffer); |
| 4419 | |
| 4420 | GLboolean result; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4421 | if (buffer->unmap(this, &result) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4422 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4423 | return GL_FALSE; |
| 4424 | } |
| 4425 | |
| 4426 | return result; |
| 4427 | } |
| 4428 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4429 | void *Context::mapBufferRange(BufferBinding target, |
| 4430 | GLintptr offset, |
| 4431 | GLsizeiptr length, |
| 4432 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4433 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4434 | Buffer *buffer = mState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4435 | ASSERT(buffer); |
| 4436 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4437 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4438 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4439 | return nullptr; |
| 4440 | } |
| 4441 | |
| 4442 | return buffer->getMapPointer(); |
| 4443 | } |
| 4444 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4445 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4446 | GLintptr /*offset*/, |
| 4447 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4448 | { |
| 4449 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4450 | } |
| 4451 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4452 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4453 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4454 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4455 | } |
| 4456 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4457 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4458 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4459 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4460 | } |
| 4461 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4462 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4463 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4464 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4465 | } |
| 4466 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4467 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4468 | { |
| 4469 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4470 | |
| 4471 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4472 | ANGLE_TRY(syncDirtyBits()); |
| 4473 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4474 | return angle::Result::Continue; |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4475 | } |
| 4476 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4477 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4478 | { |
| 4479 | UNIMPLEMENTED(); |
| 4480 | } |
| 4481 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4482 | void Context::activeTexture(GLenum texture) |
| 4483 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4484 | mState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4485 | } |
| 4486 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4487 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4488 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4489 | mState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4490 | } |
| 4491 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4492 | void Context::blendEquation(GLenum mode) |
| 4493 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4494 | mState.setBlendEquation(mode, mode); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4495 | } |
| 4496 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4497 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4498 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4499 | mState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4500 | } |
| 4501 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4502 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4503 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4504 | mState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4505 | } |
| 4506 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4507 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4508 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4509 | mState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4510 | } |
| 4511 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4512 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4513 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4514 | mState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4515 | } |
| 4516 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4517 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4518 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4519 | mState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4520 | } |
| 4521 | |
| 4522 | void Context::clearStencil(GLint s) |
| 4523 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4524 | mState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4525 | } |
| 4526 | |
| 4527 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4528 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4529 | mState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4530 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4531 | } |
| 4532 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4533 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4534 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4535 | mState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4536 | } |
| 4537 | |
| 4538 | void Context::depthFunc(GLenum func) |
| 4539 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4540 | mState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4541 | } |
| 4542 | |
| 4543 | void Context::depthMask(GLboolean flag) |
| 4544 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4545 | mState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4546 | } |
| 4547 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4548 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4549 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4550 | mState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4551 | } |
| 4552 | |
| 4553 | void Context::disable(GLenum cap) |
| 4554 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4555 | mState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4556 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4557 | } |
| 4558 | |
| 4559 | void Context::disableVertexAttribArray(GLuint index) |
| 4560 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4561 | mState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4562 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4563 | } |
| 4564 | |
| 4565 | void Context::enable(GLenum cap) |
| 4566 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4567 | mState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4568 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4569 | } |
| 4570 | |
| 4571 | void Context::enableVertexAttribArray(GLuint index) |
| 4572 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4573 | mState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4574 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4575 | } |
| 4576 | |
| 4577 | void Context::frontFace(GLenum mode) |
| 4578 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4579 | mState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4580 | } |
| 4581 | |
| 4582 | void Context::hint(GLenum target, GLenum mode) |
| 4583 | { |
| 4584 | switch (target) |
| 4585 | { |
| 4586 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4587 | mState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4588 | break; |
| 4589 | |
| 4590 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4591 | mState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4592 | break; |
| 4593 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4594 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4595 | case GL_POINT_SMOOTH_HINT: |
| 4596 | case GL_LINE_SMOOTH_HINT: |
| 4597 | case GL_FOG_HINT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4598 | mState.gles1().setHint(target, mode); |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4599 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4600 | default: |
| 4601 | UNREACHABLE(); |
| 4602 | return; |
| 4603 | } |
| 4604 | } |
| 4605 | |
| 4606 | void Context::lineWidth(GLfloat width) |
| 4607 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4608 | mState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4609 | } |
| 4610 | |
| 4611 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4612 | { |
| 4613 | switch (pname) |
| 4614 | { |
| 4615 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4616 | mState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4617 | break; |
| 4618 | |
| 4619 | case GL_PACK_ALIGNMENT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4620 | mState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4621 | break; |
| 4622 | |
| 4623 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4624 | mState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4625 | break; |
| 4626 | |
| 4627 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4628 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4629 | mState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4630 | break; |
| 4631 | |
| 4632 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4633 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4634 | mState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4635 | break; |
| 4636 | |
| 4637 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4638 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4639 | mState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4640 | break; |
| 4641 | |
| 4642 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4643 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4644 | mState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4645 | break; |
| 4646 | |
| 4647 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4648 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4649 | mState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4650 | break; |
| 4651 | |
| 4652 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4653 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4654 | mState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4655 | break; |
| 4656 | |
| 4657 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4658 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4659 | mState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4660 | break; |
| 4661 | |
| 4662 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4663 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4664 | mState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4665 | break; |
| 4666 | |
| 4667 | default: |
| 4668 | UNREACHABLE(); |
| 4669 | return; |
| 4670 | } |
| 4671 | } |
| 4672 | |
| 4673 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4674 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4675 | mState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4676 | } |
| 4677 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4678 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4679 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4680 | mState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4681 | } |
| 4682 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4683 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4684 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4685 | mState.setSampleMaskParams(maskNumber, mask); |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4686 | } |
| 4687 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4688 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4689 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4690 | mState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4691 | } |
| 4692 | |
| 4693 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4694 | { |
| 4695 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4696 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4697 | mState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4698 | } |
| 4699 | |
| 4700 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4701 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4702 | mState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4703 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4704 | |
| 4705 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4706 | } |
| 4707 | |
| 4708 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4709 | { |
| 4710 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4711 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4712 | mState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4713 | } |
| 4714 | |
| 4715 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4716 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4717 | mState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4718 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4719 | |
| 4720 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4721 | } |
| 4722 | |
| 4723 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4724 | { |
| 4725 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4726 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4727 | mState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4728 | } |
| 4729 | |
| 4730 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4731 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4732 | mState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4733 | } |
| 4734 | } |
| 4735 | |
| 4736 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4737 | { |
| 4738 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4739 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4740 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4741 | } |
| 4742 | |
| 4743 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4744 | { |
| 4745 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4746 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4747 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4748 | } |
| 4749 | |
| 4750 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4751 | { |
| 4752 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4753 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4754 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4755 | } |
| 4756 | |
| 4757 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4758 | { |
| 4759 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4760 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4761 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4762 | } |
| 4763 | |
| 4764 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4765 | { |
| 4766 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4767 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4768 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4769 | } |
| 4770 | |
| 4771 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4772 | { |
| 4773 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4774 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4775 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4776 | } |
| 4777 | |
| 4778 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4779 | { |
| 4780 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4781 | mState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4782 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4783 | } |
| 4784 | |
| 4785 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4786 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4787 | mState.setVertexAttribf(index, values); |
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::vertexAttribPointer(GLuint index, |
| 4792 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4793 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4794 | GLboolean normalized, |
| 4795 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4796 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4797 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4798 | mState.setVertexAttribPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4799 | type, ConvertToBool(normalized), stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4800 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4801 | } |
| 4802 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4803 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4804 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4805 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4806 | GLboolean normalized, |
| 4807 | GLuint relativeOffset) |
| 4808 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4809 | mState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
| 4810 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4811 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4812 | } |
| 4813 | |
| 4814 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4815 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4816 | VertexAttribType type, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4817 | GLuint relativeOffset) |
| 4818 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4819 | mState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4820 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4821 | } |
| 4822 | |
| 4823 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4824 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4825 | mState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4826 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4827 | } |
| 4828 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4829 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4830 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4831 | mState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4832 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4833 | } |
| 4834 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4835 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4836 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4837 | mState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4838 | } |
| 4839 | |
| 4840 | void Context::vertexAttribIPointer(GLuint index, |
| 4841 | GLint size, |
Jamie Madill | dd34b3b | 2019-01-16 09:59:54 -0500 | [diff] [blame] | 4842 | VertexAttribType type, |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4843 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4844 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4845 | { |
Jamie Madill | 6e18a23 | 2019-01-16 13:27:14 -0500 | [diff] [blame] | 4846 | mState.setVertexAttribIPointer(this, index, mState.getTargetBuffer(BufferBinding::Array), size, |
| 4847 | type, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4848 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4849 | } |
| 4850 | |
| 4851 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4852 | { |
| 4853 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4854 | mState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4855 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4856 | } |
| 4857 | |
| 4858 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4859 | { |
| 4860 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4861 | mState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4862 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4863 | } |
| 4864 | |
| 4865 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4866 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4867 | mState.setVertexAttribi(index, v); |
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::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4872 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4873 | mState.setVertexAttribu(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 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4877 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4878 | { |
| 4879 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4880 | getState().getVertexAttribCurrentValue(index); |
| 4881 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4882 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4883 | currentValues, pname, params); |
| 4884 | } |
| 4885 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4886 | void Context::getVertexAttribivRobust(GLuint index, |
| 4887 | GLenum pname, |
| 4888 | GLsizei bufSize, |
| 4889 | GLsizei *length, |
| 4890 | GLint *params) |
| 4891 | { |
| 4892 | getVertexAttribiv(index, pname, params); |
| 4893 | } |
| 4894 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4895 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4896 | { |
| 4897 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4898 | getState().getVertexAttribCurrentValue(index); |
| 4899 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4900 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4901 | currentValues, pname, params); |
| 4902 | } |
| 4903 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4904 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4905 | GLenum pname, |
| 4906 | GLsizei bufSize, |
| 4907 | GLsizei *length, |
| 4908 | GLfloat *params) |
| 4909 | { |
| 4910 | getVertexAttribfv(index, pname, params); |
| 4911 | } |
| 4912 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4913 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4914 | { |
| 4915 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4916 | getState().getVertexAttribCurrentValue(index); |
| 4917 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4918 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4919 | currentValues, pname, params); |
| 4920 | } |
| 4921 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4922 | void Context::getVertexAttribIivRobust(GLuint index, |
| 4923 | GLenum pname, |
| 4924 | GLsizei bufSize, |
| 4925 | GLsizei *length, |
| 4926 | GLint *params) |
| 4927 | { |
| 4928 | getVertexAttribIiv(index, pname, params); |
| 4929 | } |
| 4930 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4931 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 4932 | { |
| 4933 | const VertexAttribCurrentValueData ¤tValues = |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4934 | getState().getVertexAttribCurrentValue(index); |
| 4935 | const VertexArray *vao = getState().getVertexArray(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4936 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4937 | currentValues, pname, params); |
| 4938 | } |
| 4939 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4940 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 4941 | GLenum pname, |
| 4942 | GLsizei bufSize, |
| 4943 | GLsizei *length, |
| 4944 | GLuint *params) |
| 4945 | { |
| 4946 | getVertexAttribIuiv(index, pname, params); |
| 4947 | } |
| 4948 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4949 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4950 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4951 | const VertexAttribute &attrib = getState().getVertexArray()->getVertexAttribute(index); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4952 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 4953 | } |
| 4954 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4955 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 4956 | GLenum pname, |
| 4957 | GLsizei bufSize, |
| 4958 | GLsizei *length, |
| 4959 | void **pointer) |
| 4960 | { |
| 4961 | getVertexAttribPointerv(index, pname, pointer); |
| 4962 | } |
| 4963 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4964 | void Context::debugMessageControl(GLenum source, |
| 4965 | GLenum type, |
| 4966 | GLenum severity, |
| 4967 | GLsizei count, |
| 4968 | const GLuint *ids, |
| 4969 | GLboolean enabled) |
| 4970 | { |
| 4971 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4972 | mState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
| 4973 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4974 | } |
| 4975 | |
| 4976 | void Context::debugMessageInsert(GLenum source, |
| 4977 | GLenum type, |
| 4978 | GLuint id, |
| 4979 | GLenum severity, |
| 4980 | GLsizei length, |
| 4981 | const GLchar *buf) |
| 4982 | { |
| 4983 | 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] | 4984 | mState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4985 | } |
| 4986 | |
| 4987 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 4988 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 4989 | mState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4990 | } |
| 4991 | |
| 4992 | GLuint Context::getDebugMessageLog(GLuint count, |
| 4993 | GLsizei bufSize, |
| 4994 | GLenum *sources, |
| 4995 | GLenum *types, |
| 4996 | GLuint *ids, |
| 4997 | GLenum *severities, |
| 4998 | GLsizei *lengths, |
| 4999 | GLchar *messageLog) |
| 5000 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5001 | return static_cast<GLuint>(mState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 5002 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5003 | } |
| 5004 | |
| 5005 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 5006 | { |
| 5007 | 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] | 5008 | mState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5009 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5010 | } |
| 5011 | |
| 5012 | void Context::popDebugGroup() |
| 5013 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5014 | mState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5015 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5016 | } |
| 5017 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5018 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5019 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5020 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5021 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5022 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5023 | } |
| 5024 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5025 | void Context::bufferSubData(BufferBinding target, |
| 5026 | GLintptr offset, |
| 5027 | GLsizeiptr size, |
| 5028 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5029 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5030 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5031 | { |
| 5032 | return; |
| 5033 | } |
| 5034 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5035 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5036 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5037 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5038 | } |
| 5039 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5040 | void Context::attachShader(GLuint program, GLuint shader) |
| 5041 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5042 | Program *programObject = mState.mShaderProgramManager->getProgram(program); |
| 5043 | Shader *shaderObject = mState.mShaderProgramManager->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5044 | ASSERT(programObject && shaderObject); |
| 5045 | programObject->attachShader(shaderObject); |
| 5046 | } |
| 5047 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5048 | const Workarounds &Context::getWorkarounds() const |
| 5049 | { |
| 5050 | return mWorkarounds; |
| 5051 | } |
| 5052 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5053 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5054 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5055 | GLintptr readOffset, |
| 5056 | GLintptr writeOffset, |
| 5057 | GLsizeiptr size) |
| 5058 | { |
| 5059 | // if size is zero, the copy is a successful no-op |
| 5060 | if (size == 0) |
| 5061 | { |
| 5062 | return; |
| 5063 | } |
| 5064 | |
| 5065 | // TODO(jmadill): cache these. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5066 | Buffer *readBuffer = mState.getTargetBuffer(readTarget); |
| 5067 | Buffer *writeBuffer = mState.getTargetBuffer(writeTarget); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5068 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5069 | ANGLE_CONTEXT_TRY( |
| 5070 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5071 | } |
| 5072 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5073 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5074 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5075 | // Ideally we could share the program query with the validation layer if possible. |
| 5076 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5077 | ASSERT(programObject); |
| 5078 | programObject->bindAttributeLocation(index, name); |
| 5079 | } |
| 5080 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5081 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5082 | { |
| 5083 | bindBufferRange(target, index, buffer, 0, 0); |
| 5084 | } |
| 5085 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5086 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5087 | GLuint index, |
| 5088 | GLuint buffer, |
| 5089 | GLintptr offset, |
| 5090 | GLsizeiptr size) |
| 5091 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5092 | Buffer *object = mState.mBufferManager->checkBufferAllocation(mImplementation.get(), buffer); |
| 5093 | ANGLE_CONTEXT_TRY(mState.setIndexedBufferBinding(this, target, index, object, offset, size)); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5094 | if (target == BufferBinding::Uniform) |
| 5095 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5096 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5097 | mStateCache.onUniformBufferStateChange(this); |
| 5098 | } |
| 5099 | else |
| 5100 | { |
| 5101 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5102 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5103 | } |
| 5104 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5105 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5106 | { |
| 5107 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5108 | { |
| 5109 | bindReadFramebuffer(framebuffer); |
| 5110 | } |
| 5111 | |
| 5112 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5113 | { |
| 5114 | bindDrawFramebuffer(framebuffer); |
| 5115 | } |
| 5116 | } |
| 5117 | |
| 5118 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5119 | { |
| 5120 | ASSERT(target == GL_RENDERBUFFER); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5121 | Renderbuffer *object = mState.mRenderbufferManager->checkRenderbufferAllocation( |
| 5122 | mImplementation.get(), renderbuffer); |
| 5123 | mState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5124 | } |
| 5125 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5126 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5127 | GLsizei samples, |
| 5128 | GLenum internalformat, |
| 5129 | GLsizei width, |
| 5130 | GLsizei height, |
| 5131 | GLboolean fixedsamplelocations) |
| 5132 | { |
| 5133 | Extents size(width, height, 1); |
| 5134 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5135 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5136 | ConvertToBool(fixedsamplelocations))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5137 | } |
| 5138 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5139 | void Context::texStorage3DMultisample(TextureType target, |
| 5140 | GLsizei samples, |
| 5141 | GLenum internalformat, |
| 5142 | GLsizei width, |
| 5143 | GLsizei height, |
| 5144 | GLsizei depth, |
| 5145 | GLboolean fixedsamplelocations) |
| 5146 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5147 | Extents size(width, height, depth); |
| 5148 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5149 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5150 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5151 | } |
| 5152 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5153 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5154 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5155 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5156 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5157 | ANGLE_CONTEXT_TRY(mState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
| 5158 | const Framebuffer *framebuffer = mState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5159 | |
| 5160 | switch (pname) |
| 5161 | { |
| 5162 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5163 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5164 | break; |
| 5165 | default: |
| 5166 | UNREACHABLE(); |
| 5167 | } |
| 5168 | } |
| 5169 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5170 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5171 | GLuint index, |
| 5172 | GLsizei bufSize, |
| 5173 | GLsizei *length, |
| 5174 | GLfloat *val) |
| 5175 | { |
| 5176 | UNIMPLEMENTED(); |
| 5177 | } |
| 5178 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5179 | void Context::renderbufferStorage(GLenum target, |
| 5180 | GLenum internalformat, |
| 5181 | GLsizei width, |
| 5182 | GLsizei height) |
| 5183 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5184 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5185 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5186 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5187 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5188 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5189 | } |
| 5190 | |
| 5191 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5192 | GLsizei samples, |
| 5193 | GLenum internalformat, |
| 5194 | GLsizei width, |
| 5195 | GLsizei height) |
| 5196 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5197 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5198 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5199 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5200 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5201 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5202 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5203 | } |
| 5204 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5205 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5206 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5207 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5208 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5209 | } |
| 5210 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5211 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5212 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5213 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5214 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5215 | } |
| 5216 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5217 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5218 | GLenum pname, |
| 5219 | GLsizei bufSize, |
| 5220 | GLsizei *length, |
| 5221 | GLint *params) |
| 5222 | { |
| 5223 | UNIMPLEMENTED(); |
| 5224 | } |
| 5225 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5226 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5227 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5228 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5229 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5230 | } |
| 5231 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5232 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5233 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5234 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5235 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5236 | } |
| 5237 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5238 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5239 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5240 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5241 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5242 | } |
| 5243 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5244 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5245 | { |
| 5246 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5247 | { |
| 5248 | return; |
| 5249 | } |
| 5250 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5251 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5252 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5253 | } |
| 5254 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5255 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5256 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +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->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5259 | } |
| 5260 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5261 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5262 | GLsizei levels, |
| 5263 | GLenum internalFormat, |
| 5264 | GLsizei width, |
| 5265 | GLsizei height) |
| 5266 | { |
| 5267 | Extents size(width, height, 1); |
| 5268 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5269 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5270 | } |
| 5271 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5272 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5273 | GLsizei levels, |
| 5274 | GLenum internalFormat, |
| 5275 | GLsizei width, |
| 5276 | GLsizei height, |
| 5277 | GLsizei depth) |
| 5278 | { |
| 5279 | Extents size(width, height, depth); |
| 5280 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5281 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5282 | } |
| 5283 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5284 | void Context::memoryBarrier(GLbitfield barriers) |
| 5285 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5286 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5287 | } |
| 5288 | |
| 5289 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5290 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5291 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5292 | } |
| 5293 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5294 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5295 | const GLint *firsts, |
| 5296 | const GLsizei *counts, |
| 5297 | GLsizei drawcount) |
| 5298 | { |
| 5299 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5300 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5301 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5302 | if (hasDrawID) |
| 5303 | { |
| 5304 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5305 | { |
| 5306 | if (noopDraw(mode, counts[drawID])) |
| 5307 | { |
| 5308 | continue; |
| 5309 | } |
| 5310 | programObject->setDrawIDUniform(drawID); |
| 5311 | ANGLE_CONTEXT_TRY( |
| 5312 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5313 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5314 | } |
| 5315 | } |
| 5316 | else |
| 5317 | { |
| 5318 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5319 | { |
| 5320 | if (noopDraw(mode, counts[drawID])) |
| 5321 | { |
| 5322 | continue; |
| 5323 | } |
| 5324 | ANGLE_CONTEXT_TRY( |
| 5325 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5326 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5327 | } |
| 5328 | } |
| 5329 | } |
| 5330 | |
| 5331 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5332 | const GLint *firsts, |
| 5333 | const GLsizei *counts, |
| 5334 | const GLsizei *instanceCounts, |
| 5335 | GLsizei drawcount) |
| 5336 | { |
| 5337 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5338 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5339 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5340 | if (hasDrawID) |
| 5341 | { |
| 5342 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5343 | { |
| 5344 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5345 | { |
| 5346 | continue; |
| 5347 | } |
| 5348 | programObject->setDrawIDUniform(drawID); |
| 5349 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5350 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5351 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5352 | } |
| 5353 | } |
| 5354 | else |
| 5355 | { |
| 5356 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5357 | { |
| 5358 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5359 | { |
| 5360 | continue; |
| 5361 | } |
| 5362 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5363 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5364 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5365 | } |
| 5366 | } |
| 5367 | } |
| 5368 | |
| 5369 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5370 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5371 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5372 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5373 | GLsizei drawcount) |
| 5374 | { |
| 5375 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5376 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5377 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5378 | if (hasDrawID) |
| 5379 | { |
| 5380 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5381 | { |
| 5382 | if (noopDraw(mode, counts[drawID])) |
| 5383 | { |
| 5384 | continue; |
| 5385 | } |
| 5386 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5387 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5388 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5389 | } |
| 5390 | } |
| 5391 | else |
| 5392 | { |
| 5393 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5394 | { |
| 5395 | if (noopDraw(mode, counts[drawID])) |
| 5396 | { |
| 5397 | continue; |
| 5398 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5399 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5400 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5401 | } |
| 5402 | } |
| 5403 | } |
| 5404 | |
| 5405 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5406 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5407 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5408 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5409 | const GLsizei *instanceCounts, |
| 5410 | GLsizei drawcount) |
| 5411 | { |
| 5412 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5413 | Program *programObject = mState.getLinkedProgram(this); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5414 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5415 | if (hasDrawID) |
| 5416 | { |
| 5417 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5418 | { |
| 5419 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5420 | { |
| 5421 | continue; |
| 5422 | } |
| 5423 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5424 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5425 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5426 | } |
| 5427 | } |
| 5428 | else |
| 5429 | { |
| 5430 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5431 | { |
| 5432 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5433 | { |
| 5434 | continue; |
| 5435 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5436 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5437 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5438 | } |
| 5439 | } |
| 5440 | } |
| 5441 | |
Jeff Gilbert | 465d609 | 2019-01-02 16:21:18 -0800 | [diff] [blame] | 5442 | void Context::provokingVertex(ProvokingVertex provokeMode) |
| 5443 | { |
| 5444 | mState.setProvokingVertex(provokeMode); |
| 5445 | } |
| 5446 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5447 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5448 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5449 | Framebuffer *framebuffer = mState.getTargetFramebuffer(target); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5450 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5451 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5452 | } |
| 5453 | |
| 5454 | void Context::compileShader(GLuint shader) |
| 5455 | { |
| 5456 | Shader *shaderObject = GetValidShader(this, shader); |
| 5457 | if (!shaderObject) |
| 5458 | { |
| 5459 | return; |
| 5460 | } |
| 5461 | shaderObject->compile(this); |
| 5462 | } |
| 5463 | |
| 5464 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5465 | { |
| 5466 | for (int i = 0; i < n; i++) |
| 5467 | { |
| 5468 | deleteBuffer(buffers[i]); |
| 5469 | } |
| 5470 | } |
| 5471 | |
| 5472 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5473 | { |
| 5474 | for (int i = 0; i < n; i++) |
| 5475 | { |
| 5476 | if (framebuffers[i] != 0) |
| 5477 | { |
| 5478 | deleteFramebuffer(framebuffers[i]); |
| 5479 | } |
| 5480 | } |
| 5481 | } |
| 5482 | |
| 5483 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5484 | { |
| 5485 | for (int i = 0; i < n; i++) |
| 5486 | { |
| 5487 | deleteRenderbuffer(renderbuffers[i]); |
| 5488 | } |
| 5489 | } |
| 5490 | |
| 5491 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5492 | { |
| 5493 | for (int i = 0; i < n; i++) |
| 5494 | { |
| 5495 | if (textures[i] != 0) |
| 5496 | { |
| 5497 | deleteTexture(textures[i]); |
| 5498 | } |
| 5499 | } |
| 5500 | } |
| 5501 | |
| 5502 | void Context::detachShader(GLuint program, GLuint shader) |
| 5503 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5504 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5505 | ASSERT(programObject); |
| 5506 | |
| 5507 | Shader *shaderObject = getShader(shader); |
| 5508 | ASSERT(shaderObject); |
| 5509 | |
| 5510 | programObject->detachShader(this, shaderObject); |
| 5511 | } |
| 5512 | |
| 5513 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5514 | { |
| 5515 | for (int i = 0; i < n; i++) |
| 5516 | { |
| 5517 | buffers[i] = createBuffer(); |
| 5518 | } |
| 5519 | } |
| 5520 | |
| 5521 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5522 | { |
| 5523 | for (int i = 0; i < n; i++) |
| 5524 | { |
| 5525 | framebuffers[i] = createFramebuffer(); |
| 5526 | } |
| 5527 | } |
| 5528 | |
| 5529 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5530 | { |
| 5531 | for (int i = 0; i < n; i++) |
| 5532 | { |
| 5533 | renderbuffers[i] = createRenderbuffer(); |
| 5534 | } |
| 5535 | } |
| 5536 | |
| 5537 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5538 | { |
| 5539 | for (int i = 0; i < n; i++) |
| 5540 | { |
| 5541 | textures[i] = createTexture(); |
| 5542 | } |
| 5543 | } |
| 5544 | |
| 5545 | void Context::getActiveAttrib(GLuint program, |
| 5546 | GLuint index, |
| 5547 | GLsizei bufsize, |
| 5548 | GLsizei *length, |
| 5549 | GLint *size, |
| 5550 | GLenum *type, |
| 5551 | GLchar *name) |
| 5552 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5553 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5554 | ASSERT(programObject); |
| 5555 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5556 | } |
| 5557 | |
| 5558 | void Context::getActiveUniform(GLuint program, |
| 5559 | GLuint index, |
| 5560 | GLsizei bufsize, |
| 5561 | GLsizei *length, |
| 5562 | GLint *size, |
| 5563 | GLenum *type, |
| 5564 | GLchar *name) |
| 5565 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5566 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5567 | ASSERT(programObject); |
| 5568 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5569 | } |
| 5570 | |
| 5571 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5572 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5573 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5574 | ASSERT(programObject); |
| 5575 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5576 | } |
| 5577 | |
| 5578 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5579 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5580 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5581 | ASSERT(programObject); |
| 5582 | return programObject->getAttributeLocation(name); |
| 5583 | } |
| 5584 | |
| 5585 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5586 | { |
| 5587 | GLenum nativeType; |
| 5588 | unsigned int numParams = 0; |
| 5589 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5590 | |
| 5591 | if (nativeType == GL_BOOL) |
| 5592 | { |
| 5593 | getBooleanvImpl(pname, params); |
| 5594 | } |
| 5595 | else |
| 5596 | { |
| 5597 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5598 | } |
| 5599 | } |
| 5600 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5601 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5602 | { |
| 5603 | getBooleanv(pname, params); |
| 5604 | } |
| 5605 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5606 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5607 | { |
| 5608 | GLenum nativeType; |
| 5609 | unsigned int numParams = 0; |
| 5610 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5611 | |
| 5612 | if (nativeType == GL_FLOAT) |
| 5613 | { |
| 5614 | getFloatvImpl(pname, params); |
| 5615 | } |
| 5616 | else |
| 5617 | { |
| 5618 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5619 | } |
| 5620 | } |
| 5621 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5622 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5623 | { |
| 5624 | getFloatv(pname, params); |
| 5625 | } |
| 5626 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5627 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5628 | { |
| 5629 | GLenum nativeType; |
| 5630 | unsigned int numParams = 0; |
| 5631 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5632 | |
| 5633 | if (nativeType == GL_INT) |
| 5634 | { |
| 5635 | getIntegervImpl(pname, params); |
| 5636 | } |
| 5637 | else |
| 5638 | { |
| 5639 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5640 | } |
| 5641 | } |
| 5642 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5643 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5644 | { |
| 5645 | getIntegerv(pname, data); |
| 5646 | } |
| 5647 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5648 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5649 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5650 | // Don't resolve link if checking the link completion status. |
| 5651 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5652 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5653 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5654 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5655 | } |
| 5656 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5657 | void Context::getProgramivRobust(GLuint program, |
| 5658 | GLenum pname, |
| 5659 | GLsizei bufSize, |
| 5660 | GLsizei *length, |
| 5661 | GLint *params) |
| 5662 | { |
| 5663 | getProgramiv(program, pname, params); |
| 5664 | } |
| 5665 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5666 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5667 | { |
| 5668 | UNIMPLEMENTED(); |
| 5669 | } |
| 5670 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5671 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5672 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5673 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5674 | ASSERT(programObject); |
| 5675 | programObject->getInfoLog(bufsize, length, infolog); |
| 5676 | } |
| 5677 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5678 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5679 | GLsizei bufSize, |
| 5680 | GLsizei *length, |
| 5681 | GLchar *infoLog) |
| 5682 | { |
| 5683 | UNIMPLEMENTED(); |
| 5684 | } |
| 5685 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5686 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5687 | { |
| 5688 | Shader *shaderObject = getShader(shader); |
| 5689 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5690 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5691 | } |
| 5692 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5693 | void Context::getShaderivRobust(GLuint shader, |
| 5694 | GLenum pname, |
| 5695 | GLsizei bufSize, |
| 5696 | GLsizei *length, |
| 5697 | GLint *params) |
| 5698 | { |
| 5699 | getShaderiv(shader, pname, params); |
| 5700 | } |
| 5701 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5702 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5703 | { |
| 5704 | Shader *shaderObject = getShader(shader); |
| 5705 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5706 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5707 | } |
| 5708 | |
| 5709 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5710 | GLenum precisiontype, |
| 5711 | GLint *range, |
| 5712 | GLint *precision) |
| 5713 | { |
| 5714 | // TODO(jmadill): Compute shaders. |
| 5715 | |
| 5716 | switch (shadertype) |
| 5717 | { |
| 5718 | case GL_VERTEX_SHADER: |
| 5719 | switch (precisiontype) |
| 5720 | { |
| 5721 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5722 | mState.mCaps.vertexLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5723 | break; |
| 5724 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5725 | mState.mCaps.vertexMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5726 | break; |
| 5727 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5728 | mState.mCaps.vertexHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5729 | break; |
| 5730 | |
| 5731 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5732 | mState.mCaps.vertexLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5733 | break; |
| 5734 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5735 | mState.mCaps.vertexMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5736 | break; |
| 5737 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5738 | mState.mCaps.vertexHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5739 | break; |
| 5740 | |
| 5741 | default: |
| 5742 | UNREACHABLE(); |
| 5743 | return; |
| 5744 | } |
| 5745 | break; |
| 5746 | |
| 5747 | case GL_FRAGMENT_SHADER: |
| 5748 | switch (precisiontype) |
| 5749 | { |
| 5750 | case GL_LOW_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5751 | mState.mCaps.fragmentLowpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5752 | break; |
| 5753 | case GL_MEDIUM_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5754 | mState.mCaps.fragmentMediumpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5755 | break; |
| 5756 | case GL_HIGH_FLOAT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5757 | mState.mCaps.fragmentHighpFloat.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5758 | break; |
| 5759 | |
| 5760 | case GL_LOW_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5761 | mState.mCaps.fragmentLowpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5762 | break; |
| 5763 | case GL_MEDIUM_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5764 | mState.mCaps.fragmentMediumpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5765 | break; |
| 5766 | case GL_HIGH_INT: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5767 | mState.mCaps.fragmentHighpInt.get(range, precision); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5768 | break; |
| 5769 | |
| 5770 | default: |
| 5771 | UNREACHABLE(); |
| 5772 | return; |
| 5773 | } |
| 5774 | break; |
| 5775 | |
| 5776 | default: |
| 5777 | UNREACHABLE(); |
| 5778 | return; |
| 5779 | } |
| 5780 | } |
| 5781 | |
| 5782 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5783 | { |
| 5784 | Shader *shaderObject = getShader(shader); |
| 5785 | ASSERT(shaderObject); |
| 5786 | shaderObject->getSource(bufsize, length, source); |
| 5787 | } |
| 5788 | |
| 5789 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5790 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5791 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5792 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5793 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5794 | } |
| 5795 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5796 | void Context::getUniformfvRobust(GLuint program, |
| 5797 | GLint location, |
| 5798 | GLsizei bufSize, |
| 5799 | GLsizei *length, |
| 5800 | GLfloat *params) |
| 5801 | { |
| 5802 | getUniformfv(program, location, params); |
| 5803 | } |
| 5804 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5805 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5806 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5807 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5808 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5809 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5810 | } |
| 5811 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5812 | void Context::getUniformivRobust(GLuint program, |
| 5813 | GLint location, |
| 5814 | GLsizei bufSize, |
| 5815 | GLsizei *length, |
| 5816 | GLint *params) |
| 5817 | { |
| 5818 | getUniformiv(program, location, params); |
| 5819 | } |
| 5820 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5821 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5822 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5823 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5824 | ASSERT(programObject); |
| 5825 | return programObject->getUniformLocation(name); |
| 5826 | } |
| 5827 | |
| 5828 | GLboolean Context::isBuffer(GLuint buffer) |
| 5829 | { |
| 5830 | if (buffer == 0) |
| 5831 | { |
| 5832 | return GL_FALSE; |
| 5833 | } |
| 5834 | |
| 5835 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5836 | } |
| 5837 | |
| 5838 | GLboolean Context::isEnabled(GLenum cap) |
| 5839 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5840 | return mState.getEnableFeature(cap); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5841 | } |
| 5842 | |
| 5843 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5844 | { |
| 5845 | if (framebuffer == 0) |
| 5846 | { |
| 5847 | return GL_FALSE; |
| 5848 | } |
| 5849 | |
| 5850 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5851 | } |
| 5852 | |
| 5853 | GLboolean Context::isProgram(GLuint program) |
| 5854 | { |
| 5855 | if (program == 0) |
| 5856 | { |
| 5857 | return GL_FALSE; |
| 5858 | } |
| 5859 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5860 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5861 | } |
| 5862 | |
| 5863 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5864 | { |
| 5865 | if (renderbuffer == 0) |
| 5866 | { |
| 5867 | return GL_FALSE; |
| 5868 | } |
| 5869 | |
| 5870 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5871 | } |
| 5872 | |
| 5873 | GLboolean Context::isShader(GLuint shader) |
| 5874 | { |
| 5875 | if (shader == 0) |
| 5876 | { |
| 5877 | return GL_FALSE; |
| 5878 | } |
| 5879 | |
| 5880 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5881 | } |
| 5882 | |
| 5883 | GLboolean Context::isTexture(GLuint texture) |
| 5884 | { |
| 5885 | if (texture == 0) |
| 5886 | { |
| 5887 | return GL_FALSE; |
| 5888 | } |
| 5889 | |
| 5890 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5891 | } |
| 5892 | |
| 5893 | void Context::linkProgram(GLuint program) |
| 5894 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5895 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5896 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5897 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5898 | |
| 5899 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5900 | // don't need to worry that: |
| 5901 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5902 | // result. |
| 5903 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5904 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 5905 | // ProgramD3D. |
| 5906 | if (programObject->isInUse()) |
| 5907 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 5908 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5909 | if (programObject->isLinked()) |
| 5910 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5911 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5912 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5913 | mStateCache.onProgramExecutableChange(this); |
| 5914 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5915 | } |
| 5916 | |
| 5917 | void Context::releaseShaderCompiler() |
| 5918 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5919 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5920 | } |
| 5921 | |
| 5922 | void Context::shaderBinary(GLsizei n, |
| 5923 | const GLuint *shaders, |
| 5924 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5925 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5926 | GLsizei length) |
| 5927 | { |
| 5928 | // No binary shader formats are supported. |
| 5929 | UNIMPLEMENTED(); |
| 5930 | } |
| 5931 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 5932 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 5933 | GLuint colorNumber, |
| 5934 | GLuint index, |
| 5935 | const char *name) |
| 5936 | { |
| 5937 | Program *programObject = getProgramNoResolveLink(program); |
| 5938 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 5939 | programObject->bindFragmentOutputIndex(index, name); |
| 5940 | } |
| 5941 | |
| 5942 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 5943 | { |
| 5944 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 5945 | } |
| 5946 | |
| 5947 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 5948 | { |
| 5949 | Program *programObject = getProgramResolveLink(program); |
| 5950 | return programObject->getFragDataIndex(name); |
| 5951 | } |
| 5952 | |
| 5953 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 5954 | GLenum programInterface, |
| 5955 | const char *name) |
| 5956 | { |
| 5957 | Program *programObject = getProgramResolveLink(program); |
| 5958 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 5959 | return programObject->getFragDataIndex(name); |
| 5960 | } |
| 5961 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5962 | void Context::shaderSource(GLuint shader, |
| 5963 | GLsizei count, |
| 5964 | const GLchar *const *string, |
| 5965 | const GLint *length) |
| 5966 | { |
| 5967 | Shader *shaderObject = getShader(shader); |
| 5968 | ASSERT(shaderObject); |
| 5969 | shaderObject->setSource(count, string, length); |
| 5970 | } |
| 5971 | |
| 5972 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 5973 | { |
| 5974 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 5975 | } |
| 5976 | |
| 5977 | void Context::stencilMask(GLuint mask) |
| 5978 | { |
| 5979 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 5980 | } |
| 5981 | |
| 5982 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 5983 | { |
| 5984 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 5985 | } |
| 5986 | |
| 5987 | void Context::uniform1f(GLint location, GLfloat x) |
| 5988 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 5989 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5990 | program->setUniform1fv(location, 1, &x); |
| 5991 | } |
| 5992 | |
| 5993 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 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, count, v); |
| 5997 | } |
| 5998 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 5999 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6000 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6001 | program->setUniform1iv(this, location, count, v); |
| 6002 | } |
| 6003 | |
| 6004 | void Context::onSamplerUniformChange(size_t textureUnitIndex) |
| 6005 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6006 | mState.onActiveTextureChange(this, textureUnitIndex); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6007 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6008 | } |
| 6009 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6010 | void Context::uniform1i(GLint location, GLint x) |
| 6011 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6012 | setUniform1iImpl(mState.getProgram(), location, 1, &x); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6013 | } |
| 6014 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6015 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6016 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6017 | setUniform1iImpl(mState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6018 | } |
| 6019 | |
| 6020 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6021 | { |
| 6022 | GLfloat xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6023 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6024 | program->setUniform2fv(location, 1, xy); |
| 6025 | } |
| 6026 | |
| 6027 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6028 | { |
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, count, v); |
| 6031 | } |
| 6032 | |
| 6033 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6034 | { |
| 6035 | GLint xy[2] = {x, y}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6036 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6037 | program->setUniform2iv(location, 1, xy); |
| 6038 | } |
| 6039 | |
| 6040 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6041 | { |
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, count, v); |
| 6044 | } |
| 6045 | |
| 6046 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6047 | { |
| 6048 | GLfloat xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6049 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6050 | program->setUniform3fv(location, 1, xyz); |
| 6051 | } |
| 6052 | |
| 6053 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6054 | { |
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, count, v); |
| 6057 | } |
| 6058 | |
| 6059 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6060 | { |
| 6061 | GLint xyz[3] = {x, y, z}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6062 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6063 | program->setUniform3iv(location, 1, xyz); |
| 6064 | } |
| 6065 | |
| 6066 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6067 | { |
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, count, v); |
| 6070 | } |
| 6071 | |
| 6072 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6073 | { |
| 6074 | GLfloat xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6075 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6076 | program->setUniform4fv(location, 1, xyzw); |
| 6077 | } |
| 6078 | |
| 6079 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6080 | { |
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, count, v); |
| 6083 | } |
| 6084 | |
| 6085 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6086 | { |
| 6087 | GLint xyzw[4] = {x, y, z, w}; |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6088 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6089 | program->setUniform4iv(location, 1, xyzw); |
| 6090 | } |
| 6091 | |
| 6092 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6093 | { |
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, count, v); |
| 6096 | } |
| 6097 | |
| 6098 | void Context::uniformMatrix2fv(GLint location, |
| 6099 | GLsizei count, |
| 6100 | GLboolean transpose, |
| 6101 | const GLfloat *value) |
| 6102 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6103 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6104 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6105 | } |
| 6106 | |
| 6107 | void Context::uniformMatrix3fv(GLint location, |
| 6108 | GLsizei count, |
| 6109 | GLboolean transpose, |
| 6110 | const GLfloat *value) |
| 6111 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6112 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6113 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6114 | } |
| 6115 | |
| 6116 | void Context::uniformMatrix4fv(GLint location, |
| 6117 | GLsizei count, |
| 6118 | GLboolean transpose, |
| 6119 | const GLfloat *value) |
| 6120 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6121 | Program *program = mState.getProgram(); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6122 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6123 | } |
| 6124 | |
| 6125 | void Context::validateProgram(GLuint program) |
| 6126 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6127 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6128 | ASSERT(programObject); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6129 | programObject->validate(mState.mCaps); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6130 | } |
| 6131 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6132 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6133 | { |
| 6134 | UNIMPLEMENTED(); |
| 6135 | } |
| 6136 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6137 | void Context::getProgramBinary(GLuint program, |
| 6138 | GLsizei bufSize, |
| 6139 | GLsizei *length, |
| 6140 | GLenum *binaryFormat, |
| 6141 | void *binary) |
| 6142 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6143 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6144 | ASSERT(programObject != nullptr); |
| 6145 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6146 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6147 | } |
| 6148 | |
| 6149 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6150 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6151 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6152 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6153 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6154 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6155 | if (programObject->isInUse()) |
| 6156 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6157 | ANGLE_CONTEXT_TRY(mState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6158 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6159 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6160 | } |
| 6161 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6162 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6163 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6164 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6165 | program->setUniform1uiv(location, 1, &v0); |
| 6166 | } |
| 6167 | |
| 6168 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 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 | const GLuint xy[] = {v0, v1}; |
| 6172 | program->setUniform2uiv(location, 1, xy); |
| 6173 | } |
| 6174 | |
| 6175 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6176 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6177 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6178 | const GLuint xyz[] = {v0, v1, v2}; |
| 6179 | program->setUniform3uiv(location, 1, xyz); |
| 6180 | } |
| 6181 | |
| 6182 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6183 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6184 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6185 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6186 | program->setUniform4uiv(location, 1, xyzw); |
| 6187 | } |
| 6188 | |
| 6189 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6190 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6191 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6192 | program->setUniform1uiv(location, count, value); |
| 6193 | } |
| 6194 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6195 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6196 | Program *program = mState.getProgram(); |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6197 | program->setUniform2uiv(location, count, value); |
| 6198 | } |
| 6199 | |
| 6200 | void Context::uniform3uiv(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->setUniform3uiv(location, count, value); |
| 6204 | } |
| 6205 | |
| 6206 | void Context::uniform4uiv(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->setUniform4uiv(location, count, value); |
| 6210 | } |
| 6211 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6212 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6213 | { |
| 6214 | for (GLsizei i = 0; i < n; i++) |
| 6215 | { |
| 6216 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6217 | mQueryMap.assign(handle, nullptr); |
| 6218 | ids[i] = handle; |
| 6219 | } |
| 6220 | } |
| 6221 | |
| 6222 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6223 | { |
| 6224 | for (int i = 0; i < n; i++) |
| 6225 | { |
| 6226 | GLuint query = ids[i]; |
| 6227 | |
| 6228 | Query *queryObject = nullptr; |
| 6229 | if (mQueryMap.erase(query, &queryObject)) |
| 6230 | { |
| 6231 | mQueryHandleAllocator.release(query); |
| 6232 | if (queryObject) |
| 6233 | { |
| 6234 | queryObject->release(this); |
| 6235 | } |
| 6236 | } |
| 6237 | } |
| 6238 | } |
| 6239 | |
| 6240 | GLboolean Context::isQuery(GLuint id) |
| 6241 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6242 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6243 | } |
| 6244 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6245 | void Context::uniformMatrix2x3fv(GLint location, |
| 6246 | GLsizei count, |
| 6247 | GLboolean transpose, |
| 6248 | const GLfloat *value) |
| 6249 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6250 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6251 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6252 | } |
| 6253 | |
| 6254 | void Context::uniformMatrix3x2fv(GLint location, |
| 6255 | GLsizei count, |
| 6256 | GLboolean transpose, |
| 6257 | const GLfloat *value) |
| 6258 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6259 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6260 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6261 | } |
| 6262 | |
| 6263 | void Context::uniformMatrix2x4fv(GLint location, |
| 6264 | GLsizei count, |
| 6265 | GLboolean transpose, |
| 6266 | const GLfloat *value) |
| 6267 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6268 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6269 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6270 | } |
| 6271 | |
| 6272 | void Context::uniformMatrix4x2fv(GLint location, |
| 6273 | GLsizei count, |
| 6274 | GLboolean transpose, |
| 6275 | const GLfloat *value) |
| 6276 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6277 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6278 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6279 | } |
| 6280 | |
| 6281 | void Context::uniformMatrix3x4fv(GLint location, |
| 6282 | GLsizei count, |
| 6283 | GLboolean transpose, |
| 6284 | const GLfloat *value) |
| 6285 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6286 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6287 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6288 | } |
| 6289 | |
| 6290 | void Context::uniformMatrix4x3fv(GLint location, |
| 6291 | GLsizei count, |
| 6292 | GLboolean transpose, |
| 6293 | const GLfloat *value) |
| 6294 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6295 | Program *program = mState.getProgram(); |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6296 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6297 | } |
| 6298 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6299 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6300 | { |
| 6301 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6302 | { |
| 6303 | GLuint vertexArray = arrays[arrayIndex]; |
| 6304 | |
| 6305 | if (arrays[arrayIndex] != 0) |
| 6306 | { |
| 6307 | VertexArray *vertexArrayObject = nullptr; |
| 6308 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6309 | { |
| 6310 | if (vertexArrayObject != nullptr) |
| 6311 | { |
| 6312 | detachVertexArray(vertexArray); |
| 6313 | vertexArrayObject->onDestroy(this); |
| 6314 | } |
| 6315 | |
| 6316 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6317 | } |
| 6318 | } |
| 6319 | } |
| 6320 | } |
| 6321 | |
| 6322 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6323 | { |
| 6324 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6325 | { |
| 6326 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6327 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6328 | arrays[arrayIndex] = vertexArray; |
| 6329 | } |
| 6330 | } |
| 6331 | |
| 6332 | bool Context::isVertexArray(GLuint array) |
| 6333 | { |
| 6334 | if (array == 0) |
| 6335 | { |
| 6336 | return GL_FALSE; |
| 6337 | } |
| 6338 | |
| 6339 | VertexArray *vao = getVertexArray(array); |
| 6340 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6341 | } |
| 6342 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6343 | void Context::endTransformFeedback() |
| 6344 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6345 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6346 | ANGLE_CONTEXT_TRY(transformFeedback->end(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6347 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6348 | } |
| 6349 | |
| 6350 | void Context::transformFeedbackVaryings(GLuint program, |
| 6351 | GLsizei count, |
| 6352 | const GLchar *const *varyings, |
| 6353 | GLenum bufferMode) |
| 6354 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6355 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6356 | ASSERT(programObject); |
| 6357 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6358 | } |
| 6359 | |
| 6360 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6361 | GLuint index, |
| 6362 | GLsizei bufSize, |
| 6363 | GLsizei *length, |
| 6364 | GLsizei *size, |
| 6365 | GLenum *type, |
| 6366 | GLchar *name) |
| 6367 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6368 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6369 | ASSERT(programObject); |
| 6370 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6371 | } |
| 6372 | |
| 6373 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6374 | { |
| 6375 | for (int i = 0; i < n; i++) |
| 6376 | { |
| 6377 | GLuint transformFeedback = ids[i]; |
| 6378 | if (transformFeedback == 0) |
| 6379 | { |
| 6380 | continue; |
| 6381 | } |
| 6382 | |
| 6383 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6384 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6385 | { |
| 6386 | if (transformFeedbackObject != nullptr) |
| 6387 | { |
| 6388 | detachTransformFeedback(transformFeedback); |
| 6389 | transformFeedbackObject->release(this); |
| 6390 | } |
| 6391 | |
| 6392 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6393 | } |
| 6394 | } |
| 6395 | } |
| 6396 | |
| 6397 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6398 | { |
| 6399 | for (int i = 0; i < n; i++) |
| 6400 | { |
| 6401 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6402 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6403 | ids[i] = transformFeedback; |
| 6404 | } |
| 6405 | } |
| 6406 | |
| 6407 | bool Context::isTransformFeedback(GLuint id) |
| 6408 | { |
| 6409 | if (id == 0) |
| 6410 | { |
| 6411 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6412 | // returns FALSE |
| 6413 | return GL_FALSE; |
| 6414 | } |
| 6415 | |
| 6416 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6417 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6418 | } |
| 6419 | |
| 6420 | void Context::pauseTransformFeedback() |
| 6421 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6422 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6423 | ANGLE_CONTEXT_TRY(transformFeedback->pause(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6424 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6425 | } |
| 6426 | |
| 6427 | void Context::resumeTransformFeedback() |
| 6428 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6429 | TransformFeedback *transformFeedback = mState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6430 | ANGLE_CONTEXT_TRY(transformFeedback->resume(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6431 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6432 | } |
| 6433 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6434 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6435 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6436 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6437 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6438 | } |
| 6439 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6440 | void Context::getUniformuivRobust(GLuint program, |
| 6441 | GLint location, |
| 6442 | GLsizei bufSize, |
| 6443 | GLsizei *length, |
| 6444 | GLuint *params) |
| 6445 | { |
| 6446 | getUniformuiv(program, location, params); |
| 6447 | } |
| 6448 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6449 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6450 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6451 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6452 | return programObject->getFragDataLocation(name); |
| 6453 | } |
| 6454 | |
| 6455 | void Context::getUniformIndices(GLuint program, |
| 6456 | GLsizei uniformCount, |
| 6457 | const GLchar *const *uniformNames, |
| 6458 | GLuint *uniformIndices) |
| 6459 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6460 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6461 | if (!programObject->isLinked()) |
| 6462 | { |
| 6463 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6464 | { |
| 6465 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6466 | } |
| 6467 | } |
| 6468 | else |
| 6469 | { |
| 6470 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6471 | { |
| 6472 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6473 | } |
| 6474 | } |
| 6475 | } |
| 6476 | |
| 6477 | void Context::getActiveUniformsiv(GLuint program, |
| 6478 | GLsizei uniformCount, |
| 6479 | const GLuint *uniformIndices, |
| 6480 | GLenum pname, |
| 6481 | GLint *params) |
| 6482 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6483 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6484 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6485 | { |
| 6486 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6487 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6488 | } |
| 6489 | } |
| 6490 | |
| 6491 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6492 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6493 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6494 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6495 | } |
| 6496 | |
| 6497 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6498 | GLuint uniformBlockIndex, |
| 6499 | GLenum pname, |
| 6500 | GLint *params) |
| 6501 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6502 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6503 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6504 | } |
| 6505 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6506 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6507 | GLuint uniformBlockIndex, |
| 6508 | GLenum pname, |
| 6509 | GLsizei bufSize, |
| 6510 | GLsizei *length, |
| 6511 | GLint *params) |
| 6512 | { |
| 6513 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6514 | } |
| 6515 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6516 | void Context::getActiveUniformBlockName(GLuint program, |
| 6517 | GLuint uniformBlockIndex, |
| 6518 | GLsizei bufSize, |
| 6519 | GLsizei *length, |
| 6520 | GLchar *uniformBlockName) |
| 6521 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6522 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6523 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6524 | } |
| 6525 | |
| 6526 | void Context::uniformBlockBinding(GLuint program, |
| 6527 | GLuint uniformBlockIndex, |
| 6528 | GLuint uniformBlockBinding) |
| 6529 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6530 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6531 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6532 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6533 | // 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] | 6534 | if (programObject->isInUse()) |
| 6535 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6536 | mState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6537 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6538 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6539 | } |
| 6540 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6541 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6542 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6543 | GLuint handle = mState.mSyncManager->createSync(mImplementation.get()); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6544 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6545 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6546 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6547 | if (syncObject->set(this, condition, flags) == angle::Result::Stop) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6548 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6549 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6550 | return nullptr; |
| 6551 | } |
| 6552 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6553 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6554 | } |
| 6555 | |
| 6556 | GLboolean Context::isSync(GLsync sync) |
| 6557 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6558 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6559 | } |
| 6560 | |
| 6561 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6562 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6563 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6564 | |
| 6565 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6566 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop) |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6567 | { |
| 6568 | return GL_WAIT_FAILED; |
| 6569 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6570 | return result; |
| 6571 | } |
| 6572 | |
| 6573 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6574 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6575 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6576 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6577 | } |
| 6578 | |
| 6579 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6580 | { |
| 6581 | GLenum nativeType = GL_NONE; |
| 6582 | unsigned int numParams = 0; |
| 6583 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6584 | |
| 6585 | if (nativeType == GL_INT_64_ANGLEX) |
| 6586 | { |
| 6587 | getInteger64vImpl(pname, params); |
| 6588 | } |
| 6589 | else |
| 6590 | { |
| 6591 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6592 | } |
| 6593 | } |
| 6594 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6595 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6596 | { |
| 6597 | getInteger64v(pname, data); |
| 6598 | } |
| 6599 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6600 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6601 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6602 | Buffer *buffer = mState.getTargetBuffer(target); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6603 | QueryBufferParameteri64v(buffer, pname, params); |
| 6604 | } |
| 6605 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6606 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6607 | GLenum pname, |
| 6608 | GLsizei bufSize, |
| 6609 | GLsizei *length, |
| 6610 | GLint64 *params) |
| 6611 | { |
| 6612 | getBufferParameteri64v(target, pname, params); |
| 6613 | } |
| 6614 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6615 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6616 | { |
| 6617 | for (int i = 0; i < count; i++) |
| 6618 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6619 | samplers[i] = mState.mSamplerManager->createSampler(); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6620 | } |
| 6621 | } |
| 6622 | |
| 6623 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6624 | { |
| 6625 | for (int i = 0; i < count; i++) |
| 6626 | { |
| 6627 | GLuint sampler = samplers[i]; |
| 6628 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6629 | if (mState.mSamplerManager->getSampler(sampler)) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6630 | { |
| 6631 | detachSampler(sampler); |
| 6632 | } |
| 6633 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6634 | mState.mSamplerManager->deleteObject(this, sampler); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6635 | } |
| 6636 | } |
| 6637 | |
| 6638 | void Context::getInternalformativ(GLenum target, |
| 6639 | GLenum internalformat, |
| 6640 | GLenum pname, |
| 6641 | GLsizei bufSize, |
| 6642 | GLint *params) |
| 6643 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6644 | const TextureCaps &formatCaps = mState.mTextureCaps.get(internalformat); |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6645 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6646 | } |
| 6647 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6648 | void Context::getInternalformativRobust(GLenum target, |
| 6649 | GLenum internalformat, |
| 6650 | GLenum pname, |
| 6651 | GLsizei bufSize, |
| 6652 | GLsizei *length, |
| 6653 | GLint *params) |
| 6654 | { |
| 6655 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6656 | } |
| 6657 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6658 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6659 | { |
| 6660 | programUniform1iv(program, location, 1, &v0); |
| 6661 | } |
| 6662 | |
| 6663 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6664 | { |
| 6665 | GLint xy[2] = {v0, v1}; |
| 6666 | programUniform2iv(program, location, 1, xy); |
| 6667 | } |
| 6668 | |
| 6669 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6670 | { |
| 6671 | GLint xyz[3] = {v0, v1, v2}; |
| 6672 | programUniform3iv(program, location, 1, xyz); |
| 6673 | } |
| 6674 | |
| 6675 | void Context::programUniform4i(GLuint program, |
| 6676 | GLint location, |
| 6677 | GLint v0, |
| 6678 | GLint v1, |
| 6679 | GLint v2, |
| 6680 | GLint v3) |
| 6681 | { |
| 6682 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6683 | programUniform4iv(program, location, 1, xyzw); |
| 6684 | } |
| 6685 | |
| 6686 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6687 | { |
| 6688 | programUniform1uiv(program, location, 1, &v0); |
| 6689 | } |
| 6690 | |
| 6691 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6692 | { |
| 6693 | GLuint xy[2] = {v0, v1}; |
| 6694 | programUniform2uiv(program, location, 1, xy); |
| 6695 | } |
| 6696 | |
| 6697 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6698 | { |
| 6699 | GLuint xyz[3] = {v0, v1, v2}; |
| 6700 | programUniform3uiv(program, location, 1, xyz); |
| 6701 | } |
| 6702 | |
| 6703 | void Context::programUniform4ui(GLuint program, |
| 6704 | GLint location, |
| 6705 | GLuint v0, |
| 6706 | GLuint v1, |
| 6707 | GLuint v2, |
| 6708 | GLuint v3) |
| 6709 | { |
| 6710 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6711 | programUniform4uiv(program, location, 1, xyzw); |
| 6712 | } |
| 6713 | |
| 6714 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6715 | { |
| 6716 | programUniform1fv(program, location, 1, &v0); |
| 6717 | } |
| 6718 | |
| 6719 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6720 | { |
| 6721 | GLfloat xy[2] = {v0, v1}; |
| 6722 | programUniform2fv(program, location, 1, xy); |
| 6723 | } |
| 6724 | |
| 6725 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6726 | { |
| 6727 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6728 | programUniform3fv(program, location, 1, xyz); |
| 6729 | } |
| 6730 | |
| 6731 | void Context::programUniform4f(GLuint program, |
| 6732 | GLint location, |
| 6733 | GLfloat v0, |
| 6734 | GLfloat v1, |
| 6735 | GLfloat v2, |
| 6736 | GLfloat v3) |
| 6737 | { |
| 6738 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6739 | programUniform4fv(program, location, 1, xyzw); |
| 6740 | } |
| 6741 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6742 | void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6743 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6744 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6745 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6746 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6747 | } |
| 6748 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6749 | void Context::programUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6750 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6751 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6752 | ASSERT(programObject); |
| 6753 | programObject->setUniform2iv(location, count, value); |
| 6754 | } |
| 6755 | |
| 6756 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6757 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6758 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6759 | ASSERT(programObject); |
| 6760 | programObject->setUniform3iv(location, count, value); |
| 6761 | } |
| 6762 | |
| 6763 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6764 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6765 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6766 | ASSERT(programObject); |
| 6767 | programObject->setUniform4iv(location, count, value); |
| 6768 | } |
| 6769 | |
| 6770 | void Context::programUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6771 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6772 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6773 | ASSERT(programObject); |
| 6774 | programObject->setUniform1uiv(location, count, value); |
| 6775 | } |
| 6776 | |
| 6777 | void Context::programUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6778 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6779 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6780 | ASSERT(programObject); |
| 6781 | programObject->setUniform2uiv(location, count, value); |
| 6782 | } |
| 6783 | |
| 6784 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6785 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6786 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6787 | ASSERT(programObject); |
| 6788 | programObject->setUniform3uiv(location, count, value); |
| 6789 | } |
| 6790 | |
| 6791 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6792 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6793 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6794 | ASSERT(programObject); |
| 6795 | programObject->setUniform4uiv(location, count, value); |
| 6796 | } |
| 6797 | |
| 6798 | void Context::programUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6799 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6800 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6801 | ASSERT(programObject); |
| 6802 | programObject->setUniform1fv(location, count, value); |
| 6803 | } |
| 6804 | |
| 6805 | void Context::programUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6806 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6807 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6808 | ASSERT(programObject); |
| 6809 | programObject->setUniform2fv(location, count, value); |
| 6810 | } |
| 6811 | |
| 6812 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6813 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6814 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6815 | ASSERT(programObject); |
| 6816 | programObject->setUniform3fv(location, count, value); |
| 6817 | } |
| 6818 | |
| 6819 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6820 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6821 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6822 | ASSERT(programObject); |
| 6823 | programObject->setUniform4fv(location, count, value); |
| 6824 | } |
| 6825 | |
| 6826 | void Context::programUniformMatrix2fv(GLuint program, |
| 6827 | GLint location, |
| 6828 | GLsizei count, |
| 6829 | GLboolean transpose, |
| 6830 | const GLfloat *value) |
| 6831 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6832 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6833 | ASSERT(programObject); |
| 6834 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6835 | } |
| 6836 | |
| 6837 | void Context::programUniformMatrix3fv(GLuint program, |
| 6838 | GLint location, |
| 6839 | GLsizei count, |
| 6840 | GLboolean transpose, |
| 6841 | const GLfloat *value) |
| 6842 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6843 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6844 | ASSERT(programObject); |
| 6845 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6846 | } |
| 6847 | |
| 6848 | void Context::programUniformMatrix4fv(GLuint program, |
| 6849 | GLint location, |
| 6850 | GLsizei count, |
| 6851 | GLboolean transpose, |
| 6852 | const GLfloat *value) |
| 6853 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6854 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6855 | ASSERT(programObject); |
| 6856 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6857 | } |
| 6858 | |
| 6859 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6860 | GLint location, |
| 6861 | GLsizei count, |
| 6862 | GLboolean transpose, |
| 6863 | const GLfloat *value) |
| 6864 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6865 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6866 | ASSERT(programObject); |
| 6867 | programObject->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6868 | } |
| 6869 | |
| 6870 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6871 | GLint location, |
| 6872 | GLsizei count, |
| 6873 | GLboolean transpose, |
| 6874 | const GLfloat *value) |
| 6875 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6876 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6877 | ASSERT(programObject); |
| 6878 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6879 | } |
| 6880 | |
| 6881 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6882 | GLint location, |
| 6883 | GLsizei count, |
| 6884 | GLboolean transpose, |
| 6885 | const GLfloat *value) |
| 6886 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6887 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6888 | ASSERT(programObject); |
| 6889 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6890 | } |
| 6891 | |
| 6892 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6893 | GLint location, |
| 6894 | GLsizei count, |
| 6895 | GLboolean transpose, |
| 6896 | const GLfloat *value) |
| 6897 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6898 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6899 | ASSERT(programObject); |
| 6900 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6901 | } |
| 6902 | |
| 6903 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6904 | GLint location, |
| 6905 | GLsizei count, |
| 6906 | GLboolean transpose, |
| 6907 | const GLfloat *value) |
| 6908 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6909 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6910 | ASSERT(programObject); |
| 6911 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6912 | } |
| 6913 | |
| 6914 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 6915 | GLint location, |
| 6916 | GLsizei count, |
| 6917 | GLboolean transpose, |
| 6918 | const GLfloat *value) |
| 6919 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6920 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6921 | ASSERT(programObject); |
| 6922 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6923 | } |
| 6924 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6925 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 6926 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 6927 | return mState.isCurrentTransformFeedback(tf); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6928 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6929 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 6930 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 6931 | { |
| 6932 | for (int i = 0; i < count; i++) |
| 6933 | { |
| 6934 | pipelines[i] = createProgramPipeline(); |
| 6935 | } |
| 6936 | } |
| 6937 | |
| 6938 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 6939 | { |
| 6940 | for (int i = 0; i < count; i++) |
| 6941 | { |
| 6942 | if (pipelines[i] != 0) |
| 6943 | { |
| 6944 | deleteProgramPipeline(pipelines[i]); |
| 6945 | } |
| 6946 | } |
| 6947 | } |
| 6948 | |
| 6949 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 6950 | { |
| 6951 | if (pipeline == 0) |
| 6952 | { |
| 6953 | return GL_FALSE; |
| 6954 | } |
| 6955 | |
| 6956 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 6957 | } |
| 6958 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6959 | void Context::finishFenceNV(GLuint fence) |
| 6960 | { |
| 6961 | FenceNV *fenceObject = getFenceNV(fence); |
| 6962 | |
| 6963 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6964 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6965 | } |
| 6966 | |
| 6967 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 6968 | { |
| 6969 | FenceNV *fenceObject = getFenceNV(fence); |
| 6970 | |
| 6971 | ASSERT(fenceObject && fenceObject->isSet()); |
| 6972 | |
| 6973 | switch (pname) |
| 6974 | { |
| 6975 | case GL_FENCE_STATUS_NV: |
| 6976 | { |
| 6977 | // GL_NV_fence spec: |
| 6978 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 6979 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 6980 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 6981 | GLboolean status = GL_TRUE; |
| 6982 | if (fenceObject->getStatus() != GL_TRUE) |
| 6983 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 6984 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6985 | } |
| 6986 | *params = status; |
| 6987 | break; |
| 6988 | } |
| 6989 | |
| 6990 | case GL_FENCE_CONDITION_NV: |
| 6991 | { |
| 6992 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 6993 | break; |
| 6994 | } |
| 6995 | |
| 6996 | default: |
| 6997 | UNREACHABLE(); |
| 6998 | } |
| 6999 | } |
| 7000 | |
| 7001 | void Context::getTranslatedShaderSource(GLuint shader, |
| 7002 | GLsizei bufsize, |
| 7003 | GLsizei *length, |
| 7004 | GLchar *source) |
| 7005 | { |
| 7006 | Shader *shaderObject = getShader(shader); |
| 7007 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7008 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7009 | } |
| 7010 | |
| 7011 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7012 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7013 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7014 | ASSERT(programObject); |
| 7015 | |
| 7016 | programObject->getUniformfv(this, location, params); |
| 7017 | } |
| 7018 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7019 | void Context::getnUniformfvRobust(GLuint program, |
| 7020 | GLint location, |
| 7021 | GLsizei bufSize, |
| 7022 | GLsizei *length, |
| 7023 | GLfloat *params) |
| 7024 | { |
| 7025 | UNIMPLEMENTED(); |
| 7026 | } |
| 7027 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7028 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7029 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7030 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7031 | ASSERT(programObject); |
| 7032 | |
| 7033 | programObject->getUniformiv(this, location, params); |
| 7034 | } |
| 7035 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7036 | void Context::getnUniformivRobust(GLuint program, |
| 7037 | GLint location, |
| 7038 | GLsizei bufSize, |
| 7039 | GLsizei *length, |
| 7040 | GLint *params) |
| 7041 | { |
| 7042 | UNIMPLEMENTED(); |
| 7043 | } |
| 7044 | |
| 7045 | void Context::getnUniformuivRobust(GLuint program, |
| 7046 | GLint location, |
| 7047 | GLsizei bufSize, |
| 7048 | GLsizei *length, |
| 7049 | GLuint *params) |
| 7050 | { |
| 7051 | UNIMPLEMENTED(); |
| 7052 | } |
| 7053 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7054 | GLboolean Context::isFenceNV(GLuint fence) |
| 7055 | { |
| 7056 | FenceNV *fenceObject = getFenceNV(fence); |
| 7057 | |
| 7058 | if (fenceObject == nullptr) |
| 7059 | { |
| 7060 | return GL_FALSE; |
| 7061 | } |
| 7062 | |
| 7063 | // GL_NV_fence spec: |
| 7064 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7065 | // existing fence. |
| 7066 | return fenceObject->isSet(); |
| 7067 | } |
| 7068 | |
| 7069 | void Context::readnPixels(GLint x, |
| 7070 | GLint y, |
| 7071 | GLsizei width, |
| 7072 | GLsizei height, |
| 7073 | GLenum format, |
| 7074 | GLenum type, |
| 7075 | GLsizei bufSize, |
| 7076 | void *data) |
| 7077 | { |
| 7078 | return readPixels(x, y, width, height, format, type, data); |
| 7079 | } |
| 7080 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7081 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7082 | { |
| 7083 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7084 | |
| 7085 | FenceNV *fenceObject = getFenceNV(fence); |
| 7086 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7087 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7088 | } |
| 7089 | |
| 7090 | GLboolean Context::testFenceNV(GLuint fence) |
| 7091 | { |
| 7092 | FenceNV *fenceObject = getFenceNV(fence); |
| 7093 | |
| 7094 | ASSERT(fenceObject != nullptr); |
| 7095 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7096 | |
| 7097 | GLboolean result = GL_TRUE; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 7098 | if (fenceObject->test(this, &result) == angle::Result::Stop) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7099 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7100 | return GL_TRUE; |
| 7101 | } |
| 7102 | |
| 7103 | return result; |
| 7104 | } |
| 7105 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7106 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7107 | { |
| 7108 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7109 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7110 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7111 | } |
| 7112 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7113 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7114 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7115 | Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7116 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7117 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7118 | } |
| 7119 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7120 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7121 | { |
| 7122 | UNIMPLEMENTED(); |
| 7123 | } |
| 7124 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7125 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7126 | { |
| 7127 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7128 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7129 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7130 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7131 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7132 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7133 | // application. |
| 7134 | switch (pname) |
| 7135 | { |
| 7136 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7137 | { |
| 7138 | *type = GL_INT; |
| 7139 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7140 | return true; |
| 7141 | } |
| 7142 | case GL_SHADER_BINARY_FORMATS: |
| 7143 | { |
| 7144 | *type = GL_INT; |
| 7145 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7146 | return true; |
| 7147 | } |
| 7148 | |
| 7149 | case GL_MAX_VERTEX_ATTRIBS: |
| 7150 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7151 | case GL_MAX_VARYING_VECTORS: |
| 7152 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7153 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7154 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7155 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7156 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7157 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7158 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7159 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7160 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7161 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7162 | case GL_RENDERBUFFER_BINDING: |
| 7163 | case GL_CURRENT_PROGRAM: |
| 7164 | case GL_PACK_ALIGNMENT: |
| 7165 | case GL_UNPACK_ALIGNMENT: |
| 7166 | case GL_GENERATE_MIPMAP_HINT: |
| 7167 | case GL_RED_BITS: |
| 7168 | case GL_GREEN_BITS: |
| 7169 | case GL_BLUE_BITS: |
| 7170 | case GL_ALPHA_BITS: |
| 7171 | case GL_DEPTH_BITS: |
| 7172 | case GL_STENCIL_BITS: |
| 7173 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7174 | case GL_CULL_FACE_MODE: |
| 7175 | case GL_FRONT_FACE: |
| 7176 | case GL_ACTIVE_TEXTURE: |
| 7177 | case GL_STENCIL_FUNC: |
| 7178 | case GL_STENCIL_VALUE_MASK: |
| 7179 | case GL_STENCIL_REF: |
| 7180 | case GL_STENCIL_FAIL: |
| 7181 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7182 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7183 | case GL_STENCIL_BACK_FUNC: |
| 7184 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7185 | case GL_STENCIL_BACK_REF: |
| 7186 | case GL_STENCIL_BACK_FAIL: |
| 7187 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7188 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7189 | case GL_DEPTH_FUNC: |
| 7190 | case GL_BLEND_SRC_RGB: |
| 7191 | case GL_BLEND_SRC_ALPHA: |
| 7192 | case GL_BLEND_DST_RGB: |
| 7193 | case GL_BLEND_DST_ALPHA: |
| 7194 | case GL_BLEND_EQUATION_RGB: |
| 7195 | case GL_BLEND_EQUATION_ALPHA: |
| 7196 | case GL_STENCIL_WRITEMASK: |
| 7197 | case GL_STENCIL_BACK_WRITEMASK: |
| 7198 | case GL_STENCIL_CLEAR_VALUE: |
| 7199 | case GL_SUBPIXEL_BITS: |
| 7200 | case GL_MAX_TEXTURE_SIZE: |
| 7201 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7202 | case GL_SAMPLE_BUFFERS: |
| 7203 | case GL_SAMPLES: |
| 7204 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7205 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7206 | case GL_TEXTURE_BINDING_2D: |
| 7207 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7208 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7209 | { |
| 7210 | *type = GL_INT; |
| 7211 | *numParams = 1; |
| 7212 | return true; |
| 7213 | } |
| 7214 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7215 | { |
| 7216 | if (!getExtensions().packReverseRowOrder) |
| 7217 | { |
| 7218 | return false; |
| 7219 | } |
| 7220 | *type = GL_INT; |
| 7221 | *numParams = 1; |
| 7222 | return true; |
| 7223 | } |
| 7224 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7225 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7226 | { |
| 7227 | if (!getExtensions().textureRectangle) |
| 7228 | { |
| 7229 | return false; |
| 7230 | } |
| 7231 | *type = GL_INT; |
| 7232 | *numParams = 1; |
| 7233 | return true; |
| 7234 | } |
| 7235 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7236 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7237 | { |
| 7238 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7239 | { |
| 7240 | return false; |
| 7241 | } |
| 7242 | *type = GL_INT; |
| 7243 | *numParams = 1; |
| 7244 | return true; |
| 7245 | } |
| 7246 | case GL_MAX_VIEWPORT_DIMS: |
| 7247 | { |
| 7248 | *type = GL_INT; |
| 7249 | *numParams = 2; |
| 7250 | return true; |
| 7251 | } |
| 7252 | case GL_VIEWPORT: |
| 7253 | case GL_SCISSOR_BOX: |
| 7254 | { |
| 7255 | *type = GL_INT; |
| 7256 | *numParams = 4; |
| 7257 | return true; |
| 7258 | } |
| 7259 | case GL_SHADER_COMPILER: |
| 7260 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7261 | case GL_DEPTH_WRITEMASK: |
| 7262 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7263 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7264 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7265 | // bool-natural |
| 7266 | case GL_SAMPLE_COVERAGE: |
| 7267 | case GL_SCISSOR_TEST: |
| 7268 | case GL_STENCIL_TEST: |
| 7269 | case GL_DEPTH_TEST: |
| 7270 | case GL_BLEND: |
| 7271 | case GL_DITHER: |
| 7272 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7273 | { |
| 7274 | *type = GL_BOOL; |
| 7275 | *numParams = 1; |
| 7276 | return true; |
| 7277 | } |
| 7278 | case GL_COLOR_WRITEMASK: |
| 7279 | { |
| 7280 | *type = GL_BOOL; |
| 7281 | *numParams = 4; |
| 7282 | return true; |
| 7283 | } |
| 7284 | case GL_POLYGON_OFFSET_FACTOR: |
| 7285 | case GL_POLYGON_OFFSET_UNITS: |
| 7286 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7287 | case GL_DEPTH_CLEAR_VALUE: |
| 7288 | case GL_LINE_WIDTH: |
| 7289 | { |
| 7290 | *type = GL_FLOAT; |
| 7291 | *numParams = 1; |
| 7292 | return true; |
| 7293 | } |
| 7294 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7295 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7296 | case GL_DEPTH_RANGE: |
| 7297 | { |
| 7298 | *type = GL_FLOAT; |
| 7299 | *numParams = 2; |
| 7300 | return true; |
| 7301 | } |
| 7302 | case GL_COLOR_CLEAR_VALUE: |
| 7303 | case GL_BLEND_COLOR: |
| 7304 | { |
| 7305 | *type = GL_FLOAT; |
| 7306 | *numParams = 4; |
| 7307 | return true; |
| 7308 | } |
| 7309 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7310 | if (!getExtensions().textureFilterAnisotropic) |
| 7311 | { |
| 7312 | return false; |
| 7313 | } |
| 7314 | *type = GL_FLOAT; |
| 7315 | *numParams = 1; |
| 7316 | return true; |
| 7317 | case GL_TIMESTAMP_EXT: |
| 7318 | if (!getExtensions().disjointTimerQuery) |
| 7319 | { |
| 7320 | return false; |
| 7321 | } |
| 7322 | *type = GL_INT_64_ANGLEX; |
| 7323 | *numParams = 1; |
| 7324 | return true; |
| 7325 | case GL_GPU_DISJOINT_EXT: |
| 7326 | if (!getExtensions().disjointTimerQuery) |
| 7327 | { |
| 7328 | return false; |
| 7329 | } |
| 7330 | *type = GL_INT; |
| 7331 | *numParams = 1; |
| 7332 | return true; |
| 7333 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7334 | if (!getExtensions().framebufferMixedSamples) |
| 7335 | { |
| 7336 | return false; |
| 7337 | } |
| 7338 | *type = GL_INT; |
| 7339 | *numParams = 1; |
| 7340 | return true; |
| 7341 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7342 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7343 | { |
| 7344 | return false; |
| 7345 | } |
| 7346 | *type = GL_INT; |
| 7347 | *numParams = 1; |
| 7348 | return true; |
| 7349 | } |
| 7350 | |
| 7351 | if (getExtensions().debug) |
| 7352 | { |
| 7353 | switch (pname) |
| 7354 | { |
| 7355 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7356 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7357 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7358 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7359 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7360 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7361 | case GL_MAX_LABEL_LENGTH: |
| 7362 | *type = GL_INT; |
| 7363 | *numParams = 1; |
| 7364 | return true; |
| 7365 | |
| 7366 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7367 | case GL_DEBUG_OUTPUT: |
| 7368 | *type = GL_BOOL; |
| 7369 | *numParams = 1; |
| 7370 | return true; |
| 7371 | } |
| 7372 | } |
| 7373 | |
| 7374 | if (getExtensions().multisampleCompatibility) |
| 7375 | { |
| 7376 | switch (pname) |
| 7377 | { |
| 7378 | case GL_MULTISAMPLE_EXT: |
| 7379 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7380 | *type = GL_BOOL; |
| 7381 | *numParams = 1; |
| 7382 | return true; |
| 7383 | } |
| 7384 | } |
| 7385 | |
| 7386 | if (getExtensions().pathRendering) |
| 7387 | { |
| 7388 | switch (pname) |
| 7389 | { |
| 7390 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7391 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7392 | *type = GL_FLOAT; |
| 7393 | *numParams = 16; |
| 7394 | return true; |
| 7395 | } |
| 7396 | } |
| 7397 | |
| 7398 | if (getExtensions().bindGeneratesResource) |
| 7399 | { |
| 7400 | switch (pname) |
| 7401 | { |
| 7402 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7403 | *type = GL_BOOL; |
| 7404 | *numParams = 1; |
| 7405 | return true; |
| 7406 | } |
| 7407 | } |
| 7408 | |
| 7409 | if (getExtensions().clientArrays) |
| 7410 | { |
| 7411 | switch (pname) |
| 7412 | { |
| 7413 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7414 | *type = GL_BOOL; |
| 7415 | *numParams = 1; |
| 7416 | return true; |
| 7417 | } |
| 7418 | } |
| 7419 | |
| 7420 | if (getExtensions().sRGBWriteControl) |
| 7421 | { |
| 7422 | switch (pname) |
| 7423 | { |
| 7424 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7425 | *type = GL_BOOL; |
| 7426 | *numParams = 1; |
| 7427 | return true; |
| 7428 | } |
| 7429 | } |
| 7430 | |
| 7431 | if (getExtensions().robustResourceInitialization && |
| 7432 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7433 | { |
| 7434 | *type = GL_BOOL; |
| 7435 | *numParams = 1; |
| 7436 | return true; |
| 7437 | } |
| 7438 | |
| 7439 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7440 | { |
| 7441 | *type = GL_BOOL; |
| 7442 | *numParams = 1; |
| 7443 | return true; |
| 7444 | } |
| 7445 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7446 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7447 | { |
| 7448 | *type = GL_INT; |
| 7449 | *numParams = 1; |
| 7450 | return true; |
| 7451 | } |
| 7452 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7453 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7454 | { |
| 7455 | *type = GL_INT; |
| 7456 | *numParams = 1; |
| 7457 | return true; |
| 7458 | } |
| 7459 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7460 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7461 | switch (pname) |
| 7462 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7463 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7464 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7465 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7466 | { |
| 7467 | return false; |
| 7468 | } |
| 7469 | *type = GL_INT; |
| 7470 | *numParams = 1; |
| 7471 | return true; |
| 7472 | |
| 7473 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7474 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7475 | { |
| 7476 | return false; |
| 7477 | } |
| 7478 | *type = GL_INT; |
| 7479 | *numParams = 1; |
| 7480 | return true; |
| 7481 | |
| 7482 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7483 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7484 | { |
| 7485 | return false; |
| 7486 | } |
| 7487 | *type = GL_INT; |
| 7488 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7489 | return true; |
| 7490 | |
| 7491 | case GL_PACK_ROW_LENGTH: |
| 7492 | case GL_PACK_SKIP_ROWS: |
| 7493 | case GL_PACK_SKIP_PIXELS: |
| 7494 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7495 | { |
| 7496 | return false; |
| 7497 | } |
| 7498 | *type = GL_INT; |
| 7499 | *numParams = 1; |
| 7500 | return true; |
| 7501 | case GL_UNPACK_ROW_LENGTH: |
| 7502 | case GL_UNPACK_SKIP_ROWS: |
| 7503 | case GL_UNPACK_SKIP_PIXELS: |
| 7504 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7505 | { |
| 7506 | return false; |
| 7507 | } |
| 7508 | *type = GL_INT; |
| 7509 | *numParams = 1; |
| 7510 | return true; |
| 7511 | case GL_VERTEX_ARRAY_BINDING: |
| 7512 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7513 | { |
| 7514 | return false; |
| 7515 | } |
| 7516 | *type = GL_INT; |
| 7517 | *numParams = 1; |
| 7518 | return true; |
| 7519 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7520 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7521 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7522 | { |
| 7523 | return false; |
| 7524 | } |
| 7525 | *type = GL_INT; |
| 7526 | *numParams = 1; |
| 7527 | return true; |
| 7528 | case GL_MAX_SAMPLES: |
| 7529 | { |
| 7530 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7531 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7532 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7533 | { |
| 7534 | return false; |
| 7535 | } |
| 7536 | *type = GL_INT; |
| 7537 | *numParams = 1; |
| 7538 | return true; |
| 7539 | |
| 7540 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7541 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7542 | { |
| 7543 | return false; |
| 7544 | } |
| 7545 | *type = GL_INT; |
| 7546 | *numParams = 1; |
| 7547 | return true; |
| 7548 | } |
| 7549 | } |
| 7550 | |
| 7551 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7552 | { |
| 7553 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7554 | { |
| 7555 | return false; |
| 7556 | } |
| 7557 | *type = GL_INT; |
| 7558 | *numParams = 1; |
| 7559 | return true; |
| 7560 | } |
| 7561 | |
| 7562 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7563 | { |
| 7564 | *type = GL_INT; |
| 7565 | *numParams = 1; |
| 7566 | return true; |
| 7567 | } |
| 7568 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7569 | if (getClientVersion() < Version(2, 0)) |
| 7570 | { |
| 7571 | switch (pname) |
| 7572 | { |
| 7573 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7574 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7575 | case GL_MATRIX_MODE: |
| 7576 | case GL_MAX_TEXTURE_UNITS: |
| 7577 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7578 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7579 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7580 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7581 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7582 | case GL_VERTEX_ARRAY_STRIDE: |
| 7583 | case GL_NORMAL_ARRAY_STRIDE: |
| 7584 | case GL_COLOR_ARRAY_STRIDE: |
| 7585 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7586 | case GL_VERTEX_ARRAY_SIZE: |
| 7587 | case GL_COLOR_ARRAY_SIZE: |
| 7588 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7589 | case GL_VERTEX_ARRAY_TYPE: |
| 7590 | case GL_NORMAL_ARRAY_TYPE: |
| 7591 | case GL_COLOR_ARRAY_TYPE: |
| 7592 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7593 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7594 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7595 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7596 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7597 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7598 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7599 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7600 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7601 | case GL_MODELVIEW_STACK_DEPTH: |
| 7602 | case GL_PROJECTION_STACK_DEPTH: |
| 7603 | case GL_TEXTURE_STACK_DEPTH: |
| 7604 | case GL_LOGIC_OP_MODE: |
| 7605 | case GL_BLEND_SRC: |
| 7606 | case GL_BLEND_DST: |
| 7607 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7608 | case GL_POINT_SMOOTH_HINT: |
| 7609 | case GL_LINE_SMOOTH_HINT: |
| 7610 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7611 | *type = GL_INT; |
| 7612 | *numParams = 1; |
| 7613 | return true; |
| 7614 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7615 | case GL_FOG_DENSITY: |
| 7616 | case GL_FOG_START: |
| 7617 | case GL_FOG_END: |
| 7618 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7619 | case GL_POINT_SIZE: |
| 7620 | case GL_POINT_SIZE_MIN: |
| 7621 | case GL_POINT_SIZE_MAX: |
| 7622 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7623 | *type = GL_FLOAT; |
| 7624 | *numParams = 1; |
| 7625 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7626 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7627 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7628 | *type = GL_FLOAT; |
| 7629 | *numParams = 2; |
| 7630 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7631 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7632 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7633 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7634 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7635 | *type = GL_FLOAT; |
| 7636 | *numParams = 4; |
| 7637 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7638 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7639 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7640 | *type = GL_FLOAT; |
| 7641 | *numParams = 3; |
| 7642 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7643 | case GL_MODELVIEW_MATRIX: |
| 7644 | case GL_PROJECTION_MATRIX: |
| 7645 | case GL_TEXTURE_MATRIX: |
| 7646 | *type = GL_FLOAT; |
| 7647 | *numParams = 16; |
| 7648 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7649 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7650 | *type = GL_BOOL; |
| 7651 | *numParams = 1; |
| 7652 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7653 | } |
| 7654 | } |
| 7655 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7656 | if (getClientVersion() < Version(3, 0)) |
| 7657 | { |
| 7658 | return false; |
| 7659 | } |
| 7660 | |
| 7661 | // Check for ES3.0+ parameter names |
| 7662 | switch (pname) |
| 7663 | { |
| 7664 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7665 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7666 | case GL_UNIFORM_BUFFER_BINDING: |
| 7667 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7668 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7669 | case GL_COPY_READ_BUFFER_BINDING: |
| 7670 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7671 | case GL_SAMPLER_BINDING: |
| 7672 | case GL_READ_BUFFER: |
| 7673 | case GL_TEXTURE_BINDING_3D: |
| 7674 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7675 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7676 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7677 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7678 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7679 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7680 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7681 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7682 | case GL_MAX_VARYING_COMPONENTS: |
| 7683 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7684 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7685 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7686 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7687 | case GL_NUM_EXTENSIONS: |
| 7688 | case GL_MAJOR_VERSION: |
| 7689 | case GL_MINOR_VERSION: |
| 7690 | case GL_MAX_ELEMENTS_INDICES: |
| 7691 | case GL_MAX_ELEMENTS_VERTICES: |
| 7692 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7693 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7694 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7695 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7696 | case GL_UNPACK_SKIP_IMAGES: |
| 7697 | { |
| 7698 | *type = GL_INT; |
| 7699 | *numParams = 1; |
| 7700 | return true; |
| 7701 | } |
| 7702 | |
| 7703 | case GL_MAX_ELEMENT_INDEX: |
| 7704 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7705 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7706 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7707 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7708 | { |
| 7709 | *type = GL_INT_64_ANGLEX; |
| 7710 | *numParams = 1; |
| 7711 | return true; |
| 7712 | } |
| 7713 | |
| 7714 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7715 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7716 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7717 | case GL_RASTERIZER_DISCARD: |
| 7718 | { |
| 7719 | *type = GL_BOOL; |
| 7720 | *numParams = 1; |
| 7721 | return true; |
| 7722 | } |
| 7723 | |
| 7724 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7725 | { |
| 7726 | *type = GL_FLOAT; |
| 7727 | *numParams = 1; |
| 7728 | return true; |
| 7729 | } |
| 7730 | } |
| 7731 | |
| 7732 | if (getExtensions().requestExtension) |
| 7733 | { |
| 7734 | switch (pname) |
| 7735 | { |
| 7736 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7737 | *type = GL_INT; |
| 7738 | *numParams = 1; |
| 7739 | return true; |
| 7740 | } |
| 7741 | } |
| 7742 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7743 | if (getExtensions().textureMultisample) |
| 7744 | { |
| 7745 | switch (pname) |
| 7746 | { |
| 7747 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7748 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7749 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7750 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7751 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7752 | *type = GL_INT; |
| 7753 | *numParams = 1; |
| 7754 | return true; |
| 7755 | } |
| 7756 | } |
| 7757 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7758 | if (getClientVersion() < Version(3, 1)) |
| 7759 | { |
| 7760 | return false; |
| 7761 | } |
| 7762 | |
| 7763 | switch (pname) |
| 7764 | { |
| 7765 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7766 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7767 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7768 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7769 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7770 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7771 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7772 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7773 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7774 | case GL_MAX_INTEGER_SAMPLES: |
| 7775 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7776 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7777 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7778 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7779 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7780 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7781 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7782 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7783 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7784 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7785 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7786 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7787 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7788 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7789 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7790 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7791 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7792 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7793 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7794 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7795 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7796 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7797 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7798 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7799 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7800 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7801 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7802 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7803 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7804 | case GL_MAX_IMAGE_UNITS: |
| 7805 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7806 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7807 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7808 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7809 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7810 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7811 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7812 | *type = GL_INT; |
| 7813 | *numParams = 1; |
| 7814 | return true; |
| 7815 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7816 | *type = GL_INT_64_ANGLEX; |
| 7817 | *numParams = 1; |
| 7818 | return true; |
| 7819 | case GL_SAMPLE_MASK: |
| 7820 | *type = GL_BOOL; |
| 7821 | *numParams = 1; |
| 7822 | return true; |
| 7823 | } |
| 7824 | |
| 7825 | if (getExtensions().geometryShader) |
| 7826 | { |
| 7827 | switch (pname) |
| 7828 | { |
| 7829 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7830 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7831 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7832 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7833 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7834 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7835 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7836 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7837 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7838 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7839 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7840 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7841 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7842 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7843 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7844 | *type = GL_INT; |
| 7845 | *numParams = 1; |
| 7846 | return true; |
| 7847 | } |
| 7848 | } |
| 7849 | |
| 7850 | return false; |
| 7851 | } |
| 7852 | |
| 7853 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7854 | { |
| 7855 | if (getClientVersion() < Version(3, 0)) |
| 7856 | { |
| 7857 | return false; |
| 7858 | } |
| 7859 | |
| 7860 | switch (target) |
| 7861 | { |
| 7862 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7863 | case GL_UNIFORM_BUFFER_BINDING: |
| 7864 | { |
| 7865 | *type = GL_INT; |
| 7866 | *numParams = 1; |
| 7867 | return true; |
| 7868 | } |
| 7869 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7870 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7871 | case GL_UNIFORM_BUFFER_START: |
| 7872 | case GL_UNIFORM_BUFFER_SIZE: |
| 7873 | { |
| 7874 | *type = GL_INT_64_ANGLEX; |
| 7875 | *numParams = 1; |
| 7876 | return true; |
| 7877 | } |
| 7878 | } |
| 7879 | |
| 7880 | if (getClientVersion() < Version(3, 1)) |
| 7881 | { |
| 7882 | return false; |
| 7883 | } |
| 7884 | |
| 7885 | switch (target) |
| 7886 | { |
| 7887 | case GL_IMAGE_BINDING_LAYERED: |
| 7888 | { |
| 7889 | *type = GL_BOOL; |
| 7890 | *numParams = 1; |
| 7891 | return true; |
| 7892 | } |
| 7893 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7894 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7895 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7896 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7897 | case GL_VERTEX_BINDING_BUFFER: |
| 7898 | case GL_VERTEX_BINDING_DIVISOR: |
| 7899 | case GL_VERTEX_BINDING_OFFSET: |
| 7900 | case GL_VERTEX_BINDING_STRIDE: |
| 7901 | case GL_SAMPLE_MASK_VALUE: |
| 7902 | case GL_IMAGE_BINDING_NAME: |
| 7903 | case GL_IMAGE_BINDING_LEVEL: |
| 7904 | case GL_IMAGE_BINDING_LAYER: |
| 7905 | case GL_IMAGE_BINDING_ACCESS: |
| 7906 | case GL_IMAGE_BINDING_FORMAT: |
| 7907 | { |
| 7908 | *type = GL_INT; |
| 7909 | *numParams = 1; |
| 7910 | return true; |
| 7911 | } |
| 7912 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 7913 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7914 | case GL_SHADER_STORAGE_BUFFER_START: |
| 7915 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 7916 | { |
| 7917 | *type = GL_INT_64_ANGLEX; |
| 7918 | *numParams = 1; |
| 7919 | return true; |
| 7920 | } |
| 7921 | } |
| 7922 | |
| 7923 | return false; |
| 7924 | } |
| 7925 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7926 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7927 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7928 | return mState.mShaderProgramManager->getProgram(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7929 | } |
| 7930 | |
| 7931 | Shader *Context::getShader(GLuint handle) const |
| 7932 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7933 | return mState.mShaderProgramManager->getShader(handle); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7934 | } |
| 7935 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7936 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 7937 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7938 | return mState.mRenderbufferManager->isHandleGenerated(renderbuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7939 | } |
| 7940 | |
| 7941 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 7942 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7943 | return mState.mFramebufferManager->isHandleGenerated(framebuffer); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7944 | } |
| 7945 | |
| 7946 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 7947 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7948 | return mState.mProgramPipelineManager->isHandleGenerated(pipeline); |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7949 | } |
| 7950 | |
| 7951 | bool Context::usingDisplayTextureShareGroup() const |
| 7952 | { |
| 7953 | return mDisplayTextureShareGroup; |
| 7954 | } |
| 7955 | |
| 7956 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 7957 | { |
| 7958 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 7959 | internalformat == GL_DEPTH_STENCIL |
| 7960 | ? GL_DEPTH24_STENCIL8 |
| 7961 | : internalformat; |
| 7962 | } |
| 7963 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7964 | void Context::maxShaderCompilerThreads(GLuint count) |
| 7965 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7966 | GLuint oldCount = mState.getMaxShaderCompilerThreads(); |
| 7967 | mState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 7968 | // A count of zero specifies a request for no parallel compiling or linking. |
| 7969 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 7970 | { |
| 7971 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 7972 | } |
| 7973 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7974 | } |
| 7975 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 7976 | bool Context::isGLES1() const |
| 7977 | { |
| 7978 | return mState.getClientVersion() < Version(2, 0); |
| 7979 | } |
| 7980 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7981 | void Context::onSubjectStateChange(const Context *context, |
| 7982 | angle::SubjectIndex index, |
| 7983 | angle::SubjectMessage message) |
| 7984 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 7985 | switch (index) |
| 7986 | { |
| 7987 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7988 | switch (message) |
| 7989 | { |
| 7990 | case angle::SubjectMessage::CONTENTS_CHANGED: |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 7991 | mState.setObjectDirty(GL_VERTEX_ARRAY); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 7992 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 7993 | break; |
| 7994 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 7995 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 7996 | case angle::SubjectMessage::BINDING_CHANGED: |
| 7997 | mStateCache.onVertexArrayBufferStateChange(this); |
| 7998 | break; |
| 7999 | default: |
| 8000 | break; |
| 8001 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8002 | break; |
| 8003 | |
| 8004 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8005 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8006 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8007 | mState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8008 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8009 | break; |
| 8010 | |
| 8011 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8012 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8013 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8014 | mState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8015 | } |
| 8016 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8017 | break; |
| 8018 | |
| 8019 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8020 | if (index < kTextureMaxSubjectIndex) |
| 8021 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8022 | mState.onActiveTextureStateChange(this, index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8023 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8024 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8025 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8026 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8027 | mState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8028 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8029 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8030 | else |
| 8031 | { |
| 8032 | ASSERT(index < kSamplerMaxSubjectIndex); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8033 | mState.setSamplerDirty(index - kSampler0SubjectIndex); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8034 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8035 | break; |
| 8036 | } |
| 8037 | } |
| 8038 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8039 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8040 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8041 | |
| 8042 | ErrorSet::~ErrorSet() = default; |
| 8043 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8044 | void ErrorSet::handleError(GLenum errorCode, |
| 8045 | const char *message, |
| 8046 | const char *file, |
| 8047 | const char *function, |
| 8048 | unsigned int line) |
| 8049 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8050 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8051 | { |
| 8052 | mContext->markContextLost(); |
| 8053 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8054 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8055 | std::stringstream errorStream; |
| 8056 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8057 | << line << ". " << message; |
| 8058 | |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8059 | std::string formattedMessage = errorStream.str(); |
| 8060 | |
| 8061 | // Always log a warning, this function is only called on unexpected internal errors. |
| 8062 | WARN() << formattedMessage; |
| 8063 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8064 | // validationError does the necessary work to process the error. |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8065 | validationError(errorCode, formattedMessage.c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8066 | } |
| 8067 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8068 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8069 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8070 | ASSERT(errorCode != GL_NO_ERROR); |
| 8071 | mErrors.insert(errorCode); |
| 8072 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8073 | mContext->getState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8074 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8075 | } |
| 8076 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8077 | bool ErrorSet::empty() const |
| 8078 | { |
| 8079 | return mErrors.empty(); |
| 8080 | } |
| 8081 | |
| 8082 | GLenum ErrorSet::popError() |
| 8083 | { |
| 8084 | ASSERT(!empty()); |
| 8085 | GLenum error = *mErrors.begin(); |
| 8086 | mErrors.erase(mErrors.begin()); |
| 8087 | return error; |
| 8088 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8089 | |
| 8090 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8091 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8092 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8093 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8094 | mCachedInstancedVertexElementLimit(0), |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8095 | mCachedBasicDrawStatesError(kInvalidPointer), |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8096 | mCachedBasicDrawElementsError(kInvalidPointer), |
| 8097 | mCachedTransformFeedbackActiveUnpaused(false) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8098 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8099 | |
| 8100 | StateCache::~StateCache() = default; |
| 8101 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame] | 8102 | ANGLE_INLINE void StateCache::updateVertexElementLimits(Context *context) |
| 8103 | { |
| 8104 | if (context->isBufferAccessValidationEnabled()) |
| 8105 | { |
| 8106 | updateVertexElementLimitsImpl(context); |
| 8107 | } |
| 8108 | } |
| 8109 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8110 | void StateCache::initialize(Context *context) |
| 8111 | { |
| 8112 | updateValidDrawModes(context); |
| 8113 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8114 | updateValidDrawElementsTypes(context); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8115 | updateBasicDrawStatesError(); |
| 8116 | updateBasicDrawElementsError(); |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8117 | updateVertexAttribTypesValidation(context); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8118 | } |
| 8119 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8120 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8121 | { |
| 8122 | bool isGLES1 = context->isGLES1(); |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8123 | const State &glState = context->getState(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8124 | |
| 8125 | if (!isGLES1 && !glState.getProgram()) |
| 8126 | { |
| 8127 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8128 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8129 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8130 | return; |
| 8131 | } |
| 8132 | |
| 8133 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8134 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8135 | |
| 8136 | const VertexArray *vao = glState.getVertexArray(); |
| 8137 | ASSERT(vao); |
| 8138 | |
| 8139 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8140 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8141 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8142 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8143 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8144 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8145 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8146 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8147 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8148 | |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame] | 8149 | void StateCache::updateVertexElementLimitsImpl(Context *context) |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8150 | { |
Jamie Madill | d51fbe3 | 2019-01-25 15:03:39 -0500 | [diff] [blame] | 8151 | ASSERT(context->isBufferAccessValidationEnabled()); |
| 8152 | |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8153 | const VertexArray *vao = context->getState().getVertexArray(); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8154 | |
| 8155 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8156 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8157 | |
| 8158 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8159 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8160 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8161 | { |
| 8162 | return; |
| 8163 | } |
| 8164 | |
| 8165 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8166 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8167 | |
| 8168 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8169 | { |
| 8170 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8171 | |
| 8172 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8173 | ASSERT(context->isGLES1() || |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8174 | context->getState().getProgram()->isAttribLocationActive(attributeIndex)); |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8175 | |
| 8176 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8177 | if (binding.getDivisor() > 0) |
| 8178 | { |
| 8179 | mCachedInstancedVertexElementLimit = |
| 8180 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8181 | } |
| 8182 | else |
| 8183 | { |
| 8184 | mCachedNonInstancedVertexElementLimit = |
| 8185 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8186 | } |
| 8187 | } |
| 8188 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8189 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8190 | void StateCache::updateBasicDrawStatesError() |
| 8191 | { |
| 8192 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8193 | } |
| 8194 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8195 | void StateCache::updateBasicDrawElementsError() |
| 8196 | { |
| 8197 | mCachedBasicDrawElementsError = kInvalidPointer; |
| 8198 | } |
| 8199 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8200 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8201 | { |
| 8202 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8203 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8204 | return mCachedBasicDrawStatesError; |
| 8205 | } |
| 8206 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8207 | intptr_t StateCache::getBasicDrawElementsErrorImpl(Context *context) const |
| 8208 | { |
| 8209 | ASSERT(mCachedBasicDrawElementsError == kInvalidPointer); |
| 8210 | mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context)); |
| 8211 | return mCachedBasicDrawElementsError; |
| 8212 | } |
| 8213 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8214 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8215 | { |
| 8216 | updateActiveAttribsMask(context); |
| 8217 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8218 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8219 | } |
| 8220 | |
| 8221 | void StateCache::onProgramExecutableChange(Context *context) |
| 8222 | { |
| 8223 | updateActiveAttribsMask(context); |
| 8224 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8225 | updateBasicDrawStatesError(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8226 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8227 | } |
| 8228 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8229 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8230 | { |
| 8231 | updateVertexElementLimits(context); |
| 8232 | } |
| 8233 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8234 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8235 | { |
| 8236 | updateVertexElementLimits(context); |
| 8237 | updateBasicDrawStatesError(); |
| 8238 | } |
| 8239 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8240 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8241 | { |
| 8242 | updateActiveAttribsMask(context); |
| 8243 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8244 | updateBasicDrawStatesError(); |
| 8245 | } |
| 8246 | |
| 8247 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8248 | { |
| 8249 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8250 | updateBasicDrawElementsError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8251 | } |
| 8252 | |
| 8253 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8254 | { |
| 8255 | updateActiveAttribsMask(context); |
| 8256 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8257 | |
| 8258 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8259 | { |
| 8260 | updateBasicDrawStatesError(); |
| 8261 | } |
| 8262 | |
| 8263 | void StateCache::onContextCapChange(Context *context) |
| 8264 | { |
| 8265 | updateBasicDrawStatesError(); |
| 8266 | } |
| 8267 | |
| 8268 | void StateCache::onStencilStateChange(Context *context) |
| 8269 | { |
| 8270 | updateBasicDrawStatesError(); |
| 8271 | } |
| 8272 | |
| 8273 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8274 | { |
| 8275 | updateBasicDrawStatesError(); |
| 8276 | } |
| 8277 | |
| 8278 | void StateCache::onActiveTextureChange(Context *context) |
| 8279 | { |
| 8280 | updateBasicDrawStatesError(); |
| 8281 | } |
| 8282 | |
| 8283 | void StateCache::onQueryChange(Context *context) |
| 8284 | { |
| 8285 | updateBasicDrawStatesError(); |
| 8286 | } |
| 8287 | |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 8288 | void StateCache::onActiveTransformFeedbackChange(Context *context) |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8289 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8290 | updateTransformFeedbackActiveUnpaused(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8291 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8292 | updateBasicDrawElementsError(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8293 | updateValidDrawModes(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8294 | } |
| 8295 | |
| 8296 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8297 | { |
| 8298 | updateBasicDrawStatesError(); |
| 8299 | } |
| 8300 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8301 | void StateCache::setValidDrawModes(bool pointsOK, |
| 8302 | bool linesOK, |
| 8303 | bool trisOK, |
| 8304 | bool lineAdjOK, |
| 8305 | bool triAdjOK) |
| 8306 | { |
| 8307 | mCachedValidDrawModes[PrimitiveMode::Points] = pointsOK; |
| 8308 | mCachedValidDrawModes[PrimitiveMode::Lines] = linesOK; |
| 8309 | mCachedValidDrawModes[PrimitiveMode::LineStrip] = linesOK; |
| 8310 | mCachedValidDrawModes[PrimitiveMode::LineLoop] = linesOK; |
| 8311 | mCachedValidDrawModes[PrimitiveMode::Triangles] = trisOK; |
| 8312 | mCachedValidDrawModes[PrimitiveMode::TriangleFan] = trisOK; |
| 8313 | mCachedValidDrawModes[PrimitiveMode::TriangleStrip] = trisOK; |
| 8314 | mCachedValidDrawModes[PrimitiveMode::LinesAdjacency] = lineAdjOK; |
| 8315 | mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency] = lineAdjOK; |
| 8316 | mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency] = triAdjOK; |
| 8317 | mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK; |
| 8318 | } |
| 8319 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8320 | void StateCache::updateValidDrawModes(Context *context) |
| 8321 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8322 | const State &state = context->getState(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8323 | Program *program = state.getProgram(); |
| 8324 | |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8325 | if (mCachedTransformFeedbackActiveUnpaused) |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8326 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8327 | TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 8328 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8329 | // ES Spec 3.0 validation text: |
| 8330 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8331 | // match the value of primitiveMode passed to BeginTransformFeedback. The error |
| 8332 | // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not |
| 8333 | // identical to primitiveMode. The error INVALID_OPERATION is also generated by |
| 8334 | // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is |
| 8335 | // active and not paused, regardless of mode. Any primitive type may be used while transform |
| 8336 | // feedback is paused. |
| 8337 | if (!context->getExtensions().geometryShader) |
| 8338 | { |
| 8339 | mCachedValidDrawModes.fill(false); |
| 8340 | mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true; |
| 8341 | return; |
| 8342 | } |
| 8343 | |
| 8344 | // EXT_geometry_shader validation text: |
| 8345 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8346 | // be compatible with the value of <primitiveMode> passed to BeginTransformFeedback. If a |
| 8347 | // geometry shader is active, the type of primitive emitted by that shader is used instead |
| 8348 | // of the <mode> parameter passed to drawing commands for the purposes of this error check. |
| 8349 | // Any primitive type may be used while transform feedback is paused. |
| 8350 | bool pointsOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Points; |
| 8351 | bool linesOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Lines; |
| 8352 | bool trisOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Triangles; |
| 8353 | |
| 8354 | setValidDrawModes(pointsOK, linesOK, trisOK, false, false); |
| 8355 | return; |
| 8356 | } |
| 8357 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8358 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8359 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8360 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8361 | return; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8362 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8363 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8364 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8365 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8366 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8367 | bool pointsOK = gsMode == PrimitiveMode::Points; |
| 8368 | bool linesOK = gsMode == PrimitiveMode::Lines; |
| 8369 | bool trisOK = gsMode == PrimitiveMode::Triangles; |
| 8370 | bool lineAdjOK = gsMode == PrimitiveMode::LinesAdjacency; |
| 8371 | bool triAdjOK = gsMode == PrimitiveMode::TrianglesAdjacency; |
| 8372 | |
| 8373 | setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8374 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8375 | |
| 8376 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8377 | { |
| 8378 | const Extensions &exts = context->getExtensions(); |
| 8379 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8380 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8381 | |
| 8382 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8383 | {TextureType::_2D, true}, |
| 8384 | {TextureType::_2DArray, isGLES3}, |
| 8385 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8386 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8387 | {TextureType::_3D, isGLES3}, |
| 8388 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8389 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8390 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8391 | }}; |
| 8392 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8393 | |
| 8394 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8395 | { |
| 8396 | bool supportsUint = |
| 8397 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8398 | |
| 8399 | mCachedValidDrawElementsTypes = {{ |
| 8400 | {DrawElementsType::UnsignedByte, true}, |
| 8401 | {DrawElementsType::UnsignedShort, true}, |
| 8402 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8403 | }}; |
| 8404 | } |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8405 | |
| 8406 | void StateCache::updateTransformFeedbackActiveUnpaused(Context *context) |
| 8407 | { |
Jamie Madill | c3dc5d4 | 2018-12-30 12:12:04 -0500 | [diff] [blame] | 8408 | TransformFeedback *xfb = context->getState().getCurrentTransformFeedback(); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8409 | mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused(); |
| 8410 | } |
Jamie Madill | c8c7d40 | 2019-01-16 13:27:15 -0500 | [diff] [blame] | 8411 | |
| 8412 | void StateCache::updateVertexAttribTypesValidation(Context *context) |
| 8413 | { |
| 8414 | if (context->getClientMajorVersion() <= 2) |
| 8415 | { |
| 8416 | mCachedVertexAttribTypesValidation = {{ |
| 8417 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8418 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8419 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8420 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8421 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8422 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8423 | }}; |
| 8424 | } |
| 8425 | else |
| 8426 | { |
| 8427 | mCachedVertexAttribTypesValidation = {{ |
| 8428 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8429 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8430 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8431 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8432 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8433 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8434 | {VertexAttribType::Float, VertexAttribTypeCase::Valid}, |
| 8435 | {VertexAttribType::HalfFloat, VertexAttribTypeCase::Valid}, |
| 8436 | {VertexAttribType::Fixed, VertexAttribTypeCase::Valid}, |
| 8437 | {VertexAttribType::Int2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8438 | {VertexAttribType::UnsignedInt2101010, VertexAttribTypeCase::ValidSize4Only}, |
| 8439 | }}; |
| 8440 | |
| 8441 | mCachedIntegerVertexAttribTypesValidation = {{ |
| 8442 | {VertexAttribType::Byte, VertexAttribTypeCase::Valid}, |
| 8443 | {VertexAttribType::Short, VertexAttribTypeCase::Valid}, |
| 8444 | {VertexAttribType::Int, VertexAttribTypeCase::Valid}, |
| 8445 | {VertexAttribType::UnsignedByte, VertexAttribTypeCase::Valid}, |
| 8446 | {VertexAttribType::UnsignedShort, VertexAttribTypeCase::Valid}, |
| 8447 | {VertexAttribType::UnsignedInt, VertexAttribTypeCase::Valid}, |
| 8448 | }}; |
| 8449 | } |
| 8450 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8451 | } // namespace gl |