apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | eeba6e1 | 2014-02-03 13:12:30 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Context.cpp: Implements the gl::Context class, managing all GL state and performing |
| 8 | // rendering operations. It is the GLES2 specific implementation of EGLContext. |
| 9 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 10 | #include "libANGLE/Context.h" |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 11 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 12 | #include <string.h> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 13 | #include <iterator> |
| 14 | #include <sstream> |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 15 | #include <vector> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 16 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 17 | #include "common/PackedEnums.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 18 | #include "common/matrix_utils.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 19 | #include "common/platform.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 20 | #include "common/utilities.h" |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 21 | #include "common/version.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 22 | #include "libANGLE/Buffer.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 23 | #include "libANGLE/Compiler.h" |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 24 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 25 | #include "libANGLE/Fence.h" |
| 26 | #include "libANGLE/Framebuffer.h" |
| 27 | #include "libANGLE/FramebufferAttachment.h" |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 28 | #include "libANGLE/GLES1Renderer.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/ContextImpl.h" |
| 46 | #include "libANGLE/renderer/EGLImplFactory.h" |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 47 | #include "libANGLE/renderer/Format.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 48 | #include "libANGLE/validationES.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 49 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 50 | namespace gl |
| 51 | { |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 52 | namespace |
| 53 | { |
| 54 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 55 | #define ANGLE_HANDLE_ERR(X) \ |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 56 | (void)(X); \ |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 57 | return; |
| 58 | #define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR); |
| 59 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 60 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 61 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 62 | GLsizei numPaths, |
| 63 | const void *paths, |
| 64 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 65 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 66 | std::vector<Path *> ret; |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 67 | ret.reserve(numPaths); |
| 68 | |
| 69 | const auto *nameArray = static_cast<const T *>(paths); |
| 70 | |
| 71 | for (GLsizei i = 0; i < numPaths; ++i) |
| 72 | { |
| 73 | const GLuint pathName = nameArray[i] + pathBase; |
| 74 | |
| 75 | ret.push_back(resourceManager.getPath(pathName)); |
| 76 | } |
| 77 | |
| 78 | return ret; |
| 79 | } |
| 80 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 81 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 82 | GLsizei numPaths, |
| 83 | GLenum pathNameType, |
| 84 | const void *paths, |
| 85 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 86 | { |
| 87 | switch (pathNameType) |
| 88 | { |
| 89 | case GL_UNSIGNED_BYTE: |
| 90 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 91 | |
| 92 | case GL_BYTE: |
| 93 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 94 | |
| 95 | case GL_UNSIGNED_SHORT: |
| 96 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 97 | |
| 98 | case GL_SHORT: |
| 99 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 100 | |
| 101 | case GL_UNSIGNED_INT: |
| 102 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 103 | |
| 104 | case GL_INT: |
| 105 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 106 | } |
| 107 | |
| 108 | UNREACHABLE(); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 109 | return std::vector<Path *>(); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 113 | angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 114 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 115 | ASSERT(query != nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 116 | |
| 117 | switch (pname) |
| 118 | { |
| 119 | case GL_QUERY_RESULT_EXT: |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 120 | return query->getResult(context, params); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 121 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 122 | { |
| 123 | bool available; |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 124 | ANGLE_TRY(query->isResultAvailable(context, &available)); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 125 | *params = CastFromStateValue<T>(pname, static_cast<GLuint>(available)); |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 126 | return angle::Result::Continue(); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 127 | } |
| 128 | default: |
| 129 | UNREACHABLE(); |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 130 | return angle::Result::Stop(); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 134 | ANGLE_INLINE void MarkTransformFeedbackBufferUsage(const Context *context, |
| 135 | TransformFeedback *transformFeedback, |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 136 | GLsizei count, |
| 137 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 138 | { |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 139 | if (transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused()) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 140 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 141 | transformFeedback->onVerticesDrawn(context, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 142 | } |
| 143 | } |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 144 | |
| 145 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 146 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 147 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 148 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 151 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 152 | { |
| 153 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 154 | } |
| 155 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 156 | Version GetClientVersion(const egl::AttributeMap &attribs) |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 157 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 158 | return Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 159 | } |
| 160 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 161 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 162 | { |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 163 | EGLAttrib attrib = |
| 164 | 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] | 165 | switch (attrib) |
| 166 | { |
| 167 | case EGL_NO_RESET_NOTIFICATION: |
| 168 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 169 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 170 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 171 | default: |
| 172 | UNREACHABLE(); |
| 173 | return GL_NONE; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 178 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 179 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || |
| 180 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != |
| 181 | 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | bool GetDebug(const egl::AttributeMap &attribs) |
| 185 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 186 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || |
| 187 | ((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] | 188 | } |
| 189 | |
| 190 | bool GetNoError(const egl::AttributeMap &attribs) |
| 191 | { |
| 192 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 193 | } |
| 194 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 195 | bool GetWebGLContext(const egl::AttributeMap &attribs) |
| 196 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 197 | return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 198 | } |
| 199 | |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 200 | bool GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext) |
| 201 | { |
| 202 | // If the context is WebGL, extensions are disabled by default |
| 203 | EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE; |
| 204 | return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE); |
| 205 | } |
| 206 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 207 | bool GetBindGeneratesResource(const egl::AttributeMap &attribs) |
| 208 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 209 | 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] | 210 | } |
| 211 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 212 | bool GetClientArraysEnabled(const egl::AttributeMap &attribs) |
| 213 | { |
| 214 | return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE); |
| 215 | } |
| 216 | |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 217 | bool GetRobustResourceInit(const egl::AttributeMap &attribs) |
| 218 | { |
| 219 | return (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE); |
| 220 | } |
| 221 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 222 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 223 | { |
| 224 | std::string labelName; |
| 225 | if (label != nullptr) |
| 226 | { |
| 227 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 228 | labelName = std::string(label, labelLength); |
| 229 | } |
| 230 | return labelName; |
| 231 | } |
| 232 | |
| 233 | void GetObjectLabelBase(const std::string &objectLabel, |
| 234 | GLsizei bufSize, |
| 235 | GLsizei *length, |
| 236 | GLchar *label) |
| 237 | { |
| 238 | size_t writeLength = objectLabel.length(); |
| 239 | if (label != nullptr && bufSize > 0) |
| 240 | { |
| 241 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 242 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 243 | label[writeLength] = '\0'; |
| 244 | } |
| 245 | |
| 246 | if (length != nullptr) |
| 247 | { |
| 248 | *length = static_cast<GLsizei>(writeLength); |
| 249 | } |
| 250 | } |
| 251 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 252 | template <typename CapT, typename MaxT> |
| 253 | void LimitCap(CapT *cap, MaxT maximum) |
| 254 | { |
| 255 | *cap = std::min(*cap, static_cast<CapT>(maximum)); |
| 256 | } |
| 257 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 258 | constexpr angle::PackedEnumMap<PrimitiveMode, GLsizei> kMinimumPrimitiveCounts = {{ |
| 259 | {PrimitiveMode::Points, 1}, |
| 260 | {PrimitiveMode::Lines, 2}, |
| 261 | {PrimitiveMode::LineLoop, 2}, |
| 262 | {PrimitiveMode::LineStrip, 2}, |
| 263 | {PrimitiveMode::Triangles, 3}, |
| 264 | {PrimitiveMode::TriangleStrip, 3}, |
| 265 | {PrimitiveMode::TriangleFan, 3}, |
| 266 | {PrimitiveMode::LinesAdjacency, 2}, |
| 267 | {PrimitiveMode::LineStripAdjacency, 2}, |
| 268 | {PrimitiveMode::TrianglesAdjacency, 3}, |
| 269 | {PrimitiveMode::TriangleStripAdjacency, 3}, |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 270 | }}; |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 271 | |
| 272 | // The rest default to false. |
| 273 | constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMode>() + 1> |
| 274 | kValidBasicDrawModes = {{ |
| 275 | {PrimitiveMode::Points, true}, |
| 276 | {PrimitiveMode::Lines, true}, |
| 277 | {PrimitiveMode::LineLoop, true}, |
| 278 | {PrimitiveMode::LineStrip, true}, |
| 279 | {PrimitiveMode::Triangles, true}, |
| 280 | {PrimitiveMode::TriangleStrip, true}, |
| 281 | {PrimitiveMode::TriangleFan, true}, |
| 282 | }}; |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 283 | |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 284 | enum SubjectIndexes : angle::SubjectIndex |
| 285 | { |
| 286 | kTexture0SubjectIndex = 0, |
| 287 | kTextureMaxSubjectIndex = kTexture0SubjectIndex + gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
| 288 | kUniformBuffer0SubjectIndex = kTextureMaxSubjectIndex, |
| 289 | kUniformBufferMaxSubjectIndex = |
| 290 | kUniformBuffer0SubjectIndex + gl::IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 291 | kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex, |
| 292 | kSamplerMaxSubjectIndex = kSampler0SubjectIndex + gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
| 293 | kVertexArraySubjectIndex = kSamplerMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 294 | kReadFramebufferSubjectIndex, |
| 295 | kDrawFramebufferSubjectIndex |
| 296 | }; |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 297 | } // anonymous namespace |
| 298 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 299 | Context::Context(rx::EGLImplFactory *implFactory, |
| 300 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 301 | const Context *shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 302 | TextureManager *shareTextures, |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 303 | MemoryProgramCache *memoryProgramCache, |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 304 | const egl::AttributeMap &attribs, |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 305 | const egl::DisplayExtensions &displayExtensions, |
| 306 | const egl::ClientExtensions &clientExtensions) |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 307 | : mState(reinterpret_cast<ContextID>(this), |
| 308 | shareContext ? &shareContext->mState : nullptr, |
| 309 | shareTextures, |
| 310 | GetClientVersion(attribs), |
| 311 | &mGLState, |
| 312 | mCaps, |
| 313 | mTextureCaps, |
| 314 | mExtensions, |
| 315 | mLimitations), |
| 316 | mSkipValidation(GetNoError(attribs)), |
| 317 | mDisplayTextureShareGroup(shareTextures != nullptr), |
Geoff Lang | 3cacf69 | 2018-06-20 16:49:57 -0400 | [diff] [blame] | 318 | mImplementation(implFactory->createContext(mState, config, shareContext, attribs)), |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 319 | mLabel(nullptr), |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 320 | mCompiler(), |
Geoff Lang | 4fb8a8b | 2018-06-01 16:47:57 -0400 | [diff] [blame] | 321 | mGLState(GetDebug(attribs), |
| 322 | GetBindGeneratesResource(attribs), |
| 323 | GetClientArraysEnabled(attribs), |
| 324 | GetRobustResourceInit(attribs), |
| 325 | memoryProgramCache != nullptr), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 326 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 327 | mClientType(EGL_OPENGL_ES_API), |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 328 | mErrors(this), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 329 | mHasBeenCurrent(false), |
| 330 | mContextLost(false), |
| 331 | mResetStatus(GL_NO_ERROR), |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 332 | mContextLostForced(false), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 333 | mResetStrategy(GetResetStrategy(attribs)), |
| 334 | mRobustAccess(GetRobustAccess(attribs)), |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 335 | mSurfacelessSupported(displayExtensions.surfacelessContext), |
| 336 | mExplicitContextAvailable(clientExtensions.explicitContext), |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 337 | mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), |
| 338 | mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 339 | mWebGLContext(GetWebGLContext(attribs)), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 340 | mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 341 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 342 | mVertexArrayObserverBinding(this, kVertexArraySubjectIndex), |
| 343 | mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex), |
| 344 | mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 345 | mScratchBuffer(1000u), |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 346 | mZeroFilledBuffer(1000u), |
| 347 | mThreadPool(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 348 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 349 | for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; |
| 350 | uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) |
| 351 | { |
| 352 | mUniformBufferObserverBindings.emplace_back(this, uboIndex); |
| 353 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 354 | |
| 355 | for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex; |
| 356 | samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex) |
| 357 | { |
| 358 | mSamplerObserverBindings.emplace_back(this, samplerIndex); |
| 359 | } |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 360 | } |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 361 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 362 | void Context::initialize() |
| 363 | { |
| 364 | mImplementation->setMemoryProgramCache(mMemoryProgramCache); |
Jamie Madill | 14bbb3f | 2017-09-12 15:23:01 -0400 | [diff] [blame] | 365 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 366 | initCaps(); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 367 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 368 | |
Geoff Lang | 4fb8a8b | 2018-06-01 16:47:57 -0400 | [diff] [blame] | 369 | mGLState.initialize(this); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 370 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 371 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 372 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 373 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 374 | // 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] | 375 | // and cube map texture state vectors respectively associated with them. |
| 376 | // In order that access to these initial textures not be lost, they are treated as texture |
| 377 | // objects all of whose names are 0. |
| 378 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 379 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, TextureType::_2D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 380 | mZeroTextures[TextureType::_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 381 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 382 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, TextureType::CubeMap); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 383 | mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 384 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 385 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 386 | { |
| 387 | // TODO: These could also be enabled via extension |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 388 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, TextureType::_3D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 389 | mZeroTextures[TextureType::_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 390 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 391 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, TextureType::_2DArray); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 392 | mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 393 | } |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 394 | if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample) |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 395 | { |
| 396 | Texture *zeroTexture2DMultisample = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 397 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisample); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 398 | mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample); |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 399 | } |
| 400 | if (getClientVersion() >= Version(3, 1)) |
| 401 | { |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 402 | Texture *zeroTexture2DMultisampleArray = |
| 403 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisampleArray); |
| 404 | mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 405 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 406 | for (unsigned int i = 0; i < mCaps.maxAtomicCounterBufferBindings; i++) |
| 407 | { |
Qin Jiajia | 339f65b | 2018-02-27 12:52:48 +0800 | [diff] [blame] | 408 | bindBufferRange(BufferBinding::AtomicCounter, i, 0, 0, 0); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 409 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 410 | |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 411 | for (unsigned int i = 0; i < mCaps.maxShaderStorageBufferBindings; i++) |
| 412 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 413 | bindBufferRange(BufferBinding::ShaderStorage, i, 0, 0, 0); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 414 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 415 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 416 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 417 | if (mSupportedExtensions.textureRectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 418 | { |
| 419 | Texture *zeroTextureRectangle = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 420 | new Texture(mImplementation.get(), 0, TextureType::Rectangle); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 421 | mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 422 | } |
| 423 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 424 | if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal) |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 425 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 426 | Texture *zeroTextureExternal = new Texture(mImplementation.get(), 0, TextureType::External); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 427 | mZeroTextures[TextureType::External].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 428 | } |
| 429 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 430 | mGLState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 431 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 432 | bindVertexArray(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 433 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 434 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 435 | { |
| 436 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 437 | // In the initial state, a default transform feedback object is bound and treated as |
| 438 | // a transform feedback object with a name of zero. That object is bound any time |
| 439 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 440 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 441 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 442 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 443 | for (auto type : angle::AllEnums<BufferBinding>()) |
| 444 | { |
| 445 | bindBuffer(type, 0); |
| 446 | } |
| 447 | |
| 448 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 449 | |
| 450 | for (unsigned int i = 0; i < mCaps.maxUniformBufferBindings; i++) |
| 451 | { |
| 452 | bindBufferRange(BufferBinding::Uniform, i, 0, 0, -1); |
| 453 | } |
| 454 | |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 455 | // Initialize GLES1 renderer if appropriate. |
| 456 | if (getClientVersion() < Version(2, 0)) |
| 457 | { |
| 458 | mGLES1Renderer.reset(new GLES1Renderer()); |
| 459 | } |
| 460 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 461 | // Initialize dirty bit masks |
Jamie Madill | 9d0bb3d | 2018-10-09 20:29:13 -0400 | [diff] [blame] | 462 | mAllDirtyBits.set(); |
| 463 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 464 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 465 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
| 466 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 467 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 468 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 469 | |
| 470 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 471 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
| 472 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 473 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 474 | |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 475 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 476 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 477 | // No dirty objects. |
| 478 | |
| 479 | // Readpixels uses the pack state and read FBO |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 480 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 481 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 482 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 483 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 484 | |
| 485 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 486 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 487 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 488 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 489 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 490 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 491 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 492 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 493 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 494 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 495 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 496 | mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 497 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 498 | |
| 499 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 500 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 501 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 502 | mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 503 | mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 504 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 505 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 506 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 507 | mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 508 | mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS); |
| 509 | mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 510 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING); |
| 511 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 512 | mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS); |
| 513 | mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 514 | mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 515 | mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING); |
Jiajia Qin | 5ae6ee4 | 2018-03-06 17:39:42 +0800 | [diff] [blame] | 516 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 517 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 518 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 519 | |
Jamie Madill | b4927eb | 2018-07-16 11:39:46 -0400 | [diff] [blame] | 520 | mImplementation->setErrorSet(&mErrors); |
| 521 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 522 | ANGLE_CONTEXT_TRY(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 525 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 526 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 527 | if (mGLES1Renderer) |
| 528 | { |
| 529 | mGLES1Renderer->onDestroy(this, &mGLState); |
| 530 | } |
| 531 | |
Jamie Madill | e7b3fe2 | 2018-04-05 09:42:46 -0400 | [diff] [blame] | 532 | ANGLE_TRY(releaseSurface(display)); |
| 533 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 534 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 535 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 536 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 537 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 538 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 539 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 540 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 541 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 542 | if (query.second != nullptr) |
| 543 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 544 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 545 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 546 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 547 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 548 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 549 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 550 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 551 | if (vertexArray.second) |
| 552 | { |
| 553 | vertexArray.second->onDestroy(this); |
| 554 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 555 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 556 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 557 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 558 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 559 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 560 | if (transformFeedback.second != nullptr) |
| 561 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 562 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 563 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 564 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 565 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 566 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 567 | for (BindingPointer<Texture> &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 568 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 569 | if (zeroTexture.get() != nullptr) |
| 570 | { |
Jamie Madill | 1c7f08c | 2018-10-10 16:13:02 -0400 | [diff] [blame] | 571 | zeroTexture->onDestroy(this); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 572 | zeroTexture.set(this, nullptr); |
| 573 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 574 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 575 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 576 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 577 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 578 | mGLState.reset(this); |
| 579 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 580 | mState.mBuffers->release(this); |
| 581 | mState.mShaderPrograms->release(this); |
| 582 | mState.mTextures->release(this); |
| 583 | mState.mRenderbuffers->release(this); |
| 584 | mState.mSamplers->release(this); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 585 | mState.mSyncs->release(this); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 586 | mState.mPaths->release(this); |
| 587 | mState.mFramebuffers->release(this); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 588 | mState.mPipelines->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 589 | |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 590 | mThreadPool.reset(); |
| 591 | |
Jamie Madill | 76e471e | 2017-10-21 09:56:01 -0400 | [diff] [blame] | 592 | mImplementation->onDestroy(this); |
| 593 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 594 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 597 | Context::~Context() {} |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 598 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 599 | void Context::setLabel(EGLLabelKHR label) |
| 600 | { |
| 601 | mLabel = label; |
| 602 | } |
| 603 | |
| 604 | EGLLabelKHR Context::getLabel() const |
| 605 | { |
| 606 | return mLabel; |
| 607 | } |
| 608 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 609 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 610 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 611 | mCurrentDisplay = display; |
| 612 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 613 | if (!mHasBeenCurrent) |
| 614 | { |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 615 | initialize(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 616 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 617 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 618 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 619 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 620 | int width = 0; |
| 621 | int height = 0; |
| 622 | if (surface != nullptr) |
| 623 | { |
| 624 | width = surface->getWidth(); |
| 625 | height = surface->getHeight(); |
| 626 | } |
| 627 | |
| 628 | mGLState.setViewportParams(0, 0, width, height); |
| 629 | mGLState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 630 | |
| 631 | mHasBeenCurrent = true; |
| 632 | } |
| 633 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 634 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 635 | mGLState.setAllDirtyBits(); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 636 | mGLState.setAllDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 637 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 638 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 639 | |
| 640 | Framebuffer *newDefault = nullptr; |
| 641 | if (surface != nullptr) |
| 642 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 643 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 644 | mCurrentSurface = surface; |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 645 | newDefault = surface->createDefaultFramebuffer(this); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 646 | } |
| 647 | else |
| 648 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 649 | newDefault = new Framebuffer(mImplementation.get()); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 650 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 651 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 652 | // Update default framebuffer, the binding of the previous default |
| 653 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 654 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 655 | mState.mFramebuffers->setDefaultFramebuffer(newDefault); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 656 | if (mGLState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 657 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 658 | bindReadFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 659 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 660 | if (mGLState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 661 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 662 | bindDrawFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 663 | } |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 664 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 665 | |
Jamie Madill | 32643ce | 2018-10-19 11:38:03 -0400 | [diff] [blame] | 666 | // Notify the renderer of a context switch. |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 667 | return mImplementation->onMakeCurrent(this).toEGL(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 668 | } |
| 669 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 670 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 671 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 672 | gl::Framebuffer *defaultFramebuffer = mState.mFramebuffers->getFramebuffer(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 673 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 674 | // Remove the default framebuffer |
| 675 | if (mGLState.getReadFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 676 | { |
| 677 | mGLState.setReadFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 678 | mReadFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 679 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 680 | |
| 681 | if (mGLState.getDrawFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 682 | { |
| 683 | mGLState.setDrawFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 684 | mDrawFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 685 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 686 | |
| 687 | if (defaultFramebuffer) |
| 688 | { |
| 689 | defaultFramebuffer->onDestroy(this); |
| 690 | delete defaultFramebuffer; |
| 691 | } |
| 692 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 693 | mState.mFramebuffers->setDefaultFramebuffer(nullptr); |
| 694 | |
| 695 | if (mCurrentSurface) |
| 696 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 697 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 698 | mCurrentSurface = nullptr; |
| 699 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 700 | |
| 701 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 702 | } |
| 703 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 704 | GLuint Context::createBuffer() |
| 705 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 706 | return mState.mBuffers->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | GLuint Context::createProgram() |
| 710 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 711 | return mState.mShaderPrograms->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 712 | } |
| 713 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 714 | GLuint Context::createShader(ShaderType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 715 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 716 | return mState.mShaderPrograms->createShader(mImplementation.get(), mLimitations, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | GLuint Context::createTexture() |
| 720 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 721 | return mState.mTextures->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | GLuint Context::createRenderbuffer() |
| 725 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 726 | return mState.mRenderbuffers->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 727 | } |
| 728 | |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 729 | void Context::tryGenPaths(GLsizei range, GLuint *createdOut) |
| 730 | { |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 731 | ANGLE_CONTEXT_TRY(mState.mPaths->createPaths(this, range, createdOut)); |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 732 | } |
| 733 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 734 | GLuint Context::genPaths(GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 735 | { |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 736 | GLuint created = 0; |
| 737 | tryGenPaths(range, &created); |
| 738 | return created; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 739 | } |
| 740 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 741 | // Returns an unused framebuffer name |
| 742 | GLuint Context::createFramebuffer() |
| 743 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 744 | return mState.mFramebuffers->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 745 | } |
| 746 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 747 | void Context::genFencesNV(GLsizei n, GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 748 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 749 | for (int i = 0; i < n; i++) |
| 750 | { |
| 751 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
| 752 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
| 753 | fences[i] = handle; |
| 754 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 757 | GLuint Context::createProgramPipeline() |
| 758 | { |
| 759 | return mState.mPipelines->createProgramPipeline(); |
| 760 | } |
| 761 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 762 | GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 763 | { |
| 764 | UNIMPLEMENTED(); |
| 765 | return 0u; |
| 766 | } |
| 767 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 768 | void Context::deleteBuffer(GLuint bufferName) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 769 | { |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 770 | Buffer *buffer = mState.mBuffers->getBuffer(bufferName); |
| 771 | if (buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 772 | { |
| 773 | detachBuffer(buffer); |
| 774 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 775 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 776 | mState.mBuffers->deleteObject(this, bufferName); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | void Context::deleteShader(GLuint shader) |
| 780 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 781 | mState.mShaderPrograms->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 782 | } |
| 783 | |
| 784 | void Context::deleteProgram(GLuint program) |
| 785 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 786 | mState.mShaderPrograms->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | void Context::deleteTexture(GLuint texture) |
| 790 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 791 | if (mState.mTextures->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 792 | { |
| 793 | detachTexture(texture); |
| 794 | } |
| 795 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 796 | mState.mTextures->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 800 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 801 | if (mState.mRenderbuffers->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 802 | { |
| 803 | detachRenderbuffer(renderbuffer); |
| 804 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 805 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 806 | mState.mRenderbuffers->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 807 | } |
| 808 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 809 | void Context::deleteSync(GLsync sync) |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 810 | { |
| 811 | // The spec specifies the underlying Fence object is not deleted until all current |
| 812 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 813 | // and since our API is currently designed for being called from a single thread, we can delete |
| 814 | // the fence immediately. |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 815 | mState.mSyncs->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 816 | } |
| 817 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 818 | void Context::deleteProgramPipeline(GLuint pipeline) |
| 819 | { |
| 820 | if (mState.mPipelines->getProgramPipeline(pipeline)) |
| 821 | { |
| 822 | detachProgramPipeline(pipeline); |
| 823 | } |
| 824 | |
| 825 | mState.mPipelines->deleteObject(this, pipeline); |
| 826 | } |
| 827 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 828 | void Context::deletePaths(GLuint first, GLsizei range) |
| 829 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 830 | mState.mPaths->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 831 | } |
| 832 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 833 | bool Context::isPath(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 834 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 835 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 836 | if (pathObj == nullptr) |
| 837 | return false; |
| 838 | |
| 839 | return pathObj->hasPathData(); |
| 840 | } |
| 841 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 842 | bool Context::isPathGenerated(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 843 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 844 | return mState.mPaths->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 845 | } |
| 846 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 847 | void Context::pathCommands(GLuint path, |
| 848 | GLsizei numCommands, |
| 849 | const GLubyte *commands, |
| 850 | GLsizei numCoords, |
| 851 | GLenum coordType, |
| 852 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 853 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 854 | auto *pathObject = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 855 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 856 | ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 857 | } |
| 858 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 859 | void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 860 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 861 | Path *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 862 | |
| 863 | switch (pname) |
| 864 | { |
| 865 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 866 | pathObj->setStrokeWidth(value); |
| 867 | break; |
| 868 | case GL_PATH_END_CAPS_CHROMIUM: |
| 869 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 870 | break; |
| 871 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 872 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 873 | break; |
| 874 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 875 | pathObj->setMiterLimit(value); |
| 876 | break; |
| 877 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 878 | pathObj->setStrokeBound(value); |
| 879 | break; |
| 880 | default: |
| 881 | UNREACHABLE(); |
| 882 | break; |
| 883 | } |
| 884 | } |
| 885 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 886 | void Context::pathParameteri(GLuint path, GLenum pname, GLint value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 887 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 888 | // TODO(jmadill): Should use proper clamping/casting. |
| 889 | pathParameterf(path, pname, static_cast<GLfloat>(value)); |
| 890 | } |
| 891 | |
| 892 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) |
| 893 | { |
| 894 | const Path *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 895 | |
| 896 | switch (pname) |
| 897 | { |
| 898 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 899 | *value = pathObj->getStrokeWidth(); |
| 900 | break; |
| 901 | case GL_PATH_END_CAPS_CHROMIUM: |
| 902 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 903 | break; |
| 904 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 905 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 906 | break; |
| 907 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 908 | *value = pathObj->getMiterLimit(); |
| 909 | break; |
| 910 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 911 | *value = pathObj->getStrokeBound(); |
| 912 | break; |
| 913 | default: |
| 914 | UNREACHABLE(); |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 919 | void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value) |
| 920 | { |
| 921 | GLfloat val = 0.0f; |
| 922 | getPathParameterfv(path, pname, value != nullptr ? &val : nullptr); |
| 923 | if (value) |
| 924 | *value = static_cast<GLint>(val); |
| 925 | } |
| 926 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 927 | void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 928 | { |
| 929 | mGLState.setPathStencilFunc(func, ref, mask); |
| 930 | } |
| 931 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 932 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 933 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 934 | if (mState.mFramebuffers->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 935 | { |
| 936 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 937 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 938 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 939 | mState.mFramebuffers->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 940 | } |
| 941 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 942 | void Context::deleteFencesNV(GLsizei n, const GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 943 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 944 | for (int i = 0; i < n; i++) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 945 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 946 | GLuint fence = fences[i]; |
| 947 | |
| 948 | FenceNV *fenceObject = nullptr; |
| 949 | if (mFenceNVMap.erase(fence, &fenceObject)) |
| 950 | { |
| 951 | mFenceNVHandleAllocator.release(fence); |
| 952 | delete fenceObject; |
| 953 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 954 | } |
| 955 | } |
| 956 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 957 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 958 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 959 | return mState.mBuffers->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 962 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 963 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 964 | return mState.mRenderbuffers->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 965 | } |
| 966 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 967 | Sync *Context::getSync(GLsync handle) const |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 968 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 969 | return mState.mSyncs->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 970 | } |
| 971 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 972 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 973 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 974 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 975 | } |
| 976 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 977 | Sampler *Context::getSampler(GLuint handle) const |
| 978 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 979 | return mState.mSamplers->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 980 | } |
| 981 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 982 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 983 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 984 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 985 | } |
| 986 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 987 | ProgramPipeline *Context::getProgramPipeline(GLuint handle) const |
| 988 | { |
| 989 | return mState.mPipelines->getProgramPipeline(handle); |
| 990 | } |
| 991 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 992 | gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 993 | { |
| 994 | switch (identifier) |
| 995 | { |
| 996 | case GL_BUFFER: |
| 997 | return getBuffer(name); |
| 998 | case GL_SHADER: |
| 999 | return getShader(name); |
| 1000 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 1001 | return getProgramNoResolveLink(name); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1002 | case GL_VERTEX_ARRAY: |
| 1003 | return getVertexArray(name); |
| 1004 | case GL_QUERY: |
| 1005 | return getQuery(name); |
| 1006 | case GL_TRANSFORM_FEEDBACK: |
| 1007 | return getTransformFeedback(name); |
| 1008 | case GL_SAMPLER: |
| 1009 | return getSampler(name); |
| 1010 | case GL_TEXTURE: |
| 1011 | return getTexture(name); |
| 1012 | case GL_RENDERBUFFER: |
| 1013 | return getRenderbuffer(name); |
| 1014 | case GL_FRAMEBUFFER: |
| 1015 | return getFramebuffer(name); |
| 1016 | default: |
| 1017 | UNREACHABLE(); |
| 1018 | return nullptr; |
| 1019 | } |
| 1020 | } |
| 1021 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1022 | gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1023 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 1024 | return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1025 | } |
| 1026 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1027 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 1028 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1029 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1030 | ASSERT(object != nullptr); |
| 1031 | |
| 1032 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame^] | 1033 | object->setLabel(this, labelName); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 1034 | |
| 1035 | // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the |
| 1036 | // specified object is active until we do this. |
| 1037 | mGLState.setObjectDirty(identifier); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 1041 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1042 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1043 | ASSERT(object != nullptr); |
| 1044 | |
| 1045 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame^] | 1046 | object->setLabel(this, labelName); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | void Context::getObjectLabel(GLenum identifier, |
| 1050 | GLuint name, |
| 1051 | GLsizei bufSize, |
| 1052 | GLsizei *length, |
| 1053 | GLchar *label) const |
| 1054 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1055 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1056 | ASSERT(object != nullptr); |
| 1057 | |
| 1058 | const std::string &objectLabel = object->getLabel(); |
| 1059 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1060 | } |
| 1061 | |
| 1062 | void Context::getObjectPtrLabel(const void *ptr, |
| 1063 | GLsizei bufSize, |
| 1064 | GLsizei *length, |
| 1065 | GLchar *label) const |
| 1066 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1067 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1068 | ASSERT(object != nullptr); |
| 1069 | |
| 1070 | const std::string &objectLabel = object->getLabel(); |
| 1071 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1072 | } |
| 1073 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1074 | bool Context::isSampler(GLuint samplerName) const |
| 1075 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1076 | return mState.mSamplers->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1077 | } |
| 1078 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1079 | void Context::bindTexture(TextureType target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1080 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1081 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1082 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1083 | if (handle == 0) |
| 1084 | { |
| 1085 | texture = mZeroTextures[target].get(); |
| 1086 | } |
| 1087 | else |
| 1088 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 1089 | texture = mState.mTextures->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | ASSERT(texture); |
Jamie Madill | 1424681 | 2018-10-03 17:51:16 -0400 | [diff] [blame] | 1093 | ANGLE_CONTEXT_TRY(mGLState.setSamplerTexture(this, target, texture)); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1094 | mStateCache.onActiveTextureChange(this); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1095 | } |
| 1096 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1097 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1098 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1099 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 1100 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1101 | mGLState.setReadFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1102 | mReadFramebufferObserverBinding.bind(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1105 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1106 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1107 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 1108 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1109 | mGLState.setDrawFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1110 | mDrawFramebufferObserverBinding.bind(framebuffer); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1111 | mStateCache.onDrawFramebufferChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1114 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1115 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1116 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 1117 | mGLState.setVertexArrayBinding(this, vertexArray); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1118 | mVertexArrayObserverBinding.bind(vertexArray); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1119 | mStateCache.onVertexArrayBindingChange(this); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1120 | } |
| 1121 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1122 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 1123 | GLuint bufferHandle, |
| 1124 | GLintptr offset, |
| 1125 | GLsizei stride) |
| 1126 | { |
| 1127 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1128 | mGLState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1129 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1130 | } |
| 1131 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1132 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1133 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1134 | ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1135 | Sampler *sampler = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1136 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1137 | mGLState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 1138 | mSamplerObserverBindings[textureUnit].bind(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1139 | } |
| 1140 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1141 | void Context::bindImageTexture(GLuint unit, |
| 1142 | GLuint texture, |
| 1143 | GLint level, |
| 1144 | GLboolean layered, |
| 1145 | GLint layer, |
| 1146 | GLenum access, |
| 1147 | GLenum format) |
| 1148 | { |
| 1149 | Texture *tex = mState.mTextures->getTexture(texture); |
| 1150 | mGLState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
| 1151 | } |
| 1152 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1153 | void Context::useProgram(GLuint program) |
| 1154 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 1155 | ANGLE_CONTEXT_TRY(mGLState.setProgram(this, getProgramResolveLink(program))); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1156 | mStateCache.onProgramExecutableChange(this); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 1159 | void Context::useProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) |
| 1160 | { |
| 1161 | UNIMPLEMENTED(); |
| 1162 | } |
| 1163 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1164 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1165 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1166 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1167 | TransformFeedback *transformFeedback = |
| 1168 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1169 | mGLState.setTransformFeedbackBinding(this, transformFeedback); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1170 | mStateCache.onTransformFeedbackChange(this); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1171 | } |
| 1172 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1173 | void Context::bindProgramPipeline(GLuint pipelineHandle) |
| 1174 | { |
| 1175 | ProgramPipeline *pipeline = |
| 1176 | mState.mPipelines->checkProgramPipelineAllocation(mImplementation.get(), pipelineHandle); |
| 1177 | mGLState.setProgramPipelineBinding(this, pipeline); |
| 1178 | } |
| 1179 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1180 | void Context::beginQuery(QueryType target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1181 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1182 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1183 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1184 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1185 | // begin query |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 1186 | ANGLE_CONTEXT_TRY(queryObject->begin(this)); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1187 | |
| 1188 | // set query as active for specified target only if begin succeeded |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1189 | mGLState.setActiveQuery(this, target, queryObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1190 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1191 | } |
| 1192 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1193 | void Context::endQuery(QueryType target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1194 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1195 | Query *queryObject = mGLState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1196 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1197 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1198 | // Intentionally don't call try here. We don't want an early return. |
| 1199 | (void)(queryObject->end(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1200 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1201 | // Always unbind the query, even if there was an error. This may delete the query object. |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1202 | mGLState.setActiveQuery(this, target, nullptr); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1203 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1204 | } |
| 1205 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1206 | void Context::queryCounter(GLuint id, QueryType target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1207 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1208 | ASSERT(target == QueryType::Timestamp); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1209 | |
| 1210 | Query *queryObject = getQuery(id, true, target); |
| 1211 | ASSERT(queryObject); |
| 1212 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1213 | ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1214 | } |
| 1215 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1216 | void Context::getQueryiv(QueryType target, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1217 | { |
| 1218 | switch (pname) |
| 1219 | { |
| 1220 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1221 | params[0] = mGLState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1222 | break; |
| 1223 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1224 | switch (target) |
| 1225 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1226 | case QueryType::TimeElapsed: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1227 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1228 | break; |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1229 | case QueryType::Timestamp: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1230 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1231 | break; |
| 1232 | default: |
| 1233 | UNREACHABLE(); |
| 1234 | params[0] = 0; |
| 1235 | break; |
| 1236 | } |
| 1237 | break; |
| 1238 | default: |
| 1239 | UNREACHABLE(); |
| 1240 | return; |
| 1241 | } |
| 1242 | } |
| 1243 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1244 | void Context::getQueryivRobust(QueryType target, |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1245 | GLenum pname, |
| 1246 | GLsizei bufSize, |
| 1247 | GLsizei *length, |
| 1248 | GLint *params) |
| 1249 | { |
| 1250 | getQueryiv(target, pname, params); |
| 1251 | } |
| 1252 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1253 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1254 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1255 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1256 | } |
| 1257 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1258 | void Context::getQueryObjectivRobust(GLuint id, |
| 1259 | GLenum pname, |
| 1260 | GLsizei bufSize, |
| 1261 | GLsizei *length, |
| 1262 | GLint *params) |
| 1263 | { |
| 1264 | getQueryObjectiv(id, pname, params); |
| 1265 | } |
| 1266 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1267 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1268 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1269 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1270 | } |
| 1271 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1272 | void Context::getQueryObjectuivRobust(GLuint id, |
| 1273 | GLenum pname, |
| 1274 | GLsizei bufSize, |
| 1275 | GLsizei *length, |
| 1276 | GLuint *params) |
| 1277 | { |
| 1278 | getQueryObjectuiv(id, pname, params); |
| 1279 | } |
| 1280 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1281 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1282 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1283 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1284 | } |
| 1285 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1286 | void Context::getQueryObjecti64vRobust(GLuint id, |
| 1287 | GLenum pname, |
| 1288 | GLsizei bufSize, |
| 1289 | GLsizei *length, |
| 1290 | GLint64 *params) |
| 1291 | { |
| 1292 | getQueryObjecti64v(id, pname, params); |
| 1293 | } |
| 1294 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1295 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1296 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1297 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1298 | } |
| 1299 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1300 | void Context::getQueryObjectui64vRobust(GLuint id, |
| 1301 | GLenum pname, |
| 1302 | GLsizei bufSize, |
| 1303 | GLsizei *length, |
| 1304 | GLuint64 *params) |
| 1305 | { |
| 1306 | getQueryObjectui64v(id, pname, params); |
| 1307 | } |
| 1308 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1309 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1310 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1311 | return mState.mFramebuffers->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1312 | } |
| 1313 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1314 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1315 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1316 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1319 | Query *Context::getQuery(GLuint handle, bool create, QueryType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1320 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1321 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1322 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1323 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1324 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1325 | |
| 1326 | Query *query = mQueryMap.query(handle); |
| 1327 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1328 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1329 | ASSERT(type != QueryType::InvalidEnum); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1330 | query = new Query(mImplementation->createQuery(type), handle); |
| 1331 | query->addRef(); |
| 1332 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1333 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1334 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1335 | } |
| 1336 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1337 | Query *Context::getQuery(GLuint handle) const |
| 1338 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1339 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1340 | } |
| 1341 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1342 | Texture *Context::getTargetTexture(TextureType type) const |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1343 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1344 | ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type)); |
| 1345 | return mGLState.getTargetTexture(type); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1348 | Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1349 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1350 | return mGLState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1353 | Compiler *Context::getCompiler() const |
| 1354 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1355 | if (mCompiler.get() == nullptr) |
| 1356 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1357 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1358 | } |
| 1359 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1360 | } |
| 1361 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1362 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1363 | { |
| 1364 | switch (pname) |
| 1365 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1366 | case GL_SHADER_COMPILER: |
| 1367 | *params = GL_TRUE; |
| 1368 | break; |
| 1369 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1370 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1371 | break; |
| 1372 | default: |
| 1373 | mGLState.getBooleanv(pname, params); |
| 1374 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1375 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1378 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1379 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1380 | // Queries about context capabilities and maximums are answered by Context. |
| 1381 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1382 | switch (pname) |
| 1383 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1384 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 1385 | params[0] = mCaps.minAliasedLineWidth; |
| 1386 | params[1] = mCaps.maxAliasedLineWidth; |
| 1387 | break; |
| 1388 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 1389 | params[0] = mCaps.minAliasedPointSize; |
| 1390 | params[1] = mCaps.maxAliasedPointSize; |
| 1391 | break; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1392 | case GL_SMOOTH_POINT_SIZE_RANGE: |
| 1393 | params[0] = mCaps.minSmoothPointSize; |
| 1394 | params[1] = mCaps.maxSmoothPointSize; |
| 1395 | break; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1396 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
| 1397 | params[0] = mCaps.minSmoothLineWidth; |
| 1398 | params[1] = mCaps.maxSmoothLineWidth; |
| 1399 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1400 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 1401 | ASSERT(mExtensions.textureFilterAnisotropic); |
| 1402 | *params = mExtensions.maxTextureAnisotropy; |
| 1403 | break; |
| 1404 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 1405 | *params = mCaps.maxLODBias; |
| 1406 | break; |
| 1407 | |
| 1408 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1409 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1410 | { |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1411 | // GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the |
| 1412 | // GLES1 constants for modelview/projection matrix. |
| 1413 | if (getClientVersion() < Version(2, 0)) |
| 1414 | { |
| 1415 | mGLState.getFloatv(pname, params); |
| 1416 | } |
| 1417 | else |
| 1418 | { |
| 1419 | ASSERT(mExtensions.pathRendering); |
| 1420 | const GLfloat *m = mGLState.getPathRenderingMatrix(pname); |
| 1421 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1422 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1423 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1424 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1425 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1426 | default: |
| 1427 | mGLState.getFloatv(pname, params); |
| 1428 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1429 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1430 | } |
| 1431 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1432 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1433 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1434 | // Queries about context capabilities and maximums are answered by Context. |
| 1435 | // 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] | 1436 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1437 | switch (pname) |
| 1438 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1439 | case GL_MAX_VERTEX_ATTRIBS: |
| 1440 | *params = mCaps.maxVertexAttributes; |
| 1441 | break; |
| 1442 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 1443 | *params = mCaps.maxVertexUniformVectors; |
| 1444 | break; |
| 1445 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1446 | *params = mCaps.maxShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1447 | break; |
| 1448 | case GL_MAX_VARYING_VECTORS: |
| 1449 | *params = mCaps.maxVaryingVectors; |
| 1450 | break; |
| 1451 | case GL_MAX_VARYING_COMPONENTS: |
| 1452 | *params = mCaps.maxVertexOutputComponents; |
| 1453 | break; |
| 1454 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 1455 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1456 | break; |
| 1457 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1458 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1459 | break; |
| 1460 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1461 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1462 | break; |
| 1463 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 1464 | *params = mCaps.maxFragmentUniformVectors; |
| 1465 | break; |
| 1466 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1467 | *params = mCaps.maxShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1468 | break; |
| 1469 | case GL_MAX_RENDERBUFFER_SIZE: |
| 1470 | *params = mCaps.maxRenderbufferSize; |
| 1471 | break; |
| 1472 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 1473 | *params = mCaps.maxColorAttachments; |
| 1474 | break; |
| 1475 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 1476 | *params = mCaps.maxDrawBuffers; |
| 1477 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1478 | case GL_SUBPIXEL_BITS: |
| 1479 | *params = 4; |
| 1480 | break; |
| 1481 | case GL_MAX_TEXTURE_SIZE: |
| 1482 | *params = mCaps.max2DTextureSize; |
| 1483 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1484 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 1485 | *params = mCaps.maxRectangleTextureSize; |
| 1486 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1487 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 1488 | *params = mCaps.maxCubeMapTextureSize; |
| 1489 | break; |
| 1490 | case GL_MAX_3D_TEXTURE_SIZE: |
| 1491 | *params = mCaps.max3DTextureSize; |
| 1492 | break; |
| 1493 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 1494 | *params = mCaps.maxArrayTextureLayers; |
| 1495 | break; |
| 1496 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 1497 | *params = mCaps.uniformBufferOffsetAlignment; |
| 1498 | break; |
| 1499 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 1500 | *params = mCaps.maxUniformBufferBindings; |
| 1501 | break; |
| 1502 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1503 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1504 | break; |
| 1505 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1506 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1507 | break; |
| 1508 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 1509 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1510 | break; |
| 1511 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 1512 | *params = mCaps.maxVertexOutputComponents; |
| 1513 | break; |
| 1514 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 1515 | *params = mCaps.maxFragmentInputComponents; |
| 1516 | break; |
| 1517 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 1518 | *params = mCaps.minProgramTexelOffset; |
| 1519 | break; |
| 1520 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 1521 | *params = mCaps.maxProgramTexelOffset; |
| 1522 | break; |
| 1523 | case GL_MAJOR_VERSION: |
| 1524 | *params = getClientVersion().major; |
| 1525 | break; |
| 1526 | case GL_MINOR_VERSION: |
| 1527 | *params = getClientVersion().minor; |
| 1528 | break; |
| 1529 | case GL_MAX_ELEMENTS_INDICES: |
| 1530 | *params = mCaps.maxElementsIndices; |
| 1531 | break; |
| 1532 | case GL_MAX_ELEMENTS_VERTICES: |
| 1533 | *params = mCaps.maxElementsVertices; |
| 1534 | break; |
| 1535 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 1536 | *params = mCaps.maxTransformFeedbackInterleavedComponents; |
| 1537 | break; |
| 1538 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 1539 | *params = mCaps.maxTransformFeedbackSeparateAttributes; |
| 1540 | break; |
| 1541 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 1542 | *params = mCaps.maxTransformFeedbackSeparateComponents; |
| 1543 | break; |
| 1544 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 1545 | *params = static_cast<GLint>(mCaps.compressedTextureFormats.size()); |
| 1546 | break; |
| 1547 | case GL_MAX_SAMPLES_ANGLE: |
| 1548 | *params = mCaps.maxSamples; |
| 1549 | break; |
| 1550 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1551 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1552 | params[0] = mCaps.maxViewportWidth; |
| 1553 | params[1] = mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1554 | } |
| 1555 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1556 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 1557 | std::copy(mCaps.compressedTextureFormats.begin(), mCaps.compressedTextureFormats.end(), |
| 1558 | params); |
| 1559 | break; |
| 1560 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1561 | *params = mResetStrategy; |
| 1562 | break; |
| 1563 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 1564 | *params = static_cast<GLint>(mCaps.shaderBinaryFormats.size()); |
| 1565 | break; |
| 1566 | case GL_SHADER_BINARY_FORMATS: |
| 1567 | std::copy(mCaps.shaderBinaryFormats.begin(), mCaps.shaderBinaryFormats.end(), params); |
| 1568 | break; |
| 1569 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
| 1570 | *params = static_cast<GLint>(mCaps.programBinaryFormats.size()); |
| 1571 | break; |
| 1572 | case GL_PROGRAM_BINARY_FORMATS: |
| 1573 | std::copy(mCaps.programBinaryFormats.begin(), mCaps.programBinaryFormats.end(), params); |
| 1574 | break; |
| 1575 | case GL_NUM_EXTENSIONS: |
| 1576 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1577 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1578 | |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame] | 1579 | // GL_ANGLE_request_extension |
| 1580 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 1581 | *params = static_cast<GLint>(mRequestableExtensionStrings.size()); |
| 1582 | break; |
| 1583 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1584 | // GL_KHR_debug |
| 1585 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 1586 | *params = mExtensions.maxDebugMessageLength; |
| 1587 | break; |
| 1588 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 1589 | *params = mExtensions.maxDebugLoggedMessages; |
| 1590 | break; |
| 1591 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 1592 | *params = mExtensions.maxDebugGroupStackDepth; |
| 1593 | break; |
| 1594 | case GL_MAX_LABEL_LENGTH: |
| 1595 | *params = mExtensions.maxLabelLength; |
| 1596 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1597 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1598 | // GL_ANGLE_multiview |
| 1599 | case GL_MAX_VIEWS_ANGLE: |
| 1600 | *params = mExtensions.maxViews; |
| 1601 | break; |
| 1602 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1603 | // GL_EXT_disjoint_timer_query |
| 1604 | case GL_GPU_DISJOINT_EXT: |
| 1605 | *params = mImplementation->getGPUDisjoint(); |
| 1606 | break; |
| 1607 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 1608 | *params = mCaps.maxFramebufferWidth; |
| 1609 | break; |
| 1610 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 1611 | *params = mCaps.maxFramebufferHeight; |
| 1612 | break; |
| 1613 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 1614 | *params = mCaps.maxFramebufferSamples; |
| 1615 | break; |
| 1616 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 1617 | *params = mCaps.maxSampleMaskWords; |
| 1618 | break; |
| 1619 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 1620 | *params = mCaps.maxColorTextureSamples; |
| 1621 | break; |
| 1622 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 1623 | *params = mCaps.maxDepthTextureSamples; |
| 1624 | break; |
| 1625 | case GL_MAX_INTEGER_SAMPLES: |
| 1626 | *params = mCaps.maxIntegerSamples; |
| 1627 | break; |
| 1628 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 1629 | *params = mCaps.maxVertexAttribRelativeOffset; |
| 1630 | break; |
| 1631 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 1632 | *params = mCaps.maxVertexAttribBindings; |
| 1633 | break; |
| 1634 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 1635 | *params = mCaps.maxVertexAttribStride; |
| 1636 | break; |
| 1637 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1638 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1639 | break; |
| 1640 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1641 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1642 | break; |
| 1643 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1644 | *params = mCaps.maxShaderImageUniforms[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1645 | break; |
| 1646 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1647 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1648 | break; |
| 1649 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1650 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1651 | break; |
| 1652 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1653 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1654 | break; |
| 1655 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1656 | *params = mCaps.maxShaderImageUniforms[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1657 | break; |
| 1658 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1659 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1660 | break; |
| 1661 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1662 | *params = mCaps.minProgramTextureGatherOffset; |
| 1663 | break; |
| 1664 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1665 | *params = mCaps.maxProgramTextureGatherOffset; |
| 1666 | break; |
| 1667 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 1668 | *params = mCaps.maxComputeWorkGroupInvocations; |
| 1669 | break; |
| 1670 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1671 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1672 | break; |
| 1673 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1674 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1675 | break; |
| 1676 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 1677 | *params = mCaps.maxComputeSharedMemorySize; |
| 1678 | break; |
| 1679 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1680 | *params = mCaps.maxShaderUniformComponents[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1681 | break; |
| 1682 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1683 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1684 | break; |
| 1685 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1686 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1687 | break; |
| 1688 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1689 | *params = mCaps.maxShaderImageUniforms[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1690 | break; |
| 1691 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1692 | *params = |
| 1693 | static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1694 | break; |
| 1695 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1696 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1697 | break; |
| 1698 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 1699 | *params = mCaps.maxCombinedShaderOutputResources; |
| 1700 | break; |
| 1701 | case GL_MAX_UNIFORM_LOCATIONS: |
| 1702 | *params = mCaps.maxUniformLocations; |
| 1703 | break; |
| 1704 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 1705 | *params = mCaps.maxAtomicCounterBufferBindings; |
| 1706 | break; |
| 1707 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 1708 | *params = mCaps.maxAtomicCounterBufferSize; |
| 1709 | break; |
| 1710 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 1711 | *params = mCaps.maxCombinedAtomicCounterBuffers; |
| 1712 | break; |
| 1713 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 1714 | *params = mCaps.maxCombinedAtomicCounters; |
| 1715 | break; |
| 1716 | case GL_MAX_IMAGE_UNITS: |
| 1717 | *params = mCaps.maxImageUnits; |
| 1718 | break; |
| 1719 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 1720 | *params = mCaps.maxCombinedImageUniforms; |
| 1721 | break; |
| 1722 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 1723 | *params = mCaps.maxShaderStorageBufferBindings; |
| 1724 | break; |
| 1725 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 1726 | *params = mCaps.maxCombinedShaderStorageBlocks; |
| 1727 | break; |
| 1728 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 1729 | *params = mCaps.shaderStorageBufferOffsetAlignment; |
| 1730 | break; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1731 | |
| 1732 | // GL_EXT_geometry_shader |
| 1733 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 1734 | *params = mCaps.maxFramebufferLayers; |
| 1735 | break; |
| 1736 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 1737 | *params = mCaps.layerProvokingVertex; |
| 1738 | break; |
| 1739 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1740 | *params = mCaps.maxShaderUniformComponents[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1741 | break; |
| 1742 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1743 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1744 | break; |
| 1745 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1746 | *params = |
| 1747 | static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]); |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1748 | break; |
| 1749 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 1750 | *params = mCaps.maxGeometryInputComponents; |
| 1751 | break; |
| 1752 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 1753 | *params = mCaps.maxGeometryOutputComponents; |
| 1754 | break; |
| 1755 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 1756 | *params = mCaps.maxGeometryOutputVertices; |
| 1757 | break; |
| 1758 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 1759 | *params = mCaps.maxGeometryTotalOutputComponents; |
| 1760 | break; |
| 1761 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 1762 | *params = mCaps.maxGeometryShaderInvocations; |
| 1763 | break; |
| 1764 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1765 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1766 | break; |
| 1767 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1768 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1769 | break; |
| 1770 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1771 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1772 | break; |
| 1773 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1774 | *params = mCaps.maxShaderImageUniforms[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1775 | break; |
| 1776 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1777 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1778 | break; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1779 | // GLES1 emulation: Caps queries |
| 1780 | case GL_MAX_TEXTURE_UNITS: |
| 1781 | *params = mCaps.maxMultitextureUnits; |
| 1782 | break; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1783 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 1784 | *params = mCaps.maxModelviewMatrixStackDepth; |
| 1785 | break; |
| 1786 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 1787 | *params = mCaps.maxProjectionMatrixStackDepth; |
| 1788 | break; |
| 1789 | case GL_MAX_TEXTURE_STACK_DEPTH: |
| 1790 | *params = mCaps.maxTextureMatrixStackDepth; |
| 1791 | break; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1792 | case GL_MAX_LIGHTS: |
| 1793 | *params = mCaps.maxLights; |
| 1794 | break; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1795 | case GL_MAX_CLIP_PLANES: |
| 1796 | *params = mCaps.maxClipPlanes; |
| 1797 | break; |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1798 | // GLES1 emulation: Vertex attribute queries |
| 1799 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 1800 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 1801 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 1802 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
| 1803 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 1804 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1805 | GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params); |
| 1806 | break; |
| 1807 | case GL_VERTEX_ARRAY_STRIDE: |
| 1808 | case GL_NORMAL_ARRAY_STRIDE: |
| 1809 | case GL_COLOR_ARRAY_STRIDE: |
| 1810 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 1811 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 1812 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1813 | GL_VERTEX_ATTRIB_ARRAY_STRIDE, params); |
| 1814 | break; |
| 1815 | case GL_VERTEX_ARRAY_SIZE: |
| 1816 | case GL_COLOR_ARRAY_SIZE: |
| 1817 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 1818 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1819 | GL_VERTEX_ATTRIB_ARRAY_SIZE, params); |
| 1820 | break; |
| 1821 | case GL_VERTEX_ARRAY_TYPE: |
| 1822 | case GL_COLOR_ARRAY_TYPE: |
| 1823 | case GL_NORMAL_ARRAY_TYPE: |
| 1824 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 1825 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 1826 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1827 | GL_VERTEX_ATTRIB_ARRAY_TYPE, params); |
| 1828 | break; |
| 1829 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1830 | // GL_KHR_parallel_shader_compile |
| 1831 | case GL_MAX_SHADER_COMPILER_THREADS_KHR: |
| 1832 | *params = mGLState.getMaxShaderCompilerThreads(); |
| 1833 | break; |
| 1834 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1835 | // GL_EXT_blend_func_extended |
| 1836 | case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: |
| 1837 | *params = mExtensions.maxDualSourceDrawBuffers; |
| 1838 | break; |
| 1839 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1840 | default: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1841 | ANGLE_CONTEXT_TRY(mGLState.getIntegerv(this, pname, params)); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1842 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1843 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1844 | } |
| 1845 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 1846 | void Context::getInteger64vImpl(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1847 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1848 | // Queries about context capabilities and maximums are answered by Context. |
| 1849 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1850 | switch (pname) |
| 1851 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1852 | case GL_MAX_ELEMENT_INDEX: |
| 1853 | *params = mCaps.maxElementIndex; |
| 1854 | break; |
| 1855 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 1856 | *params = mCaps.maxUniformBlockSize; |
| 1857 | break; |
| 1858 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1859 | *params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1860 | break; |
| 1861 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1862 | *params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1863 | break; |
| 1864 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 1865 | *params = mCaps.maxServerWaitTimeout; |
| 1866 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1867 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1868 | // GL_EXT_disjoint_timer_query |
| 1869 | case GL_TIMESTAMP_EXT: |
| 1870 | *params = mImplementation->getTimestamp(); |
| 1871 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1872 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1873 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 1874 | *params = mCaps.maxShaderStorageBlockSize; |
| 1875 | break; |
| 1876 | default: |
| 1877 | UNREACHABLE(); |
| 1878 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1879 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1880 | } |
| 1881 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1882 | void Context::getPointerv(GLenum pname, void **params) const |
| 1883 | { |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1884 | mGLState.getPointerv(this, pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1885 | } |
| 1886 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 1887 | void Context::getPointervRobustANGLERobust(GLenum pname, |
| 1888 | GLsizei bufSize, |
| 1889 | GLsizei *length, |
| 1890 | void **params) |
| 1891 | { |
| 1892 | UNIMPLEMENTED(); |
| 1893 | } |
| 1894 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1895 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1896 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1897 | // Queries about context capabilities and maximums are answered by Context. |
| 1898 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1899 | |
| 1900 | GLenum nativeType; |
| 1901 | unsigned int numParams; |
| 1902 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1903 | ASSERT(queryStatus); |
| 1904 | |
| 1905 | if (nativeType == GL_INT) |
| 1906 | { |
| 1907 | switch (target) |
| 1908 | { |
| 1909 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1910 | ASSERT(index < 3u); |
| 1911 | *data = mCaps.maxComputeWorkGroupCount[index]; |
| 1912 | break; |
| 1913 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1914 | ASSERT(index < 3u); |
| 1915 | *data = mCaps.maxComputeWorkGroupSize[index]; |
| 1916 | break; |
| 1917 | default: |
| 1918 | mGLState.getIntegeri_v(target, index, data); |
| 1919 | } |
| 1920 | } |
| 1921 | else |
| 1922 | { |
| 1923 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1924 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1925 | } |
| 1926 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1927 | void Context::getIntegeri_vRobust(GLenum target, |
| 1928 | GLuint index, |
| 1929 | GLsizei bufSize, |
| 1930 | GLsizei *length, |
| 1931 | GLint *data) |
| 1932 | { |
| 1933 | getIntegeri_v(target, index, data); |
| 1934 | } |
| 1935 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1936 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1937 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1938 | // Queries about context capabilities and maximums are answered by Context. |
| 1939 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1940 | |
| 1941 | GLenum nativeType; |
| 1942 | unsigned int numParams; |
| 1943 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1944 | ASSERT(queryStatus); |
| 1945 | |
| 1946 | if (nativeType == GL_INT_64_ANGLEX) |
| 1947 | { |
| 1948 | mGLState.getInteger64i_v(target, index, data); |
| 1949 | } |
| 1950 | else |
| 1951 | { |
| 1952 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1953 | } |
| 1954 | } |
| 1955 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1956 | void Context::getInteger64i_vRobust(GLenum target, |
| 1957 | GLuint index, |
| 1958 | GLsizei bufSize, |
| 1959 | GLsizei *length, |
| 1960 | GLint64 *data) |
| 1961 | { |
| 1962 | getInteger64i_v(target, index, data); |
| 1963 | } |
| 1964 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1965 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1966 | { |
| 1967 | // Queries about context capabilities and maximums are answered by Context. |
| 1968 | // Queries about current GL state values are answered by State. |
| 1969 | |
| 1970 | GLenum nativeType; |
| 1971 | unsigned int numParams; |
| 1972 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1973 | ASSERT(queryStatus); |
| 1974 | |
| 1975 | if (nativeType == GL_BOOL) |
| 1976 | { |
| 1977 | mGLState.getBooleani_v(target, index, data); |
| 1978 | } |
| 1979 | else |
| 1980 | { |
| 1981 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1982 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1983 | } |
| 1984 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1985 | void Context::getBooleani_vRobust(GLenum target, |
| 1986 | GLuint index, |
| 1987 | GLsizei bufSize, |
| 1988 | GLsizei *length, |
| 1989 | GLboolean *data) |
| 1990 | { |
| 1991 | getBooleani_v(target, index, data); |
| 1992 | } |
| 1993 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 1994 | void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 1995 | { |
| 1996 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 1997 | QueryBufferParameteriv(buffer, pname, params); |
| 1998 | } |
| 1999 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2000 | void Context::getBufferParameterivRobust(BufferBinding target, |
| 2001 | GLenum pname, |
| 2002 | GLsizei bufSize, |
| 2003 | GLsizei *length, |
| 2004 | GLint *params) |
| 2005 | { |
| 2006 | getBufferParameteriv(target, pname, params); |
| 2007 | } |
| 2008 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2009 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 2010 | GLenum attachment, |
| 2011 | GLenum pname, |
| 2012 | GLint *params) |
| 2013 | { |
| 2014 | const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2015 | QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2016 | } |
| 2017 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2018 | void Context::getFramebufferAttachmentParameterivRobust(GLenum target, |
| 2019 | GLenum attachment, |
| 2020 | GLenum pname, |
| 2021 | GLsizei bufSize, |
| 2022 | GLsizei *length, |
| 2023 | GLint *params) |
| 2024 | { |
| 2025 | getFramebufferAttachmentParameteriv(target, attachment, pname, params); |
| 2026 | } |
| 2027 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2028 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 2029 | { |
| 2030 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
| 2031 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 2032 | } |
| 2033 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2034 | void Context::getRenderbufferParameterivRobust(GLenum target, |
| 2035 | GLenum pname, |
| 2036 | GLsizei bufSize, |
| 2037 | GLsizei *length, |
| 2038 | GLint *params) |
| 2039 | { |
| 2040 | getRenderbufferParameteriv(target, pname, params); |
| 2041 | } |
| 2042 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2043 | void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2044 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2045 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2046 | QueryTexParameterfv(texture, pname, params); |
| 2047 | } |
| 2048 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2049 | void Context::getTexParameterfvRobust(TextureType target, |
| 2050 | GLenum pname, |
| 2051 | GLsizei bufSize, |
| 2052 | GLsizei *length, |
| 2053 | GLfloat *params) |
| 2054 | { |
| 2055 | getTexParameterfv(target, pname, params); |
| 2056 | } |
| 2057 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2058 | void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2059 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2060 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2061 | QueryTexParameteriv(texture, pname, params); |
| 2062 | } |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2063 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2064 | void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params) |
| 2065 | { |
| 2066 | const Texture *const texture = getTargetTexture(target); |
| 2067 | QueryTexParameterIiv(texture, pname, params); |
| 2068 | } |
| 2069 | |
| 2070 | void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params) |
| 2071 | { |
| 2072 | const Texture *const texture = getTargetTexture(target); |
| 2073 | QueryTexParameterIuiv(texture, pname, params); |
| 2074 | } |
| 2075 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2076 | void Context::getTexParameterivRobust(TextureType target, |
| 2077 | GLenum pname, |
| 2078 | GLsizei bufSize, |
| 2079 | GLsizei *length, |
| 2080 | GLint *params) |
| 2081 | { |
| 2082 | getTexParameteriv(target, pname, params); |
| 2083 | } |
| 2084 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2085 | void Context::getTexParameterIivRobust(TextureType target, |
| 2086 | GLenum pname, |
| 2087 | GLsizei bufSize, |
| 2088 | GLsizei *length, |
| 2089 | GLint *params) |
| 2090 | { |
| 2091 | UNIMPLEMENTED(); |
| 2092 | } |
| 2093 | |
| 2094 | void Context::getTexParameterIuivRobust(TextureType target, |
| 2095 | GLenum pname, |
| 2096 | GLsizei bufSize, |
| 2097 | GLsizei *length, |
| 2098 | GLuint *params) |
| 2099 | { |
| 2100 | UNIMPLEMENTED(); |
| 2101 | } |
| 2102 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2103 | void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2104 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2105 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2106 | QueryTexLevelParameteriv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2107 | } |
| 2108 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2109 | void Context::getTexLevelParameterivRobust(TextureTarget target, |
| 2110 | GLint level, |
| 2111 | GLenum pname, |
| 2112 | GLsizei bufSize, |
| 2113 | GLsizei *length, |
| 2114 | GLint *params) |
| 2115 | { |
| 2116 | UNIMPLEMENTED(); |
| 2117 | } |
| 2118 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2119 | void Context::getTexLevelParameterfv(TextureTarget target, |
| 2120 | GLint level, |
| 2121 | GLenum pname, |
| 2122 | GLfloat *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2123 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2124 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2125 | QueryTexLevelParameterfv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2126 | } |
| 2127 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2128 | void Context::getTexLevelParameterfvRobust(TextureTarget target, |
| 2129 | GLint level, |
| 2130 | GLenum pname, |
| 2131 | GLsizei bufSize, |
| 2132 | GLsizei *length, |
| 2133 | GLfloat *params) |
| 2134 | { |
| 2135 | UNIMPLEMENTED(); |
| 2136 | } |
| 2137 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2138 | void Context::texParameterf(TextureType target, GLenum pname, GLfloat param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2139 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2140 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2141 | SetTexParameterf(this, texture, pname, param); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2142 | onTextureChange(texture); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2143 | } |
| 2144 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2145 | void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2146 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2147 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2148 | SetTexParameterfv(this, texture, pname, params); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2149 | onTextureChange(texture); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2150 | } |
| 2151 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2152 | void Context::texParameterfvRobust(TextureType target, |
| 2153 | GLenum pname, |
| 2154 | GLsizei bufSize, |
| 2155 | const GLfloat *params) |
| 2156 | { |
| 2157 | texParameterfv(target, pname, params); |
| 2158 | } |
| 2159 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2160 | void Context::texParameteri(TextureType target, GLenum pname, GLint param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2161 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2162 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2163 | SetTexParameteri(this, texture, pname, param); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2164 | onTextureChange(texture); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2165 | } |
| 2166 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2167 | void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2168 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2169 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2170 | SetTexParameteriv(this, texture, pname, params); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2171 | onTextureChange(texture); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2172 | } |
| 2173 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2174 | void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params) |
| 2175 | { |
| 2176 | Texture *const texture = getTargetTexture(target); |
| 2177 | SetTexParameterIiv(this, texture, pname, params); |
| 2178 | onTextureChange(texture); |
| 2179 | } |
| 2180 | |
| 2181 | void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params) |
| 2182 | { |
| 2183 | Texture *const texture = getTargetTexture(target); |
| 2184 | SetTexParameterIuiv(this, texture, pname, params); |
| 2185 | onTextureChange(texture); |
| 2186 | } |
| 2187 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2188 | void Context::texParameterivRobust(TextureType target, |
| 2189 | GLenum pname, |
| 2190 | GLsizei bufSize, |
| 2191 | const GLint *params) |
| 2192 | { |
| 2193 | texParameteriv(target, pname, params); |
| 2194 | } |
| 2195 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2196 | void Context::texParameterIivRobust(TextureType target, |
| 2197 | GLenum pname, |
| 2198 | GLsizei bufSize, |
| 2199 | const GLint *params) |
| 2200 | { |
| 2201 | UNIMPLEMENTED(); |
| 2202 | } |
| 2203 | |
| 2204 | void Context::texParameterIuivRobust(TextureType target, |
| 2205 | GLenum pname, |
| 2206 | GLsizei bufSize, |
| 2207 | const GLuint *params) |
| 2208 | { |
| 2209 | UNIMPLEMENTED(); |
| 2210 | } |
| 2211 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2212 | void Context::drawArrays(PrimitiveMode mode, GLint first, GLsizei count) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2213 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2214 | // No-op if count draws no primitives for given mode |
| 2215 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2216 | { |
| 2217 | return; |
| 2218 | } |
| 2219 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2220 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2221 | ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count)); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 2222 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), count, 1); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2223 | } |
| 2224 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2225 | void Context::drawArraysInstanced(PrimitiveMode mode, |
| 2226 | GLint first, |
| 2227 | GLsizei count, |
| 2228 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2229 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2230 | // No-op if count draws no primitives for given mode |
| 2231 | if (noopDrawInstanced(mode, count, instanceCount)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2232 | { |
| 2233 | return; |
| 2234 | } |
| 2235 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2236 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2237 | ANGLE_CONTEXT_TRY( |
| 2238 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 2239 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), count, |
| 2240 | instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2241 | } |
| 2242 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2243 | void Context::drawElements(PrimitiveMode mode, |
| 2244 | GLsizei count, |
| 2245 | DrawElementsType type, |
| 2246 | const void *indices) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2247 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2248 | // No-op if count draws no primitives for given mode |
| 2249 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2250 | { |
| 2251 | return; |
| 2252 | } |
| 2253 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2254 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2255 | ANGLE_CONTEXT_TRY(mImplementation->drawElements(this, mode, count, type, indices)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2256 | } |
| 2257 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2258 | void Context::drawElementsInstanced(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2259 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2260 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2261 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2262 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2263 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2264 | // No-op if count draws no primitives for given mode |
| 2265 | if (noopDrawInstanced(mode, count, instances)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2266 | { |
| 2267 | return; |
| 2268 | } |
| 2269 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2270 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2271 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 2272 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2273 | } |
| 2274 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2275 | void Context::drawRangeElements(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2276 | GLuint start, |
| 2277 | GLuint end, |
| 2278 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2279 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2280 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2281 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2282 | // No-op if count draws no primitives for given mode |
| 2283 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2284 | { |
| 2285 | return; |
| 2286 | } |
| 2287 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2288 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2289 | ANGLE_CONTEXT_TRY( |
| 2290 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2291 | } |
| 2292 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2293 | void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2294 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2295 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2296 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2297 | } |
| 2298 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2299 | void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2300 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2301 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2302 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2303 | } |
| 2304 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2305 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2306 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2307 | ANGLE_CONTEXT_TRY(mImplementation->flush(this)); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2308 | } |
| 2309 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2310 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2311 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2312 | ANGLE_CONTEXT_TRY(mImplementation->finish(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2313 | } |
| 2314 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2315 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 2316 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2317 | ASSERT(mImplementation); |
| 2318 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2319 | } |
| 2320 | |
| 2321 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 2322 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2323 | ASSERT(mImplementation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 2324 | |
| 2325 | if (marker == nullptr) |
| 2326 | { |
| 2327 | // From the EXT_debug_marker spec, |
| 2328 | // "If <marker> is null then an empty string is pushed on the stack." |
| 2329 | mImplementation->pushGroupMarker(length, ""); |
| 2330 | } |
| 2331 | else |
| 2332 | { |
| 2333 | mImplementation->pushGroupMarker(length, marker); |
| 2334 | } |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | void Context::popGroupMarker() |
| 2338 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2339 | ASSERT(mImplementation); |
| 2340 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2341 | } |
| 2342 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2343 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 2344 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2345 | Program *programObject = getProgramResolveLink(program); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2346 | ASSERT(programObject); |
| 2347 | |
| 2348 | programObject->bindUniformLocation(location, name); |
| 2349 | } |
| 2350 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2351 | void Context::coverageModulation(GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2352 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2353 | mGLState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2354 | } |
| 2355 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2356 | void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2357 | { |
| 2358 | mGLState.loadPathRenderingMatrix(matrixMode, matrix); |
| 2359 | } |
| 2360 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2361 | void Context::matrixLoadIdentity(GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2362 | { |
| 2363 | GLfloat I[16]; |
| 2364 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 2365 | |
| 2366 | mGLState.loadPathRenderingMatrix(matrixMode, I); |
| 2367 | } |
| 2368 | |
| 2369 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 2370 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2371 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2372 | if (!pathObj) |
| 2373 | return; |
| 2374 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2375 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2376 | |
| 2377 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 2378 | } |
| 2379 | |
| 2380 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 2381 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2382 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2383 | if (!pathObj) |
| 2384 | return; |
| 2385 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2386 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2387 | |
| 2388 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 2389 | } |
| 2390 | |
| 2391 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 2392 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2393 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2394 | if (!pathObj) |
| 2395 | return; |
| 2396 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2397 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2398 | |
| 2399 | mImplementation->coverFillPath(pathObj, coverMode); |
| 2400 | } |
| 2401 | |
| 2402 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 2403 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2404 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2405 | if (!pathObj) |
| 2406 | return; |
| 2407 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2408 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2409 | |
| 2410 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 2411 | } |
| 2412 | |
| 2413 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 2414 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2415 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2416 | if (!pathObj) |
| 2417 | return; |
| 2418 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2419 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2420 | |
| 2421 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 2422 | } |
| 2423 | |
| 2424 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 2425 | GLint reference, |
| 2426 | GLuint mask, |
| 2427 | GLenum coverMode) |
| 2428 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2429 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2430 | if (!pathObj) |
| 2431 | return; |
| 2432 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2433 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2434 | |
| 2435 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 2436 | } |
| 2437 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2438 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 2439 | GLenum pathNameType, |
| 2440 | const void *paths, |
| 2441 | GLuint pathBase, |
| 2442 | GLenum coverMode, |
| 2443 | GLenum transformType, |
| 2444 | const GLfloat *transformValues) |
| 2445 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2446 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2447 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2448 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2449 | |
| 2450 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 2451 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2452 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2453 | void Context::coverStrokePathInstanced(GLsizei numPaths, |
| 2454 | GLenum pathNameType, |
| 2455 | const void *paths, |
| 2456 | GLuint pathBase, |
| 2457 | GLenum coverMode, |
| 2458 | GLenum transformType, |
| 2459 | const GLfloat *transformValues) |
| 2460 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2461 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2462 | |
| 2463 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2464 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2465 | |
| 2466 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 2467 | transformValues); |
| 2468 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2469 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2470 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 2471 | GLenum pathNameType, |
| 2472 | const void *paths, |
| 2473 | GLuint pathBase, |
| 2474 | GLenum fillMode, |
| 2475 | GLuint mask, |
| 2476 | GLenum transformType, |
| 2477 | const GLfloat *transformValues) |
| 2478 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2479 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2480 | |
| 2481 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2482 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2483 | |
| 2484 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2485 | transformValues); |
| 2486 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2487 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2488 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2489 | GLenum pathNameType, |
| 2490 | const void *paths, |
| 2491 | GLuint pathBase, |
| 2492 | GLint reference, |
| 2493 | GLuint mask, |
| 2494 | GLenum transformType, |
| 2495 | const GLfloat *transformValues) |
| 2496 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2497 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2498 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2499 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2500 | |
| 2501 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2502 | transformValues); |
| 2503 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2504 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2505 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2506 | GLenum pathNameType, |
| 2507 | const void *paths, |
| 2508 | GLuint pathBase, |
| 2509 | GLenum fillMode, |
| 2510 | GLuint mask, |
| 2511 | GLenum coverMode, |
| 2512 | GLenum transformType, |
| 2513 | const GLfloat *transformValues) |
| 2514 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2515 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2516 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2517 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2518 | |
| 2519 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2520 | transformType, transformValues); |
| 2521 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2522 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2523 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2524 | GLenum pathNameType, |
| 2525 | const void *paths, |
| 2526 | GLuint pathBase, |
| 2527 | GLint reference, |
| 2528 | GLuint mask, |
| 2529 | GLenum coverMode, |
| 2530 | GLenum transformType, |
| 2531 | const GLfloat *transformValues) |
| 2532 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2533 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2534 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2535 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2536 | |
| 2537 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2538 | transformType, transformValues); |
| 2539 | } |
| 2540 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2541 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2542 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2543 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2544 | |
| 2545 | programObject->bindFragmentInputLocation(location, name); |
| 2546 | } |
| 2547 | |
| 2548 | void Context::programPathFragmentInputGen(GLuint program, |
| 2549 | GLint location, |
| 2550 | GLenum genMode, |
| 2551 | GLint components, |
| 2552 | const GLfloat *coeffs) |
| 2553 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2554 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2555 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 2556 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2557 | } |
| 2558 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2559 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2560 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2561 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2562 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2563 | } |
| 2564 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2565 | void Context::getProgramResourceName(GLuint program, |
| 2566 | GLenum programInterface, |
| 2567 | GLuint index, |
| 2568 | GLsizei bufSize, |
| 2569 | GLsizei *length, |
| 2570 | GLchar *name) |
| 2571 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2572 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2573 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2574 | } |
| 2575 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2576 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2577 | GLenum programInterface, |
| 2578 | const GLchar *name) |
| 2579 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2580 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2581 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2582 | } |
| 2583 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2584 | void Context::getProgramResourceiv(GLuint program, |
| 2585 | GLenum programInterface, |
| 2586 | GLuint index, |
| 2587 | GLsizei propCount, |
| 2588 | const GLenum *props, |
| 2589 | GLsizei bufSize, |
| 2590 | GLsizei *length, |
| 2591 | GLint *params) |
| 2592 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2593 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2594 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2595 | length, params); |
| 2596 | } |
| 2597 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2598 | void Context::getProgramInterfaceiv(GLuint program, |
| 2599 | GLenum programInterface, |
| 2600 | GLenum pname, |
| 2601 | GLint *params) |
| 2602 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2603 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2604 | QueryProgramInterfaceiv(programObject, programInterface, pname, params); |
| 2605 | } |
| 2606 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2607 | void Context::getProgramInterfaceivRobust(GLuint program, |
| 2608 | GLenum programInterface, |
| 2609 | GLenum pname, |
| 2610 | GLsizei bufSize, |
| 2611 | GLsizei *length, |
| 2612 | GLint *params) |
| 2613 | { |
| 2614 | UNIMPLEMENTED(); |
| 2615 | } |
| 2616 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 2617 | void Context::handleError(GLenum errorCode, |
| 2618 | const char *message, |
| 2619 | const char *file, |
| 2620 | const char *function, |
| 2621 | unsigned int line) |
| 2622 | { |
| 2623 | mErrors.handleError(errorCode, message, file, function, line); |
| 2624 | } |
| 2625 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 2626 | void Context::validationError(GLenum errorCode, const char *message) |
| 2627 | { |
| 2628 | mErrors.validationError(errorCode, message); |
| 2629 | } |
| 2630 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2631 | // Get one of the recorded errors and clear its flag, if any. |
| 2632 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2633 | GLenum Context::getError() |
| 2634 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2635 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2636 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2637 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2638 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2639 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2640 | { |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2641 | return mErrors.popError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2642 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2643 | } |
| 2644 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2645 | // NOTE: this function should not assume that this context is current! |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2646 | void Context::markContextLost() |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2647 | { |
| 2648 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2649 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2650 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2651 | mContextLostForced = true; |
| 2652 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2653 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2654 | } |
| 2655 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 2656 | GLenum Context::getGraphicsResetStatus() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2657 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2658 | // Even if the application doesn't want to know about resets, we want to know |
| 2659 | // as it will allow us to skip all the calls. |
| 2660 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2661 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2662 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2663 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2664 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2665 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2666 | |
| 2667 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2668 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2669 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2670 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2671 | } |
| 2672 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2673 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2674 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2675 | // once the device has finished resetting. |
| 2676 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2677 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2678 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2679 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2680 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2681 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2682 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2683 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2684 | } |
| 2685 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2686 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2687 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2688 | // If markContextLost was used to mark the context lost then |
| 2689 | // assume that is not recoverable, and continue to report the |
| 2690 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2691 | mResetStatus = mImplementation->getResetStatus(); |
| 2692 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2693 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2694 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2695 | } |
| 2696 | |
| 2697 | bool Context::isResetNotificationEnabled() |
| 2698 | { |
| 2699 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2700 | } |
| 2701 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2702 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2703 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2704 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2705 | } |
| 2706 | |
| 2707 | EGLenum Context::getClientType() const |
| 2708 | { |
| 2709 | return mClientType; |
| 2710 | } |
| 2711 | |
| 2712 | EGLenum Context::getRenderBuffer() const |
| 2713 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2714 | const Framebuffer *framebuffer = mState.mFramebuffers->getFramebuffer(0); |
| 2715 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2716 | { |
| 2717 | return EGL_NONE; |
| 2718 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2719 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2720 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2721 | ASSERT(backAttachment != nullptr); |
| 2722 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2723 | } |
| 2724 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2725 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2726 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2727 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2728 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2729 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2730 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2731 | vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2732 | mCaps.maxVertexAttributes, mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2733 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2734 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2735 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2736 | |
| 2737 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2738 | } |
| 2739 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2740 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2741 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2742 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2743 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2744 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2745 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2746 | transformFeedback = |
| 2747 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2748 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2749 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2750 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2751 | |
| 2752 | return transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2753 | } |
| 2754 | |
| 2755 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2756 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2757 | ASSERT(mVertexArrayMap.contains(0)); |
| 2758 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2759 | } |
| 2760 | |
| 2761 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2762 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2763 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2764 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2765 | } |
| 2766 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2767 | void Context::detachTexture(GLuint texture) |
| 2768 | { |
| 2769 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2770 | // allocation map management either here or in the resource manager at detach time. |
| 2771 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2772 | // the State. |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2773 | mGLState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2774 | } |
| 2775 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 2776 | void Context::detachBuffer(Buffer *buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2777 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2778 | // Simple pass-through to State's detachBuffer method, since |
| 2779 | // only buffer attachments to container objects that are bound to the current context |
| 2780 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2781 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2782 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2783 | // Attachments to unbound container objects, such as |
| 2784 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2785 | // are not affected and continue to act as references on the deleted object |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2786 | mGLState.detachBuffer(this, buffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2787 | } |
| 2788 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2789 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2790 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2791 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2792 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2793 | // to State at binding time. |
| 2794 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2795 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2796 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2797 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2798 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2799 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2800 | if (mGLState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2801 | { |
| 2802 | bindReadFramebuffer(0); |
| 2803 | } |
| 2804 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2805 | if (mGLState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2806 | { |
| 2807 | bindDrawFramebuffer(0); |
| 2808 | } |
| 2809 | } |
| 2810 | |
| 2811 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2812 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2813 | mGLState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2814 | } |
| 2815 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2816 | void Context::detachVertexArray(GLuint vertexArray) |
| 2817 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2818 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2819 | // 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] | 2820 | // binding time. |
| 2821 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2822 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2823 | // If a vertex array object that is currently bound is deleted, the binding |
| 2824 | // for that object reverts to zero and the default vertex array becomes current. |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 2825 | if (mGLState.removeVertexArrayBinding(this, vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2826 | { |
| 2827 | bindVertexArray(0); |
| 2828 | } |
| 2829 | } |
| 2830 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2831 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2832 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2833 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2834 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2835 | // binding time. |
| 2836 | |
| 2837 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2838 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2839 | // VAOs and FBOs and set the current bound transform feedback back to 0. |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2840 | if (mGLState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2841 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2842 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2843 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2844 | } |
| 2845 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2846 | void Context::detachSampler(GLuint sampler) |
| 2847 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2848 | mGLState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2849 | } |
| 2850 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2851 | void Context::detachProgramPipeline(GLuint pipeline) |
| 2852 | { |
| 2853 | mGLState.detachProgramPipeline(this, pipeline); |
| 2854 | } |
| 2855 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 2856 | void Context::vertexAttribDivisor(GLuint index, GLuint divisor) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2857 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 2858 | mGLState.setVertexAttribDivisor(this, index, divisor); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 2859 | mStateCache.onVertexArrayStateChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2860 | } |
| 2861 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2862 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2863 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2864 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2865 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2866 | SetSamplerParameteri(this, samplerObject, pname, param); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2867 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2868 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2869 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2870 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2871 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2872 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2873 | SetSamplerParameteriv(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2874 | } |
| 2875 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2876 | void Context::samplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) |
| 2877 | { |
| 2878 | Sampler *const samplerObject = |
| 2879 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2880 | SetSamplerParameterIiv(this, samplerObject, pname, param); |
| 2881 | } |
| 2882 | |
| 2883 | void Context::samplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param) |
| 2884 | { |
| 2885 | Sampler *const samplerObject = |
| 2886 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2887 | SetSamplerParameterIuiv(this, samplerObject, pname, param); |
| 2888 | } |
| 2889 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2890 | void Context::samplerParameterivRobust(GLuint sampler, |
| 2891 | GLenum pname, |
| 2892 | GLsizei bufSize, |
| 2893 | const GLint *param) |
| 2894 | { |
| 2895 | samplerParameteriv(sampler, pname, param); |
| 2896 | } |
| 2897 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2898 | void Context::samplerParameterIivRobust(GLuint sampler, |
| 2899 | GLenum pname, |
| 2900 | GLsizei bufSize, |
| 2901 | const GLint *param) |
| 2902 | { |
| 2903 | UNIMPLEMENTED(); |
| 2904 | } |
| 2905 | |
| 2906 | void Context::samplerParameterIuivRobust(GLuint sampler, |
| 2907 | GLenum pname, |
| 2908 | GLsizei bufSize, |
| 2909 | const GLuint *param) |
| 2910 | { |
| 2911 | UNIMPLEMENTED(); |
| 2912 | } |
| 2913 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2914 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2915 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2916 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2917 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2918 | SetSamplerParameterf(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2919 | } |
| 2920 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2921 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2922 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2923 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2924 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2925 | SetSamplerParameterfv(this, samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2926 | } |
| 2927 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2928 | void Context::samplerParameterfvRobust(GLuint sampler, |
| 2929 | GLenum pname, |
| 2930 | GLsizei bufSize, |
| 2931 | const GLfloat *param) |
| 2932 | { |
| 2933 | samplerParameterfv(sampler, pname, param); |
| 2934 | } |
| 2935 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2936 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2937 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2938 | const Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2939 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2940 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2941 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2942 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2943 | void Context::getSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) |
| 2944 | { |
| 2945 | const Sampler *const samplerObject = |
| 2946 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2947 | QuerySamplerParameterIiv(samplerObject, pname, params); |
| 2948 | } |
| 2949 | |
| 2950 | void Context::getSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) |
| 2951 | { |
| 2952 | const Sampler *const samplerObject = |
| 2953 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2954 | QuerySamplerParameterIuiv(samplerObject, pname, params); |
| 2955 | } |
| 2956 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2957 | void Context::getSamplerParameterivRobust(GLuint sampler, |
| 2958 | GLenum pname, |
| 2959 | GLsizei bufSize, |
| 2960 | GLsizei *length, |
| 2961 | GLint *params) |
| 2962 | { |
| 2963 | getSamplerParameteriv(sampler, pname, params); |
| 2964 | } |
| 2965 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2966 | void Context::getSamplerParameterIivRobust(GLuint sampler, |
| 2967 | GLenum pname, |
| 2968 | GLsizei bufSize, |
| 2969 | GLsizei *length, |
| 2970 | GLint *params) |
| 2971 | { |
| 2972 | UNIMPLEMENTED(); |
| 2973 | } |
| 2974 | |
| 2975 | void Context::getSamplerParameterIuivRobust(GLuint sampler, |
| 2976 | GLenum pname, |
| 2977 | GLsizei bufSize, |
| 2978 | GLsizei *length, |
| 2979 | GLuint *params) |
| 2980 | { |
| 2981 | UNIMPLEMENTED(); |
| 2982 | } |
| 2983 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2984 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2985 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2986 | const Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2987 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2988 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2989 | } |
| 2990 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2991 | void Context::getSamplerParameterfvRobust(GLuint sampler, |
| 2992 | GLenum pname, |
| 2993 | GLsizei bufSize, |
| 2994 | GLsizei *length, |
| 2995 | GLfloat *params) |
| 2996 | { |
| 2997 | getSamplerParameterfv(sampler, pname, params); |
| 2998 | } |
| 2999 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 3000 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 3001 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 3002 | gl::Program *programObject = getProgramResolveLink(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 3003 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 3004 | } |
| 3005 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3006 | void Context::initRendererString() |
| 3007 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 3008 | std::ostringstream rendererString; |
| 3009 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 3010 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 3011 | rendererString << ")"; |
| 3012 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3013 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3014 | } |
| 3015 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3016 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3017 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3018 | const Version &clientVersion = getClientVersion(); |
| 3019 | |
| 3020 | std::ostringstream versionString; |
| 3021 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 3022 | << ANGLE_VERSION_STRING << ")"; |
| 3023 | mVersionString = MakeStaticString(versionString.str()); |
| 3024 | |
| 3025 | std::ostringstream shadingLanguageVersionString; |
| 3026 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 3027 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 3028 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 3029 | << ")"; |
| 3030 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3031 | } |
| 3032 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3033 | void Context::initExtensionStrings() |
| 3034 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3035 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 3036 | std::ostringstream combinedStringStream; |
| 3037 | std::copy(strings.begin(), strings.end(), |
| 3038 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 3039 | return MakeStaticString(combinedStringStream.str()); |
| 3040 | }; |
| 3041 | |
| 3042 | mExtensionStrings.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3043 | for (const auto &extensionString : mExtensions.getStrings()) |
| 3044 | { |
| 3045 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 3046 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3047 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3048 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3049 | mRequestableExtensionStrings.clear(); |
| 3050 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3051 | { |
| 3052 | if (extensionInfo.second.Requestable && |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3053 | !(mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3054 | mSupportedExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3055 | { |
| 3056 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 3057 | } |
| 3058 | } |
| 3059 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3060 | } |
| 3061 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3062 | const GLubyte *Context::getString(GLenum name) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3063 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3064 | switch (name) |
| 3065 | { |
| 3066 | case GL_VENDOR: |
| 3067 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 3068 | |
| 3069 | case GL_RENDERER: |
| 3070 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 3071 | |
| 3072 | case GL_VERSION: |
| 3073 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 3074 | |
| 3075 | case GL_SHADING_LANGUAGE_VERSION: |
| 3076 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 3077 | |
| 3078 | case GL_EXTENSIONS: |
| 3079 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 3080 | |
| 3081 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3082 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 3083 | |
| 3084 | default: |
| 3085 | UNREACHABLE(); |
| 3086 | return nullptr; |
| 3087 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3088 | } |
| 3089 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3090 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3091 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3092 | switch (name) |
| 3093 | { |
| 3094 | case GL_EXTENSIONS: |
| 3095 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 3096 | |
| 3097 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3098 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 3099 | |
| 3100 | default: |
| 3101 | UNREACHABLE(); |
| 3102 | return nullptr; |
| 3103 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3104 | } |
| 3105 | |
| 3106 | size_t Context::getExtensionStringCount() const |
| 3107 | { |
| 3108 | return mExtensionStrings.size(); |
| 3109 | } |
| 3110 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3111 | bool Context::isExtensionRequestable(const char *name) |
| 3112 | { |
| 3113 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3114 | auto extension = extensionInfos.find(name); |
| 3115 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3116 | return extension != extensionInfos.end() && extension->second.Requestable && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3117 | mSupportedExtensions.*(extension->second.ExtensionsMember); |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3118 | } |
| 3119 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3120 | void Context::requestExtension(const char *name) |
| 3121 | { |
| 3122 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3123 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 3124 | const auto &extension = extensionInfos.at(name); |
| 3125 | ASSERT(extension.Requestable); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3126 | ASSERT(isExtensionRequestable(name)); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3127 | |
| 3128 | if (mExtensions.*(extension.ExtensionsMember)) |
| 3129 | { |
| 3130 | // Extension already enabled |
| 3131 | return; |
| 3132 | } |
| 3133 | |
| 3134 | mExtensions.*(extension.ExtensionsMember) = true; |
| 3135 | updateCaps(); |
| 3136 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3137 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 3138 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 3139 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3140 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 3141 | // Invalidate all textures and framebuffer. Some extensions make new formats renderable or |
| 3142 | // sampleable. |
Jamie Madill | d444255 | 2018-02-27 22:03:47 -0500 | [diff] [blame] | 3143 | mState.mTextures->signalAllTexturesDirty(this); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3144 | for (auto &zeroTexture : mZeroTextures) |
| 3145 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3146 | if (zeroTexture.get() != nullptr) |
| 3147 | { |
| 3148 | zeroTexture->signalDirty(this, InitState::Initialized); |
| 3149 | } |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3150 | } |
| 3151 | |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 3152 | mState.mFramebuffers->invalidateFramebufferComplenessCache(this); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | size_t Context::getRequestableExtensionStringCount() const |
| 3156 | { |
| 3157 | return mRequestableExtensionStrings.size(); |
| 3158 | } |
| 3159 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 3160 | void Context::beginTransformFeedback(PrimitiveMode primitiveMode) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3161 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3162 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3163 | ASSERT(transformFeedback != nullptr); |
| 3164 | ASSERT(!transformFeedback->isPaused()); |
| 3165 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 3166 | transformFeedback->begin(this, primitiveMode, mGLState.getProgram()); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3167 | mStateCache.onTransformFeedbackChange(this); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 3171 | { |
| 3172 | for (auto pair : mTransformFeedbackMap) |
| 3173 | { |
| 3174 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 3175 | { |
| 3176 | return true; |
| 3177 | } |
| 3178 | } |
| 3179 | return false; |
| 3180 | } |
| 3181 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3182 | Extensions Context::generateSupportedExtensions() const |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3183 | { |
| 3184 | Extensions supportedExtensions = mImplementation->getNativeExtensions(); |
| 3185 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3186 | // Explicitly enable GL_KHR_parallel_shader_compile |
| 3187 | supportedExtensions.parallelShaderCompile = true; |
| 3188 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3189 | if (getClientVersion() < ES_2_0) |
| 3190 | { |
| 3191 | // Default extensions for GLES1 |
Lingfeng Yang | 0df813c | 2018-07-12 12:52:06 -0700 | [diff] [blame] | 3192 | supportedExtensions.pointSizeArray = true; |
| 3193 | supportedExtensions.textureCubeMap = true; |
| 3194 | supportedExtensions.pointSprite = true; |
| 3195 | supportedExtensions.drawTexture = true; |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3196 | supportedExtensions.parallelShaderCompile = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3197 | } |
| 3198 | |
| 3199 | if (getClientVersion() < ES_3_0) |
| 3200 | { |
| 3201 | // Disable ES3+ extensions |
| 3202 | supportedExtensions.colorBufferFloat = false; |
| 3203 | supportedExtensions.eglImageExternalEssl3 = false; |
| 3204 | supportedExtensions.textureNorm16 = false; |
| 3205 | supportedExtensions.multiview = false; |
| 3206 | supportedExtensions.maxViews = 1u; |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 3207 | supportedExtensions.copyTexture3d = false; |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 3208 | supportedExtensions.textureMultisample = false; |
Geoff Lang | 7198ebc | 2018-11-22 14:36:06 -0500 | [diff] [blame] | 3209 | |
| 3210 | // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support |
| 3211 | if (!supportedExtensions.sRGB) |
| 3212 | { |
| 3213 | supportedExtensions.textureSRGBDecode = false; |
| 3214 | } |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3215 | } |
| 3216 | |
| 3217 | if (getClientVersion() < ES_3_1) |
| 3218 | { |
| 3219 | // Disable ES3.1+ extensions |
| 3220 | supportedExtensions.geometryShader = false; |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 3221 | |
| 3222 | // TODO(http://anglebug.com/2775): Multisample arrays could be supported on ES 3.0 as well |
| 3223 | // once 2D multisample texture extension is exposed there. |
Olli Etuaho | 064458a | 2018-08-30 14:02:02 +0300 | [diff] [blame] | 3224 | supportedExtensions.textureStorageMultisample2DArray = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | if (getClientVersion() > ES_2_0) |
| 3228 | { |
| 3229 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 3230 | // supportedExtensions.sRGB = false; |
| 3231 | } |
| 3232 | |
| 3233 | // Some extensions are always available because they are implemented in the GL layer. |
| 3234 | supportedExtensions.bindUniformLocation = true; |
| 3235 | supportedExtensions.vertexArrayObject = true; |
| 3236 | supportedExtensions.bindGeneratesResource = true; |
| 3237 | supportedExtensions.clientArrays = true; |
| 3238 | supportedExtensions.requestExtension = true; |
Austin Eng | 7cf9cd2 | 2018-10-09 15:27:32 -0700 | [diff] [blame] | 3239 | supportedExtensions.multiDraw = true; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3240 | |
| 3241 | // Enable the no error extension if the context was created with the flag. |
| 3242 | supportedExtensions.noError = mSkipValidation; |
| 3243 | |
| 3244 | // 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] | 3245 | supportedExtensions.surfacelessContext = mSurfacelessSupported; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3246 | |
| 3247 | // Explicitly enable GL_KHR_debug |
| 3248 | supportedExtensions.debug = true; |
| 3249 | supportedExtensions.maxDebugMessageLength = 1024; |
| 3250 | supportedExtensions.maxDebugLoggedMessages = 1024; |
| 3251 | supportedExtensions.maxDebugGroupStackDepth = 1024; |
| 3252 | supportedExtensions.maxLabelLength = 1024; |
| 3253 | |
| 3254 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 3255 | supportedExtensions.robustClientMemory = true; |
| 3256 | |
| 3257 | // Determine robust resource init availability from EGL. |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3258 | supportedExtensions.robustResourceInitialization = mGLState.isRobustResourceInitEnabled(); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3259 | |
| 3260 | // mExtensions.robustBufferAccessBehavior is true only if robust access is true and the backend |
| 3261 | // supports it. |
| 3262 | supportedExtensions.robustBufferAccessBehavior = |
| 3263 | mRobustAccess && supportedExtensions.robustBufferAccessBehavior; |
| 3264 | |
| 3265 | // Enable the cache control query unconditionally. |
| 3266 | supportedExtensions.programCacheControl = true; |
| 3267 | |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3268 | // Enable EGL_ANGLE_explicit_context subextensions |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3269 | if (mExplicitContextAvailable) |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3270 | { |
| 3271 | // GL_ANGLE_explicit_context_gles1 |
| 3272 | supportedExtensions.explicitContextGles1 = true; |
| 3273 | // GL_ANGLE_explicit_context |
| 3274 | supportedExtensions.explicitContext = true; |
| 3275 | } |
| 3276 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3277 | supportedExtensions.memorySize = true; |
| 3278 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3279 | return supportedExtensions; |
| 3280 | } |
| 3281 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3282 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3283 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 3284 | mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3285 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3286 | mSupportedExtensions = generateSupportedExtensions(); |
| 3287 | mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3288 | |
| 3289 | mLimitations = mImplementation->getNativeLimitations(); |
| 3290 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3291 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3292 | if (getClientVersion() < Version(2, 0)) |
| 3293 | { |
| 3294 | mCaps.maxMultitextureUnits = 4; |
| 3295 | mCaps.maxClipPlanes = 6; |
| 3296 | mCaps.maxLights = 8; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 3297 | mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3298 | mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3299 | mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 3300 | mCaps.minSmoothPointSize = 1.0f; |
| 3301 | mCaps.maxSmoothPointSize = 1.0f; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 3302 | mCaps.minSmoothLineWidth = 1.0f; |
| 3303 | mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3304 | } |
| 3305 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3306 | // Apply/Verify implementation limits |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3307 | LimitCap(&mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3308 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3309 | ASSERT(mCaps.minAliasedPointSize >= 1.0f); |
| 3310 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3311 | if (getClientVersion() < ES_3_1) |
| 3312 | { |
| 3313 | mCaps.maxVertexAttribBindings = mCaps.maxVertexAttributes; |
| 3314 | } |
| 3315 | else |
| 3316 | { |
| 3317 | LimitCap(&mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
| 3318 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3319 | |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3320 | LimitCap(&mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
| 3321 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3322 | LimitCap(&mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
| 3323 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3324 | LimitCap(&mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3325 | LimitCap(&mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3326 | |
| 3327 | // Limit textures as well, so we can use fast bitsets with texture bindings. |
| 3328 | LimitCap(&mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3329 | LimitCap(&mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
| 3330 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
| 3331 | LimitCap(&mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
| 3332 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3333 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3334 | mCaps.maxSampleMaskWords = std::min<GLuint>(mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
| 3335 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3336 | // WebGL compatibility |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 3337 | mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3338 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3339 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3340 | // If the user has requested that extensions start disabled and they are requestable, |
| 3341 | // disable them. |
| 3342 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3343 | { |
| 3344 | mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
| 3345 | } |
| 3346 | } |
| 3347 | |
| 3348 | // Generate texture caps |
| 3349 | updateCaps(); |
| 3350 | } |
| 3351 | |
| 3352 | void Context::updateCaps() |
| 3353 | { |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3354 | mCaps.compressedTextureFormats.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3355 | mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3356 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3357 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3358 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3359 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3360 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3361 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3362 | // Update the format caps based on the client version and extensions. |
| 3363 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3364 | // ES3. |
| 3365 | formatCaps.texturable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 3366 | formatCaps.texturable && formatInfo.textureSupport(getClientVersion(), mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3367 | formatCaps.filterable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 3368 | formatCaps.filterable && formatInfo.filterSupport(getClientVersion(), mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3369 | formatCaps.textureAttachment = |
| 3370 | formatCaps.textureAttachment && |
| 3371 | formatInfo.textureAttachmentSupport(getClientVersion(), mExtensions); |
| 3372 | formatCaps.renderbuffer = formatCaps.renderbuffer && |
| 3373 | formatInfo.renderbufferSupport(getClientVersion(), mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3374 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3375 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3376 | // 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] | 3377 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3378 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3379 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3380 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3381 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3382 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3383 | else |
| 3384 | { |
| 3385 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3386 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3387 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3388 | |
| 3389 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3390 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3391 | // exception of signed and unsigned integer formats." |
| 3392 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3393 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3394 | { |
| 3395 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
| 3396 | mCaps.maxSamples = std::min(mCaps.maxSamples, formatMaxSamples); |
| 3397 | } |
| 3398 | |
| 3399 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3400 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3401 | { |
| 3402 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3403 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3404 | // the exception that the signed and unsigned integer formats are required only to |
| 3405 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3406 | // multisamples, which must be at least one." |
| 3407 | if (formatInfo.componentType == GL_INT || |
| 3408 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3409 | { |
| 3410 | mCaps.maxIntegerSamples = std::min(mCaps.maxIntegerSamples, formatMaxSamples); |
| 3411 | } |
| 3412 | |
| 3413 | // GLES 3.1 section 19.3.1. |
| 3414 | if (formatCaps.texturable) |
| 3415 | { |
| 3416 | if (formatInfo.depthBits > 0) |
| 3417 | { |
| 3418 | mCaps.maxDepthTextureSamples = |
| 3419 | std::min(mCaps.maxDepthTextureSamples, formatMaxSamples); |
| 3420 | } |
| 3421 | else if (formatInfo.redBits > 0) |
| 3422 | { |
| 3423 | mCaps.maxColorTextureSamples = |
| 3424 | std::min(mCaps.maxColorTextureSamples, formatMaxSamples); |
| 3425 | } |
| 3426 | } |
| 3427 | } |
| 3428 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3429 | |
| 3430 | if (formatCaps.texturable && formatInfo.compressed) |
| 3431 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3432 | mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3433 | } |
| 3434 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3435 | mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3436 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3437 | |
| 3438 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3439 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3440 | { |
| 3441 | mMemoryProgramCache = nullptr; |
| 3442 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3443 | |
| 3444 | // Compute which buffer types are allowed |
| 3445 | mValidBufferBindings.reset(); |
| 3446 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3447 | mValidBufferBindings.set(BufferBinding::Array); |
| 3448 | |
| 3449 | if (mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
| 3450 | { |
| 3451 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3452 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3453 | } |
| 3454 | |
| 3455 | if (getClientVersion() >= ES_3_0) |
| 3456 | { |
| 3457 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3458 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3459 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3460 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3461 | } |
| 3462 | |
| 3463 | if (getClientVersion() >= ES_3_1) |
| 3464 | { |
| 3465 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3466 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3467 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3468 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3469 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3470 | |
| 3471 | mThreadPool = angle::WorkerThreadPool::Create(mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3472 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3473 | // Reinitialize some dirty bits that depend on extensions. |
| 3474 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, |
| 3475 | mGLState.isRobustResourceInitEnabled()); |
| 3476 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, |
| 3477 | mGLState.isRobustResourceInitEnabled()); |
| 3478 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3479 | // Reinitialize state cache after extension changes. |
| 3480 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3481 | } |
| 3482 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3483 | void Context::initWorkarounds() |
| 3484 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3485 | // Apply back-end workarounds. |
| 3486 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3487 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3488 | // Lose the context upon out of memory error if the application is |
| 3489 | // expecting to watch for those events. |
| 3490 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3491 | |
| 3492 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3493 | { |
| 3494 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3495 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3496 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3497 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3498 | } |
| 3499 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3500 | // Return true if the draw is a no-op, else return false. |
| 3501 | // A no-op draw occurs if the count of vertices is less than the minimum required to |
| 3502 | // have a valid primitive for this mode (0 for points, 0-1 for lines, 0-2 for tris). |
| 3503 | bool Context::noopDraw(PrimitiveMode mode, GLsizei count) |
| 3504 | { |
| 3505 | return count < kMinimumPrimitiveCounts[mode]; |
| 3506 | } |
| 3507 | |
| 3508 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3509 | { |
| 3510 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3511 | } |
| 3512 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 3513 | angle::Result Context::prepareForDraw(PrimitiveMode mode) |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3514 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 3515 | if (mGLES1Renderer) |
| 3516 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 3517 | ANGLE_TRY(mGLES1Renderer->prepareForDraw(mode, this, &mGLState)); |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 3518 | } |
| 3519 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 3520 | ANGLE_TRY(syncDirtyObjects(mDrawDirtyObjects)); |
Jamie Madill | a59fc19 | 2017-11-02 12:57:58 -0400 | [diff] [blame] | 3521 | |
| 3522 | if (isRobustResourceInitEnabled()) |
| 3523 | { |
| 3524 | ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this)); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3525 | ASSERT(!mGLState.getDrawFramebuffer()->hasResourceThatNeedsInit()); |
Jamie Madill | a59fc19 | 2017-11-02 12:57:58 -0400 | [diff] [blame] | 3526 | } |
| 3527 | |
Jamie Madill | 9e63a81 | 2018-11-16 12:30:04 +0000 | [diff] [blame] | 3528 | ANGLE_TRY(syncDirtyBits()); |
| 3529 | return angle::Result::Continue(); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3530 | } |
| 3531 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3532 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3533 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3534 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3535 | ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3536 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3537 | return angle::Result::Continue(); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3538 | } |
| 3539 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3540 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3541 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3542 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3543 | ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3544 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3545 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3546 | return angle::Result::Continue(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3547 | } |
| 3548 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3549 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3550 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3551 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3552 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3553 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3554 | return angle::Result::Continue(); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3555 | } |
| 3556 | |
Jamie Madill | 9e63a81 | 2018-11-16 12:30:04 +0000 | [diff] [blame] | 3557 | angle::Result Context::syncDirtyBits() |
| 3558 | { |
| 3559 | const State::DirtyBits &dirtyBits = mGLState.getDirtyBits(); |
| 3560 | ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits)); |
| 3561 | mGLState.clearDirtyBits(); |
| 3562 | return angle::Result::Continue(); |
| 3563 | } |
| 3564 | |
| 3565 | angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMask) |
| 3566 | { |
| 3567 | const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask); |
| 3568 | ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask)); |
| 3569 | mGLState.clearDirtyBits(dirtyBits); |
| 3570 | return angle::Result::Continue(); |
| 3571 | } |
| 3572 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3573 | void Context::blitFramebuffer(GLint srcX0, |
| 3574 | GLint srcY0, |
| 3575 | GLint srcX1, |
| 3576 | GLint srcY1, |
| 3577 | GLint dstX0, |
| 3578 | GLint dstY0, |
| 3579 | GLint dstX1, |
| 3580 | GLint dstY1, |
| 3581 | GLbitfield mask, |
| 3582 | GLenum filter) |
| 3583 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3584 | if (mask == 0) |
| 3585 | { |
| 3586 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3587 | // buffers are copied. |
| 3588 | return; |
| 3589 | } |
| 3590 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3591 | Framebuffer *drawFramebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3592 | ASSERT(drawFramebuffer); |
| 3593 | |
| 3594 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3595 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3596 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3597 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3598 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3599 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3600 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3601 | |
| 3602 | void Context::clear(GLbitfield mask) |
| 3603 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3604 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
| 3605 | ANGLE_CONTEXT_TRY(mGLState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3606 | } |
| 3607 | |
| 3608 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3609 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3610 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3611 | const FramebufferAttachment *attachment = nullptr; |
| 3612 | if (buffer == GL_DEPTH) |
| 3613 | { |
| 3614 | attachment = framebufferObject->getDepthbuffer(); |
| 3615 | } |
| 3616 | if (buffer == GL_COLOR && |
| 3617 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3618 | { |
| 3619 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3620 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3621 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3622 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3623 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3624 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3625 | return; |
| 3626 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3627 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3628 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3629 | } |
| 3630 | |
| 3631 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3632 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3633 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3634 | const FramebufferAttachment *attachment = nullptr; |
| 3635 | if (buffer == GL_COLOR && |
| 3636 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3637 | { |
| 3638 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3639 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3640 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3641 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3642 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3643 | { |
| 3644 | return; |
| 3645 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3646 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3647 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3651 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3652 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3653 | const FramebufferAttachment *attachment = nullptr; |
| 3654 | if (buffer == GL_STENCIL) |
| 3655 | { |
| 3656 | attachment = framebufferObject->getStencilbuffer(); |
| 3657 | } |
| 3658 | if (buffer == GL_COLOR && |
| 3659 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3660 | { |
| 3661 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3662 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3663 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3664 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3665 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3666 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3667 | return; |
| 3668 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3669 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3670 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3671 | } |
| 3672 | |
| 3673 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3674 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3675 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3676 | ASSERT(framebufferObject); |
| 3677 | |
| 3678 | // If a buffer is not present, the clear has no effect |
| 3679 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3680 | framebufferObject->getStencilbuffer() == nullptr) |
| 3681 | { |
| 3682 | return; |
| 3683 | } |
| 3684 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3685 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3686 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3687 | } |
| 3688 | |
| 3689 | void Context::readPixels(GLint x, |
| 3690 | GLint y, |
| 3691 | GLsizei width, |
| 3692 | GLsizei height, |
| 3693 | GLenum format, |
| 3694 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3695 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3696 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3697 | if (width == 0 || height == 0) |
| 3698 | { |
| 3699 | return; |
| 3700 | } |
| 3701 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3702 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3703 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3704 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
| 3705 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3706 | |
| 3707 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3708 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3709 | } |
| 3710 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3711 | void Context::readPixelsRobust(GLint x, |
| 3712 | GLint y, |
| 3713 | GLsizei width, |
| 3714 | GLsizei height, |
| 3715 | GLenum format, |
| 3716 | GLenum type, |
| 3717 | GLsizei bufSize, |
| 3718 | GLsizei *length, |
| 3719 | GLsizei *columns, |
| 3720 | GLsizei *rows, |
| 3721 | void *pixels) |
| 3722 | { |
| 3723 | readPixels(x, y, width, height, format, type, pixels); |
| 3724 | } |
| 3725 | |
| 3726 | void Context::readnPixelsRobust(GLint x, |
| 3727 | GLint y, |
| 3728 | GLsizei width, |
| 3729 | GLsizei height, |
| 3730 | GLenum format, |
| 3731 | GLenum type, |
| 3732 | GLsizei bufSize, |
| 3733 | GLsizei *length, |
| 3734 | GLsizei *columns, |
| 3735 | GLsizei *rows, |
| 3736 | void *data) |
| 3737 | { |
| 3738 | readPixels(x, y, width, height, format, type, data); |
| 3739 | } |
| 3740 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3741 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3742 | GLint level, |
| 3743 | GLenum internalformat, |
| 3744 | GLint x, |
| 3745 | GLint y, |
| 3746 | GLsizei width, |
| 3747 | GLsizei height, |
| 3748 | GLint border) |
| 3749 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3750 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3751 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3752 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3753 | Rectangle sourceArea(x, y, width, height); |
| 3754 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3755 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3756 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3757 | ANGLE_CONTEXT_TRY( |
| 3758 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3759 | } |
| 3760 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3761 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3762 | GLint level, |
| 3763 | GLint xoffset, |
| 3764 | GLint yoffset, |
| 3765 | GLint x, |
| 3766 | GLint y, |
| 3767 | GLsizei width, |
| 3768 | GLsizei height) |
| 3769 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3770 | if (width == 0 || height == 0) |
| 3771 | { |
| 3772 | return; |
| 3773 | } |
| 3774 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3775 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3776 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3777 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3778 | Offset destOffset(xoffset, yoffset, 0); |
| 3779 | Rectangle sourceArea(x, y, width, height); |
| 3780 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3781 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3782 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3783 | ANGLE_CONTEXT_TRY( |
| 3784 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3785 | } |
| 3786 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3787 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3788 | GLint level, |
| 3789 | GLint xoffset, |
| 3790 | GLint yoffset, |
| 3791 | GLint zoffset, |
| 3792 | GLint x, |
| 3793 | GLint y, |
| 3794 | GLsizei width, |
| 3795 | GLsizei height) |
| 3796 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3797 | if (width == 0 || height == 0) |
| 3798 | { |
| 3799 | return; |
| 3800 | } |
| 3801 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3802 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3803 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3804 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3805 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3806 | Rectangle sourceArea(x, y, width, height); |
| 3807 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3808 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
| 3809 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3810 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3811 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3812 | } |
| 3813 | |
| 3814 | void Context::framebufferTexture2D(GLenum target, |
| 3815 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3816 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3817 | GLuint texture, |
| 3818 | GLint level) |
| 3819 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3820 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3821 | ASSERT(framebuffer); |
| 3822 | |
| 3823 | if (texture != 0) |
| 3824 | { |
| 3825 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3826 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3827 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3828 | } |
| 3829 | else |
| 3830 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3831 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3832 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3833 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3834 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3835 | } |
| 3836 | |
| 3837 | void Context::framebufferRenderbuffer(GLenum target, |
| 3838 | GLenum attachment, |
| 3839 | GLenum renderbuffertarget, |
| 3840 | GLuint renderbuffer) |
| 3841 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3842 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3843 | ASSERT(framebuffer); |
| 3844 | |
| 3845 | if (renderbuffer != 0) |
| 3846 | { |
| 3847 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3848 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3849 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3850 | renderbufferObject); |
| 3851 | } |
| 3852 | else |
| 3853 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3854 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3855 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3856 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3857 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3858 | } |
| 3859 | |
| 3860 | void Context::framebufferTextureLayer(GLenum target, |
| 3861 | GLenum attachment, |
| 3862 | GLuint texture, |
| 3863 | GLint level, |
| 3864 | GLint layer) |
| 3865 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3866 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3867 | ASSERT(framebuffer); |
| 3868 | |
| 3869 | if (texture != 0) |
| 3870 | { |
| 3871 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3872 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3873 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3874 | } |
| 3875 | else |
| 3876 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3877 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3878 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3879 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3880 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3881 | } |
| 3882 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3883 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3884 | GLenum attachment, |
| 3885 | GLuint texture, |
| 3886 | GLint level, |
| 3887 | GLint baseViewIndex, |
| 3888 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3889 | { |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3890 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3891 | ASSERT(framebuffer); |
| 3892 | |
| 3893 | if (texture != 0) |
| 3894 | { |
| 3895 | Texture *textureObj = getTexture(texture); |
| 3896 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3897 | ImageIndex index; |
| 3898 | if (textureObj->getType() == TextureType::_2DArray) |
| 3899 | { |
| 3900 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3901 | } |
| 3902 | else |
| 3903 | { |
| 3904 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3905 | ASSERT(level == 0); |
| 3906 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3907 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3908 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3909 | numViews, baseViewIndex); |
| 3910 | } |
| 3911 | else |
| 3912 | { |
| 3913 | framebuffer->resetAttachment(this, attachment); |
| 3914 | } |
| 3915 | |
| 3916 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3917 | } |
| 3918 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3919 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3920 | GLenum attachment, |
| 3921 | GLuint texture, |
| 3922 | GLint level, |
| 3923 | GLsizei numViews, |
| 3924 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3925 | { |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3926 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3927 | ASSERT(framebuffer); |
| 3928 | |
| 3929 | if (texture != 0) |
| 3930 | { |
| 3931 | Texture *textureObj = getTexture(texture); |
| 3932 | |
| 3933 | ImageIndex index = ImageIndex::Make2D(level); |
| 3934 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3935 | textureObj, numViews, viewportOffsets); |
| 3936 | } |
| 3937 | else |
| 3938 | { |
| 3939 | framebuffer->resetAttachment(this, attachment); |
| 3940 | } |
| 3941 | |
| 3942 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3943 | } |
| 3944 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3945 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3946 | { |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3947 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3948 | ASSERT(framebuffer); |
| 3949 | |
| 3950 | if (texture != 0) |
| 3951 | { |
| 3952 | Texture *textureObj = getTexture(texture); |
| 3953 | |
| 3954 | ImageIndex index = ImageIndex::MakeFromType( |
| 3955 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3956 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3957 | } |
| 3958 | else |
| 3959 | { |
| 3960 | framebuffer->resetAttachment(this, attachment); |
| 3961 | } |
| 3962 | |
| 3963 | mGLState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3964 | } |
| 3965 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3966 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3967 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3968 | Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3969 | ASSERT(framebuffer); |
| 3970 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3971 | mGLState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3972 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3973 | } |
| 3974 | |
| 3975 | void Context::readBuffer(GLenum mode) |
| 3976 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3977 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3978 | readFBO->setReadBuffer(mode); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3979 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3980 | } |
| 3981 | |
| 3982 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3983 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3984 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3985 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3986 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3987 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3988 | ASSERT(framebuffer); |
| 3989 | |
| 3990 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3991 | // 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] | 3992 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3993 | } |
| 3994 | |
| 3995 | void Context::invalidateFramebuffer(GLenum target, |
| 3996 | GLsizei numAttachments, |
| 3997 | const GLenum *attachments) |
| 3998 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3999 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4000 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 4001 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4002 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4003 | ASSERT(framebuffer); |
| 4004 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 4005 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4006 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 4007 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4008 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 4009 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4010 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4011 | } |
| 4012 | |
| 4013 | void Context::invalidateSubFramebuffer(GLenum target, |
| 4014 | GLsizei numAttachments, |
| 4015 | const GLenum *attachments, |
| 4016 | GLint x, |
| 4017 | GLint y, |
| 4018 | GLsizei width, |
| 4019 | GLsizei height) |
| 4020 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 4021 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4022 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 4023 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4024 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4025 | ASSERT(framebuffer); |
| 4026 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 4027 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4028 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 4029 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4030 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 4031 | |
| 4032 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4033 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 4034 | } |
| 4035 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4036 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4037 | GLint level, |
| 4038 | GLint internalformat, |
| 4039 | GLsizei width, |
| 4040 | GLsizei height, |
| 4041 | GLint border, |
| 4042 | GLenum format, |
| 4043 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4044 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4045 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4046 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4047 | |
| 4048 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4049 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4050 | ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(), target, level, |
| 4051 | internalformat, size, 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::texImage2DRobust(TextureTarget target, |
| 4056 | GLint level, |
| 4057 | GLint internalformat, |
| 4058 | GLsizei width, |
| 4059 | GLsizei height, |
| 4060 | GLint border, |
| 4061 | GLenum format, |
| 4062 | GLenum type, |
| 4063 | GLsizei bufSize, |
| 4064 | const void *pixels) |
| 4065 | { |
| 4066 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 4067 | } |
| 4068 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4069 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4070 | GLint level, |
| 4071 | GLint internalformat, |
| 4072 | GLsizei width, |
| 4073 | GLsizei height, |
| 4074 | GLsizei depth, |
| 4075 | GLint border, |
| 4076 | GLenum format, |
| 4077 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4078 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4079 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4080 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4081 | |
| 4082 | Extents size(width, height, depth); |
| 4083 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4084 | ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(), |
| 4085 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4086 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4087 | } |
| 4088 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4089 | void Context::texImage3DRobust(TextureType target, |
| 4090 | GLint level, |
| 4091 | GLint internalformat, |
| 4092 | GLsizei width, |
| 4093 | GLsizei height, |
| 4094 | GLsizei depth, |
| 4095 | GLint border, |
| 4096 | GLenum format, |
| 4097 | GLenum type, |
| 4098 | GLsizei bufSize, |
| 4099 | const void *pixels) |
| 4100 | { |
| 4101 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4102 | } |
| 4103 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4104 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4105 | GLint level, |
| 4106 | GLint xoffset, |
| 4107 | GLint yoffset, |
| 4108 | GLsizei width, |
| 4109 | GLsizei height, |
| 4110 | GLenum format, |
| 4111 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4112 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4113 | { |
| 4114 | // Zero sized uploads are valid but no-ops |
| 4115 | if (width == 0 || height == 0) |
| 4116 | { |
| 4117 | return; |
| 4118 | } |
| 4119 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4120 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4121 | |
| 4122 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4123 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4124 | |
| 4125 | gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
| 4126 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4127 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, target, |
| 4128 | level, area, format, type, |
| 4129 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4130 | } |
| 4131 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4132 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4133 | GLint level, |
| 4134 | GLint xoffset, |
| 4135 | GLint yoffset, |
| 4136 | GLsizei width, |
| 4137 | GLsizei height, |
| 4138 | GLenum format, |
| 4139 | GLenum type, |
| 4140 | GLsizei bufSize, |
| 4141 | const void *pixels) |
| 4142 | { |
| 4143 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4144 | } |
| 4145 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4146 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4147 | GLint level, |
| 4148 | GLint xoffset, |
| 4149 | GLint yoffset, |
| 4150 | GLint zoffset, |
| 4151 | GLsizei width, |
| 4152 | GLsizei height, |
| 4153 | GLsizei depth, |
| 4154 | GLenum format, |
| 4155 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4156 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4157 | { |
| 4158 | // Zero sized uploads are valid but no-ops |
| 4159 | if (width == 0 || height == 0 || depth == 0) |
| 4160 | { |
| 4161 | return; |
| 4162 | } |
| 4163 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4164 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4165 | |
| 4166 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4167 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4168 | |
| 4169 | gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
| 4170 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4171 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, |
| 4172 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4173 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4174 | } |
| 4175 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4176 | void Context::texSubImage3DRobust(TextureType target, |
| 4177 | GLint level, |
| 4178 | GLint xoffset, |
| 4179 | GLint yoffset, |
| 4180 | GLint zoffset, |
| 4181 | GLsizei width, |
| 4182 | GLsizei height, |
| 4183 | GLsizei depth, |
| 4184 | GLenum format, |
| 4185 | GLenum type, |
| 4186 | GLsizei bufSize, |
| 4187 | const void *pixels) |
| 4188 | { |
| 4189 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4190 | pixels); |
| 4191 | } |
| 4192 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4193 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4194 | GLint level, |
| 4195 | GLenum internalformat, |
| 4196 | GLsizei width, |
| 4197 | GLsizei height, |
| 4198 | GLint border, |
| 4199 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4200 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4201 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4202 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4203 | |
| 4204 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4205 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4206 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level, |
| 4207 | internalformat, size, imageSize, |
| 4208 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4209 | } |
| 4210 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4211 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4212 | GLint level, |
| 4213 | GLenum internalformat, |
| 4214 | GLsizei width, |
| 4215 | GLsizei height, |
| 4216 | GLint border, |
| 4217 | GLsizei imageSize, |
| 4218 | GLsizei dataSize, |
| 4219 | const GLvoid *data) |
| 4220 | { |
| 4221 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4222 | } |
| 4223 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4224 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4225 | GLint level, |
| 4226 | GLenum internalformat, |
| 4227 | GLsizei width, |
| 4228 | GLsizei height, |
| 4229 | GLsizei depth, |
| 4230 | GLint border, |
| 4231 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4232 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4233 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4234 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4235 | |
| 4236 | Extents size(width, height, depth); |
| 4237 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4238 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4239 | this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4240 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4241 | } |
| 4242 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4243 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4244 | GLint level, |
| 4245 | GLenum internalformat, |
| 4246 | GLsizei width, |
| 4247 | GLsizei height, |
| 4248 | GLsizei depth, |
| 4249 | GLint border, |
| 4250 | GLsizei imageSize, |
| 4251 | GLsizei dataSize, |
| 4252 | const GLvoid *data) |
| 4253 | { |
| 4254 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4255 | data); |
| 4256 | } |
| 4257 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4258 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4259 | GLint level, |
| 4260 | GLint xoffset, |
| 4261 | GLint yoffset, |
| 4262 | GLsizei width, |
| 4263 | GLsizei height, |
| 4264 | GLenum format, |
| 4265 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4266 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4267 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4268 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4269 | |
| 4270 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4271 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4272 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, |
| 4273 | area, format, imageSize, |
| 4274 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4275 | } |
| 4276 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4277 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4278 | GLint level, |
| 4279 | GLint xoffset, |
| 4280 | GLint yoffset, |
| 4281 | GLsizei width, |
| 4282 | GLsizei height, |
| 4283 | GLenum format, |
| 4284 | GLsizei imageSize, |
| 4285 | GLsizei dataSize, |
| 4286 | const GLvoid *data) |
| 4287 | { |
| 4288 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4289 | data); |
| 4290 | } |
| 4291 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4292 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4293 | GLint level, |
| 4294 | GLint xoffset, |
| 4295 | GLint yoffset, |
| 4296 | GLint zoffset, |
| 4297 | GLsizei width, |
| 4298 | GLsizei height, |
| 4299 | GLsizei depth, |
| 4300 | GLenum format, |
| 4301 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4302 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4303 | { |
| 4304 | // Zero sized uploads are valid but no-ops |
| 4305 | if (width == 0 || height == 0) |
| 4306 | { |
| 4307 | return; |
| 4308 | } |
| 4309 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4310 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4311 | |
| 4312 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4313 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4314 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4315 | this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4316 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4317 | } |
| 4318 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4319 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4320 | GLint level, |
| 4321 | GLint xoffset, |
| 4322 | GLint yoffset, |
| 4323 | GLint zoffset, |
| 4324 | GLsizei width, |
| 4325 | GLsizei height, |
| 4326 | GLsizei depth, |
| 4327 | GLenum format, |
| 4328 | GLsizei imageSize, |
| 4329 | GLsizei dataSize, |
| 4330 | const GLvoid *data) |
| 4331 | { |
| 4332 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4333 | imageSize, data); |
| 4334 | } |
| 4335 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4336 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4337 | { |
| 4338 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4339 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4340 | } |
| 4341 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4342 | void Context::copyTexture(GLuint sourceId, |
| 4343 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4344 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4345 | GLuint destId, |
| 4346 | GLint destLevel, |
| 4347 | GLint internalFormat, |
| 4348 | GLenum destType, |
| 4349 | GLboolean unpackFlipY, |
| 4350 | GLboolean unpackPremultiplyAlpha, |
| 4351 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4352 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4353 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4354 | |
| 4355 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4356 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4357 | ANGLE_CONTEXT_TRY( |
| 4358 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4359 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4360 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4361 | } |
| 4362 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4363 | void Context::copySubTexture(GLuint sourceId, |
| 4364 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4365 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4366 | GLuint destId, |
| 4367 | GLint destLevel, |
| 4368 | GLint xoffset, |
| 4369 | GLint yoffset, |
| 4370 | GLint x, |
| 4371 | GLint y, |
| 4372 | GLsizei width, |
| 4373 | GLsizei height, |
| 4374 | GLboolean unpackFlipY, |
| 4375 | GLboolean unpackPremultiplyAlpha, |
| 4376 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4377 | { |
| 4378 | // Zero sized copies are valid but no-ops |
| 4379 | if (width == 0 || height == 0) |
| 4380 | { |
| 4381 | return; |
| 4382 | } |
| 4383 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4384 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4385 | |
| 4386 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4387 | gl::Texture *destTexture = getTexture(destId); |
| 4388 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4389 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4390 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4391 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4392 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4393 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4394 | } |
| 4395 | |
| 4396 | void Context::copyTexture3D(GLuint sourceId, |
| 4397 | GLint sourceLevel, |
| 4398 | TextureTarget destTarget, |
| 4399 | GLuint destId, |
| 4400 | GLint destLevel, |
| 4401 | GLint internalFormat, |
| 4402 | GLenum destType, |
| 4403 | GLboolean unpackFlipY, |
| 4404 | GLboolean unpackPremultiplyAlpha, |
| 4405 | GLboolean unpackUnmultiplyAlpha) |
| 4406 | { |
| 4407 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4408 | |
| 4409 | Texture *sourceTexture = getTexture(sourceId); |
| 4410 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4411 | ANGLE_CONTEXT_TRY( |
| 4412 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4413 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4414 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4415 | } |
| 4416 | |
| 4417 | void Context::copySubTexture3D(GLuint sourceId, |
| 4418 | GLint sourceLevel, |
| 4419 | TextureTarget destTarget, |
| 4420 | GLuint destId, |
| 4421 | GLint destLevel, |
| 4422 | GLint xoffset, |
| 4423 | GLint yoffset, |
| 4424 | GLint zoffset, |
| 4425 | GLint x, |
| 4426 | GLint y, |
| 4427 | GLint z, |
| 4428 | GLsizei width, |
| 4429 | GLsizei height, |
| 4430 | GLsizei depth, |
| 4431 | GLboolean unpackFlipY, |
| 4432 | GLboolean unpackPremultiplyAlpha, |
| 4433 | GLboolean unpackUnmultiplyAlpha) |
| 4434 | { |
| 4435 | // Zero sized copies are valid but no-ops |
| 4436 | if (width == 0 || height == 0 || depth == 0) |
| 4437 | { |
| 4438 | return; |
| 4439 | } |
| 4440 | |
| 4441 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4442 | |
| 4443 | Texture *sourceTexture = getTexture(sourceId); |
| 4444 | Texture *destTexture = getTexture(destId); |
| 4445 | Offset offset(xoffset, yoffset, zoffset); |
| 4446 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4447 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4448 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4449 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4450 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4451 | } |
| 4452 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4453 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4454 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4455 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4456 | |
| 4457 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4458 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4459 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4460 | } |
| 4461 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4462 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4463 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4464 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4465 | ASSERT(buffer); |
| 4466 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4467 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4468 | } |
| 4469 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4470 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4471 | GLenum pname, |
| 4472 | GLsizei bufSize, |
| 4473 | GLsizei *length, |
| 4474 | void **params) |
| 4475 | { |
| 4476 | getBufferPointerv(target, pname, params); |
| 4477 | } |
| 4478 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4479 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4480 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4481 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4482 | ASSERT(buffer); |
| 4483 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4484 | if (buffer->map(this, access) == angle::Result::Stop()) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4485 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4486 | return nullptr; |
| 4487 | } |
| 4488 | |
| 4489 | return buffer->getMapPointer(); |
| 4490 | } |
| 4491 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4492 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4493 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4494 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4495 | ASSERT(buffer); |
| 4496 | |
| 4497 | GLboolean result; |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4498 | if (buffer->unmap(this, &result) == angle::Result::Stop()) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4499 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4500 | return GL_FALSE; |
| 4501 | } |
| 4502 | |
| 4503 | return result; |
| 4504 | } |
| 4505 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4506 | void *Context::mapBufferRange(BufferBinding target, |
| 4507 | GLintptr offset, |
| 4508 | GLsizeiptr length, |
| 4509 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4510 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4511 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4512 | ASSERT(buffer); |
| 4513 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4514 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop()) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4515 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4516 | return nullptr; |
| 4517 | } |
| 4518 | |
| 4519 | return buffer->getMapPointer(); |
| 4520 | } |
| 4521 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4522 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4523 | GLintptr /*offset*/, |
| 4524 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4525 | { |
| 4526 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4527 | } |
| 4528 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4529 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4530 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4531 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4532 | } |
| 4533 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4534 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4535 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4536 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4537 | } |
| 4538 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4539 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4540 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4541 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4542 | } |
| 4543 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4544 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4545 | { |
| 4546 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4547 | |
| 4548 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4549 | ANGLE_TRY(syncDirtyBits()); |
| 4550 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4551 | return angle::Result::Continue(); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4552 | } |
| 4553 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4554 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4555 | { |
| 4556 | UNIMPLEMENTED(); |
| 4557 | } |
| 4558 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4559 | void Context::activeTexture(GLenum texture) |
| 4560 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4561 | mGLState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4562 | } |
| 4563 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4564 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4565 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4566 | mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4567 | } |
| 4568 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4569 | void Context::blendEquation(GLenum mode) |
| 4570 | { |
| 4571 | mGLState.setBlendEquation(mode, mode); |
| 4572 | } |
| 4573 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4574 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4575 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4576 | mGLState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4577 | } |
| 4578 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4579 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4580 | { |
| 4581 | mGLState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
| 4582 | } |
| 4583 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4584 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4585 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4586 | mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4587 | } |
| 4588 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4589 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4590 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4591 | mGLState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4592 | } |
| 4593 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4594 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4595 | { |
Joonatan Saarhelo | 945dea3 | 2018-10-17 20:49:06 +0300 | [diff] [blame] | 4596 | mGLState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4597 | } |
| 4598 | |
| 4599 | void Context::clearStencil(GLint s) |
| 4600 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4601 | mGLState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4602 | } |
| 4603 | |
| 4604 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4605 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4606 | mGLState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4607 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4608 | } |
| 4609 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4610 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4611 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4612 | mGLState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4613 | } |
| 4614 | |
| 4615 | void Context::depthFunc(GLenum func) |
| 4616 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4617 | mGLState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4618 | } |
| 4619 | |
| 4620 | void Context::depthMask(GLboolean flag) |
| 4621 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4622 | mGLState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4623 | } |
| 4624 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4625 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4626 | { |
Joonatan Saarhelo | 945dea3 | 2018-10-17 20:49:06 +0300 | [diff] [blame] | 4627 | mGLState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4628 | } |
| 4629 | |
| 4630 | void Context::disable(GLenum cap) |
| 4631 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4632 | mGLState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4633 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4634 | } |
| 4635 | |
| 4636 | void Context::disableVertexAttribArray(GLuint index) |
| 4637 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4638 | mGLState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4639 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4640 | } |
| 4641 | |
| 4642 | void Context::enable(GLenum cap) |
| 4643 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4644 | mGLState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4645 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4646 | } |
| 4647 | |
| 4648 | void Context::enableVertexAttribArray(GLuint index) |
| 4649 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4650 | mGLState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4651 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4652 | } |
| 4653 | |
| 4654 | void Context::frontFace(GLenum mode) |
| 4655 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4656 | mGLState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4657 | } |
| 4658 | |
| 4659 | void Context::hint(GLenum target, GLenum mode) |
| 4660 | { |
| 4661 | switch (target) |
| 4662 | { |
| 4663 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4664 | mGLState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4665 | break; |
| 4666 | |
| 4667 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4668 | mGLState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4669 | break; |
| 4670 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4671 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4672 | case GL_POINT_SMOOTH_HINT: |
| 4673 | case GL_LINE_SMOOTH_HINT: |
| 4674 | case GL_FOG_HINT: |
| 4675 | mGLState.gles1().setHint(target, mode); |
| 4676 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4677 | default: |
| 4678 | UNREACHABLE(); |
| 4679 | return; |
| 4680 | } |
| 4681 | } |
| 4682 | |
| 4683 | void Context::lineWidth(GLfloat width) |
| 4684 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4685 | mGLState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4686 | } |
| 4687 | |
| 4688 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4689 | { |
| 4690 | switch (pname) |
| 4691 | { |
| 4692 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4693 | mGLState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4694 | break; |
| 4695 | |
| 4696 | case GL_PACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4697 | mGLState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4698 | break; |
| 4699 | |
| 4700 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4701 | mGLState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4702 | break; |
| 4703 | |
| 4704 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4705 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4706 | mGLState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4707 | break; |
| 4708 | |
| 4709 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4710 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4711 | mGLState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4712 | break; |
| 4713 | |
| 4714 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4715 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4716 | mGLState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4717 | break; |
| 4718 | |
| 4719 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4720 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4721 | mGLState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4722 | break; |
| 4723 | |
| 4724 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4725 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4726 | mGLState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4727 | break; |
| 4728 | |
| 4729 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4730 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4731 | mGLState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4732 | break; |
| 4733 | |
| 4734 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4735 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4736 | mGLState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4737 | break; |
| 4738 | |
| 4739 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4740 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4741 | mGLState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4742 | break; |
| 4743 | |
| 4744 | default: |
| 4745 | UNREACHABLE(); |
| 4746 | return; |
| 4747 | } |
| 4748 | } |
| 4749 | |
| 4750 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4751 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4752 | mGLState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4753 | } |
| 4754 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4755 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4756 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4757 | mGLState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4758 | } |
| 4759 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4760 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4761 | { |
| 4762 | mGLState.setSampleMaskParams(maskNumber, mask); |
| 4763 | } |
| 4764 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4765 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4766 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4767 | mGLState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4768 | } |
| 4769 | |
| 4770 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4771 | { |
| 4772 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4773 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4774 | mGLState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4775 | } |
| 4776 | |
| 4777 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4778 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4779 | mGLState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4780 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4781 | |
| 4782 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4783 | } |
| 4784 | |
| 4785 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4786 | { |
| 4787 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4788 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4789 | mGLState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4790 | } |
| 4791 | |
| 4792 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4793 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4794 | mGLState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4795 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4796 | |
| 4797 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4798 | } |
| 4799 | |
| 4800 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4801 | { |
| 4802 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4803 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4804 | mGLState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4805 | } |
| 4806 | |
| 4807 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4808 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4809 | mGLState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4810 | } |
| 4811 | } |
| 4812 | |
| 4813 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4814 | { |
| 4815 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4816 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4817 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4818 | } |
| 4819 | |
| 4820 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4821 | { |
| 4822 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4823 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4824 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4825 | } |
| 4826 | |
| 4827 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4828 | { |
| 4829 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4830 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4831 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4832 | } |
| 4833 | |
| 4834 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4835 | { |
| 4836 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4837 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4838 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4839 | } |
| 4840 | |
| 4841 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4842 | { |
| 4843 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4844 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4845 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4846 | } |
| 4847 | |
| 4848 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4849 | { |
| 4850 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4851 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4852 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4853 | } |
| 4854 | |
| 4855 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4856 | { |
| 4857 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4858 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4859 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4860 | } |
| 4861 | |
| 4862 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4863 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4864 | mGLState.setVertexAttribf(index, values); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4865 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4866 | } |
| 4867 | |
| 4868 | void Context::vertexAttribPointer(GLuint index, |
| 4869 | GLint size, |
| 4870 | GLenum type, |
| 4871 | GLboolean normalized, |
| 4872 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4873 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4874 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4875 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(BufferBinding::Array), |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4876 | size, type, ConvertToBool(normalized), false, stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4877 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4878 | } |
| 4879 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4880 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4881 | GLint size, |
| 4882 | GLenum type, |
| 4883 | GLboolean normalized, |
| 4884 | GLuint relativeOffset) |
| 4885 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4886 | mGLState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4887 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4888 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4889 | } |
| 4890 | |
| 4891 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4892 | GLint size, |
| 4893 | GLenum type, |
| 4894 | GLuint relativeOffset) |
| 4895 | { |
| 4896 | mGLState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4897 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4901 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 4902 | mGLState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4903 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4904 | } |
| 4905 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4906 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4907 | { |
| 4908 | mGLState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4909 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4910 | } |
| 4911 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4912 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4913 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4914 | mGLState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4915 | } |
| 4916 | |
| 4917 | void Context::vertexAttribIPointer(GLuint index, |
| 4918 | GLint size, |
| 4919 | GLenum type, |
| 4920 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4921 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4922 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4923 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(BufferBinding::Array), |
| 4924 | size, type, false, true, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4925 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4926 | } |
| 4927 | |
| 4928 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4929 | { |
| 4930 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4931 | mGLState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4932 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4933 | } |
| 4934 | |
| 4935 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4936 | { |
| 4937 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4938 | mGLState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4939 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4940 | } |
| 4941 | |
| 4942 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4943 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4944 | mGLState.setVertexAttribi(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4945 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4946 | } |
| 4947 | |
| 4948 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4949 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4950 | mGLState.setVertexAttribu(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4951 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4952 | } |
| 4953 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4954 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4955 | { |
| 4956 | const VertexAttribCurrentValueData ¤tValues = |
| 4957 | getGLState().getVertexAttribCurrentValue(index); |
| 4958 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4959 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4960 | currentValues, pname, params); |
| 4961 | } |
| 4962 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4963 | void Context::getVertexAttribivRobust(GLuint index, |
| 4964 | GLenum pname, |
| 4965 | GLsizei bufSize, |
| 4966 | GLsizei *length, |
| 4967 | GLint *params) |
| 4968 | { |
| 4969 | getVertexAttribiv(index, pname, params); |
| 4970 | } |
| 4971 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4972 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4973 | { |
| 4974 | const VertexAttribCurrentValueData ¤tValues = |
| 4975 | getGLState().getVertexAttribCurrentValue(index); |
| 4976 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4977 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4978 | currentValues, pname, params); |
| 4979 | } |
| 4980 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4981 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4982 | GLenum pname, |
| 4983 | GLsizei bufSize, |
| 4984 | GLsizei *length, |
| 4985 | GLfloat *params) |
| 4986 | { |
| 4987 | getVertexAttribfv(index, pname, params); |
| 4988 | } |
| 4989 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4990 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4991 | { |
| 4992 | const VertexAttribCurrentValueData ¤tValues = |
| 4993 | getGLState().getVertexAttribCurrentValue(index); |
| 4994 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4995 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4996 | currentValues, pname, params); |
| 4997 | } |
| 4998 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4999 | void Context::getVertexAttribIivRobust(GLuint index, |
| 5000 | GLenum pname, |
| 5001 | GLsizei bufSize, |
| 5002 | GLsizei *length, |
| 5003 | GLint *params) |
| 5004 | { |
| 5005 | getVertexAttribIiv(index, pname, params); |
| 5006 | } |
| 5007 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 5008 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 5009 | { |
| 5010 | const VertexAttribCurrentValueData ¤tValues = |
| 5011 | getGLState().getVertexAttribCurrentValue(index); |
| 5012 | const VertexArray *vao = getGLState().getVertexArray(); |
| 5013 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 5014 | currentValues, pname, params); |
| 5015 | } |
| 5016 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5017 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 5018 | GLenum pname, |
| 5019 | GLsizei bufSize, |
| 5020 | GLsizei *length, |
| 5021 | GLuint *params) |
| 5022 | { |
| 5023 | getVertexAttribIuiv(index, pname, params); |
| 5024 | } |
| 5025 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5026 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 5027 | { |
| 5028 | const VertexAttribute &attrib = getGLState().getVertexArray()->getVertexAttribute(index); |
| 5029 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 5030 | } |
| 5031 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5032 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 5033 | GLenum pname, |
| 5034 | GLsizei bufSize, |
| 5035 | GLsizei *length, |
| 5036 | void **pointer) |
| 5037 | { |
| 5038 | getVertexAttribPointerv(index, pname, pointer); |
| 5039 | } |
| 5040 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5041 | void Context::debugMessageControl(GLenum source, |
| 5042 | GLenum type, |
| 5043 | GLenum severity, |
| 5044 | GLsizei count, |
| 5045 | const GLuint *ids, |
| 5046 | GLboolean enabled) |
| 5047 | { |
| 5048 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5049 | mGLState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 5050 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | void Context::debugMessageInsert(GLenum source, |
| 5054 | GLenum type, |
| 5055 | GLuint id, |
| 5056 | GLenum severity, |
| 5057 | GLsizei length, |
| 5058 | const GLchar *buf) |
| 5059 | { |
| 5060 | std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5061 | mGLState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5062 | } |
| 5063 | |
| 5064 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 5065 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5066 | mGLState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5067 | } |
| 5068 | |
| 5069 | GLuint Context::getDebugMessageLog(GLuint count, |
| 5070 | GLsizei bufSize, |
| 5071 | GLenum *sources, |
| 5072 | GLenum *types, |
| 5073 | GLuint *ids, |
| 5074 | GLenum *severities, |
| 5075 | GLsizei *lengths, |
| 5076 | GLchar *messageLog) |
| 5077 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5078 | return static_cast<GLuint>(mGLState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 5079 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5080 | } |
| 5081 | |
| 5082 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 5083 | { |
| 5084 | std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message)); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5085 | mGLState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5086 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5087 | } |
| 5088 | |
| 5089 | void Context::popDebugGroup() |
| 5090 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5091 | mGLState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5092 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5093 | } |
| 5094 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5095 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5096 | { |
| 5097 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 5098 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5099 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5100 | } |
| 5101 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5102 | void Context::bufferSubData(BufferBinding target, |
| 5103 | GLintptr offset, |
| 5104 | GLsizeiptr size, |
| 5105 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5106 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5107 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5108 | { |
| 5109 | return; |
| 5110 | } |
| 5111 | |
| 5112 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 5113 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5114 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5115 | } |
| 5116 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5117 | void Context::attachShader(GLuint program, GLuint shader) |
| 5118 | { |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 5119 | Program *programObject = mState.mShaderPrograms->getProgram(program); |
| 5120 | Shader *shaderObject = mState.mShaderPrograms->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5121 | ASSERT(programObject && shaderObject); |
| 5122 | programObject->attachShader(shaderObject); |
| 5123 | } |
| 5124 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5125 | const Workarounds &Context::getWorkarounds() const |
| 5126 | { |
| 5127 | return mWorkarounds; |
| 5128 | } |
| 5129 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5130 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5131 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5132 | GLintptr readOffset, |
| 5133 | GLintptr writeOffset, |
| 5134 | GLsizeiptr size) |
| 5135 | { |
| 5136 | // if size is zero, the copy is a successful no-op |
| 5137 | if (size == 0) |
| 5138 | { |
| 5139 | return; |
| 5140 | } |
| 5141 | |
| 5142 | // TODO(jmadill): cache these. |
| 5143 | Buffer *readBuffer = mGLState.getTargetBuffer(readTarget); |
| 5144 | Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget); |
| 5145 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5146 | ANGLE_CONTEXT_TRY( |
| 5147 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5148 | } |
| 5149 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5150 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5151 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5152 | // Ideally we could share the program query with the validation layer if possible. |
| 5153 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5154 | ASSERT(programObject); |
| 5155 | programObject->bindAttributeLocation(index, name); |
| 5156 | } |
| 5157 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5158 | void Context::bindBuffer(BufferBinding target, GLuint buffer) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5159 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5160 | Buffer *bufferObject = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); |
| 5161 | mGLState.setBufferBinding(this, target, bufferObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5162 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5163 | } |
| 5164 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5165 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5166 | { |
| 5167 | bindBufferRange(target, index, buffer, 0, 0); |
| 5168 | } |
| 5169 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5170 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5171 | GLuint index, |
| 5172 | GLuint buffer, |
| 5173 | GLintptr offset, |
| 5174 | GLsizeiptr size) |
| 5175 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5176 | Buffer *object = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); |
| 5177 | mGLState.setIndexedBufferBinding(this, target, index, object, offset, size); |
| 5178 | if (target == BufferBinding::Uniform) |
| 5179 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5180 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5181 | mStateCache.onUniformBufferStateChange(this); |
| 5182 | } |
| 5183 | else |
| 5184 | { |
| 5185 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5186 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5187 | } |
| 5188 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5189 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5190 | { |
| 5191 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5192 | { |
| 5193 | bindReadFramebuffer(framebuffer); |
| 5194 | } |
| 5195 | |
| 5196 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5197 | { |
| 5198 | bindDrawFramebuffer(framebuffer); |
| 5199 | } |
| 5200 | } |
| 5201 | |
| 5202 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5203 | { |
| 5204 | ASSERT(target == GL_RENDERBUFFER); |
| 5205 | Renderbuffer *object = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 5206 | mState.mRenderbuffers->checkRenderbufferAllocation(mImplementation.get(), renderbuffer); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5207 | mGLState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5208 | } |
| 5209 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5210 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5211 | GLsizei samples, |
| 5212 | GLenum internalformat, |
| 5213 | GLsizei width, |
| 5214 | GLsizei height, |
| 5215 | GLboolean fixedsamplelocations) |
| 5216 | { |
| 5217 | Extents size(width, height, 1); |
| 5218 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5219 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5220 | ConvertToBool(fixedsamplelocations))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5221 | } |
| 5222 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5223 | void Context::texStorage3DMultisample(TextureType target, |
| 5224 | GLsizei samples, |
| 5225 | GLenum internalformat, |
| 5226 | GLsizei width, |
| 5227 | GLsizei height, |
| 5228 | GLsizei depth, |
| 5229 | GLboolean fixedsamplelocations) |
| 5230 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5231 | Extents size(width, height, depth); |
| 5232 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5233 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5234 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5235 | } |
| 5236 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5237 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5238 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5239 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5240 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 5241 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5242 | const Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5243 | |
| 5244 | switch (pname) |
| 5245 | { |
| 5246 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5247 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5248 | break; |
| 5249 | default: |
| 5250 | UNREACHABLE(); |
| 5251 | } |
| 5252 | } |
| 5253 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5254 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5255 | GLuint index, |
| 5256 | GLsizei bufSize, |
| 5257 | GLsizei *length, |
| 5258 | GLfloat *val) |
| 5259 | { |
| 5260 | UNIMPLEMENTED(); |
| 5261 | } |
| 5262 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5263 | void Context::renderbufferStorage(GLenum target, |
| 5264 | GLenum internalformat, |
| 5265 | GLsizei width, |
| 5266 | GLsizei height) |
| 5267 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5268 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5269 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5270 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5271 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5272 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5273 | } |
| 5274 | |
| 5275 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5276 | GLsizei samples, |
| 5277 | GLenum internalformat, |
| 5278 | GLsizei width, |
| 5279 | GLsizei height) |
| 5280 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5281 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5282 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5283 | |
| 5284 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5285 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5286 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5287 | } |
| 5288 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5289 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5290 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5291 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5292 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5293 | } |
| 5294 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5295 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5296 | { |
| 5297 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 5298 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5299 | } |
| 5300 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5301 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5302 | GLenum pname, |
| 5303 | GLsizei bufSize, |
| 5304 | GLsizei *length, |
| 5305 | GLint *params) |
| 5306 | { |
| 5307 | UNIMPLEMENTED(); |
| 5308 | } |
| 5309 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5310 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5311 | { |
| 5312 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5313 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5314 | } |
| 5315 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5316 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5317 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5318 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5319 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5320 | } |
| 5321 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5322 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5323 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5324 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5325 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5326 | } |
| 5327 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 5328 | angle::Result Context::prepareForDispatch() |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5329 | { |
Jamie Madill | 0cc11c6 | 2018-10-12 18:07:18 -0400 | [diff] [blame] | 5330 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5331 | |
| 5332 | if (isRobustResourceInitEnabled()) |
| 5333 | { |
| 5334 | ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this)); |
| 5335 | } |
| 5336 | |
Jamie Madill | 0cc11c6 | 2018-10-12 18:07:18 -0400 | [diff] [blame] | 5337 | return syncDirtyBits(mComputeDirtyBits); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5338 | } |
| 5339 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5340 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5341 | { |
| 5342 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5343 | { |
| 5344 | return; |
| 5345 | } |
| 5346 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5347 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5348 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5349 | } |
| 5350 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5351 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5352 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 5353 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5354 | ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5355 | } |
| 5356 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5357 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5358 | GLsizei levels, |
| 5359 | GLenum internalFormat, |
| 5360 | GLsizei width, |
| 5361 | GLsizei height) |
| 5362 | { |
| 5363 | Extents size(width, height, 1); |
| 5364 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5365 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5366 | } |
| 5367 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5368 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5369 | GLsizei levels, |
| 5370 | GLenum internalFormat, |
| 5371 | GLsizei width, |
| 5372 | GLsizei height, |
| 5373 | GLsizei depth) |
| 5374 | { |
| 5375 | Extents size(width, height, depth); |
| 5376 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5377 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5378 | } |
| 5379 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5380 | void Context::memoryBarrier(GLbitfield barriers) |
| 5381 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5382 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5383 | } |
| 5384 | |
| 5385 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5386 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5387 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5388 | } |
| 5389 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5390 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5391 | const GLint *firsts, |
| 5392 | const GLsizei *counts, |
| 5393 | GLsizei drawcount) |
| 5394 | { |
| 5395 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5396 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5397 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5398 | if (hasDrawID) |
| 5399 | { |
| 5400 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5401 | { |
| 5402 | if (noopDraw(mode, counts[drawID])) |
| 5403 | { |
| 5404 | continue; |
| 5405 | } |
| 5406 | programObject->setDrawIDUniform(drawID); |
| 5407 | ANGLE_CONTEXT_TRY( |
| 5408 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
| 5409 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), |
| 5410 | counts[drawID], 1); |
| 5411 | } |
| 5412 | } |
| 5413 | else |
| 5414 | { |
| 5415 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5416 | { |
| 5417 | if (noopDraw(mode, counts[drawID])) |
| 5418 | { |
| 5419 | continue; |
| 5420 | } |
| 5421 | ANGLE_CONTEXT_TRY( |
| 5422 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
| 5423 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), |
| 5424 | counts[drawID], 1); |
| 5425 | } |
| 5426 | } |
| 5427 | } |
| 5428 | |
| 5429 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5430 | const GLint *firsts, |
| 5431 | const GLsizei *counts, |
| 5432 | const GLsizei *instanceCounts, |
| 5433 | GLsizei drawcount) |
| 5434 | { |
| 5435 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5436 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5437 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5438 | if (hasDrawID) |
| 5439 | { |
| 5440 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5441 | { |
| 5442 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5443 | { |
| 5444 | continue; |
| 5445 | } |
| 5446 | programObject->setDrawIDUniform(drawID); |
| 5447 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5448 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
| 5449 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), |
| 5450 | counts[drawID], instanceCounts[drawID]); |
| 5451 | } |
| 5452 | } |
| 5453 | else |
| 5454 | { |
| 5455 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5456 | { |
| 5457 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5458 | { |
| 5459 | continue; |
| 5460 | } |
| 5461 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5462 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
| 5463 | MarkTransformFeedbackBufferUsage(this, mGLState.getCurrentTransformFeedback(), |
| 5464 | counts[drawID], instanceCounts[drawID]); |
| 5465 | } |
| 5466 | } |
| 5467 | } |
| 5468 | |
| 5469 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5470 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5471 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5472 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5473 | GLsizei drawcount) |
| 5474 | { |
| 5475 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5476 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5477 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5478 | if (hasDrawID) |
| 5479 | { |
| 5480 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5481 | { |
| 5482 | if (noopDraw(mode, counts[drawID])) |
| 5483 | { |
| 5484 | continue; |
| 5485 | } |
| 5486 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5487 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5488 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5489 | } |
| 5490 | } |
| 5491 | else |
| 5492 | { |
| 5493 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5494 | { |
| 5495 | if (noopDraw(mode, counts[drawID])) |
| 5496 | { |
| 5497 | continue; |
| 5498 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5499 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5500 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5501 | } |
| 5502 | } |
| 5503 | } |
| 5504 | |
| 5505 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5506 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5507 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5508 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5509 | const GLsizei *instanceCounts, |
| 5510 | GLsizei drawcount) |
| 5511 | { |
| 5512 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5513 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5514 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5515 | if (hasDrawID) |
| 5516 | { |
| 5517 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5518 | { |
| 5519 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5520 | { |
| 5521 | continue; |
| 5522 | } |
| 5523 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5524 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5525 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5526 | } |
| 5527 | } |
| 5528 | else |
| 5529 | { |
| 5530 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5531 | { |
| 5532 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5533 | { |
| 5534 | continue; |
| 5535 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5536 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5537 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5538 | } |
| 5539 | } |
| 5540 | } |
| 5541 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5542 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5543 | { |
| 5544 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 5545 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5546 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5547 | } |
| 5548 | |
| 5549 | void Context::compileShader(GLuint shader) |
| 5550 | { |
| 5551 | Shader *shaderObject = GetValidShader(this, shader); |
| 5552 | if (!shaderObject) |
| 5553 | { |
| 5554 | return; |
| 5555 | } |
| 5556 | shaderObject->compile(this); |
| 5557 | } |
| 5558 | |
| 5559 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5560 | { |
| 5561 | for (int i = 0; i < n; i++) |
| 5562 | { |
| 5563 | deleteBuffer(buffers[i]); |
| 5564 | } |
| 5565 | } |
| 5566 | |
| 5567 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5568 | { |
| 5569 | for (int i = 0; i < n; i++) |
| 5570 | { |
| 5571 | if (framebuffers[i] != 0) |
| 5572 | { |
| 5573 | deleteFramebuffer(framebuffers[i]); |
| 5574 | } |
| 5575 | } |
| 5576 | } |
| 5577 | |
| 5578 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5579 | { |
| 5580 | for (int i = 0; i < n; i++) |
| 5581 | { |
| 5582 | deleteRenderbuffer(renderbuffers[i]); |
| 5583 | } |
| 5584 | } |
| 5585 | |
| 5586 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5587 | { |
| 5588 | for (int i = 0; i < n; i++) |
| 5589 | { |
| 5590 | if (textures[i] != 0) |
| 5591 | { |
| 5592 | deleteTexture(textures[i]); |
| 5593 | } |
| 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | void Context::detachShader(GLuint program, GLuint shader) |
| 5598 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5599 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5600 | ASSERT(programObject); |
| 5601 | |
| 5602 | Shader *shaderObject = getShader(shader); |
| 5603 | ASSERT(shaderObject); |
| 5604 | |
| 5605 | programObject->detachShader(this, shaderObject); |
| 5606 | } |
| 5607 | |
| 5608 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5609 | { |
| 5610 | for (int i = 0; i < n; i++) |
| 5611 | { |
| 5612 | buffers[i] = createBuffer(); |
| 5613 | } |
| 5614 | } |
| 5615 | |
| 5616 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5617 | { |
| 5618 | for (int i = 0; i < n; i++) |
| 5619 | { |
| 5620 | framebuffers[i] = createFramebuffer(); |
| 5621 | } |
| 5622 | } |
| 5623 | |
| 5624 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5625 | { |
| 5626 | for (int i = 0; i < n; i++) |
| 5627 | { |
| 5628 | renderbuffers[i] = createRenderbuffer(); |
| 5629 | } |
| 5630 | } |
| 5631 | |
| 5632 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5633 | { |
| 5634 | for (int i = 0; i < n; i++) |
| 5635 | { |
| 5636 | textures[i] = createTexture(); |
| 5637 | } |
| 5638 | } |
| 5639 | |
| 5640 | void Context::getActiveAttrib(GLuint program, |
| 5641 | GLuint index, |
| 5642 | GLsizei bufsize, |
| 5643 | GLsizei *length, |
| 5644 | GLint *size, |
| 5645 | GLenum *type, |
| 5646 | GLchar *name) |
| 5647 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5648 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5649 | ASSERT(programObject); |
| 5650 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5651 | } |
| 5652 | |
| 5653 | void Context::getActiveUniform(GLuint program, |
| 5654 | GLuint index, |
| 5655 | GLsizei bufsize, |
| 5656 | GLsizei *length, |
| 5657 | GLint *size, |
| 5658 | GLenum *type, |
| 5659 | GLchar *name) |
| 5660 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5661 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5662 | ASSERT(programObject); |
| 5663 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5664 | } |
| 5665 | |
| 5666 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5667 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5668 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5669 | ASSERT(programObject); |
| 5670 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5671 | } |
| 5672 | |
| 5673 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5674 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5675 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5676 | ASSERT(programObject); |
| 5677 | return programObject->getAttributeLocation(name); |
| 5678 | } |
| 5679 | |
| 5680 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5681 | { |
| 5682 | GLenum nativeType; |
| 5683 | unsigned int numParams = 0; |
| 5684 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5685 | |
| 5686 | if (nativeType == GL_BOOL) |
| 5687 | { |
| 5688 | getBooleanvImpl(pname, params); |
| 5689 | } |
| 5690 | else |
| 5691 | { |
| 5692 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5693 | } |
| 5694 | } |
| 5695 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5696 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5697 | { |
| 5698 | getBooleanv(pname, params); |
| 5699 | } |
| 5700 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5701 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5702 | { |
| 5703 | GLenum nativeType; |
| 5704 | unsigned int numParams = 0; |
| 5705 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5706 | |
| 5707 | if (nativeType == GL_FLOAT) |
| 5708 | { |
| 5709 | getFloatvImpl(pname, params); |
| 5710 | } |
| 5711 | else |
| 5712 | { |
| 5713 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5714 | } |
| 5715 | } |
| 5716 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5717 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5718 | { |
| 5719 | getFloatv(pname, params); |
| 5720 | } |
| 5721 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5722 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5723 | { |
| 5724 | GLenum nativeType; |
| 5725 | unsigned int numParams = 0; |
| 5726 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5727 | |
| 5728 | if (nativeType == GL_INT) |
| 5729 | { |
| 5730 | getIntegervImpl(pname, params); |
| 5731 | } |
| 5732 | else |
| 5733 | { |
| 5734 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5735 | } |
| 5736 | } |
| 5737 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5738 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5739 | { |
| 5740 | getIntegerv(pname, data); |
| 5741 | } |
| 5742 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5743 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5744 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5745 | // Don't resolve link if checking the link completion status. |
| 5746 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5747 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5748 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5749 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5750 | } |
| 5751 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5752 | void Context::getProgramivRobust(GLuint program, |
| 5753 | GLenum pname, |
| 5754 | GLsizei bufSize, |
| 5755 | GLsizei *length, |
| 5756 | GLint *params) |
| 5757 | { |
| 5758 | getProgramiv(program, pname, params); |
| 5759 | } |
| 5760 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5761 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5762 | { |
| 5763 | UNIMPLEMENTED(); |
| 5764 | } |
| 5765 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5766 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5767 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5768 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5769 | ASSERT(programObject); |
| 5770 | programObject->getInfoLog(bufsize, length, infolog); |
| 5771 | } |
| 5772 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5773 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5774 | GLsizei bufSize, |
| 5775 | GLsizei *length, |
| 5776 | GLchar *infoLog) |
| 5777 | { |
| 5778 | UNIMPLEMENTED(); |
| 5779 | } |
| 5780 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5781 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5782 | { |
| 5783 | Shader *shaderObject = getShader(shader); |
| 5784 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5785 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5786 | } |
| 5787 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5788 | void Context::getShaderivRobust(GLuint shader, |
| 5789 | GLenum pname, |
| 5790 | GLsizei bufSize, |
| 5791 | GLsizei *length, |
| 5792 | GLint *params) |
| 5793 | { |
| 5794 | getShaderiv(shader, pname, params); |
| 5795 | } |
| 5796 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5797 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5798 | { |
| 5799 | Shader *shaderObject = getShader(shader); |
| 5800 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5801 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5802 | } |
| 5803 | |
| 5804 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5805 | GLenum precisiontype, |
| 5806 | GLint *range, |
| 5807 | GLint *precision) |
| 5808 | { |
| 5809 | // TODO(jmadill): Compute shaders. |
| 5810 | |
| 5811 | switch (shadertype) |
| 5812 | { |
| 5813 | case GL_VERTEX_SHADER: |
| 5814 | switch (precisiontype) |
| 5815 | { |
| 5816 | case GL_LOW_FLOAT: |
| 5817 | mCaps.vertexLowpFloat.get(range, precision); |
| 5818 | break; |
| 5819 | case GL_MEDIUM_FLOAT: |
| 5820 | mCaps.vertexMediumpFloat.get(range, precision); |
| 5821 | break; |
| 5822 | case GL_HIGH_FLOAT: |
| 5823 | mCaps.vertexHighpFloat.get(range, precision); |
| 5824 | break; |
| 5825 | |
| 5826 | case GL_LOW_INT: |
| 5827 | mCaps.vertexLowpInt.get(range, precision); |
| 5828 | break; |
| 5829 | case GL_MEDIUM_INT: |
| 5830 | mCaps.vertexMediumpInt.get(range, precision); |
| 5831 | break; |
| 5832 | case GL_HIGH_INT: |
| 5833 | mCaps.vertexHighpInt.get(range, precision); |
| 5834 | break; |
| 5835 | |
| 5836 | default: |
| 5837 | UNREACHABLE(); |
| 5838 | return; |
| 5839 | } |
| 5840 | break; |
| 5841 | |
| 5842 | case GL_FRAGMENT_SHADER: |
| 5843 | switch (precisiontype) |
| 5844 | { |
| 5845 | case GL_LOW_FLOAT: |
| 5846 | mCaps.fragmentLowpFloat.get(range, precision); |
| 5847 | break; |
| 5848 | case GL_MEDIUM_FLOAT: |
| 5849 | mCaps.fragmentMediumpFloat.get(range, precision); |
| 5850 | break; |
| 5851 | case GL_HIGH_FLOAT: |
| 5852 | mCaps.fragmentHighpFloat.get(range, precision); |
| 5853 | break; |
| 5854 | |
| 5855 | case GL_LOW_INT: |
| 5856 | mCaps.fragmentLowpInt.get(range, precision); |
| 5857 | break; |
| 5858 | case GL_MEDIUM_INT: |
| 5859 | mCaps.fragmentMediumpInt.get(range, precision); |
| 5860 | break; |
| 5861 | case GL_HIGH_INT: |
| 5862 | mCaps.fragmentHighpInt.get(range, precision); |
| 5863 | break; |
| 5864 | |
| 5865 | default: |
| 5866 | UNREACHABLE(); |
| 5867 | return; |
| 5868 | } |
| 5869 | break; |
| 5870 | |
| 5871 | default: |
| 5872 | UNREACHABLE(); |
| 5873 | return; |
| 5874 | } |
| 5875 | } |
| 5876 | |
| 5877 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5878 | { |
| 5879 | Shader *shaderObject = getShader(shader); |
| 5880 | ASSERT(shaderObject); |
| 5881 | shaderObject->getSource(bufsize, length, source); |
| 5882 | } |
| 5883 | |
| 5884 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5885 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5886 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5887 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5888 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5889 | } |
| 5890 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5891 | void Context::getUniformfvRobust(GLuint program, |
| 5892 | GLint location, |
| 5893 | GLsizei bufSize, |
| 5894 | GLsizei *length, |
| 5895 | GLfloat *params) |
| 5896 | { |
| 5897 | getUniformfv(program, location, params); |
| 5898 | } |
| 5899 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5900 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5901 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5902 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5903 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5904 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5905 | } |
| 5906 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5907 | void Context::getUniformivRobust(GLuint program, |
| 5908 | GLint location, |
| 5909 | GLsizei bufSize, |
| 5910 | GLsizei *length, |
| 5911 | GLint *params) |
| 5912 | { |
| 5913 | getUniformiv(program, location, params); |
| 5914 | } |
| 5915 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5916 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5917 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5918 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5919 | ASSERT(programObject); |
| 5920 | return programObject->getUniformLocation(name); |
| 5921 | } |
| 5922 | |
| 5923 | GLboolean Context::isBuffer(GLuint buffer) |
| 5924 | { |
| 5925 | if (buffer == 0) |
| 5926 | { |
| 5927 | return GL_FALSE; |
| 5928 | } |
| 5929 | |
| 5930 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5931 | } |
| 5932 | |
| 5933 | GLboolean Context::isEnabled(GLenum cap) |
| 5934 | { |
| 5935 | return mGLState.getEnableFeature(cap); |
| 5936 | } |
| 5937 | |
| 5938 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5939 | { |
| 5940 | if (framebuffer == 0) |
| 5941 | { |
| 5942 | return GL_FALSE; |
| 5943 | } |
| 5944 | |
| 5945 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5946 | } |
| 5947 | |
| 5948 | GLboolean Context::isProgram(GLuint program) |
| 5949 | { |
| 5950 | if (program == 0) |
| 5951 | { |
| 5952 | return GL_FALSE; |
| 5953 | } |
| 5954 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5955 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5956 | } |
| 5957 | |
| 5958 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5959 | { |
| 5960 | if (renderbuffer == 0) |
| 5961 | { |
| 5962 | return GL_FALSE; |
| 5963 | } |
| 5964 | |
| 5965 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5966 | } |
| 5967 | |
| 5968 | GLboolean Context::isShader(GLuint shader) |
| 5969 | { |
| 5970 | if (shader == 0) |
| 5971 | { |
| 5972 | return GL_FALSE; |
| 5973 | } |
| 5974 | |
| 5975 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5976 | } |
| 5977 | |
| 5978 | GLboolean Context::isTexture(GLuint texture) |
| 5979 | { |
| 5980 | if (texture == 0) |
| 5981 | { |
| 5982 | return GL_FALSE; |
| 5983 | } |
| 5984 | |
| 5985 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5986 | } |
| 5987 | |
| 5988 | void Context::linkProgram(GLuint program) |
| 5989 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5990 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5991 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5992 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5993 | |
| 5994 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5995 | // don't need to worry that: |
| 5996 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5997 | // result. |
| 5998 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5999 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 6000 | // ProgramD3D. |
| 6001 | if (programObject->isInUse()) |
| 6002 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 6003 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6004 | if (programObject->isLinked()) |
| 6005 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 6006 | ANGLE_CONTEXT_TRY(mGLState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6007 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 6008 | mStateCache.onProgramExecutableChange(this); |
| 6009 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6010 | } |
| 6011 | |
| 6012 | void Context::releaseShaderCompiler() |
| 6013 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 6014 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6015 | } |
| 6016 | |
| 6017 | void Context::shaderBinary(GLsizei n, |
| 6018 | const GLuint *shaders, |
| 6019 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 6020 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6021 | GLsizei length) |
| 6022 | { |
| 6023 | // No binary shader formats are supported. |
| 6024 | UNIMPLEMENTED(); |
| 6025 | } |
| 6026 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 6027 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 6028 | GLuint colorNumber, |
| 6029 | GLuint index, |
| 6030 | const char *name) |
| 6031 | { |
| 6032 | Program *programObject = getProgramNoResolveLink(program); |
| 6033 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 6034 | programObject->bindFragmentOutputIndex(index, name); |
| 6035 | } |
| 6036 | |
| 6037 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 6038 | { |
| 6039 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 6040 | } |
| 6041 | |
| 6042 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 6043 | { |
| 6044 | Program *programObject = getProgramResolveLink(program); |
| 6045 | return programObject->getFragDataIndex(name); |
| 6046 | } |
| 6047 | |
| 6048 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 6049 | GLenum programInterface, |
| 6050 | const char *name) |
| 6051 | { |
| 6052 | Program *programObject = getProgramResolveLink(program); |
| 6053 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 6054 | return programObject->getFragDataIndex(name); |
| 6055 | } |
| 6056 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6057 | void Context::shaderSource(GLuint shader, |
| 6058 | GLsizei count, |
| 6059 | const GLchar *const *string, |
| 6060 | const GLint *length) |
| 6061 | { |
| 6062 | Shader *shaderObject = getShader(shader); |
| 6063 | ASSERT(shaderObject); |
| 6064 | shaderObject->setSource(count, string, length); |
| 6065 | } |
| 6066 | |
| 6067 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6068 | { |
| 6069 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 6070 | } |
| 6071 | |
| 6072 | void Context::stencilMask(GLuint mask) |
| 6073 | { |
| 6074 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6075 | } |
| 6076 | |
| 6077 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6078 | { |
| 6079 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6080 | } |
| 6081 | |
| 6082 | void Context::uniform1f(GLint location, GLfloat x) |
| 6083 | { |
| 6084 | Program *program = mGLState.getProgram(); |
| 6085 | program->setUniform1fv(location, 1, &x); |
| 6086 | } |
| 6087 | |
| 6088 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 6089 | { |
| 6090 | Program *program = mGLState.getProgram(); |
| 6091 | program->setUniform1fv(location, count, v); |
| 6092 | } |
| 6093 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6094 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6095 | { |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6096 | if (program->setUniform1iv(location, count, v) == Program::SetUniformResult::SamplerChanged) |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6097 | { |
| 6098 | mGLState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6099 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6100 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6101 | } |
| 6102 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6103 | void Context::uniform1i(GLint location, GLint x) |
| 6104 | { |
| 6105 | setUniform1iImpl(mGLState.getProgram(), location, 1, &x); |
| 6106 | } |
| 6107 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6108 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6109 | { |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6110 | setUniform1iImpl(mGLState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6111 | } |
| 6112 | |
| 6113 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6114 | { |
| 6115 | GLfloat xy[2] = {x, y}; |
| 6116 | Program *program = mGLState.getProgram(); |
| 6117 | program->setUniform2fv(location, 1, xy); |
| 6118 | } |
| 6119 | |
| 6120 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6121 | { |
| 6122 | Program *program = mGLState.getProgram(); |
| 6123 | program->setUniform2fv(location, count, v); |
| 6124 | } |
| 6125 | |
| 6126 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6127 | { |
| 6128 | GLint xy[2] = {x, y}; |
| 6129 | Program *program = mGLState.getProgram(); |
| 6130 | program->setUniform2iv(location, 1, xy); |
| 6131 | } |
| 6132 | |
| 6133 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6134 | { |
| 6135 | Program *program = mGLState.getProgram(); |
| 6136 | program->setUniform2iv(location, count, v); |
| 6137 | } |
| 6138 | |
| 6139 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6140 | { |
| 6141 | GLfloat xyz[3] = {x, y, z}; |
| 6142 | Program *program = mGLState.getProgram(); |
| 6143 | program->setUniform3fv(location, 1, xyz); |
| 6144 | } |
| 6145 | |
| 6146 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6147 | { |
| 6148 | Program *program = mGLState.getProgram(); |
| 6149 | program->setUniform3fv(location, count, v); |
| 6150 | } |
| 6151 | |
| 6152 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6153 | { |
| 6154 | GLint xyz[3] = {x, y, z}; |
| 6155 | Program *program = mGLState.getProgram(); |
| 6156 | program->setUniform3iv(location, 1, xyz); |
| 6157 | } |
| 6158 | |
| 6159 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6160 | { |
| 6161 | Program *program = mGLState.getProgram(); |
| 6162 | program->setUniform3iv(location, count, v); |
| 6163 | } |
| 6164 | |
| 6165 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6166 | { |
| 6167 | GLfloat xyzw[4] = {x, y, z, w}; |
| 6168 | Program *program = mGLState.getProgram(); |
| 6169 | program->setUniform4fv(location, 1, xyzw); |
| 6170 | } |
| 6171 | |
| 6172 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6173 | { |
| 6174 | Program *program = mGLState.getProgram(); |
| 6175 | program->setUniform4fv(location, count, v); |
| 6176 | } |
| 6177 | |
| 6178 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6179 | { |
| 6180 | GLint xyzw[4] = {x, y, z, w}; |
| 6181 | Program *program = mGLState.getProgram(); |
| 6182 | program->setUniform4iv(location, 1, xyzw); |
| 6183 | } |
| 6184 | |
| 6185 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6186 | { |
| 6187 | Program *program = mGLState.getProgram(); |
| 6188 | program->setUniform4iv(location, count, v); |
| 6189 | } |
| 6190 | |
| 6191 | void Context::uniformMatrix2fv(GLint location, |
| 6192 | GLsizei count, |
| 6193 | GLboolean transpose, |
| 6194 | const GLfloat *value) |
| 6195 | { |
| 6196 | Program *program = mGLState.getProgram(); |
| 6197 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6198 | } |
| 6199 | |
| 6200 | void Context::uniformMatrix3fv(GLint location, |
| 6201 | GLsizei count, |
| 6202 | GLboolean transpose, |
| 6203 | const GLfloat *value) |
| 6204 | { |
| 6205 | Program *program = mGLState.getProgram(); |
| 6206 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6207 | } |
| 6208 | |
| 6209 | void Context::uniformMatrix4fv(GLint location, |
| 6210 | GLsizei count, |
| 6211 | GLboolean transpose, |
| 6212 | const GLfloat *value) |
| 6213 | { |
| 6214 | Program *program = mGLState.getProgram(); |
| 6215 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6216 | } |
| 6217 | |
| 6218 | void Context::validateProgram(GLuint program) |
| 6219 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6220 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6221 | ASSERT(programObject); |
| 6222 | programObject->validate(mCaps); |
| 6223 | } |
| 6224 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6225 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6226 | { |
| 6227 | UNIMPLEMENTED(); |
| 6228 | } |
| 6229 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6230 | void Context::getProgramBinary(GLuint program, |
| 6231 | GLsizei bufSize, |
| 6232 | GLsizei *length, |
| 6233 | GLenum *binaryFormat, |
| 6234 | void *binary) |
| 6235 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6236 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6237 | ASSERT(programObject != nullptr); |
| 6238 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6239 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6240 | } |
| 6241 | |
| 6242 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6243 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6244 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6245 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6246 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6247 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6248 | if (programObject->isInUse()) |
| 6249 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 6250 | ANGLE_CONTEXT_TRY(mGLState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6251 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6252 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6253 | } |
| 6254 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6255 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6256 | { |
| 6257 | Program *program = mGLState.getProgram(); |
| 6258 | program->setUniform1uiv(location, 1, &v0); |
| 6259 | } |
| 6260 | |
| 6261 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 6262 | { |
| 6263 | Program *program = mGLState.getProgram(); |
| 6264 | const GLuint xy[] = {v0, v1}; |
| 6265 | program->setUniform2uiv(location, 1, xy); |
| 6266 | } |
| 6267 | |
| 6268 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6269 | { |
| 6270 | Program *program = mGLState.getProgram(); |
| 6271 | const GLuint xyz[] = {v0, v1, v2}; |
| 6272 | program->setUniform3uiv(location, 1, xyz); |
| 6273 | } |
| 6274 | |
| 6275 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6276 | { |
| 6277 | Program *program = mGLState.getProgram(); |
| 6278 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6279 | program->setUniform4uiv(location, 1, xyzw); |
| 6280 | } |
| 6281 | |
| 6282 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6283 | { |
| 6284 | Program *program = mGLState.getProgram(); |
| 6285 | program->setUniform1uiv(location, count, value); |
| 6286 | } |
| 6287 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6288 | { |
| 6289 | Program *program = mGLState.getProgram(); |
| 6290 | program->setUniform2uiv(location, count, value); |
| 6291 | } |
| 6292 | |
| 6293 | void Context::uniform3uiv(GLint location, GLsizei count, const GLuint *value) |
| 6294 | { |
| 6295 | Program *program = mGLState.getProgram(); |
| 6296 | program->setUniform3uiv(location, count, value); |
| 6297 | } |
| 6298 | |
| 6299 | void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) |
| 6300 | { |
| 6301 | Program *program = mGLState.getProgram(); |
| 6302 | program->setUniform4uiv(location, count, value); |
| 6303 | } |
| 6304 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6305 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6306 | { |
| 6307 | for (GLsizei i = 0; i < n; i++) |
| 6308 | { |
| 6309 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6310 | mQueryMap.assign(handle, nullptr); |
| 6311 | ids[i] = handle; |
| 6312 | } |
| 6313 | } |
| 6314 | |
| 6315 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6316 | { |
| 6317 | for (int i = 0; i < n; i++) |
| 6318 | { |
| 6319 | GLuint query = ids[i]; |
| 6320 | |
| 6321 | Query *queryObject = nullptr; |
| 6322 | if (mQueryMap.erase(query, &queryObject)) |
| 6323 | { |
| 6324 | mQueryHandleAllocator.release(query); |
| 6325 | if (queryObject) |
| 6326 | { |
| 6327 | queryObject->release(this); |
| 6328 | } |
| 6329 | } |
| 6330 | } |
| 6331 | } |
| 6332 | |
| 6333 | GLboolean Context::isQuery(GLuint id) |
| 6334 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6335 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6336 | } |
| 6337 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6338 | void Context::uniformMatrix2x3fv(GLint location, |
| 6339 | GLsizei count, |
| 6340 | GLboolean transpose, |
| 6341 | const GLfloat *value) |
| 6342 | { |
| 6343 | Program *program = mGLState.getProgram(); |
| 6344 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6345 | } |
| 6346 | |
| 6347 | void Context::uniformMatrix3x2fv(GLint location, |
| 6348 | GLsizei count, |
| 6349 | GLboolean transpose, |
| 6350 | const GLfloat *value) |
| 6351 | { |
| 6352 | Program *program = mGLState.getProgram(); |
| 6353 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6354 | } |
| 6355 | |
| 6356 | void Context::uniformMatrix2x4fv(GLint location, |
| 6357 | GLsizei count, |
| 6358 | GLboolean transpose, |
| 6359 | const GLfloat *value) |
| 6360 | { |
| 6361 | Program *program = mGLState.getProgram(); |
| 6362 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6363 | } |
| 6364 | |
| 6365 | void Context::uniformMatrix4x2fv(GLint location, |
| 6366 | GLsizei count, |
| 6367 | GLboolean transpose, |
| 6368 | const GLfloat *value) |
| 6369 | { |
| 6370 | Program *program = mGLState.getProgram(); |
| 6371 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6372 | } |
| 6373 | |
| 6374 | void Context::uniformMatrix3x4fv(GLint location, |
| 6375 | GLsizei count, |
| 6376 | GLboolean transpose, |
| 6377 | const GLfloat *value) |
| 6378 | { |
| 6379 | Program *program = mGLState.getProgram(); |
| 6380 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6381 | } |
| 6382 | |
| 6383 | void Context::uniformMatrix4x3fv(GLint location, |
| 6384 | GLsizei count, |
| 6385 | GLboolean transpose, |
| 6386 | const GLfloat *value) |
| 6387 | { |
| 6388 | Program *program = mGLState.getProgram(); |
| 6389 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6390 | } |
| 6391 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6392 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6393 | { |
| 6394 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6395 | { |
| 6396 | GLuint vertexArray = arrays[arrayIndex]; |
| 6397 | |
| 6398 | if (arrays[arrayIndex] != 0) |
| 6399 | { |
| 6400 | VertexArray *vertexArrayObject = nullptr; |
| 6401 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6402 | { |
| 6403 | if (vertexArrayObject != nullptr) |
| 6404 | { |
| 6405 | detachVertexArray(vertexArray); |
| 6406 | vertexArrayObject->onDestroy(this); |
| 6407 | } |
| 6408 | |
| 6409 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6410 | } |
| 6411 | } |
| 6412 | } |
| 6413 | } |
| 6414 | |
| 6415 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6416 | { |
| 6417 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6418 | { |
| 6419 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6420 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6421 | arrays[arrayIndex] = vertexArray; |
| 6422 | } |
| 6423 | } |
| 6424 | |
| 6425 | bool Context::isVertexArray(GLuint array) |
| 6426 | { |
| 6427 | if (array == 0) |
| 6428 | { |
| 6429 | return GL_FALSE; |
| 6430 | } |
| 6431 | |
| 6432 | VertexArray *vao = getVertexArray(array); |
| 6433 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6434 | } |
| 6435 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6436 | void Context::endTransformFeedback() |
| 6437 | { |
| 6438 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 6439 | transformFeedback->end(this); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6440 | mStateCache.onTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6441 | } |
| 6442 | |
| 6443 | void Context::transformFeedbackVaryings(GLuint program, |
| 6444 | GLsizei count, |
| 6445 | const GLchar *const *varyings, |
| 6446 | GLenum bufferMode) |
| 6447 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6448 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6449 | ASSERT(programObject); |
| 6450 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6451 | } |
| 6452 | |
| 6453 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6454 | GLuint index, |
| 6455 | GLsizei bufSize, |
| 6456 | GLsizei *length, |
| 6457 | GLsizei *size, |
| 6458 | GLenum *type, |
| 6459 | GLchar *name) |
| 6460 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6461 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6462 | ASSERT(programObject); |
| 6463 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6464 | } |
| 6465 | |
| 6466 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6467 | { |
| 6468 | for (int i = 0; i < n; i++) |
| 6469 | { |
| 6470 | GLuint transformFeedback = ids[i]; |
| 6471 | if (transformFeedback == 0) |
| 6472 | { |
| 6473 | continue; |
| 6474 | } |
| 6475 | |
| 6476 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6477 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6478 | { |
| 6479 | if (transformFeedbackObject != nullptr) |
| 6480 | { |
| 6481 | detachTransformFeedback(transformFeedback); |
| 6482 | transformFeedbackObject->release(this); |
| 6483 | } |
| 6484 | |
| 6485 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6486 | } |
| 6487 | } |
| 6488 | } |
| 6489 | |
| 6490 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6491 | { |
| 6492 | for (int i = 0; i < n; i++) |
| 6493 | { |
| 6494 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6495 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6496 | ids[i] = transformFeedback; |
| 6497 | } |
| 6498 | } |
| 6499 | |
| 6500 | bool Context::isTransformFeedback(GLuint id) |
| 6501 | { |
| 6502 | if (id == 0) |
| 6503 | { |
| 6504 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6505 | // returns FALSE |
| 6506 | return GL_FALSE; |
| 6507 | } |
| 6508 | |
| 6509 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6510 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6511 | } |
| 6512 | |
| 6513 | void Context::pauseTransformFeedback() |
| 6514 | { |
| 6515 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 6516 | transformFeedback->pause(); |
| 6517 | } |
| 6518 | |
| 6519 | void Context::resumeTransformFeedback() |
| 6520 | { |
| 6521 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
| 6522 | transformFeedback->resume(); |
| 6523 | } |
| 6524 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6525 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6526 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6527 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6528 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6529 | } |
| 6530 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6531 | void Context::getUniformuivRobust(GLuint program, |
| 6532 | GLint location, |
| 6533 | GLsizei bufSize, |
| 6534 | GLsizei *length, |
| 6535 | GLuint *params) |
| 6536 | { |
| 6537 | getUniformuiv(program, location, params); |
| 6538 | } |
| 6539 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6540 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6541 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6542 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6543 | return programObject->getFragDataLocation(name); |
| 6544 | } |
| 6545 | |
| 6546 | void Context::getUniformIndices(GLuint program, |
| 6547 | GLsizei uniformCount, |
| 6548 | const GLchar *const *uniformNames, |
| 6549 | GLuint *uniformIndices) |
| 6550 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6551 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6552 | if (!programObject->isLinked()) |
| 6553 | { |
| 6554 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6555 | { |
| 6556 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6557 | } |
| 6558 | } |
| 6559 | else |
| 6560 | { |
| 6561 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6562 | { |
| 6563 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6564 | } |
| 6565 | } |
| 6566 | } |
| 6567 | |
| 6568 | void Context::getActiveUniformsiv(GLuint program, |
| 6569 | GLsizei uniformCount, |
| 6570 | const GLuint *uniformIndices, |
| 6571 | GLenum pname, |
| 6572 | GLint *params) |
| 6573 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6574 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6575 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6576 | { |
| 6577 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6578 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6579 | } |
| 6580 | } |
| 6581 | |
| 6582 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6583 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6584 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6585 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6586 | } |
| 6587 | |
| 6588 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6589 | GLuint uniformBlockIndex, |
| 6590 | GLenum pname, |
| 6591 | GLint *params) |
| 6592 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6593 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6594 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6595 | } |
| 6596 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6597 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6598 | GLuint uniformBlockIndex, |
| 6599 | GLenum pname, |
| 6600 | GLsizei bufSize, |
| 6601 | GLsizei *length, |
| 6602 | GLint *params) |
| 6603 | { |
| 6604 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6605 | } |
| 6606 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6607 | void Context::getActiveUniformBlockName(GLuint program, |
| 6608 | GLuint uniformBlockIndex, |
| 6609 | GLsizei bufSize, |
| 6610 | GLsizei *length, |
| 6611 | GLchar *uniformBlockName) |
| 6612 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6613 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6614 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6615 | } |
| 6616 | |
| 6617 | void Context::uniformBlockBinding(GLuint program, |
| 6618 | GLuint uniformBlockIndex, |
| 6619 | GLuint uniformBlockBinding) |
| 6620 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6621 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6622 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6623 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6624 | // 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] | 6625 | if (programObject->isInUse()) |
| 6626 | { |
| 6627 | mGLState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6628 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6629 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6630 | } |
| 6631 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6632 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6633 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6634 | GLuint handle = mState.mSyncs->createSync(mImplementation.get()); |
| 6635 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6636 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6637 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6638 | if (syncObject->set(this, condition, flags) == angle::Result::Stop()) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6639 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6640 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6641 | return nullptr; |
| 6642 | } |
| 6643 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6644 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6645 | } |
| 6646 | |
| 6647 | GLboolean Context::isSync(GLsync sync) |
| 6648 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6649 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6650 | } |
| 6651 | |
| 6652 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6653 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6654 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6655 | |
| 6656 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6657 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop()) |
| 6658 | { |
| 6659 | return GL_WAIT_FAILED; |
| 6660 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6661 | return result; |
| 6662 | } |
| 6663 | |
| 6664 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6665 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6666 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6667 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6668 | } |
| 6669 | |
| 6670 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6671 | { |
| 6672 | GLenum nativeType = GL_NONE; |
| 6673 | unsigned int numParams = 0; |
| 6674 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6675 | |
| 6676 | if (nativeType == GL_INT_64_ANGLEX) |
| 6677 | { |
| 6678 | getInteger64vImpl(pname, params); |
| 6679 | } |
| 6680 | else |
| 6681 | { |
| 6682 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6683 | } |
| 6684 | } |
| 6685 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6686 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6687 | { |
| 6688 | getInteger64v(pname, data); |
| 6689 | } |
| 6690 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6691 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6692 | { |
| 6693 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 6694 | QueryBufferParameteri64v(buffer, pname, params); |
| 6695 | } |
| 6696 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6697 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6698 | GLenum pname, |
| 6699 | GLsizei bufSize, |
| 6700 | GLsizei *length, |
| 6701 | GLint64 *params) |
| 6702 | { |
| 6703 | getBufferParameteri64v(target, pname, params); |
| 6704 | } |
| 6705 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6706 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6707 | { |
| 6708 | for (int i = 0; i < count; i++) |
| 6709 | { |
| 6710 | samplers[i] = mState.mSamplers->createSampler(); |
| 6711 | } |
| 6712 | } |
| 6713 | |
| 6714 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6715 | { |
| 6716 | for (int i = 0; i < count; i++) |
| 6717 | { |
| 6718 | GLuint sampler = samplers[i]; |
| 6719 | |
| 6720 | if (mState.mSamplers->getSampler(sampler)) |
| 6721 | { |
| 6722 | detachSampler(sampler); |
| 6723 | } |
| 6724 | |
| 6725 | mState.mSamplers->deleteObject(this, sampler); |
| 6726 | } |
| 6727 | } |
| 6728 | |
| 6729 | void Context::getInternalformativ(GLenum target, |
| 6730 | GLenum internalformat, |
| 6731 | GLenum pname, |
| 6732 | GLsizei bufSize, |
| 6733 | GLint *params) |
| 6734 | { |
| 6735 | const TextureCaps &formatCaps = mTextureCaps.get(internalformat); |
| 6736 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6737 | } |
| 6738 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6739 | void Context::getInternalformativRobust(GLenum target, |
| 6740 | GLenum internalformat, |
| 6741 | GLenum pname, |
| 6742 | GLsizei bufSize, |
| 6743 | GLsizei *length, |
| 6744 | GLint *params) |
| 6745 | { |
| 6746 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6747 | } |
| 6748 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6749 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6750 | { |
| 6751 | programUniform1iv(program, location, 1, &v0); |
| 6752 | } |
| 6753 | |
| 6754 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6755 | { |
| 6756 | GLint xy[2] = {v0, v1}; |
| 6757 | programUniform2iv(program, location, 1, xy); |
| 6758 | } |
| 6759 | |
| 6760 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6761 | { |
| 6762 | GLint xyz[3] = {v0, v1, v2}; |
| 6763 | programUniform3iv(program, location, 1, xyz); |
| 6764 | } |
| 6765 | |
| 6766 | void Context::programUniform4i(GLuint program, |
| 6767 | GLint location, |
| 6768 | GLint v0, |
| 6769 | GLint v1, |
| 6770 | GLint v2, |
| 6771 | GLint v3) |
| 6772 | { |
| 6773 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6774 | programUniform4iv(program, location, 1, xyzw); |
| 6775 | } |
| 6776 | |
| 6777 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6778 | { |
| 6779 | programUniform1uiv(program, location, 1, &v0); |
| 6780 | } |
| 6781 | |
| 6782 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6783 | { |
| 6784 | GLuint xy[2] = {v0, v1}; |
| 6785 | programUniform2uiv(program, location, 1, xy); |
| 6786 | } |
| 6787 | |
| 6788 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6789 | { |
| 6790 | GLuint xyz[3] = {v0, v1, v2}; |
| 6791 | programUniform3uiv(program, location, 1, xyz); |
| 6792 | } |
| 6793 | |
| 6794 | void Context::programUniform4ui(GLuint program, |
| 6795 | GLint location, |
| 6796 | GLuint v0, |
| 6797 | GLuint v1, |
| 6798 | GLuint v2, |
| 6799 | GLuint v3) |
| 6800 | { |
| 6801 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6802 | programUniform4uiv(program, location, 1, xyzw); |
| 6803 | } |
| 6804 | |
| 6805 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6806 | { |
| 6807 | programUniform1fv(program, location, 1, &v0); |
| 6808 | } |
| 6809 | |
| 6810 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6811 | { |
| 6812 | GLfloat xy[2] = {v0, v1}; |
| 6813 | programUniform2fv(program, location, 1, xy); |
| 6814 | } |
| 6815 | |
| 6816 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6817 | { |
| 6818 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6819 | programUniform3fv(program, location, 1, xyz); |
| 6820 | } |
| 6821 | |
| 6822 | void Context::programUniform4f(GLuint program, |
| 6823 | GLint location, |
| 6824 | GLfloat v0, |
| 6825 | GLfloat v1, |
| 6826 | GLfloat v2, |
| 6827 | GLfloat v3) |
| 6828 | { |
| 6829 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6830 | programUniform4fv(program, location, 1, xyzw); |
| 6831 | } |
| 6832 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6833 | void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6834 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6835 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6836 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6837 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6838 | } |
| 6839 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6840 | void Context::programUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6841 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6842 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6843 | ASSERT(programObject); |
| 6844 | programObject->setUniform2iv(location, count, value); |
| 6845 | } |
| 6846 | |
| 6847 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6848 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6849 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6850 | ASSERT(programObject); |
| 6851 | programObject->setUniform3iv(location, count, value); |
| 6852 | } |
| 6853 | |
| 6854 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6855 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6856 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6857 | ASSERT(programObject); |
| 6858 | programObject->setUniform4iv(location, count, value); |
| 6859 | } |
| 6860 | |
| 6861 | void Context::programUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6862 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6863 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6864 | ASSERT(programObject); |
| 6865 | programObject->setUniform1uiv(location, count, value); |
| 6866 | } |
| 6867 | |
| 6868 | void Context::programUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6869 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6870 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6871 | ASSERT(programObject); |
| 6872 | programObject->setUniform2uiv(location, count, value); |
| 6873 | } |
| 6874 | |
| 6875 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6876 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6877 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6878 | ASSERT(programObject); |
| 6879 | programObject->setUniform3uiv(location, count, value); |
| 6880 | } |
| 6881 | |
| 6882 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6883 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6884 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6885 | ASSERT(programObject); |
| 6886 | programObject->setUniform4uiv(location, count, value); |
| 6887 | } |
| 6888 | |
| 6889 | void Context::programUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6890 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6891 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6892 | ASSERT(programObject); |
| 6893 | programObject->setUniform1fv(location, count, value); |
| 6894 | } |
| 6895 | |
| 6896 | void Context::programUniform2fv(GLuint program, GLint location, GLsizei count, 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->setUniform2fv(location, count, value); |
| 6901 | } |
| 6902 | |
| 6903 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6904 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6905 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6906 | ASSERT(programObject); |
| 6907 | programObject->setUniform3fv(location, count, value); |
| 6908 | } |
| 6909 | |
| 6910 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6911 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6912 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6913 | ASSERT(programObject); |
| 6914 | programObject->setUniform4fv(location, count, value); |
| 6915 | } |
| 6916 | |
| 6917 | void Context::programUniformMatrix2fv(GLuint program, |
| 6918 | GLint location, |
| 6919 | GLsizei count, |
| 6920 | GLboolean transpose, |
| 6921 | const GLfloat *value) |
| 6922 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6923 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6924 | ASSERT(programObject); |
| 6925 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6926 | } |
| 6927 | |
| 6928 | void Context::programUniformMatrix3fv(GLuint program, |
| 6929 | GLint location, |
| 6930 | GLsizei count, |
| 6931 | GLboolean transpose, |
| 6932 | const GLfloat *value) |
| 6933 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6934 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6935 | ASSERT(programObject); |
| 6936 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6937 | } |
| 6938 | |
| 6939 | void Context::programUniformMatrix4fv(GLuint program, |
| 6940 | GLint location, |
| 6941 | GLsizei count, |
| 6942 | GLboolean transpose, |
| 6943 | const GLfloat *value) |
| 6944 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6945 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6946 | ASSERT(programObject); |
| 6947 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6948 | } |
| 6949 | |
| 6950 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6951 | GLint location, |
| 6952 | GLsizei count, |
| 6953 | GLboolean transpose, |
| 6954 | const GLfloat *value) |
| 6955 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6956 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6957 | ASSERT(programObject); |
| 6958 | programObject->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6959 | } |
| 6960 | |
| 6961 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6962 | GLint location, |
| 6963 | GLsizei count, |
| 6964 | GLboolean transpose, |
| 6965 | const GLfloat *value) |
| 6966 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6967 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6968 | ASSERT(programObject); |
| 6969 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6970 | } |
| 6971 | |
| 6972 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6973 | GLint location, |
| 6974 | GLsizei count, |
| 6975 | GLboolean transpose, |
| 6976 | const GLfloat *value) |
| 6977 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6978 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6979 | ASSERT(programObject); |
| 6980 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6981 | } |
| 6982 | |
| 6983 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6984 | GLint location, |
| 6985 | GLsizei count, |
| 6986 | GLboolean transpose, |
| 6987 | const GLfloat *value) |
| 6988 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6989 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6990 | ASSERT(programObject); |
| 6991 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6992 | } |
| 6993 | |
| 6994 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6995 | GLint location, |
| 6996 | GLsizei count, |
| 6997 | GLboolean transpose, |
| 6998 | const GLfloat *value) |
| 6999 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7000 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 7001 | ASSERT(programObject); |
| 7002 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 7003 | } |
| 7004 | |
| 7005 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 7006 | GLint location, |
| 7007 | GLsizei count, |
| 7008 | GLboolean transpose, |
| 7009 | const GLfloat *value) |
| 7010 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7011 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 7012 | ASSERT(programObject); |
| 7013 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 7014 | } |
| 7015 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 7016 | void Context::onTextureChange(const Texture *texture) |
| 7017 | { |
| 7018 | // Conservatively assume all textures are dirty. |
| 7019 | // TODO(jmadill): More fine-grained update. |
| 7020 | mGLState.setObjectDirty(GL_TEXTURE); |
| 7021 | } |
| 7022 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 7023 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 7024 | { |
| 7025 | return mGLState.isCurrentTransformFeedback(tf); |
| 7026 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 7027 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 7028 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 7029 | { |
| 7030 | for (int i = 0; i < count; i++) |
| 7031 | { |
| 7032 | pipelines[i] = createProgramPipeline(); |
| 7033 | } |
| 7034 | } |
| 7035 | |
| 7036 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 7037 | { |
| 7038 | for (int i = 0; i < count; i++) |
| 7039 | { |
| 7040 | if (pipelines[i] != 0) |
| 7041 | { |
| 7042 | deleteProgramPipeline(pipelines[i]); |
| 7043 | } |
| 7044 | } |
| 7045 | } |
| 7046 | |
| 7047 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 7048 | { |
| 7049 | if (pipeline == 0) |
| 7050 | { |
| 7051 | return GL_FALSE; |
| 7052 | } |
| 7053 | |
| 7054 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 7055 | } |
| 7056 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7057 | void Context::finishFenceNV(GLuint fence) |
| 7058 | { |
| 7059 | FenceNV *fenceObject = getFenceNV(fence); |
| 7060 | |
| 7061 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7062 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7063 | } |
| 7064 | |
| 7065 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 7066 | { |
| 7067 | FenceNV *fenceObject = getFenceNV(fence); |
| 7068 | |
| 7069 | ASSERT(fenceObject && fenceObject->isSet()); |
| 7070 | |
| 7071 | switch (pname) |
| 7072 | { |
| 7073 | case GL_FENCE_STATUS_NV: |
| 7074 | { |
| 7075 | // GL_NV_fence spec: |
| 7076 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 7077 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 7078 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 7079 | GLboolean status = GL_TRUE; |
| 7080 | if (fenceObject->getStatus() != GL_TRUE) |
| 7081 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 7082 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7083 | } |
| 7084 | *params = status; |
| 7085 | break; |
| 7086 | } |
| 7087 | |
| 7088 | case GL_FENCE_CONDITION_NV: |
| 7089 | { |
| 7090 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 7091 | break; |
| 7092 | } |
| 7093 | |
| 7094 | default: |
| 7095 | UNREACHABLE(); |
| 7096 | } |
| 7097 | } |
| 7098 | |
| 7099 | void Context::getTranslatedShaderSource(GLuint shader, |
| 7100 | GLsizei bufsize, |
| 7101 | GLsizei *length, |
| 7102 | GLchar *source) |
| 7103 | { |
| 7104 | Shader *shaderObject = getShader(shader); |
| 7105 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7106 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7107 | } |
| 7108 | |
| 7109 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7110 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7111 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7112 | ASSERT(programObject); |
| 7113 | |
| 7114 | programObject->getUniformfv(this, location, params); |
| 7115 | } |
| 7116 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7117 | void Context::getnUniformfvRobust(GLuint program, |
| 7118 | GLint location, |
| 7119 | GLsizei bufSize, |
| 7120 | GLsizei *length, |
| 7121 | GLfloat *params) |
| 7122 | { |
| 7123 | UNIMPLEMENTED(); |
| 7124 | } |
| 7125 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7126 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7127 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7128 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7129 | ASSERT(programObject); |
| 7130 | |
| 7131 | programObject->getUniformiv(this, location, params); |
| 7132 | } |
| 7133 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7134 | void Context::getnUniformivRobust(GLuint program, |
| 7135 | GLint location, |
| 7136 | GLsizei bufSize, |
| 7137 | GLsizei *length, |
| 7138 | GLint *params) |
| 7139 | { |
| 7140 | UNIMPLEMENTED(); |
| 7141 | } |
| 7142 | |
| 7143 | void Context::getnUniformuivRobust(GLuint program, |
| 7144 | GLint location, |
| 7145 | GLsizei bufSize, |
| 7146 | GLsizei *length, |
| 7147 | GLuint *params) |
| 7148 | { |
| 7149 | UNIMPLEMENTED(); |
| 7150 | } |
| 7151 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7152 | GLboolean Context::isFenceNV(GLuint fence) |
| 7153 | { |
| 7154 | FenceNV *fenceObject = getFenceNV(fence); |
| 7155 | |
| 7156 | if (fenceObject == nullptr) |
| 7157 | { |
| 7158 | return GL_FALSE; |
| 7159 | } |
| 7160 | |
| 7161 | // GL_NV_fence spec: |
| 7162 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7163 | // existing fence. |
| 7164 | return fenceObject->isSet(); |
| 7165 | } |
| 7166 | |
| 7167 | void Context::readnPixels(GLint x, |
| 7168 | GLint y, |
| 7169 | GLsizei width, |
| 7170 | GLsizei height, |
| 7171 | GLenum format, |
| 7172 | GLenum type, |
| 7173 | GLsizei bufSize, |
| 7174 | void *data) |
| 7175 | { |
| 7176 | return readPixels(x, y, width, height, format, type, data); |
| 7177 | } |
| 7178 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7179 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7180 | { |
| 7181 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7182 | |
| 7183 | FenceNV *fenceObject = getFenceNV(fence); |
| 7184 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7185 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7186 | } |
| 7187 | |
| 7188 | GLboolean Context::testFenceNV(GLuint fence) |
| 7189 | { |
| 7190 | FenceNV *fenceObject = getFenceNV(fence); |
| 7191 | |
| 7192 | ASSERT(fenceObject != nullptr); |
| 7193 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7194 | |
| 7195 | GLboolean result = GL_TRUE; |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7196 | if (fenceObject->test(this, &result) == angle::Result::Stop()) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7197 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7198 | return GL_TRUE; |
| 7199 | } |
| 7200 | |
| 7201 | return result; |
| 7202 | } |
| 7203 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7204 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7205 | { |
| 7206 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7207 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7208 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7209 | } |
| 7210 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7211 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7212 | { |
| 7213 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7214 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7215 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7216 | } |
| 7217 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7218 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7219 | { |
| 7220 | UNIMPLEMENTED(); |
| 7221 | } |
| 7222 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7223 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7224 | { |
| 7225 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7226 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7227 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7228 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7229 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7230 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7231 | // application. |
| 7232 | switch (pname) |
| 7233 | { |
| 7234 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7235 | { |
| 7236 | *type = GL_INT; |
| 7237 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7238 | return true; |
| 7239 | } |
| 7240 | case GL_SHADER_BINARY_FORMATS: |
| 7241 | { |
| 7242 | *type = GL_INT; |
| 7243 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7244 | return true; |
| 7245 | } |
| 7246 | |
| 7247 | case GL_MAX_VERTEX_ATTRIBS: |
| 7248 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7249 | case GL_MAX_VARYING_VECTORS: |
| 7250 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7251 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7252 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7253 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7254 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7255 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7256 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7257 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7258 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7259 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7260 | case GL_RENDERBUFFER_BINDING: |
| 7261 | case GL_CURRENT_PROGRAM: |
| 7262 | case GL_PACK_ALIGNMENT: |
| 7263 | case GL_UNPACK_ALIGNMENT: |
| 7264 | case GL_GENERATE_MIPMAP_HINT: |
| 7265 | case GL_RED_BITS: |
| 7266 | case GL_GREEN_BITS: |
| 7267 | case GL_BLUE_BITS: |
| 7268 | case GL_ALPHA_BITS: |
| 7269 | case GL_DEPTH_BITS: |
| 7270 | case GL_STENCIL_BITS: |
| 7271 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7272 | case GL_CULL_FACE_MODE: |
| 7273 | case GL_FRONT_FACE: |
| 7274 | case GL_ACTIVE_TEXTURE: |
| 7275 | case GL_STENCIL_FUNC: |
| 7276 | case GL_STENCIL_VALUE_MASK: |
| 7277 | case GL_STENCIL_REF: |
| 7278 | case GL_STENCIL_FAIL: |
| 7279 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7280 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7281 | case GL_STENCIL_BACK_FUNC: |
| 7282 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7283 | case GL_STENCIL_BACK_REF: |
| 7284 | case GL_STENCIL_BACK_FAIL: |
| 7285 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7286 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7287 | case GL_DEPTH_FUNC: |
| 7288 | case GL_BLEND_SRC_RGB: |
| 7289 | case GL_BLEND_SRC_ALPHA: |
| 7290 | case GL_BLEND_DST_RGB: |
| 7291 | case GL_BLEND_DST_ALPHA: |
| 7292 | case GL_BLEND_EQUATION_RGB: |
| 7293 | case GL_BLEND_EQUATION_ALPHA: |
| 7294 | case GL_STENCIL_WRITEMASK: |
| 7295 | case GL_STENCIL_BACK_WRITEMASK: |
| 7296 | case GL_STENCIL_CLEAR_VALUE: |
| 7297 | case GL_SUBPIXEL_BITS: |
| 7298 | case GL_MAX_TEXTURE_SIZE: |
| 7299 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7300 | case GL_SAMPLE_BUFFERS: |
| 7301 | case GL_SAMPLES: |
| 7302 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7303 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7304 | case GL_TEXTURE_BINDING_2D: |
| 7305 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7306 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7307 | { |
| 7308 | *type = GL_INT; |
| 7309 | *numParams = 1; |
| 7310 | return true; |
| 7311 | } |
| 7312 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7313 | { |
| 7314 | if (!getExtensions().packReverseRowOrder) |
| 7315 | { |
| 7316 | return false; |
| 7317 | } |
| 7318 | *type = GL_INT; |
| 7319 | *numParams = 1; |
| 7320 | return true; |
| 7321 | } |
| 7322 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7323 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7324 | { |
| 7325 | if (!getExtensions().textureRectangle) |
| 7326 | { |
| 7327 | return false; |
| 7328 | } |
| 7329 | *type = GL_INT; |
| 7330 | *numParams = 1; |
| 7331 | return true; |
| 7332 | } |
| 7333 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7334 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7335 | { |
| 7336 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7337 | { |
| 7338 | return false; |
| 7339 | } |
| 7340 | *type = GL_INT; |
| 7341 | *numParams = 1; |
| 7342 | return true; |
| 7343 | } |
| 7344 | case GL_MAX_VIEWPORT_DIMS: |
| 7345 | { |
| 7346 | *type = GL_INT; |
| 7347 | *numParams = 2; |
| 7348 | return true; |
| 7349 | } |
| 7350 | case GL_VIEWPORT: |
| 7351 | case GL_SCISSOR_BOX: |
| 7352 | { |
| 7353 | *type = GL_INT; |
| 7354 | *numParams = 4; |
| 7355 | return true; |
| 7356 | } |
| 7357 | case GL_SHADER_COMPILER: |
| 7358 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7359 | case GL_DEPTH_WRITEMASK: |
| 7360 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7361 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7362 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7363 | // bool-natural |
| 7364 | case GL_SAMPLE_COVERAGE: |
| 7365 | case GL_SCISSOR_TEST: |
| 7366 | case GL_STENCIL_TEST: |
| 7367 | case GL_DEPTH_TEST: |
| 7368 | case GL_BLEND: |
| 7369 | case GL_DITHER: |
| 7370 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7371 | { |
| 7372 | *type = GL_BOOL; |
| 7373 | *numParams = 1; |
| 7374 | return true; |
| 7375 | } |
| 7376 | case GL_COLOR_WRITEMASK: |
| 7377 | { |
| 7378 | *type = GL_BOOL; |
| 7379 | *numParams = 4; |
| 7380 | return true; |
| 7381 | } |
| 7382 | case GL_POLYGON_OFFSET_FACTOR: |
| 7383 | case GL_POLYGON_OFFSET_UNITS: |
| 7384 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7385 | case GL_DEPTH_CLEAR_VALUE: |
| 7386 | case GL_LINE_WIDTH: |
| 7387 | { |
| 7388 | *type = GL_FLOAT; |
| 7389 | *numParams = 1; |
| 7390 | return true; |
| 7391 | } |
| 7392 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7393 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7394 | case GL_DEPTH_RANGE: |
| 7395 | { |
| 7396 | *type = GL_FLOAT; |
| 7397 | *numParams = 2; |
| 7398 | return true; |
| 7399 | } |
| 7400 | case GL_COLOR_CLEAR_VALUE: |
| 7401 | case GL_BLEND_COLOR: |
| 7402 | { |
| 7403 | *type = GL_FLOAT; |
| 7404 | *numParams = 4; |
| 7405 | return true; |
| 7406 | } |
| 7407 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7408 | if (!getExtensions().textureFilterAnisotropic) |
| 7409 | { |
| 7410 | return false; |
| 7411 | } |
| 7412 | *type = GL_FLOAT; |
| 7413 | *numParams = 1; |
| 7414 | return true; |
| 7415 | case GL_TIMESTAMP_EXT: |
| 7416 | if (!getExtensions().disjointTimerQuery) |
| 7417 | { |
| 7418 | return false; |
| 7419 | } |
| 7420 | *type = GL_INT_64_ANGLEX; |
| 7421 | *numParams = 1; |
| 7422 | return true; |
| 7423 | case GL_GPU_DISJOINT_EXT: |
| 7424 | if (!getExtensions().disjointTimerQuery) |
| 7425 | { |
| 7426 | return false; |
| 7427 | } |
| 7428 | *type = GL_INT; |
| 7429 | *numParams = 1; |
| 7430 | return true; |
| 7431 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7432 | if (!getExtensions().framebufferMixedSamples) |
| 7433 | { |
| 7434 | return false; |
| 7435 | } |
| 7436 | *type = GL_INT; |
| 7437 | *numParams = 1; |
| 7438 | return true; |
| 7439 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7440 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7441 | { |
| 7442 | return false; |
| 7443 | } |
| 7444 | *type = GL_INT; |
| 7445 | *numParams = 1; |
| 7446 | return true; |
| 7447 | } |
| 7448 | |
| 7449 | if (getExtensions().debug) |
| 7450 | { |
| 7451 | switch (pname) |
| 7452 | { |
| 7453 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7454 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7455 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7456 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7457 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7458 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7459 | case GL_MAX_LABEL_LENGTH: |
| 7460 | *type = GL_INT; |
| 7461 | *numParams = 1; |
| 7462 | return true; |
| 7463 | |
| 7464 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7465 | case GL_DEBUG_OUTPUT: |
| 7466 | *type = GL_BOOL; |
| 7467 | *numParams = 1; |
| 7468 | return true; |
| 7469 | } |
| 7470 | } |
| 7471 | |
| 7472 | if (getExtensions().multisampleCompatibility) |
| 7473 | { |
| 7474 | switch (pname) |
| 7475 | { |
| 7476 | case GL_MULTISAMPLE_EXT: |
| 7477 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7478 | *type = GL_BOOL; |
| 7479 | *numParams = 1; |
| 7480 | return true; |
| 7481 | } |
| 7482 | } |
| 7483 | |
| 7484 | if (getExtensions().pathRendering) |
| 7485 | { |
| 7486 | switch (pname) |
| 7487 | { |
| 7488 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7489 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7490 | *type = GL_FLOAT; |
| 7491 | *numParams = 16; |
| 7492 | return true; |
| 7493 | } |
| 7494 | } |
| 7495 | |
| 7496 | if (getExtensions().bindGeneratesResource) |
| 7497 | { |
| 7498 | switch (pname) |
| 7499 | { |
| 7500 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7501 | *type = GL_BOOL; |
| 7502 | *numParams = 1; |
| 7503 | return true; |
| 7504 | } |
| 7505 | } |
| 7506 | |
| 7507 | if (getExtensions().clientArrays) |
| 7508 | { |
| 7509 | switch (pname) |
| 7510 | { |
| 7511 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7512 | *type = GL_BOOL; |
| 7513 | *numParams = 1; |
| 7514 | return true; |
| 7515 | } |
| 7516 | } |
| 7517 | |
| 7518 | if (getExtensions().sRGBWriteControl) |
| 7519 | { |
| 7520 | switch (pname) |
| 7521 | { |
| 7522 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7523 | *type = GL_BOOL; |
| 7524 | *numParams = 1; |
| 7525 | return true; |
| 7526 | } |
| 7527 | } |
| 7528 | |
| 7529 | if (getExtensions().robustResourceInitialization && |
| 7530 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7531 | { |
| 7532 | *type = GL_BOOL; |
| 7533 | *numParams = 1; |
| 7534 | return true; |
| 7535 | } |
| 7536 | |
| 7537 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7538 | { |
| 7539 | *type = GL_BOOL; |
| 7540 | *numParams = 1; |
| 7541 | return true; |
| 7542 | } |
| 7543 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7544 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7545 | { |
| 7546 | *type = GL_INT; |
| 7547 | *numParams = 1; |
| 7548 | return true; |
| 7549 | } |
| 7550 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7551 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7552 | { |
| 7553 | *type = GL_INT; |
| 7554 | *numParams = 1; |
| 7555 | return true; |
| 7556 | } |
| 7557 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7558 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7559 | switch (pname) |
| 7560 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7561 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7562 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7563 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7564 | { |
| 7565 | return false; |
| 7566 | } |
| 7567 | *type = GL_INT; |
| 7568 | *numParams = 1; |
| 7569 | return true; |
| 7570 | |
| 7571 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7572 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7573 | { |
| 7574 | return false; |
| 7575 | } |
| 7576 | *type = GL_INT; |
| 7577 | *numParams = 1; |
| 7578 | return true; |
| 7579 | |
| 7580 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7581 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7582 | { |
| 7583 | return false; |
| 7584 | } |
| 7585 | *type = GL_INT; |
| 7586 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7587 | return true; |
| 7588 | |
| 7589 | case GL_PACK_ROW_LENGTH: |
| 7590 | case GL_PACK_SKIP_ROWS: |
| 7591 | case GL_PACK_SKIP_PIXELS: |
| 7592 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7593 | { |
| 7594 | return false; |
| 7595 | } |
| 7596 | *type = GL_INT; |
| 7597 | *numParams = 1; |
| 7598 | return true; |
| 7599 | case GL_UNPACK_ROW_LENGTH: |
| 7600 | case GL_UNPACK_SKIP_ROWS: |
| 7601 | case GL_UNPACK_SKIP_PIXELS: |
| 7602 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7603 | { |
| 7604 | return false; |
| 7605 | } |
| 7606 | *type = GL_INT; |
| 7607 | *numParams = 1; |
| 7608 | return true; |
| 7609 | case GL_VERTEX_ARRAY_BINDING: |
| 7610 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7611 | { |
| 7612 | return false; |
| 7613 | } |
| 7614 | *type = GL_INT; |
| 7615 | *numParams = 1; |
| 7616 | return true; |
| 7617 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7618 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7619 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7620 | { |
| 7621 | return false; |
| 7622 | } |
| 7623 | *type = GL_INT; |
| 7624 | *numParams = 1; |
| 7625 | return true; |
| 7626 | case GL_MAX_SAMPLES: |
| 7627 | { |
| 7628 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7629 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7630 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7631 | { |
| 7632 | return false; |
| 7633 | } |
| 7634 | *type = GL_INT; |
| 7635 | *numParams = 1; |
| 7636 | return true; |
| 7637 | |
| 7638 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7639 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7640 | { |
| 7641 | return false; |
| 7642 | } |
| 7643 | *type = GL_INT; |
| 7644 | *numParams = 1; |
| 7645 | return true; |
| 7646 | } |
| 7647 | } |
| 7648 | |
| 7649 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7650 | { |
| 7651 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7652 | { |
| 7653 | return false; |
| 7654 | } |
| 7655 | *type = GL_INT; |
| 7656 | *numParams = 1; |
| 7657 | return true; |
| 7658 | } |
| 7659 | |
| 7660 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7661 | { |
| 7662 | *type = GL_INT; |
| 7663 | *numParams = 1; |
| 7664 | return true; |
| 7665 | } |
| 7666 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7667 | if (getClientVersion() < Version(2, 0)) |
| 7668 | { |
| 7669 | switch (pname) |
| 7670 | { |
| 7671 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7672 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7673 | case GL_MATRIX_MODE: |
| 7674 | case GL_MAX_TEXTURE_UNITS: |
| 7675 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7676 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7677 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7678 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7679 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7680 | case GL_VERTEX_ARRAY_STRIDE: |
| 7681 | case GL_NORMAL_ARRAY_STRIDE: |
| 7682 | case GL_COLOR_ARRAY_STRIDE: |
| 7683 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7684 | case GL_VERTEX_ARRAY_SIZE: |
| 7685 | case GL_COLOR_ARRAY_SIZE: |
| 7686 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7687 | case GL_VERTEX_ARRAY_TYPE: |
| 7688 | case GL_NORMAL_ARRAY_TYPE: |
| 7689 | case GL_COLOR_ARRAY_TYPE: |
| 7690 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7691 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7692 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7693 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7694 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7695 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7696 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7697 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7698 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7699 | case GL_MODELVIEW_STACK_DEPTH: |
| 7700 | case GL_PROJECTION_STACK_DEPTH: |
| 7701 | case GL_TEXTURE_STACK_DEPTH: |
| 7702 | case GL_LOGIC_OP_MODE: |
| 7703 | case GL_BLEND_SRC: |
| 7704 | case GL_BLEND_DST: |
| 7705 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7706 | case GL_POINT_SMOOTH_HINT: |
| 7707 | case GL_LINE_SMOOTH_HINT: |
| 7708 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7709 | *type = GL_INT; |
| 7710 | *numParams = 1; |
| 7711 | return true; |
| 7712 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7713 | case GL_FOG_DENSITY: |
| 7714 | case GL_FOG_START: |
| 7715 | case GL_FOG_END: |
| 7716 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7717 | case GL_POINT_SIZE: |
| 7718 | case GL_POINT_SIZE_MIN: |
| 7719 | case GL_POINT_SIZE_MAX: |
| 7720 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7721 | *type = GL_FLOAT; |
| 7722 | *numParams = 1; |
| 7723 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7724 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7725 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7726 | *type = GL_FLOAT; |
| 7727 | *numParams = 2; |
| 7728 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7729 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7730 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7731 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7732 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7733 | *type = GL_FLOAT; |
| 7734 | *numParams = 4; |
| 7735 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7736 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7737 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7738 | *type = GL_FLOAT; |
| 7739 | *numParams = 3; |
| 7740 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7741 | case GL_MODELVIEW_MATRIX: |
| 7742 | case GL_PROJECTION_MATRIX: |
| 7743 | case GL_TEXTURE_MATRIX: |
| 7744 | *type = GL_FLOAT; |
| 7745 | *numParams = 16; |
| 7746 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7747 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7748 | *type = GL_BOOL; |
| 7749 | *numParams = 1; |
| 7750 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7751 | } |
| 7752 | } |
| 7753 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7754 | if (getClientVersion() < Version(3, 0)) |
| 7755 | { |
| 7756 | return false; |
| 7757 | } |
| 7758 | |
| 7759 | // Check for ES3.0+ parameter names |
| 7760 | switch (pname) |
| 7761 | { |
| 7762 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7763 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7764 | case GL_UNIFORM_BUFFER_BINDING: |
| 7765 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7766 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7767 | case GL_COPY_READ_BUFFER_BINDING: |
| 7768 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7769 | case GL_SAMPLER_BINDING: |
| 7770 | case GL_READ_BUFFER: |
| 7771 | case GL_TEXTURE_BINDING_3D: |
| 7772 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7773 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7774 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7775 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7776 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7777 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7778 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7779 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7780 | case GL_MAX_VARYING_COMPONENTS: |
| 7781 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7782 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7783 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7784 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7785 | case GL_NUM_EXTENSIONS: |
| 7786 | case GL_MAJOR_VERSION: |
| 7787 | case GL_MINOR_VERSION: |
| 7788 | case GL_MAX_ELEMENTS_INDICES: |
| 7789 | case GL_MAX_ELEMENTS_VERTICES: |
| 7790 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7791 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7792 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7793 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7794 | case GL_UNPACK_SKIP_IMAGES: |
| 7795 | { |
| 7796 | *type = GL_INT; |
| 7797 | *numParams = 1; |
| 7798 | return true; |
| 7799 | } |
| 7800 | |
| 7801 | case GL_MAX_ELEMENT_INDEX: |
| 7802 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7803 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7804 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7805 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7806 | { |
| 7807 | *type = GL_INT_64_ANGLEX; |
| 7808 | *numParams = 1; |
| 7809 | return true; |
| 7810 | } |
| 7811 | |
| 7812 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7813 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7814 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7815 | case GL_RASTERIZER_DISCARD: |
| 7816 | { |
| 7817 | *type = GL_BOOL; |
| 7818 | *numParams = 1; |
| 7819 | return true; |
| 7820 | } |
| 7821 | |
| 7822 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7823 | { |
| 7824 | *type = GL_FLOAT; |
| 7825 | *numParams = 1; |
| 7826 | return true; |
| 7827 | } |
| 7828 | } |
| 7829 | |
| 7830 | if (getExtensions().requestExtension) |
| 7831 | { |
| 7832 | switch (pname) |
| 7833 | { |
| 7834 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7835 | *type = GL_INT; |
| 7836 | *numParams = 1; |
| 7837 | return true; |
| 7838 | } |
| 7839 | } |
| 7840 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7841 | if (getExtensions().textureMultisample) |
| 7842 | { |
| 7843 | switch (pname) |
| 7844 | { |
| 7845 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7846 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7847 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7848 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7849 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7850 | *type = GL_INT; |
| 7851 | *numParams = 1; |
| 7852 | return true; |
| 7853 | } |
| 7854 | } |
| 7855 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7856 | if (getClientVersion() < Version(3, 1)) |
| 7857 | { |
| 7858 | return false; |
| 7859 | } |
| 7860 | |
| 7861 | switch (pname) |
| 7862 | { |
| 7863 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7864 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7865 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7866 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7867 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7868 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7869 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7870 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7871 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7872 | case GL_MAX_INTEGER_SAMPLES: |
| 7873 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7874 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7875 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7876 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7877 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7878 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7879 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7880 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7881 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7882 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7883 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7884 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7885 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7886 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7887 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7888 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7889 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7890 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7891 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7892 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7893 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7894 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7895 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7896 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7897 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7898 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7899 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7900 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7901 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7902 | case GL_MAX_IMAGE_UNITS: |
| 7903 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7904 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7905 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7906 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7907 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7908 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7909 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7910 | *type = GL_INT; |
| 7911 | *numParams = 1; |
| 7912 | return true; |
| 7913 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7914 | *type = GL_INT_64_ANGLEX; |
| 7915 | *numParams = 1; |
| 7916 | return true; |
| 7917 | case GL_SAMPLE_MASK: |
| 7918 | *type = GL_BOOL; |
| 7919 | *numParams = 1; |
| 7920 | return true; |
| 7921 | } |
| 7922 | |
| 7923 | if (getExtensions().geometryShader) |
| 7924 | { |
| 7925 | switch (pname) |
| 7926 | { |
| 7927 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7928 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7929 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7930 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7931 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7932 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7933 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7934 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7935 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7936 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7937 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7938 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7939 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7940 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7941 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7942 | *type = GL_INT; |
| 7943 | *numParams = 1; |
| 7944 | return true; |
| 7945 | } |
| 7946 | } |
| 7947 | |
| 7948 | return false; |
| 7949 | } |
| 7950 | |
| 7951 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7952 | { |
| 7953 | if (getClientVersion() < Version(3, 0)) |
| 7954 | { |
| 7955 | return false; |
| 7956 | } |
| 7957 | |
| 7958 | switch (target) |
| 7959 | { |
| 7960 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7961 | case GL_UNIFORM_BUFFER_BINDING: |
| 7962 | { |
| 7963 | *type = GL_INT; |
| 7964 | *numParams = 1; |
| 7965 | return true; |
| 7966 | } |
| 7967 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7968 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7969 | case GL_UNIFORM_BUFFER_START: |
| 7970 | case GL_UNIFORM_BUFFER_SIZE: |
| 7971 | { |
| 7972 | *type = GL_INT_64_ANGLEX; |
| 7973 | *numParams = 1; |
| 7974 | return true; |
| 7975 | } |
| 7976 | } |
| 7977 | |
| 7978 | if (getClientVersion() < Version(3, 1)) |
| 7979 | { |
| 7980 | return false; |
| 7981 | } |
| 7982 | |
| 7983 | switch (target) |
| 7984 | { |
| 7985 | case GL_IMAGE_BINDING_LAYERED: |
| 7986 | { |
| 7987 | *type = GL_BOOL; |
| 7988 | *numParams = 1; |
| 7989 | return true; |
| 7990 | } |
| 7991 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7992 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7993 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7994 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7995 | case GL_VERTEX_BINDING_BUFFER: |
| 7996 | case GL_VERTEX_BINDING_DIVISOR: |
| 7997 | case GL_VERTEX_BINDING_OFFSET: |
| 7998 | case GL_VERTEX_BINDING_STRIDE: |
| 7999 | case GL_SAMPLE_MASK_VALUE: |
| 8000 | case GL_IMAGE_BINDING_NAME: |
| 8001 | case GL_IMAGE_BINDING_LEVEL: |
| 8002 | case GL_IMAGE_BINDING_LAYER: |
| 8003 | case GL_IMAGE_BINDING_ACCESS: |
| 8004 | case GL_IMAGE_BINDING_FORMAT: |
| 8005 | { |
| 8006 | *type = GL_INT; |
| 8007 | *numParams = 1; |
| 8008 | return true; |
| 8009 | } |
| 8010 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 8011 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 8012 | case GL_SHADER_STORAGE_BUFFER_START: |
| 8013 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 8014 | { |
| 8015 | *type = GL_INT_64_ANGLEX; |
| 8016 | *numParams = 1; |
| 8017 | return true; |
| 8018 | } |
| 8019 | } |
| 8020 | |
| 8021 | return false; |
| 8022 | } |
| 8023 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 8024 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 8025 | { |
| 8026 | return mState.mShaderPrograms->getProgram(handle); |
| 8027 | } |
| 8028 | |
| 8029 | Shader *Context::getShader(GLuint handle) const |
| 8030 | { |
| 8031 | return mState.mShaderPrograms->getShader(handle); |
| 8032 | } |
| 8033 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 8034 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 8035 | { |
| 8036 | return mState.mRenderbuffers->isHandleGenerated(renderbuffer); |
| 8037 | } |
| 8038 | |
| 8039 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 8040 | { |
| 8041 | return mState.mFramebuffers->isHandleGenerated(framebuffer); |
| 8042 | } |
| 8043 | |
| 8044 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 8045 | { |
| 8046 | return mState.mPipelines->isHandleGenerated(pipeline); |
| 8047 | } |
| 8048 | |
| 8049 | bool Context::usingDisplayTextureShareGroup() const |
| 8050 | { |
| 8051 | return mDisplayTextureShareGroup; |
| 8052 | } |
| 8053 | |
| 8054 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 8055 | { |
| 8056 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 8057 | internalformat == GL_DEPTH_STENCIL |
| 8058 | ? GL_DEPTH24_STENCIL8 |
| 8059 | : internalformat; |
| 8060 | } |
| 8061 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8062 | void Context::maxShaderCompilerThreads(GLuint count) |
| 8063 | { |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 8064 | GLuint oldCount = mGLState.getMaxShaderCompilerThreads(); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8065 | mGLState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 8066 | // A count of zero specifies a request for no parallel compiling or linking. |
| 8067 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 8068 | { |
| 8069 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 8070 | } |
| 8071 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8072 | } |
| 8073 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 8074 | bool Context::isGLES1() const |
| 8075 | { |
| 8076 | return mState.getClientVersion() < Version(2, 0); |
| 8077 | } |
| 8078 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8079 | void Context::onSubjectStateChange(const Context *context, |
| 8080 | angle::SubjectIndex index, |
| 8081 | angle::SubjectMessage message) |
| 8082 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8083 | switch (index) |
| 8084 | { |
| 8085 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8086 | switch (message) |
| 8087 | { |
| 8088 | case angle::SubjectMessage::CONTENTS_CHANGED: |
| 8089 | mGLState.setObjectDirty(GL_VERTEX_ARRAY); |
| 8090 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 8091 | break; |
| 8092 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 8093 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 8094 | case angle::SubjectMessage::BINDING_CHANGED: |
| 8095 | mStateCache.onVertexArrayBufferStateChange(this); |
| 8096 | break; |
| 8097 | default: |
| 8098 | break; |
| 8099 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8100 | break; |
| 8101 | |
| 8102 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8103 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8104 | { |
| 8105 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
| 8106 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8107 | break; |
| 8108 | |
| 8109 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8110 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8111 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 8112 | mGLState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8113 | } |
| 8114 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8115 | break; |
| 8116 | |
| 8117 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8118 | if (index < kTextureMaxSubjectIndex) |
| 8119 | { |
| 8120 | mGLState.onActiveTextureStateChange(index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8121 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8122 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8123 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8124 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8125 | mGLState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8126 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8127 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8128 | else |
| 8129 | { |
| 8130 | ASSERT(index < kSamplerMaxSubjectIndex); |
| 8131 | mGLState.setSamplerDirty(index - kSampler0SubjectIndex); |
| 8132 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8133 | break; |
| 8134 | } |
| 8135 | } |
| 8136 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8137 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8138 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8139 | |
| 8140 | ErrorSet::~ErrorSet() = default; |
| 8141 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8142 | void ErrorSet::handleError(GLenum errorCode, |
| 8143 | const char *message, |
| 8144 | const char *file, |
| 8145 | const char *function, |
| 8146 | unsigned int line) |
| 8147 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8148 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8149 | { |
| 8150 | mContext->markContextLost(); |
| 8151 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8152 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8153 | std::stringstream errorStream; |
| 8154 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8155 | << line << ". " << message; |
| 8156 | |
| 8157 | // validationError does the necessary work to process the error. |
| 8158 | validationError(errorCode, errorStream.str().c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8159 | } |
| 8160 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8161 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8162 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8163 | ASSERT(errorCode != GL_NO_ERROR); |
| 8164 | mErrors.insert(errorCode); |
| 8165 | |
| 8166 | mContext->getGLState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8167 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8168 | } |
| 8169 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8170 | bool ErrorSet::empty() const |
| 8171 | { |
| 8172 | return mErrors.empty(); |
| 8173 | } |
| 8174 | |
| 8175 | GLenum ErrorSet::popError() |
| 8176 | { |
| 8177 | ASSERT(!empty()); |
| 8178 | GLenum error = *mErrors.begin(); |
| 8179 | mErrors.erase(mErrors.begin()); |
| 8180 | return error; |
| 8181 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8182 | |
| 8183 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8184 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8185 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8186 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8187 | mCachedInstancedVertexElementLimit(0), |
| 8188 | mCachedBasicDrawStatesError(kInvalidPointer) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8189 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8190 | |
| 8191 | StateCache::~StateCache() = default; |
| 8192 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8193 | void StateCache::initialize(Context *context) |
| 8194 | { |
| 8195 | updateValidDrawModes(context); |
| 8196 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8197 | updateValidDrawElementsTypes(context); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8198 | } |
| 8199 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8200 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8201 | { |
| 8202 | bool isGLES1 = context->isGLES1(); |
| 8203 | const State &glState = context->getGLState(); |
| 8204 | |
| 8205 | if (!isGLES1 && !glState.getProgram()) |
| 8206 | { |
| 8207 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8208 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8209 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8210 | return; |
| 8211 | } |
| 8212 | |
| 8213 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8214 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8215 | |
| 8216 | const VertexArray *vao = glState.getVertexArray(); |
| 8217 | ASSERT(vao); |
| 8218 | |
| 8219 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8220 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8221 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8222 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8223 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8224 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8225 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8226 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8227 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8228 | |
| 8229 | void StateCache::updateVertexElementLimits(Context *context) |
| 8230 | { |
| 8231 | const VertexArray *vao = context->getGLState().getVertexArray(); |
| 8232 | |
| 8233 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8234 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8235 | |
| 8236 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8237 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8238 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8239 | { |
| 8240 | return; |
| 8241 | } |
| 8242 | |
| 8243 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8244 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8245 | |
| 8246 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8247 | { |
| 8248 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
| 8249 | ASSERT(attrib.enabled); |
| 8250 | |
| 8251 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8252 | ASSERT(context->isGLES1() || |
| 8253 | context->getGLState().getProgram()->isAttribLocationActive(attributeIndex)); |
| 8254 | |
| 8255 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8256 | if (binding.getDivisor() > 0) |
| 8257 | { |
| 8258 | mCachedInstancedVertexElementLimit = |
| 8259 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8260 | } |
| 8261 | else |
| 8262 | { |
| 8263 | mCachedNonInstancedVertexElementLimit = |
| 8264 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8265 | } |
| 8266 | } |
| 8267 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8268 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8269 | void StateCache::updateBasicDrawStatesError() |
| 8270 | { |
| 8271 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8272 | } |
| 8273 | |
| 8274 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8275 | { |
| 8276 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8277 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8278 | return mCachedBasicDrawStatesError; |
| 8279 | } |
| 8280 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8281 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8282 | { |
| 8283 | updateActiveAttribsMask(context); |
| 8284 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8285 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8286 | } |
| 8287 | |
| 8288 | void StateCache::onProgramExecutableChange(Context *context) |
| 8289 | { |
| 8290 | updateActiveAttribsMask(context); |
| 8291 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8292 | updateBasicDrawStatesError(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8293 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8294 | } |
| 8295 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8296 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8297 | { |
| 8298 | updateVertexElementLimits(context); |
| 8299 | } |
| 8300 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8301 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8302 | { |
| 8303 | updateVertexElementLimits(context); |
| 8304 | updateBasicDrawStatesError(); |
| 8305 | } |
| 8306 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8307 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8308 | { |
| 8309 | updateActiveAttribsMask(context); |
| 8310 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8311 | updateBasicDrawStatesError(); |
| 8312 | } |
| 8313 | |
| 8314 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8315 | { |
| 8316 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8317 | } |
| 8318 | |
| 8319 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8320 | { |
| 8321 | updateActiveAttribsMask(context); |
| 8322 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8323 | |
| 8324 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8325 | { |
| 8326 | updateBasicDrawStatesError(); |
| 8327 | } |
| 8328 | |
| 8329 | void StateCache::onContextCapChange(Context *context) |
| 8330 | { |
| 8331 | updateBasicDrawStatesError(); |
| 8332 | } |
| 8333 | |
| 8334 | void StateCache::onStencilStateChange(Context *context) |
| 8335 | { |
| 8336 | updateBasicDrawStatesError(); |
| 8337 | } |
| 8338 | |
| 8339 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8340 | { |
| 8341 | updateBasicDrawStatesError(); |
| 8342 | } |
| 8343 | |
| 8344 | void StateCache::onActiveTextureChange(Context *context) |
| 8345 | { |
| 8346 | updateBasicDrawStatesError(); |
| 8347 | } |
| 8348 | |
| 8349 | void StateCache::onQueryChange(Context *context) |
| 8350 | { |
| 8351 | updateBasicDrawStatesError(); |
| 8352 | } |
| 8353 | |
| 8354 | void StateCache::onTransformFeedbackChange(Context *context) |
| 8355 | { |
| 8356 | updateBasicDrawStatesError(); |
| 8357 | } |
| 8358 | |
| 8359 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8360 | { |
| 8361 | updateBasicDrawStatesError(); |
| 8362 | } |
| 8363 | |
| 8364 | void StateCache::onBufferBindingChange(Context *context) |
| 8365 | { |
| 8366 | updateBasicDrawStatesError(); |
| 8367 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8368 | |
| 8369 | void StateCache::updateValidDrawModes(Context *context) |
| 8370 | { |
| 8371 | Program *program = context->getGLState().getProgram(); |
| 8372 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8373 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8374 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8375 | } |
| 8376 | else |
| 8377 | { |
| 8378 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8379 | |
| 8380 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
| 8381 | |
| 8382 | mCachedValidDrawModes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8383 | {PrimitiveMode::Points, gsMode == PrimitiveMode::Points}, |
| 8384 | {PrimitiveMode::Lines, gsMode == PrimitiveMode::Lines}, |
| 8385 | {PrimitiveMode::LineLoop, gsMode == PrimitiveMode::Lines}, |
| 8386 | {PrimitiveMode::LineStrip, gsMode == PrimitiveMode::Lines}, |
| 8387 | {PrimitiveMode::Triangles, gsMode == PrimitiveMode::Triangles}, |
| 8388 | {PrimitiveMode::TriangleStrip, gsMode == PrimitiveMode::Triangles}, |
| 8389 | {PrimitiveMode::TriangleFan, gsMode == PrimitiveMode::Triangles}, |
| 8390 | {PrimitiveMode::LinesAdjacency, gsMode == PrimitiveMode::LinesAdjacency}, |
| 8391 | {PrimitiveMode::LineStripAdjacency, gsMode == PrimitiveMode::LinesAdjacency}, |
| 8392 | {PrimitiveMode::TrianglesAdjacency, gsMode == PrimitiveMode::TrianglesAdjacency}, |
| 8393 | {PrimitiveMode::TriangleStripAdjacency, gsMode == PrimitiveMode::TrianglesAdjacency}, |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8394 | }}; |
| 8395 | } |
| 8396 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8397 | |
| 8398 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8399 | { |
| 8400 | const Extensions &exts = context->getExtensions(); |
| 8401 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8402 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8403 | |
| 8404 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8405 | {TextureType::_2D, true}, |
| 8406 | {TextureType::_2DArray, isGLES3}, |
| 8407 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8408 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8409 | {TextureType::_3D, isGLES3}, |
| 8410 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8411 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8412 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8413 | }}; |
| 8414 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8415 | |
| 8416 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8417 | { |
| 8418 | bool supportsUint = |
| 8419 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8420 | |
| 8421 | mCachedValidDrawElementsTypes = {{ |
| 8422 | {DrawElementsType::UnsignedByte, true}, |
| 8423 | {DrawElementsType::UnsignedShort, true}, |
| 8424 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8425 | }}; |
| 8426 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8427 | } // namespace gl |