apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | eeba6e1 | 2014-02-03 13:12:30 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Context.cpp: Implements the gl::Context class, managing all GL state and performing |
| 8 | // rendering operations. It is the GLES2 specific implementation of EGLContext. |
| 9 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 10 | #include "libANGLE/Context.h" |
Markus Tavenrath | cb9609f | 2018-12-26 00:52:44 +0900 | [diff] [blame^] | 11 | #include "libANGLE/Context.inl.h" |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 12 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 13 | #include <string.h> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 14 | #include <iterator> |
| 15 | #include <sstream> |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 16 | #include <vector> |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 17 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 18 | #include "common/PackedEnums.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 19 | #include "common/matrix_utils.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 20 | #include "common/platform.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 21 | #include "common/utilities.h" |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 22 | #include "common/version.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 23 | #include "libANGLE/Buffer.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 24 | #include "libANGLE/Compiler.h" |
Jamie Madill | 948bbe5 | 2017-06-01 13:10:42 -0400 | [diff] [blame] | 25 | #include "libANGLE/Display.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 26 | #include "libANGLE/Fence.h" |
| 27 | #include "libANGLE/Framebuffer.h" |
| 28 | #include "libANGLE/FramebufferAttachment.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 29 | #include "libANGLE/Path.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 30 | #include "libANGLE/Program.h" |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 31 | #include "libANGLE/ProgramPipeline.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 32 | #include "libANGLE/Query.h" |
Jamie Madill | b929397 | 2015-02-19 11:07:54 -0500 | [diff] [blame] | 33 | #include "libANGLE/Renderbuffer.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 34 | #include "libANGLE/ResourceManager.h" |
| 35 | #include "libANGLE/Sampler.h" |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 36 | #include "libANGLE/Surface.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 37 | #include "libANGLE/Texture.h" |
| 38 | #include "libANGLE/TransformFeedback.h" |
| 39 | #include "libANGLE/VertexArray.h" |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 40 | #include "libANGLE/Workarounds.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 41 | #include "libANGLE/formatutils.h" |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 42 | #include "libANGLE/queryconversions.h" |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 43 | #include "libANGLE/queryutils.h" |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 44 | #include "libANGLE/renderer/BufferImpl.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 45 | #include "libANGLE/renderer/EGLImplFactory.h" |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 46 | #include "libANGLE/renderer/Format.h" |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 47 | #include "libANGLE/validationES.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 48 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 49 | namespace gl |
| 50 | { |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 51 | namespace |
| 52 | { |
| 53 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 54 | #define ANGLE_HANDLE_ERR(X) \ |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 55 | (void)(X); \ |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 56 | return; |
| 57 | #define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR); |
| 58 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 59 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 60 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 61 | GLsizei numPaths, |
| 62 | const void *paths, |
| 63 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 64 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 65 | std::vector<Path *> ret; |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 66 | ret.reserve(numPaths); |
| 67 | |
| 68 | const auto *nameArray = static_cast<const T *>(paths); |
| 69 | |
| 70 | for (GLsizei i = 0; i < numPaths; ++i) |
| 71 | { |
| 72 | const GLuint pathName = nameArray[i] + pathBase; |
| 73 | |
| 74 | ret.push_back(resourceManager.getPath(pathName)); |
| 75 | } |
| 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 80 | std::vector<Path *> GatherPaths(PathManager &resourceManager, |
| 81 | GLsizei numPaths, |
| 82 | GLenum pathNameType, |
| 83 | const void *paths, |
| 84 | GLuint pathBase) |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 85 | { |
| 86 | switch (pathNameType) |
| 87 | { |
| 88 | case GL_UNSIGNED_BYTE: |
| 89 | return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase); |
| 90 | |
| 91 | case GL_BYTE: |
| 92 | return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase); |
| 93 | |
| 94 | case GL_UNSIGNED_SHORT: |
| 95 | return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase); |
| 96 | |
| 97 | case GL_SHORT: |
| 98 | return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase); |
| 99 | |
| 100 | case GL_UNSIGNED_INT: |
| 101 | return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase); |
| 102 | |
| 103 | case GL_INT: |
| 104 | return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase); |
| 105 | } |
| 106 | |
| 107 | UNREACHABLE(); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 108 | return std::vector<Path *>(); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | template <typename T> |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 112 | angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 113 | { |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 114 | ASSERT(query != nullptr); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 115 | |
| 116 | switch (pname) |
| 117 | { |
| 118 | case GL_QUERY_RESULT_EXT: |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 119 | return query->getResult(context, params); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 120 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 121 | { |
| 122 | bool available; |
Jamie Madill | 666818e | 2018-11-14 09:54:33 -0500 | [diff] [blame] | 123 | ANGLE_TRY(query->isResultAvailable(context, &available)); |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 124 | *params = CastFromStateValue<T>(pname, static_cast<GLuint>(available)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 125 | return angle::Result::Continue; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 126 | } |
| 127 | default: |
| 128 | UNREACHABLE(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 129 | return angle::Result::Stop; |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 133 | ANGLE_INLINE void MarkTransformFeedbackBufferUsage(const Context *context, |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 134 | GLsizei count, |
| 135 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 136 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 137 | if (context->getStateCache().isTransformFeedbackActiveUnpaused()) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 138 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 139 | TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 140 | transformFeedback->onVerticesDrawn(context, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 141 | } |
| 142 | } |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 143 | |
| 144 | // Attribute map queries. |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 145 | EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 146 | { |
Ian Ewell | ec2c0c5 | 2016-04-05 13:46:26 -0400 | [diff] [blame] | 147 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1)); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 148 | } |
| 149 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 150 | EGLint GetClientMinorVersion(const egl::AttributeMap &attribs) |
| 151 | { |
| 152 | return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0)); |
| 153 | } |
| 154 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 155 | Version GetClientVersion(const egl::AttributeMap &attribs) |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 156 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 157 | return Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs)); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 158 | } |
| 159 | |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 160 | GLenum GetResetStrategy(const egl::AttributeMap &attribs) |
| 161 | { |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 162 | EGLAttrib attrib = |
| 163 | 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] | 164 | switch (attrib) |
| 165 | { |
| 166 | case EGL_NO_RESET_NOTIFICATION: |
| 167 | return GL_NO_RESET_NOTIFICATION_EXT; |
| 168 | case EGL_LOSE_CONTEXT_ON_RESET: |
| 169 | return GL_LOSE_CONTEXT_ON_RESET_EXT; |
| 170 | default: |
| 171 | UNREACHABLE(); |
| 172 | return GL_NONE; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | bool GetRobustAccess(const egl::AttributeMap &attribs) |
| 177 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 178 | return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) || |
| 179 | ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != |
| 180 | 0); |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | bool GetDebug(const egl::AttributeMap &attribs) |
| 184 | { |
Geoff Lang | 077f20a | 2016-11-01 10:08:02 -0400 | [diff] [blame] | 185 | return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) || |
| 186 | ((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] | 187 | } |
| 188 | |
| 189 | bool GetNoError(const egl::AttributeMap &attribs) |
| 190 | { |
| 191 | return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE); |
| 192 | } |
| 193 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 194 | bool GetWebGLContext(const egl::AttributeMap &attribs) |
| 195 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 196 | return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 197 | } |
| 198 | |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 199 | bool GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext) |
| 200 | { |
| 201 | // If the context is WebGL, extensions are disabled by default |
| 202 | EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE; |
| 203 | return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE); |
| 204 | } |
| 205 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 206 | bool GetBindGeneratesResource(const egl::AttributeMap &attribs) |
| 207 | { |
Jamie Madill | 4230d48 | 2018-09-14 10:14:45 -0400 | [diff] [blame] | 208 | 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] | 209 | } |
| 210 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 211 | bool GetClientArraysEnabled(const egl::AttributeMap &attribs) |
| 212 | { |
| 213 | return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE); |
| 214 | } |
| 215 | |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 216 | bool GetRobustResourceInit(const egl::AttributeMap &attribs) |
| 217 | { |
| 218 | return (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE); |
| 219 | } |
| 220 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 221 | std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label) |
| 222 | { |
| 223 | std::string labelName; |
| 224 | if (label != nullptr) |
| 225 | { |
| 226 | size_t labelLength = length < 0 ? strlen(label) : length; |
| 227 | labelName = std::string(label, labelLength); |
| 228 | } |
| 229 | return labelName; |
| 230 | } |
| 231 | |
| 232 | void GetObjectLabelBase(const std::string &objectLabel, |
| 233 | GLsizei bufSize, |
| 234 | GLsizei *length, |
| 235 | GLchar *label) |
| 236 | { |
| 237 | size_t writeLength = objectLabel.length(); |
| 238 | if (label != nullptr && bufSize > 0) |
| 239 | { |
| 240 | writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length()); |
| 241 | std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label); |
| 242 | label[writeLength] = '\0'; |
| 243 | } |
| 244 | |
| 245 | if (length != nullptr) |
| 246 | { |
| 247 | *length = static_cast<GLsizei>(writeLength); |
| 248 | } |
| 249 | } |
| 250 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 251 | template <typename CapT, typename MaxT> |
| 252 | void LimitCap(CapT *cap, MaxT maximum) |
| 253 | { |
| 254 | *cap = std::min(*cap, static_cast<CapT>(maximum)); |
| 255 | } |
| 256 | |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 257 | constexpr angle::PackedEnumMap<PrimitiveMode, GLsizei> kMinimumPrimitiveCounts = {{ |
| 258 | {PrimitiveMode::Points, 1}, |
| 259 | {PrimitiveMode::Lines, 2}, |
| 260 | {PrimitiveMode::LineLoop, 2}, |
| 261 | {PrimitiveMode::LineStrip, 2}, |
| 262 | {PrimitiveMode::Triangles, 3}, |
| 263 | {PrimitiveMode::TriangleStrip, 3}, |
| 264 | {PrimitiveMode::TriangleFan, 3}, |
| 265 | {PrimitiveMode::LinesAdjacency, 2}, |
| 266 | {PrimitiveMode::LineStripAdjacency, 2}, |
| 267 | {PrimitiveMode::TrianglesAdjacency, 3}, |
| 268 | {PrimitiveMode::TriangleStripAdjacency, 3}, |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 269 | }}; |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 270 | |
| 271 | // The rest default to false. |
| 272 | constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMode>() + 1> |
| 273 | kValidBasicDrawModes = {{ |
| 274 | {PrimitiveMode::Points, true}, |
| 275 | {PrimitiveMode::Lines, true}, |
| 276 | {PrimitiveMode::LineLoop, true}, |
| 277 | {PrimitiveMode::LineStrip, true}, |
| 278 | {PrimitiveMode::Triangles, true}, |
| 279 | {PrimitiveMode::TriangleStrip, true}, |
| 280 | {PrimitiveMode::TriangleFan, true}, |
| 281 | }}; |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 282 | |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 283 | enum SubjectIndexes : angle::SubjectIndex |
| 284 | { |
| 285 | kTexture0SubjectIndex = 0, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 286 | kTextureMaxSubjectIndex = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
| 287 | kImage0SubjectIndex = kTextureMaxSubjectIndex, |
| 288 | kImageMaxSubjectIndex = kImage0SubjectIndex + IMPLEMENTATION_MAX_IMAGE_UNITS, |
| 289 | kUniformBuffer0SubjectIndex = kImageMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 290 | kUniformBufferMaxSubjectIndex = |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 291 | kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 292 | kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex, |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 293 | kSamplerMaxSubjectIndex = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES, |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 294 | kVertexArraySubjectIndex = kSamplerMaxSubjectIndex, |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 295 | kReadFramebufferSubjectIndex, |
| 296 | kDrawFramebufferSubjectIndex |
| 297 | }; |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 298 | } // anonymous namespace |
| 299 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 300 | Context::Context(rx::EGLImplFactory *implFactory, |
| 301 | const egl::Config *config, |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 302 | const Context *shareContext, |
Geoff Lang | ce02f08 | 2017-02-06 16:46:21 -0500 | [diff] [blame] | 303 | TextureManager *shareTextures, |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 304 | MemoryProgramCache *memoryProgramCache, |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 305 | const egl::AttributeMap &attribs, |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 306 | const egl::DisplayExtensions &displayExtensions, |
| 307 | const egl::ClientExtensions &clientExtensions) |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 308 | : mState(reinterpret_cast<ContextID>(this), |
| 309 | shareContext ? &shareContext->mState : nullptr, |
| 310 | shareTextures, |
| 311 | GetClientVersion(attribs), |
| 312 | &mGLState, |
| 313 | mCaps, |
| 314 | mTextureCaps, |
| 315 | mExtensions, |
| 316 | mLimitations), |
| 317 | mSkipValidation(GetNoError(attribs)), |
| 318 | mDisplayTextureShareGroup(shareTextures != nullptr), |
Geoff Lang | 3cacf69 | 2018-06-20 16:49:57 -0400 | [diff] [blame] | 319 | mImplementation(implFactory->createContext(mState, config, shareContext, attribs)), |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 320 | mLabel(nullptr), |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 321 | mCompiler(), |
Geoff Lang | 4fb8a8b | 2018-06-01 16:47:57 -0400 | [diff] [blame] | 322 | mGLState(GetDebug(attribs), |
| 323 | GetBindGeneratesResource(attribs), |
| 324 | GetClientArraysEnabled(attribs), |
| 325 | GetRobustResourceInit(attribs), |
| 326 | memoryProgramCache != nullptr), |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 327 | mConfig(config), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 328 | mClientType(EGL_OPENGL_ES_API), |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 329 | mErrors(this), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 330 | mHasBeenCurrent(false), |
| 331 | mContextLost(false), |
| 332 | mResetStatus(GL_NO_ERROR), |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 333 | mContextLostForced(false), |
Jamie Madill | 46e6c7a | 2016-01-18 14:42:30 -0500 | [diff] [blame] | 334 | mResetStrategy(GetResetStrategy(attribs)), |
| 335 | mRobustAccess(GetRobustAccess(attribs)), |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 336 | mSurfacelessSupported(displayExtensions.surfacelessContext), |
| 337 | mExplicitContextAvailable(clientExtensions.explicitContext), |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 338 | mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), |
| 339 | mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 340 | mWebGLContext(GetWebGLContext(attribs)), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 341 | mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)), |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 342 | mMemoryProgramCache(memoryProgramCache), |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 343 | mVertexArrayObserverBinding(this, kVertexArraySubjectIndex), |
| 344 | mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex), |
| 345 | mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex), |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 346 | mScratchBuffer(1000u), |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 347 | mZeroFilledBuffer(1000u), |
| 348 | mThreadPool(nullptr) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 349 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 350 | for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; |
| 351 | uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) |
| 352 | { |
| 353 | mUniformBufferObserverBindings.emplace_back(this, uboIndex); |
| 354 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 355 | |
| 356 | for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex; |
| 357 | samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex) |
| 358 | { |
| 359 | mSamplerObserverBindings.emplace_back(this, samplerIndex); |
| 360 | } |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 361 | |
| 362 | for (angle::SubjectIndex imageIndex = kImage0SubjectIndex; imageIndex < kImageMaxSubjectIndex; |
| 363 | ++imageIndex) |
| 364 | { |
| 365 | mImageObserverBindings.emplace_back(this, imageIndex); |
| 366 | } |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 367 | } |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 368 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 369 | void Context::initialize() |
| 370 | { |
| 371 | mImplementation->setMemoryProgramCache(mMemoryProgramCache); |
Jamie Madill | 14bbb3f | 2017-09-12 15:23:01 -0400 | [diff] [blame] | 372 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 373 | initCaps(); |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 374 | initWorkarounds(); |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 375 | |
Geoff Lang | 4fb8a8b | 2018-06-01 16:47:57 -0400 | [diff] [blame] | 376 | mGLState.initialize(this); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 377 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 378 | mFenceNVHandleAllocator.setBaseHandle(0); |
Geoff Lang | 7dca186 | 2013-07-30 16:30:46 -0400 | [diff] [blame] | 379 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 380 | // [OpenGL ES 2.0.24] section 3.7 page 83: |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 381 | // 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] | 382 | // and cube map texture state vectors respectively associated with them. |
| 383 | // In order that access to these initial textures not be lost, they are treated as texture |
| 384 | // objects all of whose names are 0. |
| 385 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 386 | Texture *zeroTexture2D = new Texture(mImplementation.get(), 0, TextureType::_2D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 387 | mZeroTextures[TextureType::_2D].set(this, zeroTexture2D); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 388 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 389 | Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, TextureType::CubeMap); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 390 | mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 391 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 392 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 393 | { |
| 394 | // TODO: These could also be enabled via extension |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 395 | Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, TextureType::_3D); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 396 | mZeroTextures[TextureType::_3D].set(this, zeroTexture3D); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 397 | |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 398 | Texture *zeroTexture2DArray = new Texture(mImplementation.get(), 0, TextureType::_2DArray); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 399 | mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 400 | } |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 401 | if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample) |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 402 | { |
| 403 | Texture *zeroTexture2DMultisample = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 404 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisample); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 405 | mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample); |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 406 | } |
| 407 | if (getClientVersion() >= Version(3, 1)) |
| 408 | { |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 409 | Texture *zeroTexture2DMultisampleArray = |
| 410 | new Texture(mImplementation.get(), 0, TextureType::_2DMultisampleArray); |
| 411 | mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 412 | |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 413 | for (unsigned int i = 0; i < mCaps.maxAtomicCounterBufferBindings; i++) |
| 414 | { |
Qin Jiajia | 339f65b | 2018-02-27 12:52:48 +0800 | [diff] [blame] | 415 | bindBufferRange(BufferBinding::AtomicCounter, i, 0, 0, 0); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 416 | } |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 417 | |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 418 | for (unsigned int i = 0; i < mCaps.maxShaderStorageBufferBindings; i++) |
| 419 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 420 | bindBufferRange(BufferBinding::ShaderStorage, i, 0, 0, 0); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 421 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 422 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 423 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 424 | if (mSupportedExtensions.textureRectangle) |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 425 | { |
| 426 | Texture *zeroTextureRectangle = |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 427 | new Texture(mImplementation.get(), 0, TextureType::Rectangle); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 428 | mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle); |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 429 | } |
| 430 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 431 | if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal) |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 432 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 433 | Texture *zeroTextureExternal = new Texture(mImplementation.get(), 0, TextureType::External); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 434 | mZeroTextures[TextureType::External].set(this, zeroTextureExternal); |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 435 | } |
| 436 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 437 | mGLState.initializeZeroTextures(this, mZeroTextures); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 438 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 439 | bindVertexArray(0); |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 440 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 441 | if (getClientVersion() >= Version(3, 0)) |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 442 | { |
| 443 | // [OpenGL ES 3.0.2] section 2.14.1 pg 85: |
| 444 | // In the initial state, a default transform feedback object is bound and treated as |
| 445 | // a transform feedback object with a name of zero. That object is bound any time |
| 446 | // BindTransformFeedback is called with id of zero |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 447 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Geoff Lang | 1a68346 | 2015-09-29 15:09:59 -0400 | [diff] [blame] | 448 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 449 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 450 | for (auto type : angle::AllEnums<BufferBinding>()) |
| 451 | { |
| 452 | bindBuffer(type, 0); |
| 453 | } |
| 454 | |
| 455 | bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 456 | |
| 457 | for (unsigned int i = 0; i < mCaps.maxUniformBufferBindings; i++) |
| 458 | { |
| 459 | bindBufferRange(BufferBinding::Uniform, i, 0, 0, -1); |
| 460 | } |
| 461 | |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 462 | // Initialize GLES1 renderer if appropriate. |
| 463 | if (getClientVersion() < Version(2, 0)) |
| 464 | { |
| 465 | mGLES1Renderer.reset(new GLES1Renderer()); |
| 466 | } |
| 467 | |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 468 | // Initialize dirty bit masks |
Jamie Madill | 9d0bb3d | 2018-10-09 20:29:13 -0400 | [diff] [blame] | 469 | mAllDirtyBits.set(); |
| 470 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 471 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 472 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 473 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 474 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 475 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 476 | |
| 477 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 478 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 479 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 480 | mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 481 | |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 482 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 483 | mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 484 | // No dirty objects. |
| 485 | |
| 486 | // Readpixels uses the pack state and read FBO |
Jamie Madill | c67323a | 2017-11-02 23:11:41 -0400 | [diff] [blame] | 487 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE); |
Corentin Wallez | 29a2099 | 2017-11-06 18:23:16 -0500 | [diff] [blame] | 488 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 489 | mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 490 | mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 491 | |
| 492 | mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
| 493 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 494 | mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
| 495 | mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT); |
| 496 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR); |
| 497 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH); |
| 498 | mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL); |
| 499 | mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK); |
| 500 | mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK); |
| 501 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
| 502 | mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 503 | mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 504 | mClearDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 505 | |
| 506 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED); |
| 507 | mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 508 | mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB); |
Luc Ferron | af7dc01 | 2018-06-26 07:56:49 -0400 | [diff] [blame] | 509 | mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 510 | mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 511 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 512 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 513 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 514 | mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 515 | mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS); |
| 516 | mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 517 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING); |
| 518 | mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 519 | mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS); |
| 520 | mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS); |
jchen10 | 99118c1 | 2018-09-10 16:28:51 +0800 | [diff] [blame] | 521 | mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS); |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 522 | mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 523 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 524 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 525 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS); |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 526 | |
Jamie Madill | b4927eb | 2018-07-16 11:39:46 -0400 | [diff] [blame] | 527 | mImplementation->setErrorSet(&mErrors); |
| 528 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 529 | ANGLE_CONTEXT_TRY(mImplementation->initialize()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 530 | } |
| 531 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 532 | egl::Error Context::onDestroy(const egl::Display *display) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 533 | { |
Lingfeng Yang | 461b09a | 2018-04-23 09:02:09 -0700 | [diff] [blame] | 534 | if (mGLES1Renderer) |
| 535 | { |
| 536 | mGLES1Renderer->onDestroy(this, &mGLState); |
| 537 | } |
| 538 | |
Jamie Madill | e7b3fe2 | 2018-04-05 09:42:46 -0400 | [diff] [blame] | 539 | ANGLE_TRY(releaseSurface(display)); |
| 540 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 541 | for (auto fence : mFenceNVMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 542 | { |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 543 | SafeDelete(fence.second); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 544 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 545 | mFenceNVMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 546 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 547 | for (auto query : mQueryMap) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 548 | { |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 549 | if (query.second != nullptr) |
| 550 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 551 | query.second->release(this); |
Geoff Lang | f0aa842 | 2015-09-29 15:08:34 -0400 | [diff] [blame] | 552 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 553 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 554 | mQueryMap.clear(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 555 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 556 | for (auto vertexArray : mVertexArrayMap) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 557 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 558 | if (vertexArray.second) |
| 559 | { |
| 560 | vertexArray.second->onDestroy(this); |
| 561 | } |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 562 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 563 | mVertexArrayMap.clear(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 564 | |
Corentin Wallez | 80b2411 | 2015-08-25 16:41:57 -0400 | [diff] [blame] | 565 | for (auto transformFeedback : mTransformFeedbackMap) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 566 | { |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 567 | if (transformFeedback.second != nullptr) |
| 568 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 569 | transformFeedback.second->release(this); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 570 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 571 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 572 | mTransformFeedbackMap.clear(); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 573 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 574 | for (BindingPointer<Texture> &zeroTexture : mZeroTextures) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 575 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 576 | if (zeroTexture.get() != nullptr) |
| 577 | { |
Jamie Madill | 1c7f08c | 2018-10-10 16:13:02 -0400 | [diff] [blame] | 578 | zeroTexture->onDestroy(this); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 579 | zeroTexture.set(this, nullptr); |
| 580 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 581 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 582 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 583 | releaseShaderCompiler(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 584 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 585 | mGLState.reset(this); |
| 586 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 587 | mState.mBuffers->release(this); |
| 588 | mState.mShaderPrograms->release(this); |
| 589 | mState.mTextures->release(this); |
| 590 | mState.mRenderbuffers->release(this); |
| 591 | mState.mSamplers->release(this); |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 592 | mState.mSyncs->release(this); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 593 | mState.mPaths->release(this); |
| 594 | mState.mFramebuffers->release(this); |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 595 | mState.mPipelines->release(this); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 596 | |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 597 | mThreadPool.reset(); |
| 598 | |
Jamie Madill | 76e471e | 2017-10-21 09:56:01 -0400 | [diff] [blame] | 599 | mImplementation->onDestroy(this); |
| 600 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 601 | return egl::NoError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 602 | } |
| 603 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 604 | Context::~Context() {} |
Jamie Madill | 70ee0f6 | 2017-02-06 16:04:20 -0500 | [diff] [blame] | 605 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 606 | void Context::setLabel(EGLLabelKHR label) |
| 607 | { |
| 608 | mLabel = label; |
| 609 | } |
| 610 | |
| 611 | EGLLabelKHR Context::getLabel() const |
| 612 | { |
| 613 | return mLabel; |
| 614 | } |
| 615 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 616 | egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 617 | { |
Jamie Madill | 61e16b4 | 2017-06-19 11:13:23 -0400 | [diff] [blame] | 618 | mCurrentDisplay = display; |
| 619 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 620 | if (!mHasBeenCurrent) |
| 621 | { |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 622 | initialize(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 623 | initRendererString(); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 624 | initVersionStrings(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 625 | initExtensionStrings(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 626 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 627 | int width = 0; |
| 628 | int height = 0; |
| 629 | if (surface != nullptr) |
| 630 | { |
| 631 | width = surface->getWidth(); |
| 632 | height = surface->getHeight(); |
| 633 | } |
| 634 | |
| 635 | mGLState.setViewportParams(0, 0, width, height); |
| 636 | mGLState.setScissorParams(0, 0, width, height); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 637 | |
| 638 | mHasBeenCurrent = true; |
| 639 | } |
| 640 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 641 | // TODO(jmadill): Rework this when we support ContextImpl |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 642 | mGLState.setAllDirtyBits(); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 643 | mGLState.setAllDirtyObjects(); |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 644 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 645 | ANGLE_TRY(releaseSurface(display)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 646 | |
| 647 | Framebuffer *newDefault = nullptr; |
| 648 | if (surface != nullptr) |
| 649 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 650 | ANGLE_TRY(surface->setIsCurrent(this, true)); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 651 | mCurrentSurface = surface; |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 652 | newDefault = surface->createDefaultFramebuffer(this); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 653 | } |
| 654 | else |
| 655 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 656 | newDefault = new Framebuffer(mImplementation.get()); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 657 | } |
Jamie Madill | 18fdcbc | 2015-08-19 18:12:44 +0000 | [diff] [blame] | 658 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 659 | // Update default framebuffer, the binding of the previous default |
| 660 | // framebuffer (or lack of) will have a nullptr. |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 661 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 662 | mState.mFramebuffers->setDefaultFramebuffer(newDefault); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 663 | if (mGLState.getReadFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 664 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 665 | bindReadFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 666 | } |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 667 | if (mGLState.getDrawFramebuffer() == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 668 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 669 | bindDrawFramebuffer(0); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 670 | } |
Jamie Madill | c1c1cdc | 2015-04-30 09:42:26 -0400 | [diff] [blame] | 671 | } |
Ian Ewell | 292f005 | 2016-02-04 10:37:32 -0500 | [diff] [blame] | 672 | |
Jamie Madill | 32643ce | 2018-10-19 11:38:03 -0400 | [diff] [blame] | 673 | // Notify the renderer of a context switch. |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 674 | return angle::ResultToEGL(mImplementation->onMakeCurrent(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 675 | } |
| 676 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 677 | egl::Error Context::releaseSurface(const egl::Display *display) |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 678 | { |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 679 | gl::Framebuffer *defaultFramebuffer = mState.mFramebuffers->getFramebuffer(0); |
Corentin Wallez | 51706ea | 2015-08-07 14:39:22 -0400 | [diff] [blame] | 680 | |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 681 | // Remove the default framebuffer |
| 682 | if (mGLState.getReadFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 683 | { |
| 684 | mGLState.setReadFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 685 | mReadFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 686 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 687 | |
| 688 | if (mGLState.getDrawFramebuffer() == defaultFramebuffer) |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 689 | { |
| 690 | mGLState.setDrawFramebufferBinding(nullptr); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 691 | mDrawFramebufferObserverBinding.bind(nullptr); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 692 | } |
Geoff Lang | bf7b95d | 2018-05-01 16:48:21 -0400 | [diff] [blame] | 693 | |
| 694 | if (defaultFramebuffer) |
| 695 | { |
| 696 | defaultFramebuffer->onDestroy(this); |
| 697 | delete defaultFramebuffer; |
| 698 | } |
| 699 | |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 700 | mState.mFramebuffers->setDefaultFramebuffer(nullptr); |
| 701 | |
| 702 | if (mCurrentSurface) |
| 703 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 704 | ANGLE_TRY(mCurrentSurface->setIsCurrent(this, false)); |
Corentin Wallez | c295e51 | 2017-01-27 17:47:50 -0500 | [diff] [blame] | 705 | mCurrentSurface = nullptr; |
| 706 | } |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 707 | |
| 708 | return egl::NoError(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 709 | } |
| 710 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 711 | GLuint Context::createBuffer() |
| 712 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 713 | return mState.mBuffers->createBuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | GLuint Context::createProgram() |
| 717 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 718 | return mState.mShaderPrograms->createProgram(mImplementation.get()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 721 | GLuint Context::createShader(ShaderType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 722 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 723 | return mState.mShaderPrograms->createShader(mImplementation.get(), mLimitations, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | GLuint Context::createTexture() |
| 727 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 728 | return mState.mTextures->createTexture(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | GLuint Context::createRenderbuffer() |
| 732 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 733 | return mState.mRenderbuffers->createRenderbuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 736 | void Context::tryGenPaths(GLsizei range, GLuint *createdOut) |
| 737 | { |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 738 | ANGLE_CONTEXT_TRY(mState.mPaths->createPaths(this, range, createdOut)); |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 739 | } |
| 740 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 741 | GLuint Context::genPaths(GLsizei range) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 742 | { |
Jamie Madill | 1395134 | 2018-09-30 15:24:28 -0400 | [diff] [blame] | 743 | GLuint created = 0; |
| 744 | tryGenPaths(range, &created); |
| 745 | return created; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 746 | } |
| 747 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 748 | // Returns an unused framebuffer name |
| 749 | GLuint Context::createFramebuffer() |
| 750 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 751 | return mState.mFramebuffers->createFramebuffer(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 752 | } |
| 753 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 754 | void Context::genFencesNV(GLsizei n, GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 755 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 756 | for (int i = 0; i < n; i++) |
| 757 | { |
| 758 | GLuint handle = mFenceNVHandleAllocator.allocate(); |
| 759 | mFenceNVMap.assign(handle, new FenceNV(mImplementation->createFenceNV())); |
| 760 | fences[i] = handle; |
| 761 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 762 | } |
| 763 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 764 | GLuint Context::createProgramPipeline() |
| 765 | { |
| 766 | return mState.mPipelines->createProgramPipeline(); |
| 767 | } |
| 768 | |
Jiawei Shao | 385b3e0 | 2018-03-21 09:43:28 +0800 | [diff] [blame] | 769 | GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 770 | { |
| 771 | UNIMPLEMENTED(); |
| 772 | return 0u; |
| 773 | } |
| 774 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 775 | void Context::deleteBuffer(GLuint bufferName) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 776 | { |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 777 | Buffer *buffer = mState.mBuffers->getBuffer(bufferName); |
| 778 | if (buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 779 | { |
| 780 | detachBuffer(buffer); |
| 781 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 782 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 783 | mState.mBuffers->deleteObject(this, bufferName); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | void Context::deleteShader(GLuint shader) |
| 787 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 788 | mState.mShaderPrograms->deleteShader(this, shader); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | void Context::deleteProgram(GLuint program) |
| 792 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 793 | mState.mShaderPrograms->deleteProgram(this, program); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | void Context::deleteTexture(GLuint texture) |
| 797 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 798 | if (mState.mTextures->getTexture(texture)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 799 | { |
| 800 | detachTexture(texture); |
| 801 | } |
| 802 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 803 | mState.mTextures->deleteObject(this, texture); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | void Context::deleteRenderbuffer(GLuint renderbuffer) |
| 807 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 808 | if (mState.mRenderbuffers->getRenderbuffer(renderbuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 809 | { |
| 810 | detachRenderbuffer(renderbuffer); |
| 811 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 812 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 813 | mState.mRenderbuffers->deleteObject(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 816 | void Context::deleteSync(GLsync sync) |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 817 | { |
| 818 | // The spec specifies the underlying Fence object is not deleted until all current |
| 819 | // wait commands finish. However, since the name becomes invalid, we cannot query the fence, |
| 820 | // and since our API is currently designed for being called from a single thread, we can delete |
| 821 | // the fence immediately. |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 822 | mState.mSyncs->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 823 | } |
| 824 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 825 | void Context::deleteProgramPipeline(GLuint pipeline) |
| 826 | { |
| 827 | if (mState.mPipelines->getProgramPipeline(pipeline)) |
| 828 | { |
| 829 | detachProgramPipeline(pipeline); |
| 830 | } |
| 831 | |
| 832 | mState.mPipelines->deleteObject(this, pipeline); |
| 833 | } |
| 834 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 835 | void Context::deletePaths(GLuint first, GLsizei range) |
| 836 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 837 | mState.mPaths->deletePaths(first, range); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 838 | } |
| 839 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 840 | bool Context::isPath(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 841 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 842 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 843 | if (pathObj == nullptr) |
| 844 | return false; |
| 845 | |
| 846 | return pathObj->hasPathData(); |
| 847 | } |
| 848 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 849 | bool Context::isPathGenerated(GLuint path) const |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 850 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 851 | return mState.mPaths->hasPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 852 | } |
| 853 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 854 | void Context::pathCommands(GLuint path, |
| 855 | GLsizei numCommands, |
| 856 | const GLubyte *commands, |
| 857 | GLsizei numCoords, |
| 858 | GLenum coordType, |
| 859 | const void *coords) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 860 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 861 | auto *pathObject = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 862 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 863 | ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords)); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 864 | } |
| 865 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 866 | void Context::pathParameterf(GLuint path, GLenum pname, GLfloat value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 867 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 868 | Path *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 869 | |
| 870 | switch (pname) |
| 871 | { |
| 872 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 873 | pathObj->setStrokeWidth(value); |
| 874 | break; |
| 875 | case GL_PATH_END_CAPS_CHROMIUM: |
| 876 | pathObj->setEndCaps(static_cast<GLenum>(value)); |
| 877 | break; |
| 878 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 879 | pathObj->setJoinStyle(static_cast<GLenum>(value)); |
| 880 | break; |
| 881 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 882 | pathObj->setMiterLimit(value); |
| 883 | break; |
| 884 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 885 | pathObj->setStrokeBound(value); |
| 886 | break; |
| 887 | default: |
| 888 | UNREACHABLE(); |
| 889 | break; |
| 890 | } |
| 891 | } |
| 892 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 893 | void Context::pathParameteri(GLuint path, GLenum pname, GLint value) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 894 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 895 | // TODO(jmadill): Should use proper clamping/casting. |
| 896 | pathParameterf(path, pname, static_cast<GLfloat>(value)); |
| 897 | } |
| 898 | |
| 899 | void Context::getPathParameterfv(GLuint path, GLenum pname, GLfloat *value) |
| 900 | { |
| 901 | const Path *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 902 | |
| 903 | switch (pname) |
| 904 | { |
| 905 | case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 906 | *value = pathObj->getStrokeWidth(); |
| 907 | break; |
| 908 | case GL_PATH_END_CAPS_CHROMIUM: |
| 909 | *value = static_cast<GLfloat>(pathObj->getEndCaps()); |
| 910 | break; |
| 911 | case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 912 | *value = static_cast<GLfloat>(pathObj->getJoinStyle()); |
| 913 | break; |
| 914 | case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 915 | *value = pathObj->getMiterLimit(); |
| 916 | break; |
| 917 | case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 918 | *value = pathObj->getStrokeBound(); |
| 919 | break; |
| 920 | default: |
| 921 | UNREACHABLE(); |
| 922 | break; |
| 923 | } |
| 924 | } |
| 925 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 926 | void Context::getPathParameteriv(GLuint path, GLenum pname, GLint *value) |
| 927 | { |
| 928 | GLfloat val = 0.0f; |
| 929 | getPathParameterfv(path, pname, value != nullptr ? &val : nullptr); |
| 930 | if (value) |
| 931 | *value = static_cast<GLint>(val); |
| 932 | } |
| 933 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 934 | void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 935 | { |
| 936 | mGLState.setPathStencilFunc(func, ref, mask); |
| 937 | } |
| 938 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 939 | void Context::deleteFramebuffer(GLuint framebuffer) |
| 940 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 941 | if (mState.mFramebuffers->getFramebuffer(framebuffer)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 942 | { |
| 943 | detachFramebuffer(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 944 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 945 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 946 | mState.mFramebuffers->deleteObject(this, framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 947 | } |
| 948 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 949 | void Context::deleteFencesNV(GLsizei n, const GLuint *fences) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 950 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 951 | for (int i = 0; i < n; i++) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 952 | { |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 953 | GLuint fence = fences[i]; |
| 954 | |
| 955 | FenceNV *fenceObject = nullptr; |
| 956 | if (mFenceNVMap.erase(fence, &fenceObject)) |
| 957 | { |
| 958 | mFenceNVHandleAllocator.release(fence); |
| 959 | delete fenceObject; |
| 960 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 964 | Buffer *Context::getBuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 965 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 966 | return mState.mBuffers->getBuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 967 | } |
| 968 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 969 | Renderbuffer *Context::getRenderbuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 970 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 971 | return mState.mRenderbuffers->getRenderbuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 974 | Sync *Context::getSync(GLsync handle) const |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 975 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 976 | return mState.mSyncs->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle))); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 977 | } |
| 978 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 979 | VertexArray *Context::getVertexArray(GLuint handle) const |
| 980 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 981 | return mVertexArrayMap.query(handle); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 982 | } |
| 983 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 984 | Sampler *Context::getSampler(GLuint handle) const |
| 985 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 986 | return mState.mSamplers->getSampler(handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 987 | } |
| 988 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 989 | TransformFeedback *Context::getTransformFeedback(GLuint handle) const |
| 990 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 991 | return mTransformFeedbackMap.query(handle); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 992 | } |
| 993 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 994 | ProgramPipeline *Context::getProgramPipeline(GLuint handle) const |
| 995 | { |
| 996 | return mState.mPipelines->getProgramPipeline(handle); |
| 997 | } |
| 998 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 999 | gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1000 | { |
| 1001 | switch (identifier) |
| 1002 | { |
| 1003 | case GL_BUFFER: |
| 1004 | return getBuffer(name); |
| 1005 | case GL_SHADER: |
| 1006 | return getShader(name); |
| 1007 | case GL_PROGRAM: |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 1008 | return getProgramNoResolveLink(name); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1009 | case GL_VERTEX_ARRAY: |
| 1010 | return getVertexArray(name); |
| 1011 | case GL_QUERY: |
| 1012 | return getQuery(name); |
| 1013 | case GL_TRANSFORM_FEEDBACK: |
| 1014 | return getTransformFeedback(name); |
| 1015 | case GL_SAMPLER: |
| 1016 | return getSampler(name); |
| 1017 | case GL_TEXTURE: |
| 1018 | return getTexture(name); |
| 1019 | case GL_RENDERBUFFER: |
| 1020 | return getRenderbuffer(name); |
| 1021 | case GL_FRAMEBUFFER: |
| 1022 | return getFramebuffer(name); |
| 1023 | default: |
| 1024 | UNREACHABLE(); |
| 1025 | return nullptr; |
| 1026 | } |
| 1027 | } |
| 1028 | |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1029 | gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1030 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 1031 | return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr))); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1032 | } |
| 1033 | |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1034 | void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) |
| 1035 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1036 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1037 | ASSERT(object != nullptr); |
| 1038 | |
| 1039 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1040 | object->setLabel(this, labelName); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 1041 | |
| 1042 | // TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the |
| 1043 | // specified object is active until we do this. |
| 1044 | mGLState.setObjectDirty(identifier); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1045 | } |
| 1046 | |
| 1047 | void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) |
| 1048 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1049 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1050 | ASSERT(object != nullptr); |
| 1051 | |
| 1052 | std::string labelName = GetObjectLabelFromPointer(length, label); |
Jamie Madill | e90d4ee | 2018-11-28 14:04:00 -0500 | [diff] [blame] | 1053 | object->setLabel(this, labelName); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | void Context::getObjectLabel(GLenum identifier, |
| 1057 | GLuint name, |
| 1058 | GLsizei bufSize, |
| 1059 | GLsizei *length, |
| 1060 | GLchar *label) const |
| 1061 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1062 | gl::LabeledObject *object = getLabeledObject(identifier, name); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1063 | ASSERT(object != nullptr); |
| 1064 | |
| 1065 | const std::string &objectLabel = object->getLabel(); |
| 1066 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1067 | } |
| 1068 | |
| 1069 | void Context::getObjectPtrLabel(const void *ptr, |
| 1070 | GLsizei bufSize, |
| 1071 | GLsizei *length, |
| 1072 | GLchar *label) const |
| 1073 | { |
Geoff Lang | 7535966 | 2018-04-11 01:42:27 -0400 | [diff] [blame] | 1074 | gl::LabeledObject *object = getLabeledObjectFromPtr(ptr); |
Martin Radev | 9d90179 | 2016-07-15 15:58:58 +0300 | [diff] [blame] | 1075 | ASSERT(object != nullptr); |
| 1076 | |
| 1077 | const std::string &objectLabel = object->getLabel(); |
| 1078 | GetObjectLabelBase(objectLabel, bufSize, length, label); |
| 1079 | } |
| 1080 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1081 | bool Context::isSampler(GLuint samplerName) const |
| 1082 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1083 | return mState.mSamplers->isSampler(samplerName); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1084 | } |
| 1085 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1086 | void Context::bindTexture(TextureType target, GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1087 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1088 | Texture *texture = nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1089 | |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1090 | if (handle == 0) |
| 1091 | { |
| 1092 | texture = mZeroTextures[target].get(); |
| 1093 | } |
| 1094 | else |
| 1095 | { |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 1096 | texture = mState.mTextures->checkTextureAllocation(mImplementation.get(), handle, target); |
Jamie Madill | dedd7b9 | 2014-11-05 16:30:36 -0500 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | ASSERT(texture); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 1100 | mGLState.setSamplerTexture(this, target, texture); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1101 | mStateCache.onActiveTextureChange(this); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 1102 | } |
| 1103 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1104 | void Context::bindReadFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1105 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1106 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 1107 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1108 | mGLState.setReadFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1109 | mReadFramebufferObserverBinding.bind(framebuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 1112 | void Context::bindDrawFramebuffer(GLuint framebufferHandle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1113 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1114 | Framebuffer *framebuffer = mState.mFramebuffers->checkFramebufferAllocation( |
| 1115 | mImplementation.get(), mCaps, framebufferHandle); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1116 | mGLState.setDrawFramebufferBinding(framebuffer); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1117 | mDrawFramebufferObserverBinding.bind(framebuffer); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1118 | mStateCache.onDrawFramebufferChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1121 | void Context::bindVertexArray(GLuint vertexArrayHandle) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1122 | { |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1123 | VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle); |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 1124 | mGLState.setVertexArrayBinding(this, vertexArray); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 1125 | mVertexArrayObserverBinding.bind(vertexArray); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1126 | mStateCache.onVertexArrayBindingChange(this); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1127 | } |
| 1128 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1129 | void Context::bindVertexBuffer(GLuint bindingIndex, |
| 1130 | GLuint bufferHandle, |
| 1131 | GLintptr offset, |
| 1132 | GLsizei stride) |
| 1133 | { |
| 1134 | Buffer *buffer = mState.mBuffers->checkBufferAllocation(mImplementation.get(), bufferHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1135 | mGLState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1136 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1137 | } |
| 1138 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1139 | void Context::bindSampler(GLuint textureUnit, GLuint samplerHandle) |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1140 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 1141 | ASSERT(textureUnit < mCaps.maxCombinedTextureImageUnits); |
Jamie Madill | 901b379 | 2016-05-26 09:20:40 -0400 | [diff] [blame] | 1142 | Sampler *sampler = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 1143 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), samplerHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1144 | mGLState.setSamplerBinding(this, textureUnit, sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 1145 | mSamplerObserverBindings[textureUnit].bind(sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 1146 | } |
| 1147 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1148 | void Context::bindImageTexture(GLuint unit, |
| 1149 | GLuint texture, |
| 1150 | GLint level, |
| 1151 | GLboolean layered, |
| 1152 | GLint layer, |
| 1153 | GLenum access, |
| 1154 | GLenum format) |
| 1155 | { |
| 1156 | Texture *tex = mState.mTextures->getTexture(texture); |
| 1157 | mGLState.setImageUnit(this, unit, tex, level, layered, layer, access, format); |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 1158 | mImageObserverBindings[unit].bind(tex); |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 1159 | } |
| 1160 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1161 | void Context::useProgram(GLuint program) |
| 1162 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 1163 | ANGLE_CONTEXT_TRY(mGLState.setProgram(this, getProgramResolveLink(program))); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 1164 | mStateCache.onProgramExecutableChange(this); |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 1167 | void Context::useProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) |
| 1168 | { |
| 1169 | UNIMPLEMENTED(); |
| 1170 | } |
| 1171 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1172 | void Context::bindTransformFeedback(GLenum target, GLuint transformFeedbackHandle) |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1173 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 1174 | ASSERT(target == GL_TRANSFORM_FEEDBACK); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 1175 | TransformFeedback *transformFeedback = |
| 1176 | checkTransformFeedbackAllocation(transformFeedbackHandle); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1177 | mGLState.setTransformFeedbackBinding(this, transformFeedback); |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 1178 | } |
| 1179 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1180 | void Context::bindProgramPipeline(GLuint pipelineHandle) |
| 1181 | { |
| 1182 | ProgramPipeline *pipeline = |
| 1183 | mState.mPipelines->checkProgramPipelineAllocation(mImplementation.get(), pipelineHandle); |
| 1184 | mGLState.setProgramPipelineBinding(this, pipeline); |
| 1185 | } |
| 1186 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1187 | void Context::beginQuery(QueryType target, GLuint query) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1188 | { |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1189 | Query *queryObject = getQuery(query, true, target); |
Jamie Madill | db2f14c | 2014-05-13 13:56:30 -0400 | [diff] [blame] | 1190 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1191 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1192 | // begin query |
Jamie Madill | 5188a27 | 2018-07-25 10:53:56 -0400 | [diff] [blame] | 1193 | ANGLE_CONTEXT_TRY(queryObject->begin(this)); |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1194 | |
| 1195 | // set query as active for specified target only if begin succeeded |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1196 | mGLState.setActiveQuery(this, target, queryObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1197 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1200 | void Context::endQuery(QueryType target) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1201 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1202 | Query *queryObject = mGLState.getActiveQuery(target); |
Jamie Madill | 45c785d | 2014-05-13 14:09:34 -0400 | [diff] [blame] | 1203 | ASSERT(queryObject); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1204 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1205 | // Intentionally don't call try here. We don't want an early return. |
| 1206 | (void)(queryObject->end(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1207 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1208 | // 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] | 1209 | mGLState.setActiveQuery(this, target, nullptr); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 1210 | mStateCache.onQueryChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1211 | } |
| 1212 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1213 | void Context::queryCounter(GLuint id, QueryType target) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1214 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1215 | ASSERT(target == QueryType::Timestamp); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1216 | |
| 1217 | Query *queryObject = getQuery(id, true, target); |
| 1218 | ASSERT(queryObject); |
| 1219 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1220 | ANGLE_CONTEXT_TRY(queryObject->queryCounter(this)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1221 | } |
| 1222 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1223 | void Context::getQueryiv(QueryType target, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1224 | { |
| 1225 | switch (pname) |
| 1226 | { |
| 1227 | case GL_CURRENT_QUERY_EXT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1228 | params[0] = mGLState.getActiveQueryId(target); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1229 | break; |
| 1230 | case GL_QUERY_COUNTER_BITS_EXT: |
| 1231 | switch (target) |
| 1232 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1233 | case QueryType::TimeElapsed: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1234 | params[0] = getExtensions().queryCounterBitsTimeElapsed; |
| 1235 | break; |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1236 | case QueryType::Timestamp: |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1237 | params[0] = getExtensions().queryCounterBitsTimestamp; |
| 1238 | break; |
| 1239 | default: |
| 1240 | UNREACHABLE(); |
| 1241 | params[0] = 0; |
| 1242 | break; |
| 1243 | } |
| 1244 | break; |
| 1245 | default: |
| 1246 | UNREACHABLE(); |
| 1247 | return; |
| 1248 | } |
| 1249 | } |
| 1250 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1251 | void Context::getQueryivRobust(QueryType target, |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1252 | GLenum pname, |
| 1253 | GLsizei bufSize, |
| 1254 | GLsizei *length, |
| 1255 | GLint *params) |
| 1256 | { |
| 1257 | getQueryiv(target, pname, params); |
| 1258 | } |
| 1259 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1260 | void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1261 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1262 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1263 | } |
| 1264 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1265 | void Context::getQueryObjectivRobust(GLuint id, |
| 1266 | GLenum pname, |
| 1267 | GLsizei bufSize, |
| 1268 | GLsizei *length, |
| 1269 | GLint *params) |
| 1270 | { |
| 1271 | getQueryObjectiv(id, pname, params); |
| 1272 | } |
| 1273 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1274 | void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1275 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1276 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1277 | } |
| 1278 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1279 | void Context::getQueryObjectuivRobust(GLuint id, |
| 1280 | GLenum pname, |
| 1281 | GLsizei bufSize, |
| 1282 | GLsizei *length, |
| 1283 | GLuint *params) |
| 1284 | { |
| 1285 | getQueryObjectuiv(id, pname, params); |
| 1286 | } |
| 1287 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1288 | void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1289 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1290 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1291 | } |
| 1292 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1293 | void Context::getQueryObjecti64vRobust(GLuint id, |
| 1294 | GLenum pname, |
| 1295 | GLsizei bufSize, |
| 1296 | GLsizei *length, |
| 1297 | GLint64 *params) |
| 1298 | { |
| 1299 | getQueryObjecti64v(id, pname, params); |
| 1300 | } |
| 1301 | |
Geoff Lang | 2186c38 | 2016-10-14 10:54:54 -0400 | [diff] [blame] | 1302 | void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1303 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1304 | ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params)); |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1305 | } |
| 1306 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1307 | void Context::getQueryObjectui64vRobust(GLuint id, |
| 1308 | GLenum pname, |
| 1309 | GLsizei bufSize, |
| 1310 | GLsizei *length, |
| 1311 | GLuint64 *params) |
| 1312 | { |
| 1313 | getQueryObjectui64v(id, pname, params); |
| 1314 | } |
| 1315 | |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1316 | Framebuffer *Context::getFramebuffer(GLuint handle) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1317 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 1318 | return mState.mFramebuffers->getFramebuffer(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1321 | FenceNV *Context::getFenceNV(GLuint handle) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1322 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1323 | return mFenceNVMap.query(handle); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1324 | } |
| 1325 | |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1326 | Query *Context::getQuery(GLuint handle, bool create, QueryType type) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1327 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1328 | if (!mQueryMap.contains(handle)) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1329 | { |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1330 | return nullptr; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1331 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1332 | |
| 1333 | Query *query = mQueryMap.query(handle); |
| 1334 | if (!query && create) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1335 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 1336 | ASSERT(type != QueryType::InvalidEnum); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1337 | query = new Query(mImplementation->createQuery(type), handle); |
| 1338 | query->addRef(); |
| 1339 | mQueryMap.assign(handle, query); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1340 | } |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1341 | return query; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1342 | } |
| 1343 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1344 | Query *Context::getQuery(GLuint handle) const |
| 1345 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 1346 | return mQueryMap.query(handle); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1347 | } |
| 1348 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1349 | Texture *Context::getTargetTexture(TextureType type) const |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1350 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1351 | ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type)); |
| 1352 | return mGLState.getTargetTexture(type); |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 1355 | Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1356 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 1357 | return mGLState.getSamplerTexture(sampler, type); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1360 | Compiler *Context::getCompiler() const |
| 1361 | { |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1362 | if (mCompiler.get() == nullptr) |
| 1363 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1364 | mCompiler.set(this, new Compiler(mImplementation.get(), mState)); |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 1365 | } |
| 1366 | return mCompiler.get(); |
Geoff Lang | 492a7e4 | 2014-11-05 13:27:06 -0500 | [diff] [blame] | 1367 | } |
| 1368 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1369 | void Context::getBooleanvImpl(GLenum pname, GLboolean *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1370 | { |
| 1371 | switch (pname) |
| 1372 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1373 | case GL_SHADER_COMPILER: |
| 1374 | *params = GL_TRUE; |
| 1375 | break; |
| 1376 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 1377 | *params = mRobustAccess ? GL_TRUE : GL_FALSE; |
| 1378 | break; |
| 1379 | default: |
| 1380 | mGLState.getBooleanv(pname, params); |
| 1381 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1382 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1385 | void Context::getFloatvImpl(GLenum pname, GLfloat *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1386 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1387 | // Queries about context capabilities and maximums are answered by Context. |
| 1388 | // Queries about current GL state values are answered by State. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1389 | switch (pname) |
| 1390 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1391 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 1392 | params[0] = mCaps.minAliasedLineWidth; |
| 1393 | params[1] = mCaps.maxAliasedLineWidth; |
| 1394 | break; |
| 1395 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 1396 | params[0] = mCaps.minAliasedPointSize; |
| 1397 | params[1] = mCaps.maxAliasedPointSize; |
| 1398 | break; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 1399 | case GL_SMOOTH_POINT_SIZE_RANGE: |
| 1400 | params[0] = mCaps.minSmoothPointSize; |
| 1401 | params[1] = mCaps.maxSmoothPointSize; |
| 1402 | break; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 1403 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
| 1404 | params[0] = mCaps.minSmoothLineWidth; |
| 1405 | params[1] = mCaps.maxSmoothLineWidth; |
| 1406 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1407 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 1408 | ASSERT(mExtensions.textureFilterAnisotropic); |
| 1409 | *params = mExtensions.maxTextureAnisotropy; |
| 1410 | break; |
| 1411 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 1412 | *params = mCaps.maxLODBias; |
| 1413 | break; |
| 1414 | |
| 1415 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 1416 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 1417 | { |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 1418 | // GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the |
| 1419 | // GLES1 constants for modelview/projection matrix. |
| 1420 | if (getClientVersion() < Version(2, 0)) |
| 1421 | { |
| 1422 | mGLState.getFloatv(pname, params); |
| 1423 | } |
| 1424 | else |
| 1425 | { |
| 1426 | ASSERT(mExtensions.pathRendering); |
| 1427 | const GLfloat *m = mGLState.getPathRenderingMatrix(pname); |
| 1428 | memcpy(params, m, 16 * sizeof(GLfloat)); |
| 1429 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1430 | } |
Geoff Lang | e6d4e12 | 2015-06-29 13:33:55 -0400 | [diff] [blame] | 1431 | break; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1432 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1433 | default: |
| 1434 | mGLState.getFloatv(pname, params); |
| 1435 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1436 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1437 | } |
| 1438 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 1439 | void Context::getIntegervImpl(GLenum pname, GLint *params) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1440 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1441 | // Queries about context capabilities and maximums are answered by Context. |
| 1442 | // 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] | 1443 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1444 | switch (pname) |
| 1445 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1446 | case GL_MAX_VERTEX_ATTRIBS: |
| 1447 | *params = mCaps.maxVertexAttributes; |
| 1448 | break; |
| 1449 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 1450 | *params = mCaps.maxVertexUniformVectors; |
| 1451 | break; |
| 1452 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1453 | *params = mCaps.maxShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1454 | break; |
| 1455 | case GL_MAX_VARYING_VECTORS: |
| 1456 | *params = mCaps.maxVaryingVectors; |
| 1457 | break; |
| 1458 | case GL_MAX_VARYING_COMPONENTS: |
| 1459 | *params = mCaps.maxVertexOutputComponents; |
| 1460 | break; |
| 1461 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 1462 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1463 | break; |
| 1464 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1465 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1466 | break; |
| 1467 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1468 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1469 | break; |
| 1470 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 1471 | *params = mCaps.maxFragmentUniformVectors; |
| 1472 | break; |
| 1473 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1474 | *params = mCaps.maxShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1475 | break; |
| 1476 | case GL_MAX_RENDERBUFFER_SIZE: |
| 1477 | *params = mCaps.maxRenderbufferSize; |
| 1478 | break; |
| 1479 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 1480 | *params = mCaps.maxColorAttachments; |
| 1481 | break; |
| 1482 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 1483 | *params = mCaps.maxDrawBuffers; |
| 1484 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1485 | case GL_SUBPIXEL_BITS: |
| 1486 | *params = 4; |
| 1487 | break; |
| 1488 | case GL_MAX_TEXTURE_SIZE: |
| 1489 | *params = mCaps.max2DTextureSize; |
| 1490 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1491 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 1492 | *params = mCaps.maxRectangleTextureSize; |
| 1493 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1494 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 1495 | *params = mCaps.maxCubeMapTextureSize; |
| 1496 | break; |
| 1497 | case GL_MAX_3D_TEXTURE_SIZE: |
| 1498 | *params = mCaps.max3DTextureSize; |
| 1499 | break; |
| 1500 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 1501 | *params = mCaps.maxArrayTextureLayers; |
| 1502 | break; |
| 1503 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 1504 | *params = mCaps.uniformBufferOffsetAlignment; |
| 1505 | break; |
| 1506 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 1507 | *params = mCaps.maxUniformBufferBindings; |
| 1508 | break; |
| 1509 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1510 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1511 | break; |
| 1512 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1513 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1514 | break; |
| 1515 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 1516 | *params = mCaps.maxCombinedTextureImageUnits; |
| 1517 | break; |
| 1518 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 1519 | *params = mCaps.maxVertexOutputComponents; |
| 1520 | break; |
| 1521 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 1522 | *params = mCaps.maxFragmentInputComponents; |
| 1523 | break; |
| 1524 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 1525 | *params = mCaps.minProgramTexelOffset; |
| 1526 | break; |
| 1527 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 1528 | *params = mCaps.maxProgramTexelOffset; |
| 1529 | break; |
| 1530 | case GL_MAJOR_VERSION: |
| 1531 | *params = getClientVersion().major; |
| 1532 | break; |
| 1533 | case GL_MINOR_VERSION: |
| 1534 | *params = getClientVersion().minor; |
| 1535 | break; |
| 1536 | case GL_MAX_ELEMENTS_INDICES: |
| 1537 | *params = mCaps.maxElementsIndices; |
| 1538 | break; |
| 1539 | case GL_MAX_ELEMENTS_VERTICES: |
| 1540 | *params = mCaps.maxElementsVertices; |
| 1541 | break; |
| 1542 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 1543 | *params = mCaps.maxTransformFeedbackInterleavedComponents; |
| 1544 | break; |
| 1545 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 1546 | *params = mCaps.maxTransformFeedbackSeparateAttributes; |
| 1547 | break; |
| 1548 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 1549 | *params = mCaps.maxTransformFeedbackSeparateComponents; |
| 1550 | break; |
| 1551 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 1552 | *params = static_cast<GLint>(mCaps.compressedTextureFormats.size()); |
| 1553 | break; |
| 1554 | case GL_MAX_SAMPLES_ANGLE: |
| 1555 | *params = mCaps.maxSamples; |
| 1556 | break; |
| 1557 | case GL_MAX_VIEWPORT_DIMS: |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1558 | { |
Geoff Lang | c0b9ef4 | 2014-07-02 10:02:37 -0400 | [diff] [blame] | 1559 | params[0] = mCaps.maxViewportWidth; |
| 1560 | params[1] = mCaps.maxViewportHeight; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1561 | } |
| 1562 | break; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1563 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 1564 | std::copy(mCaps.compressedTextureFormats.begin(), mCaps.compressedTextureFormats.end(), |
| 1565 | params); |
| 1566 | break; |
| 1567 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 1568 | *params = mResetStrategy; |
| 1569 | break; |
| 1570 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 1571 | *params = static_cast<GLint>(mCaps.shaderBinaryFormats.size()); |
| 1572 | break; |
| 1573 | case GL_SHADER_BINARY_FORMATS: |
| 1574 | std::copy(mCaps.shaderBinaryFormats.begin(), mCaps.shaderBinaryFormats.end(), params); |
| 1575 | break; |
| 1576 | case GL_NUM_PROGRAM_BINARY_FORMATS: |
| 1577 | *params = static_cast<GLint>(mCaps.programBinaryFormats.size()); |
| 1578 | break; |
| 1579 | case GL_PROGRAM_BINARY_FORMATS: |
| 1580 | std::copy(mCaps.programBinaryFormats.begin(), mCaps.programBinaryFormats.end(), params); |
| 1581 | break; |
| 1582 | case GL_NUM_EXTENSIONS: |
| 1583 | *params = static_cast<GLint>(mExtensionStrings.size()); |
| 1584 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1585 | |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame] | 1586 | // GL_ANGLE_request_extension |
| 1587 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 1588 | *params = static_cast<GLint>(mRequestableExtensionStrings.size()); |
| 1589 | break; |
| 1590 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1591 | // GL_KHR_debug |
| 1592 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 1593 | *params = mExtensions.maxDebugMessageLength; |
| 1594 | break; |
| 1595 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 1596 | *params = mExtensions.maxDebugLoggedMessages; |
| 1597 | break; |
| 1598 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 1599 | *params = mExtensions.maxDebugGroupStackDepth; |
| 1600 | break; |
| 1601 | case GL_MAX_LABEL_LENGTH: |
| 1602 | *params = mExtensions.maxLabelLength; |
| 1603 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1604 | |
Martin Radev | e5285d2 | 2017-07-14 16:23:53 +0300 | [diff] [blame] | 1605 | // GL_ANGLE_multiview |
| 1606 | case GL_MAX_VIEWS_ANGLE: |
| 1607 | *params = mExtensions.maxViews; |
| 1608 | break; |
| 1609 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1610 | // GL_EXT_disjoint_timer_query |
| 1611 | case GL_GPU_DISJOINT_EXT: |
| 1612 | *params = mImplementation->getGPUDisjoint(); |
| 1613 | break; |
| 1614 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 1615 | *params = mCaps.maxFramebufferWidth; |
| 1616 | break; |
| 1617 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 1618 | *params = mCaps.maxFramebufferHeight; |
| 1619 | break; |
| 1620 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 1621 | *params = mCaps.maxFramebufferSamples; |
| 1622 | break; |
| 1623 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 1624 | *params = mCaps.maxSampleMaskWords; |
| 1625 | break; |
| 1626 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 1627 | *params = mCaps.maxColorTextureSamples; |
| 1628 | break; |
| 1629 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 1630 | *params = mCaps.maxDepthTextureSamples; |
| 1631 | break; |
| 1632 | case GL_MAX_INTEGER_SAMPLES: |
| 1633 | *params = mCaps.maxIntegerSamples; |
| 1634 | break; |
| 1635 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 1636 | *params = mCaps.maxVertexAttribRelativeOffset; |
| 1637 | break; |
| 1638 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 1639 | *params = mCaps.maxVertexAttribBindings; |
| 1640 | break; |
| 1641 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 1642 | *params = mCaps.maxVertexAttribStride; |
| 1643 | break; |
| 1644 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1645 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1646 | break; |
| 1647 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1648 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1649 | break; |
| 1650 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1651 | *params = mCaps.maxShaderImageUniforms[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1652 | break; |
| 1653 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1654 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1655 | break; |
| 1656 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1657 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1658 | break; |
| 1659 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1660 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1661 | break; |
| 1662 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1663 | *params = mCaps.maxShaderImageUniforms[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1664 | break; |
| 1665 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1666 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1667 | break; |
| 1668 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1669 | *params = mCaps.minProgramTextureGatherOffset; |
| 1670 | break; |
| 1671 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 1672 | *params = mCaps.maxProgramTextureGatherOffset; |
| 1673 | break; |
| 1674 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 1675 | *params = mCaps.maxComputeWorkGroupInvocations; |
| 1676 | break; |
| 1677 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1678 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1679 | break; |
| 1680 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1681 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1682 | break; |
| 1683 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 1684 | *params = mCaps.maxComputeSharedMemorySize; |
| 1685 | break; |
| 1686 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1687 | *params = mCaps.maxShaderUniformComponents[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1688 | break; |
| 1689 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1690 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1691 | break; |
| 1692 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1693 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1694 | break; |
| 1695 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1696 | *params = mCaps.maxShaderImageUniforms[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1697 | break; |
| 1698 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1699 | *params = |
| 1700 | static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1701 | break; |
| 1702 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1703 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Compute]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1704 | break; |
| 1705 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 1706 | *params = mCaps.maxCombinedShaderOutputResources; |
| 1707 | break; |
| 1708 | case GL_MAX_UNIFORM_LOCATIONS: |
| 1709 | *params = mCaps.maxUniformLocations; |
| 1710 | break; |
| 1711 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 1712 | *params = mCaps.maxAtomicCounterBufferBindings; |
| 1713 | break; |
| 1714 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 1715 | *params = mCaps.maxAtomicCounterBufferSize; |
| 1716 | break; |
| 1717 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 1718 | *params = mCaps.maxCombinedAtomicCounterBuffers; |
| 1719 | break; |
| 1720 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 1721 | *params = mCaps.maxCombinedAtomicCounters; |
| 1722 | break; |
| 1723 | case GL_MAX_IMAGE_UNITS: |
| 1724 | *params = mCaps.maxImageUnits; |
| 1725 | break; |
| 1726 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 1727 | *params = mCaps.maxCombinedImageUniforms; |
| 1728 | break; |
| 1729 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 1730 | *params = mCaps.maxShaderStorageBufferBindings; |
| 1731 | break; |
| 1732 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 1733 | *params = mCaps.maxCombinedShaderStorageBlocks; |
| 1734 | break; |
| 1735 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 1736 | *params = mCaps.shaderStorageBufferOffsetAlignment; |
| 1737 | break; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1738 | |
| 1739 | // GL_EXT_geometry_shader |
| 1740 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 1741 | *params = mCaps.maxFramebufferLayers; |
| 1742 | break; |
| 1743 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 1744 | *params = mCaps.layerProvokingVertex; |
| 1745 | break; |
| 1746 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1747 | *params = mCaps.maxShaderUniformComponents[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1748 | break; |
| 1749 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1750 | *params = mCaps.maxShaderUniformBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1751 | break; |
| 1752 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1753 | *params = |
| 1754 | static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]); |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1755 | break; |
| 1756 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 1757 | *params = mCaps.maxGeometryInputComponents; |
| 1758 | break; |
| 1759 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 1760 | *params = mCaps.maxGeometryOutputComponents; |
| 1761 | break; |
| 1762 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 1763 | *params = mCaps.maxGeometryOutputVertices; |
| 1764 | break; |
| 1765 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 1766 | *params = mCaps.maxGeometryTotalOutputComponents; |
| 1767 | break; |
| 1768 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 1769 | *params = mCaps.maxGeometryShaderInvocations; |
| 1770 | break; |
| 1771 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1772 | *params = mCaps.maxShaderTextureImageUnits[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1773 | break; |
| 1774 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1775 | *params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1776 | break; |
| 1777 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1778 | *params = mCaps.maxShaderAtomicCounters[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1779 | break; |
| 1780 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1781 | *params = mCaps.maxShaderImageUniforms[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1782 | break; |
| 1783 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 1784 | *params = mCaps.maxShaderStorageBlocks[ShaderType::Geometry]; |
Jiawei Shao | 361df07 | 2017-11-22 09:33:59 +0800 | [diff] [blame] | 1785 | break; |
Lingfeng Yang | 96310cd | 2018-03-28 11:56:28 -0700 | [diff] [blame] | 1786 | // GLES1 emulation: Caps queries |
| 1787 | case GL_MAX_TEXTURE_UNITS: |
| 1788 | *params = mCaps.maxMultitextureUnits; |
| 1789 | break; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 1790 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 1791 | *params = mCaps.maxModelviewMatrixStackDepth; |
| 1792 | break; |
| 1793 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 1794 | *params = mCaps.maxProjectionMatrixStackDepth; |
| 1795 | break; |
| 1796 | case GL_MAX_TEXTURE_STACK_DEPTH: |
| 1797 | *params = mCaps.maxTextureMatrixStackDepth; |
| 1798 | break; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 1799 | case GL_MAX_LIGHTS: |
| 1800 | *params = mCaps.maxLights; |
| 1801 | break; |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 1802 | case GL_MAX_CLIP_PLANES: |
| 1803 | *params = mCaps.maxClipPlanes; |
| 1804 | break; |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1805 | // GLES1 emulation: Vertex attribute queries |
| 1806 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 1807 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 1808 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 1809 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
| 1810 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 1811 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1812 | GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params); |
| 1813 | break; |
| 1814 | case GL_VERTEX_ARRAY_STRIDE: |
| 1815 | case GL_NORMAL_ARRAY_STRIDE: |
| 1816 | case GL_COLOR_ARRAY_STRIDE: |
| 1817 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 1818 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 1819 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1820 | GL_VERTEX_ATTRIB_ARRAY_STRIDE, params); |
| 1821 | break; |
| 1822 | case GL_VERTEX_ARRAY_SIZE: |
| 1823 | case GL_COLOR_ARRAY_SIZE: |
| 1824 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 1825 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1826 | GL_VERTEX_ATTRIB_ARRAY_SIZE, params); |
| 1827 | break; |
| 1828 | case GL_VERTEX_ARRAY_TYPE: |
| 1829 | case GL_COLOR_ARRAY_TYPE: |
| 1830 | case GL_NORMAL_ARRAY_TYPE: |
| 1831 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 1832 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 1833 | getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))), |
| 1834 | GL_VERTEX_ATTRIB_ARRAY_TYPE, params); |
| 1835 | break; |
| 1836 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 1837 | // GL_KHR_parallel_shader_compile |
| 1838 | case GL_MAX_SHADER_COMPILER_THREADS_KHR: |
| 1839 | *params = mGLState.getMaxShaderCompilerThreads(); |
| 1840 | break; |
| 1841 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 1842 | // GL_EXT_blend_func_extended |
| 1843 | case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT: |
| 1844 | *params = mExtensions.maxDualSourceDrawBuffers; |
| 1845 | break; |
| 1846 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1847 | default: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 1848 | ANGLE_CONTEXT_TRY(mGLState.getIntegerv(this, pname, params)); |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1849 | break; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1850 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 1851 | } |
| 1852 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 1853 | void Context::getInteger64vImpl(GLenum pname, GLint64 *params) |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1854 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1855 | // Queries about context capabilities and maximums are answered by Context. |
| 1856 | // Queries about current GL state values are answered by State. |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1857 | switch (pname) |
| 1858 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1859 | case GL_MAX_ELEMENT_INDEX: |
| 1860 | *params = mCaps.maxElementIndex; |
| 1861 | break; |
| 1862 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 1863 | *params = mCaps.maxUniformBlockSize; |
| 1864 | break; |
| 1865 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1866 | *params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1867 | break; |
| 1868 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
Jiawei Shao | 0c4e08e | 2018-05-08 11:00:36 +0800 | [diff] [blame] | 1869 | *params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment]; |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1870 | break; |
| 1871 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 1872 | *params = mCaps.maxServerWaitTimeout; |
| 1873 | break; |
Ian Ewell | 53f59f4 | 2016-01-28 17:36:55 -0500 | [diff] [blame] | 1874 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1875 | // GL_EXT_disjoint_timer_query |
| 1876 | case GL_TIMESTAMP_EXT: |
| 1877 | *params = mImplementation->getTimestamp(); |
| 1878 | break; |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1879 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 1880 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 1881 | *params = mCaps.maxShaderStorageBlockSize; |
| 1882 | break; |
| 1883 | default: |
| 1884 | UNREACHABLE(); |
| 1885 | break; |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1886 | } |
Jamie Madill | 0fda986 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 1887 | } |
| 1888 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1889 | void Context::getPointerv(GLenum pname, void **params) const |
| 1890 | { |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 1891 | mGLState.getPointerv(this, pname, params); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1892 | } |
| 1893 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 1894 | void Context::getPointervRobustANGLERobust(GLenum pname, |
| 1895 | GLsizei bufSize, |
| 1896 | GLsizei *length, |
| 1897 | void **params) |
| 1898 | { |
| 1899 | UNIMPLEMENTED(); |
| 1900 | } |
| 1901 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1902 | void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1903 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1904 | // Queries about context capabilities and maximums are answered by Context. |
| 1905 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1906 | |
| 1907 | GLenum nativeType; |
| 1908 | unsigned int numParams; |
| 1909 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1910 | ASSERT(queryStatus); |
| 1911 | |
| 1912 | if (nativeType == GL_INT) |
| 1913 | { |
| 1914 | switch (target) |
| 1915 | { |
| 1916 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 1917 | ASSERT(index < 3u); |
| 1918 | *data = mCaps.maxComputeWorkGroupCount[index]; |
| 1919 | break; |
| 1920 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 1921 | ASSERT(index < 3u); |
| 1922 | *data = mCaps.maxComputeWorkGroupSize[index]; |
| 1923 | break; |
| 1924 | default: |
| 1925 | mGLState.getIntegeri_v(target, index, data); |
| 1926 | } |
| 1927 | } |
| 1928 | else |
| 1929 | { |
| 1930 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1931 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1932 | } |
| 1933 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1934 | void Context::getIntegeri_vRobust(GLenum target, |
| 1935 | GLuint index, |
| 1936 | GLsizei bufSize, |
| 1937 | GLsizei *length, |
| 1938 | GLint *data) |
| 1939 | { |
| 1940 | getIntegeri_v(target, index, data); |
| 1941 | } |
| 1942 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1943 | void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1944 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1945 | // Queries about context capabilities and maximums are answered by Context. |
| 1946 | // Queries about current GL state values are answered by State. |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1947 | |
| 1948 | GLenum nativeType; |
| 1949 | unsigned int numParams; |
| 1950 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1951 | ASSERT(queryStatus); |
| 1952 | |
| 1953 | if (nativeType == GL_INT_64_ANGLEX) |
| 1954 | { |
| 1955 | mGLState.getInteger64i_v(target, index, data); |
| 1956 | } |
| 1957 | else |
| 1958 | { |
| 1959 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1960 | } |
| 1961 | } |
| 1962 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1963 | void Context::getInteger64i_vRobust(GLenum target, |
| 1964 | GLuint index, |
| 1965 | GLsizei bufSize, |
| 1966 | GLsizei *length, |
| 1967 | GLint64 *data) |
| 1968 | { |
| 1969 | getInteger64i_v(target, index, data); |
| 1970 | } |
| 1971 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 1972 | void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 1973 | { |
| 1974 | // Queries about context capabilities and maximums are answered by Context. |
| 1975 | // Queries about current GL state values are answered by State. |
| 1976 | |
| 1977 | GLenum nativeType; |
| 1978 | unsigned int numParams; |
| 1979 | bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams); |
| 1980 | ASSERT(queryStatus); |
| 1981 | |
| 1982 | if (nativeType == GL_BOOL) |
| 1983 | { |
| 1984 | mGLState.getBooleani_v(target, index, data); |
| 1985 | } |
| 1986 | else |
| 1987 | { |
| 1988 | CastIndexedStateValues(this, nativeType, target, index, numParams, data); |
| 1989 | } |
Shannon Woods | 1b2fb85 | 2013-08-19 14:28:48 -0400 | [diff] [blame] | 1990 | } |
| 1991 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 1992 | void Context::getBooleani_vRobust(GLenum target, |
| 1993 | GLuint index, |
| 1994 | GLsizei bufSize, |
| 1995 | GLsizei *length, |
| 1996 | GLboolean *data) |
| 1997 | { |
| 1998 | getBooleani_v(target, index, data); |
| 1999 | } |
| 2000 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 2001 | void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2002 | { |
| 2003 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 2004 | QueryBufferParameteriv(buffer, pname, params); |
| 2005 | } |
| 2006 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2007 | void Context::getBufferParameterivRobust(BufferBinding target, |
| 2008 | GLenum pname, |
| 2009 | GLsizei bufSize, |
| 2010 | GLsizei *length, |
| 2011 | GLint *params) |
| 2012 | { |
| 2013 | getBufferParameteriv(target, pname, params); |
| 2014 | } |
| 2015 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2016 | void Context::getFramebufferAttachmentParameteriv(GLenum target, |
| 2017 | GLenum attachment, |
| 2018 | GLenum pname, |
| 2019 | GLint *params) |
| 2020 | { |
| 2021 | const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2022 | QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2023 | } |
| 2024 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2025 | void Context::getFramebufferAttachmentParameterivRobust(GLenum target, |
| 2026 | GLenum attachment, |
| 2027 | GLenum pname, |
| 2028 | GLsizei bufSize, |
| 2029 | GLsizei *length, |
| 2030 | GLint *params) |
| 2031 | { |
| 2032 | getFramebufferAttachmentParameteriv(target, attachment, pname, params); |
| 2033 | } |
| 2034 | |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2035 | void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 2036 | { |
| 2037 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
| 2038 | QueryRenderbufferiv(this, renderbuffer, pname, params); |
| 2039 | } |
| 2040 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2041 | void Context::getRenderbufferParameterivRobust(GLenum target, |
| 2042 | GLenum pname, |
| 2043 | GLsizei bufSize, |
| 2044 | GLsizei *length, |
| 2045 | GLint *params) |
| 2046 | { |
| 2047 | getRenderbufferParameteriv(target, pname, params); |
| 2048 | } |
| 2049 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2050 | void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2051 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2052 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2053 | QueryTexParameterfv(texture, pname, params); |
| 2054 | } |
| 2055 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2056 | void Context::getTexParameterfvRobust(TextureType target, |
| 2057 | GLenum pname, |
| 2058 | GLsizei bufSize, |
| 2059 | GLsizei *length, |
| 2060 | GLfloat *params) |
| 2061 | { |
| 2062 | getTexParameterfv(target, pname, params); |
| 2063 | } |
| 2064 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2065 | void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2066 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2067 | const Texture *const texture = getTargetTexture(target); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2068 | QueryTexParameteriv(texture, pname, params); |
| 2069 | } |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2070 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2071 | void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params) |
| 2072 | { |
| 2073 | const Texture *const texture = getTargetTexture(target); |
| 2074 | QueryTexParameterIiv(texture, pname, params); |
| 2075 | } |
| 2076 | |
| 2077 | void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params) |
| 2078 | { |
| 2079 | const Texture *const texture = getTargetTexture(target); |
| 2080 | QueryTexParameterIuiv(texture, pname, params); |
| 2081 | } |
| 2082 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2083 | void Context::getTexParameterivRobust(TextureType target, |
| 2084 | GLenum pname, |
| 2085 | GLsizei bufSize, |
| 2086 | GLsizei *length, |
| 2087 | GLint *params) |
| 2088 | { |
| 2089 | getTexParameteriv(target, pname, params); |
| 2090 | } |
| 2091 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2092 | void Context::getTexParameterIivRobust(TextureType target, |
| 2093 | GLenum pname, |
| 2094 | GLsizei bufSize, |
| 2095 | GLsizei *length, |
| 2096 | GLint *params) |
| 2097 | { |
| 2098 | UNIMPLEMENTED(); |
| 2099 | } |
| 2100 | |
| 2101 | void Context::getTexParameterIuivRobust(TextureType target, |
| 2102 | GLenum pname, |
| 2103 | GLsizei bufSize, |
| 2104 | GLsizei *length, |
| 2105 | GLuint *params) |
| 2106 | { |
| 2107 | UNIMPLEMENTED(); |
| 2108 | } |
| 2109 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2110 | void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2111 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2112 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2113 | QueryTexLevelParameteriv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2114 | } |
| 2115 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2116 | void Context::getTexLevelParameterivRobust(TextureTarget target, |
| 2117 | GLint level, |
| 2118 | GLenum pname, |
| 2119 | GLsizei bufSize, |
| 2120 | GLsizei *length, |
| 2121 | GLint *params) |
| 2122 | { |
| 2123 | UNIMPLEMENTED(); |
| 2124 | } |
| 2125 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2126 | void Context::getTexLevelParameterfv(TextureTarget target, |
| 2127 | GLint level, |
| 2128 | GLenum pname, |
| 2129 | GLfloat *params) |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2130 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2131 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 2132 | QueryTexLevelParameterfv(texture, target, level, pname, params); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 2133 | } |
| 2134 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2135 | void Context::getTexLevelParameterfvRobust(TextureTarget target, |
| 2136 | GLint level, |
| 2137 | GLenum pname, |
| 2138 | GLsizei bufSize, |
| 2139 | GLsizei *length, |
| 2140 | GLfloat *params) |
| 2141 | { |
| 2142 | UNIMPLEMENTED(); |
| 2143 | } |
| 2144 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2145 | void Context::texParameterf(TextureType target, GLenum pname, GLfloat param) |
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 | SetTexParameterf(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2149 | } |
| 2150 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2151 | void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2152 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2153 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2154 | SetTexParameterfv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2155 | } |
| 2156 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2157 | void Context::texParameterfvRobust(TextureType target, |
| 2158 | GLenum pname, |
| 2159 | GLsizei bufSize, |
| 2160 | const GLfloat *params) |
| 2161 | { |
| 2162 | texParameterfv(target, pname, params); |
| 2163 | } |
| 2164 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2165 | void Context::texParameteri(TextureType target, GLenum pname, GLint param) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2166 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2167 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2168 | SetTexParameteri(this, texture, pname, param); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2169 | } |
| 2170 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 2171 | void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params) |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2172 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2173 | Texture *const texture = getTargetTexture(target); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2174 | SetTexParameteriv(this, texture, pname, params); |
He Yunchao | 010e4db | 2017-03-03 14:22:06 +0800 | [diff] [blame] | 2175 | } |
| 2176 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2177 | void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params) |
| 2178 | { |
| 2179 | Texture *const texture = getTargetTexture(target); |
| 2180 | SetTexParameterIiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2181 | } |
| 2182 | |
| 2183 | void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params) |
| 2184 | { |
| 2185 | Texture *const texture = getTargetTexture(target); |
| 2186 | SetTexParameterIuiv(this, texture, pname, params); |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2187 | } |
| 2188 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2189 | void Context::texParameterivRobust(TextureType target, |
| 2190 | GLenum pname, |
| 2191 | GLsizei bufSize, |
| 2192 | const GLint *params) |
| 2193 | { |
| 2194 | texParameteriv(target, pname, params); |
| 2195 | } |
| 2196 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2197 | void Context::texParameterIivRobust(TextureType target, |
| 2198 | GLenum pname, |
| 2199 | GLsizei bufSize, |
| 2200 | const GLint *params) |
| 2201 | { |
| 2202 | UNIMPLEMENTED(); |
| 2203 | } |
| 2204 | |
| 2205 | void Context::texParameterIuivRobust(TextureType target, |
| 2206 | GLenum pname, |
| 2207 | GLsizei bufSize, |
| 2208 | const GLuint *params) |
| 2209 | { |
| 2210 | UNIMPLEMENTED(); |
| 2211 | } |
| 2212 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2213 | void Context::drawArrays(PrimitiveMode mode, GLint first, GLsizei count) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2214 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2215 | // No-op if count draws no primitives for given mode |
| 2216 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2217 | { |
| 2218 | return; |
| 2219 | } |
| 2220 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2221 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2222 | ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count)); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 2223 | MarkTransformFeedbackBufferUsage(this, count, 1); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2226 | void Context::drawArraysInstanced(PrimitiveMode mode, |
| 2227 | GLint first, |
| 2228 | GLsizei count, |
| 2229 | GLsizei instanceCount) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2230 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2231 | // No-op if count draws no primitives for given mode |
| 2232 | if (noopDrawInstanced(mode, count, instanceCount)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2233 | { |
| 2234 | return; |
| 2235 | } |
| 2236 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2237 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2238 | ANGLE_CONTEXT_TRY( |
| 2239 | mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount)); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 2240 | MarkTransformFeedbackBufferUsage(this, count, instanceCount); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2241 | } |
| 2242 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2243 | void Context::drawElementsInstanced(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2244 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2245 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2246 | const void *indices, |
Jamie Madill | 9c9b40a | 2017-04-26 16:31:57 -0400 | [diff] [blame] | 2247 | GLsizei instances) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2248 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2249 | // No-op if count draws no primitives for given mode |
| 2250 | if (noopDrawInstanced(mode, count, instances)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2251 | { |
| 2252 | return; |
| 2253 | } |
| 2254 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2255 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2256 | ANGLE_CONTEXT_TRY( |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 2257 | mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances)); |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2258 | } |
| 2259 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2260 | void Context::drawRangeElements(PrimitiveMode mode, |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2261 | GLuint start, |
| 2262 | GLuint end, |
| 2263 | GLsizei count, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2264 | DrawElementsType type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 2265 | const void *indices) |
Geoff Lang | f6db098 | 2015-08-25 13:04:00 -0400 | [diff] [blame] | 2266 | { |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 2267 | // No-op if count draws no primitives for given mode |
| 2268 | if (noopDraw(mode, count)) |
Jamie Madill | 9fdaa49 | 2018-02-16 10:52:11 -0500 | [diff] [blame] | 2269 | { |
| 2270 | return; |
| 2271 | } |
| 2272 | |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2273 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2274 | ANGLE_CONTEXT_TRY( |
| 2275 | mImplementation->drawRangeElements(this, mode, start, end, count, type, indices)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2276 | } |
| 2277 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 2278 | void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2279 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2280 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2281 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2282 | } |
| 2283 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 2284 | void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2285 | { |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 2286 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 2287 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect)); |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 2288 | } |
| 2289 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2290 | void Context::flush() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2291 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2292 | ANGLE_CONTEXT_TRY(mImplementation->flush(this)); |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2293 | } |
| 2294 | |
Jamie Madill | 675fe71 | 2016-12-19 13:07:54 -0500 | [diff] [blame] | 2295 | void Context::finish() |
Geoff Lang | 129753a | 2015-01-09 16:52:09 -0500 | [diff] [blame] | 2296 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 2297 | ANGLE_CONTEXT_TRY(mImplementation->finish(this)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2298 | } |
| 2299 | |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2300 | void Context::insertEventMarker(GLsizei length, const char *marker) |
| 2301 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2302 | ASSERT(mImplementation); |
| 2303 | mImplementation->insertEventMarker(length, marker); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2304 | } |
| 2305 | |
| 2306 | void Context::pushGroupMarker(GLsizei length, const char *marker) |
| 2307 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2308 | ASSERT(mImplementation); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 2309 | |
| 2310 | if (marker == nullptr) |
| 2311 | { |
| 2312 | // From the EXT_debug_marker spec, |
| 2313 | // "If <marker> is null then an empty string is pushed on the stack." |
| 2314 | mImplementation->pushGroupMarker(length, ""); |
| 2315 | } |
| 2316 | else |
| 2317 | { |
| 2318 | mImplementation->pushGroupMarker(length, marker); |
| 2319 | } |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2320 | } |
| 2321 | |
| 2322 | void Context::popGroupMarker() |
| 2323 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2324 | ASSERT(mImplementation); |
| 2325 | mImplementation->popGroupMarker(); |
Austin Kinross | 6ee1e78 | 2015-05-29 17:05:37 -0700 | [diff] [blame] | 2326 | } |
| 2327 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2328 | void Context::bindUniformLocation(GLuint program, GLint location, const GLchar *name) |
| 2329 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2330 | Program *programObject = getProgramResolveLink(program); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 2331 | ASSERT(programObject); |
| 2332 | |
| 2333 | programObject->bindUniformLocation(location, name); |
| 2334 | } |
| 2335 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2336 | void Context::coverageModulation(GLenum components) |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2337 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2338 | mGLState.setCoverageModulation(components); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2339 | } |
| 2340 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2341 | void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2342 | { |
| 2343 | mGLState.loadPathRenderingMatrix(matrixMode, matrix); |
| 2344 | } |
| 2345 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2346 | void Context::matrixLoadIdentity(GLenum matrixMode) |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2347 | { |
| 2348 | GLfloat I[16]; |
| 2349 | angle::Matrix<GLfloat>::setToIdentity(I); |
| 2350 | |
| 2351 | mGLState.loadPathRenderingMatrix(matrixMode, I); |
| 2352 | } |
| 2353 | |
| 2354 | void Context::stencilFillPath(GLuint path, GLenum fillMode, GLuint mask) |
| 2355 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2356 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2357 | if (!pathObj) |
| 2358 | return; |
| 2359 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2360 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2361 | |
| 2362 | mImplementation->stencilFillPath(pathObj, fillMode, mask); |
| 2363 | } |
| 2364 | |
| 2365 | void Context::stencilStrokePath(GLuint path, GLint reference, GLuint mask) |
| 2366 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2367 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2368 | if (!pathObj) |
| 2369 | return; |
| 2370 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2371 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2372 | |
| 2373 | mImplementation->stencilStrokePath(pathObj, reference, mask); |
| 2374 | } |
| 2375 | |
| 2376 | void Context::coverFillPath(GLuint path, GLenum coverMode) |
| 2377 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2378 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2379 | if (!pathObj) |
| 2380 | return; |
| 2381 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2382 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2383 | |
| 2384 | mImplementation->coverFillPath(pathObj, coverMode); |
| 2385 | } |
| 2386 | |
| 2387 | void Context::coverStrokePath(GLuint path, GLenum coverMode) |
| 2388 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2389 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2390 | if (!pathObj) |
| 2391 | return; |
| 2392 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2393 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2394 | |
| 2395 | mImplementation->coverStrokePath(pathObj, coverMode); |
| 2396 | } |
| 2397 | |
| 2398 | void Context::stencilThenCoverFillPath(GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode) |
| 2399 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2400 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2401 | if (!pathObj) |
| 2402 | return; |
| 2403 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2404 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2405 | |
| 2406 | mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode); |
| 2407 | } |
| 2408 | |
| 2409 | void Context::stencilThenCoverStrokePath(GLuint path, |
| 2410 | GLint reference, |
| 2411 | GLuint mask, |
| 2412 | GLenum coverMode) |
| 2413 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2414 | const auto *pathObj = mState.mPaths->getPath(path); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2415 | if (!pathObj) |
| 2416 | return; |
| 2417 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2418 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 2419 | |
| 2420 | mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode); |
| 2421 | } |
| 2422 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2423 | void Context::coverFillPathInstanced(GLsizei numPaths, |
| 2424 | GLenum pathNameType, |
| 2425 | const void *paths, |
| 2426 | GLuint pathBase, |
| 2427 | GLenum coverMode, |
| 2428 | GLenum transformType, |
| 2429 | const GLfloat *transformValues) |
| 2430 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2431 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2432 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2433 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2434 | |
| 2435 | mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues); |
| 2436 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2437 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2438 | void Context::coverStrokePathInstanced(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 | |
| 2448 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2449 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2450 | |
| 2451 | mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType, |
| 2452 | transformValues); |
| 2453 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2454 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2455 | void Context::stencilFillPathInstanced(GLsizei numPaths, |
| 2456 | GLenum pathNameType, |
| 2457 | const void *paths, |
| 2458 | GLuint pathBase, |
| 2459 | GLenum fillMode, |
| 2460 | GLuint mask, |
| 2461 | GLenum transformType, |
| 2462 | const GLfloat *transformValues) |
| 2463 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2464 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2465 | |
| 2466 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2467 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2468 | |
| 2469 | mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType, |
| 2470 | transformValues); |
| 2471 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2472 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2473 | void Context::stencilStrokePathInstanced(GLsizei numPaths, |
| 2474 | GLenum pathNameType, |
| 2475 | const void *paths, |
| 2476 | GLuint pathBase, |
| 2477 | GLint reference, |
| 2478 | GLuint mask, |
| 2479 | GLenum transformType, |
| 2480 | const GLfloat *transformValues) |
| 2481 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2482 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2483 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2484 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2485 | |
| 2486 | mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType, |
| 2487 | transformValues); |
| 2488 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2489 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2490 | void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths, |
| 2491 | GLenum pathNameType, |
| 2492 | const void *paths, |
| 2493 | GLuint pathBase, |
| 2494 | GLenum fillMode, |
| 2495 | GLuint mask, |
| 2496 | GLenum coverMode, |
| 2497 | GLenum transformType, |
| 2498 | const GLfloat *transformValues) |
| 2499 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2500 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2501 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2502 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2503 | |
| 2504 | mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask, |
| 2505 | transformType, transformValues); |
| 2506 | } |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2507 | |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2508 | void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths, |
| 2509 | GLenum pathNameType, |
| 2510 | const void *paths, |
| 2511 | GLuint pathBase, |
| 2512 | GLint reference, |
| 2513 | GLuint mask, |
| 2514 | GLenum coverMode, |
| 2515 | GLenum transformType, |
| 2516 | const GLfloat *transformValues) |
| 2517 | { |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2518 | const auto &pathObjects = GatherPaths(*mState.mPaths, numPaths, pathNameType, paths, pathBase); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2519 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 2520 | ANGLE_CONTEXT_TRY(syncStateForPathOperation()); |
Sami Väisänen | d59ca05 | 2016-06-21 16:10:00 +0300 | [diff] [blame] | 2521 | |
| 2522 | mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask, |
| 2523 | transformType, transformValues); |
| 2524 | } |
| 2525 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2526 | void Context::bindFragmentInputLocation(GLuint program, GLint location, const GLchar *name) |
| 2527 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2528 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2529 | |
| 2530 | programObject->bindFragmentInputLocation(location, name); |
| 2531 | } |
| 2532 | |
| 2533 | void Context::programPathFragmentInputGen(GLuint program, |
| 2534 | GLint location, |
| 2535 | GLenum genMode, |
| 2536 | GLint components, |
| 2537 | const GLfloat *coeffs) |
| 2538 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2539 | auto *programObject = getProgramResolveLink(program); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2540 | |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 2541 | programObject->pathFragmentInputGen(location, genMode, components, coeffs); |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 2542 | } |
| 2543 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2544 | GLuint Context::getProgramResourceIndex(GLuint program, GLenum programInterface, const GLchar *name) |
| 2545 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2546 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 2547 | return QueryProgramResourceIndex(programObject, programInterface, name); |
| 2548 | } |
| 2549 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2550 | void Context::getProgramResourceName(GLuint program, |
| 2551 | GLenum programInterface, |
| 2552 | GLuint index, |
| 2553 | GLsizei bufSize, |
| 2554 | GLsizei *length, |
| 2555 | GLchar *name) |
| 2556 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2557 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 2558 | QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name); |
| 2559 | } |
| 2560 | |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2561 | GLint Context::getProgramResourceLocation(GLuint program, |
| 2562 | GLenum programInterface, |
| 2563 | const GLchar *name) |
| 2564 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2565 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 191381f | 2017-04-11 13:59:04 +0800 | [diff] [blame] | 2566 | return QueryProgramResourceLocation(programObject, programInterface, name); |
| 2567 | } |
| 2568 | |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2569 | void Context::getProgramResourceiv(GLuint program, |
| 2570 | GLenum programInterface, |
| 2571 | GLuint index, |
| 2572 | GLsizei propCount, |
| 2573 | const GLenum *props, |
| 2574 | GLsizei bufSize, |
| 2575 | GLsizei *length, |
| 2576 | GLint *params) |
| 2577 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2578 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | 880683b | 2017-04-12 16:21:55 +0800 | [diff] [blame] | 2579 | QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize, |
| 2580 | length, params); |
| 2581 | } |
| 2582 | |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2583 | void Context::getProgramInterfaceiv(GLuint program, |
| 2584 | GLenum programInterface, |
| 2585 | GLenum pname, |
| 2586 | GLint *params) |
| 2587 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2588 | const Program *programObject = getProgramResolveLink(program); |
jchen10 | d9cd7b7 | 2017-08-30 15:04:25 +0800 | [diff] [blame] | 2589 | QueryProgramInterfaceiv(programObject, programInterface, pname, params); |
| 2590 | } |
| 2591 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2592 | void Context::getProgramInterfaceivRobust(GLuint program, |
| 2593 | GLenum programInterface, |
| 2594 | GLenum pname, |
| 2595 | GLsizei bufSize, |
| 2596 | GLsizei *length, |
| 2597 | GLint *params) |
| 2598 | { |
| 2599 | UNIMPLEMENTED(); |
| 2600 | } |
| 2601 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 2602 | void Context::handleError(GLenum errorCode, |
| 2603 | const char *message, |
| 2604 | const char *file, |
| 2605 | const char *function, |
| 2606 | unsigned int line) |
| 2607 | { |
| 2608 | mErrors.handleError(errorCode, message, file, function, line); |
| 2609 | } |
| 2610 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 2611 | void Context::validationError(GLenum errorCode, const char *message) |
| 2612 | { |
| 2613 | mErrors.validationError(errorCode, message); |
| 2614 | } |
| 2615 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2616 | // Get one of the recorded errors and clear its flag, if any. |
| 2617 | // [OpenGL ES 2.0.24] section 2.5 page 13. |
| 2618 | GLenum Context::getError() |
| 2619 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2620 | if (mErrors.empty()) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2621 | { |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2622 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2623 | } |
Geoff Lang | da5777c | 2014-07-11 09:52:58 -0400 | [diff] [blame] | 2624 | else |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2625 | { |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2626 | return mErrors.popError(); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2627 | } |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2628 | } |
| 2629 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2630 | // NOTE: this function should not assume that this context is current! |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 2631 | void Context::markContextLost() |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2632 | { |
| 2633 | if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT) |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2634 | { |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2635 | mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT; |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2636 | mContextLostForced = true; |
| 2637 | } |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2638 | mContextLost = true; |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2639 | } |
| 2640 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 2641 | GLenum Context::getGraphicsResetStatus() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2642 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2643 | // Even if the application doesn't want to know about resets, we want to know |
| 2644 | // as it will allow us to skip all the calls. |
| 2645 | if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2646 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2647 | if (!mContextLost && mImplementation->getResetStatus() != GL_NO_ERROR) |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2648 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2649 | mContextLost = true; |
Jamie Madill | 9dd0cf0 | 2014-11-24 11:38:51 -0500 | [diff] [blame] | 2650 | } |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2651 | |
| 2652 | // EXT_robustness, section 2.6: If the reset notification behavior is |
| 2653 | // NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of |
| 2654 | // reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR. |
| 2655 | return GL_NO_ERROR; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2656 | } |
| 2657 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2658 | // The GL_EXT_robustness spec says that if a reset is encountered, a reset |
| 2659 | // status should be returned at least once, and GL_NO_ERROR should be returned |
| 2660 | // once the device has finished resetting. |
| 2661 | if (!mContextLost) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2662 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2663 | ASSERT(mResetStatus == GL_NO_ERROR); |
| 2664 | mResetStatus = mImplementation->getResetStatus(); |
shannon.woods@transgaming.com | ddd6c80 | 2013-02-28 23:05:14 +0000 | [diff] [blame] | 2665 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2666 | if (mResetStatus != GL_NO_ERROR) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2667 | { |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2668 | mContextLost = true; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2669 | } |
| 2670 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2671 | else if (!mContextLostForced && mResetStatus != GL_NO_ERROR) |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2672 | { |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 2673 | // If markContextLost was used to mark the context lost then |
| 2674 | // assume that is not recoverable, and continue to report the |
| 2675 | // lost reset status for the lifetime of this context. |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2676 | mResetStatus = mImplementation->getResetStatus(); |
| 2677 | } |
Jamie Madill | 893ab08 | 2014-05-16 16:56:10 -0400 | [diff] [blame] | 2678 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 2679 | return mResetStatus; |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2680 | } |
| 2681 | |
| 2682 | bool Context::isResetNotificationEnabled() |
| 2683 | { |
| 2684 | return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
| 2685 | } |
| 2686 | |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2687 | const egl::Config *Context::getConfig() const |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2688 | { |
Corentin Wallez | e3b10e8 | 2015-05-20 11:06:25 -0400 | [diff] [blame] | 2689 | return mConfig; |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2690 | } |
| 2691 | |
| 2692 | EGLenum Context::getClientType() const |
| 2693 | { |
| 2694 | return mClientType; |
| 2695 | } |
| 2696 | |
| 2697 | EGLenum Context::getRenderBuffer() const |
| 2698 | { |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2699 | const Framebuffer *framebuffer = mState.mFramebuffers->getFramebuffer(0); |
| 2700 | if (framebuffer == nullptr) |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 2701 | { |
| 2702 | return EGL_NONE; |
| 2703 | } |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2704 | |
Bryan Bernhart (Intel Americas Inc) | 2eeb1b3 | 2017-11-29 16:06:43 -0800 | [diff] [blame] | 2705 | const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK); |
Geoff Lang | 3bf8e3a | 2016-12-01 17:28:52 -0500 | [diff] [blame] | 2706 | ASSERT(backAttachment != nullptr); |
| 2707 | return backAttachment->getSurface()->getRenderBuffer(); |
Régis Fénéon | 8310797 | 2015-02-05 12:57:44 +0100 | [diff] [blame] | 2708 | } |
| 2709 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2710 | VertexArray *Context::checkVertexArrayAllocation(GLuint vertexArrayHandle) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2711 | { |
Jamie Madill | 5bf9ff4 | 2016-02-01 11:13:03 -0500 | [diff] [blame] | 2712 | // Only called after a prior call to Gen. |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2713 | VertexArray *vertexArray = getVertexArray(vertexArrayHandle); |
| 2714 | if (!vertexArray) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2715 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2716 | vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, |
| 2717 | mCaps.maxVertexAttributes, mCaps.maxVertexAttribBindings); |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2718 | |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2719 | mVertexArrayMap.assign(vertexArrayHandle, vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2720 | } |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2721 | |
| 2722 | return vertexArray; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2723 | } |
| 2724 | |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2725 | TransformFeedback *Context::checkTransformFeedbackAllocation(GLuint transformFeedbackHandle) |
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 | TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle); |
| 2729 | if (!transformFeedback) |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2730 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2731 | transformFeedback = |
| 2732 | new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mCaps); |
Jamie Madill | 3f01e6c | 2016-03-08 13:53:02 -0500 | [diff] [blame] | 2733 | transformFeedback->addRef(); |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2734 | mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback); |
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 transformFeedback; |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2738 | } |
| 2739 | |
| 2740 | bool Context::isVertexArrayGenerated(GLuint vertexArray) |
| 2741 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2742 | ASSERT(mVertexArrayMap.contains(0)); |
| 2743 | return mVertexArrayMap.contains(vertexArray); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2744 | } |
| 2745 | |
| 2746 | bool Context::isTransformFeedbackGenerated(GLuint transformFeedback) |
| 2747 | { |
Jamie Madill | 96a483b | 2017-06-27 16:49:21 -0400 | [diff] [blame] | 2748 | ASSERT(mTransformFeedbackMap.contains(0)); |
| 2749 | return mTransformFeedbackMap.contains(transformFeedback); |
Geoff Lang | 36167ab | 2015-12-07 10:27:14 -0500 | [diff] [blame] | 2750 | } |
| 2751 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2752 | void Context::detachTexture(GLuint texture) |
| 2753 | { |
| 2754 | // Simple pass-through to State's detachTexture method, as textures do not require |
| 2755 | // allocation map management either here or in the resource manager at detach time. |
| 2756 | // Zero textures are held by the Context, and we don't attempt to request them from |
| 2757 | // the State. |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2758 | mGLState.detachTexture(this, mZeroTextures, texture); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2759 | } |
| 2760 | |
James Darpinian | 4d9d483 | 2018-03-13 12:43:28 -0700 | [diff] [blame] | 2761 | void Context::detachBuffer(Buffer *buffer) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2762 | { |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2763 | // Simple pass-through to State's detachBuffer method, since |
| 2764 | // only buffer attachments to container objects that are bound to the current context |
| 2765 | // should be detached. And all those are available in State. |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2766 | |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 2767 | // [OpenGL ES 3.2] section 5.1.2 page 45: |
| 2768 | // Attachments to unbound container objects, such as |
| 2769 | // deletion of a buffer attached to a vertex array object which is not bound to the context, |
| 2770 | // are not affected and continue to act as references on the deleted object |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 2771 | ANGLE_CONTEXT_TRY(mGLState.detachBuffer(this, buffer)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2772 | } |
| 2773 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2774 | void Context::detachFramebuffer(GLuint framebuffer) |
| 2775 | { |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2776 | // Framebuffer detachment is handled by Context, because 0 is a valid |
| 2777 | // Framebuffer object, and a pointer to it must be passed from Context |
| 2778 | // to State at binding time. |
| 2779 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2780 | // [OpenGL ES 2.0.24] section 4.4 page 107: |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 2781 | // If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as |
| 2782 | // though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of |
| 2783 | // zero. |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2784 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2785 | if (mGLState.removeReadFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2786 | { |
| 2787 | bindReadFramebuffer(0); |
| 2788 | } |
| 2789 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 2790 | if (mGLState.removeDrawFramebufferBinding(framebuffer) && framebuffer != 0) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2791 | { |
| 2792 | bindDrawFramebuffer(0); |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | void Context::detachRenderbuffer(GLuint renderbuffer) |
| 2797 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 2798 | mGLState.detachRenderbuffer(this, renderbuffer); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2799 | } |
| 2800 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2801 | void Context::detachVertexArray(GLuint vertexArray) |
| 2802 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 2803 | // Vertex array detachment is handled by Context, because 0 is a valid |
| 2804 | // 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] | 2805 | // binding time. |
| 2806 | |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2807 | // [OpenGL ES 3.0.2] section 2.10 page 43: |
| 2808 | // If a vertex array object that is currently bound is deleted, the binding |
| 2809 | // 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] | 2810 | if (mGLState.removeVertexArrayBinding(this, vertexArray)) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 2811 | { |
| 2812 | bindVertexArray(0); |
| 2813 | } |
| 2814 | } |
| 2815 | |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2816 | void Context::detachTransformFeedback(GLuint transformFeedback) |
| 2817 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2818 | // Transform feedback detachment is handled by Context, because 0 is a valid |
| 2819 | // transform feedback, and a pointer to it must be passed from Context to State at |
| 2820 | // binding time. |
| 2821 | |
| 2822 | // The OpenGL specification doesn't mention what should happen when the currently bound |
| 2823 | // transform feedback object is deleted. Since it is a container object, we treat it like |
| 2824 | // 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] | 2825 | if (mGLState.removeTransformFeedbackBinding(this, transformFeedback)) |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2826 | { |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 2827 | bindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 2828 | } |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 2829 | } |
| 2830 | |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2831 | void Context::detachSampler(GLuint sampler) |
| 2832 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 2833 | mGLState.detachSampler(this, sampler); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2834 | } |
| 2835 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 2836 | void Context::detachProgramPipeline(GLuint pipeline) |
| 2837 | { |
| 2838 | mGLState.detachProgramPipeline(this, pipeline); |
| 2839 | } |
| 2840 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 2841 | void Context::vertexAttribDivisor(GLuint index, GLuint divisor) |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2842 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 2843 | mGLState.setVertexAttribDivisor(this, index, divisor); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 2844 | mStateCache.onVertexArrayStateChange(this); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2845 | } |
| 2846 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2847 | void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 2848 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2849 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2850 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2851 | SetSamplerParameteri(this, samplerObject, pname, param); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2852 | } |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2853 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2854 | void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) |
| 2855 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2856 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2857 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2858 | SetSamplerParameteriv(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2859 | } |
| 2860 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2861 | void Context::samplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) |
| 2862 | { |
| 2863 | Sampler *const samplerObject = |
| 2864 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2865 | SetSamplerParameterIiv(this, samplerObject, pname, param); |
| 2866 | } |
| 2867 | |
| 2868 | void Context::samplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *param) |
| 2869 | { |
| 2870 | Sampler *const samplerObject = |
| 2871 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2872 | SetSamplerParameterIuiv(this, samplerObject, pname, param); |
| 2873 | } |
| 2874 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2875 | void Context::samplerParameterivRobust(GLuint sampler, |
| 2876 | GLenum pname, |
| 2877 | GLsizei bufSize, |
| 2878 | const GLint *param) |
| 2879 | { |
| 2880 | samplerParameteriv(sampler, pname, param); |
| 2881 | } |
| 2882 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2883 | void Context::samplerParameterIivRobust(GLuint sampler, |
| 2884 | GLenum pname, |
| 2885 | GLsizei bufSize, |
| 2886 | const GLint *param) |
| 2887 | { |
| 2888 | UNIMPLEMENTED(); |
| 2889 | } |
| 2890 | |
| 2891 | void Context::samplerParameterIuivRobust(GLuint sampler, |
| 2892 | GLenum pname, |
| 2893 | GLsizei bufSize, |
| 2894 | const GLuint *param) |
| 2895 | { |
| 2896 | UNIMPLEMENTED(); |
| 2897 | } |
| 2898 | |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2899 | void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 2900 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2901 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2902 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2903 | SetSamplerParameterf(this, samplerObject, pname, param); |
Jamie Madill | e29d167 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2904 | } |
| 2905 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2906 | void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param) |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2907 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2908 | Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2909 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 2910 | SetSamplerParameterfv(this, samplerObject, pname, param); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2911 | } |
| 2912 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2913 | void Context::samplerParameterfvRobust(GLuint sampler, |
| 2914 | GLenum pname, |
| 2915 | GLsizei bufSize, |
| 2916 | const GLfloat *param) |
| 2917 | { |
| 2918 | samplerParameterfv(sampler, pname, param); |
| 2919 | } |
| 2920 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2921 | void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) |
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 | const Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2924 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2925 | QuerySamplerParameteriv(samplerObject, pname, params); |
| 2926 | } |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2927 | |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2928 | void Context::getSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) |
| 2929 | { |
| 2930 | const Sampler *const samplerObject = |
| 2931 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2932 | QuerySamplerParameterIiv(samplerObject, pname, params); |
| 2933 | } |
| 2934 | |
| 2935 | void Context::getSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) |
| 2936 | { |
| 2937 | const Sampler *const samplerObject = |
| 2938 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
| 2939 | QuerySamplerParameterIuiv(samplerObject, pname, params); |
| 2940 | } |
| 2941 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2942 | void Context::getSamplerParameterivRobust(GLuint sampler, |
| 2943 | GLenum pname, |
| 2944 | GLsizei bufSize, |
| 2945 | GLsizei *length, |
| 2946 | GLint *params) |
| 2947 | { |
| 2948 | getSamplerParameteriv(sampler, pname, params); |
| 2949 | } |
| 2950 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 2951 | void Context::getSamplerParameterIivRobust(GLuint sampler, |
| 2952 | GLenum pname, |
| 2953 | GLsizei bufSize, |
| 2954 | GLsizei *length, |
| 2955 | GLint *params) |
| 2956 | { |
| 2957 | UNIMPLEMENTED(); |
| 2958 | } |
| 2959 | |
| 2960 | void Context::getSamplerParameterIuivRobust(GLuint sampler, |
| 2961 | GLenum pname, |
| 2962 | GLsizei bufSize, |
| 2963 | GLsizei *length, |
| 2964 | GLuint *params) |
| 2965 | { |
| 2966 | UNIMPLEMENTED(); |
| 2967 | } |
| 2968 | |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2969 | void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) |
| 2970 | { |
Till Rathmann | b854363 | 2018-10-02 19:46:14 +0200 | [diff] [blame] | 2971 | const Sampler *const samplerObject = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 2972 | mState.mSamplers->checkSamplerAllocation(mImplementation.get(), sampler); |
Geoff Lang | c1984ed | 2016-10-07 12:41:00 -0400 | [diff] [blame] | 2973 | QuerySamplerParameterfv(samplerObject, pname, params); |
Jamie Madill | 9675b80 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 2974 | } |
| 2975 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 2976 | void Context::getSamplerParameterfvRobust(GLuint sampler, |
| 2977 | GLenum pname, |
| 2978 | GLsizei bufSize, |
| 2979 | GLsizei *length, |
| 2980 | GLfloat *params) |
| 2981 | { |
| 2982 | getSamplerParameterfv(sampler, pname, params); |
| 2983 | } |
| 2984 | |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2985 | void Context::programParameteri(GLuint program, GLenum pname, GLint value) |
| 2986 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 2987 | gl::Program *programObject = getProgramResolveLink(program); |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 2988 | SetProgramParameteri(programObject, pname, value); |
Olli Etuaho | f0fee07 | 2016-03-30 15:11:58 +0300 | [diff] [blame] | 2989 | } |
| 2990 | |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2991 | void Context::initRendererString() |
| 2992 | { |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2993 | std::ostringstream rendererString; |
| 2994 | rendererString << "ANGLE ("; |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 2995 | rendererString << mImplementation->getRendererDescription(); |
daniel@transgaming.com | ca1ac1f | 2013-01-11 04:13:05 +0000 | [diff] [blame] | 2996 | rendererString << ")"; |
| 2997 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2998 | mRendererString = MakeStaticString(rendererString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 2999 | } |
| 3000 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3001 | void Context::initVersionStrings() |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3002 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3003 | const Version &clientVersion = getClientVersion(); |
| 3004 | |
| 3005 | std::ostringstream versionString; |
| 3006 | versionString << "OpenGL ES " << clientVersion.major << "." << clientVersion.minor << " (ANGLE " |
| 3007 | << ANGLE_VERSION_STRING << ")"; |
| 3008 | mVersionString = MakeStaticString(versionString.str()); |
| 3009 | |
| 3010 | std::ostringstream shadingLanguageVersionString; |
| 3011 | shadingLanguageVersionString << "OpenGL ES GLSL ES " |
| 3012 | << (clientVersion.major == 2 ? 1 : clientVersion.major) << "." |
| 3013 | << clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING |
| 3014 | << ")"; |
| 3015 | mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str()); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3016 | } |
| 3017 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3018 | void Context::initExtensionStrings() |
| 3019 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3020 | auto mergeExtensionStrings = [](const std::vector<const char *> &strings) { |
| 3021 | std::ostringstream combinedStringStream; |
| 3022 | std::copy(strings.begin(), strings.end(), |
| 3023 | std::ostream_iterator<const char *>(combinedStringStream, " ")); |
| 3024 | return MakeStaticString(combinedStringStream.str()); |
| 3025 | }; |
| 3026 | |
| 3027 | mExtensionStrings.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3028 | for (const auto &extensionString : mExtensions.getStrings()) |
| 3029 | { |
| 3030 | mExtensionStrings.push_back(MakeStaticString(extensionString)); |
| 3031 | } |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3032 | mExtensionString = mergeExtensionStrings(mExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3033 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3034 | mRequestableExtensionStrings.clear(); |
| 3035 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3036 | { |
| 3037 | if (extensionInfo.second.Requestable && |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3038 | !(mExtensions.*(extensionInfo.second.ExtensionsMember)) && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3039 | mSupportedExtensions.*(extensionInfo.second.ExtensionsMember)) |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3040 | { |
| 3041 | mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first)); |
| 3042 | } |
| 3043 | } |
| 3044 | mRequestableExtensionString = mergeExtensionStrings(mRequestableExtensionStrings); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3045 | } |
| 3046 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3047 | const GLubyte *Context::getString(GLenum name) const |
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 | switch (name) |
| 3050 | { |
| 3051 | case GL_VENDOR: |
| 3052 | return reinterpret_cast<const GLubyte *>("Google Inc."); |
| 3053 | |
| 3054 | case GL_RENDERER: |
| 3055 | return reinterpret_cast<const GLubyte *>(mRendererString); |
| 3056 | |
| 3057 | case GL_VERSION: |
| 3058 | return reinterpret_cast<const GLubyte *>(mVersionString); |
| 3059 | |
| 3060 | case GL_SHADING_LANGUAGE_VERSION: |
| 3061 | return reinterpret_cast<const GLubyte *>(mShadingLanguageString); |
| 3062 | |
| 3063 | case GL_EXTENSIONS: |
| 3064 | return reinterpret_cast<const GLubyte *>(mExtensionString); |
| 3065 | |
| 3066 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3067 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionString); |
| 3068 | |
| 3069 | default: |
| 3070 | UNREACHABLE(); |
| 3071 | return nullptr; |
| 3072 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3073 | } |
| 3074 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3075 | const GLubyte *Context::getStringi(GLenum name, GLuint index) const |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3076 | { |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3077 | switch (name) |
| 3078 | { |
| 3079 | case GL_EXTENSIONS: |
| 3080 | return reinterpret_cast<const GLubyte *>(mExtensionStrings[index]); |
| 3081 | |
| 3082 | case GL_REQUESTABLE_EXTENSIONS_ANGLE: |
| 3083 | return reinterpret_cast<const GLubyte *>(mRequestableExtensionStrings[index]); |
| 3084 | |
| 3085 | default: |
| 3086 | UNREACHABLE(); |
| 3087 | return nullptr; |
| 3088 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 3089 | } |
| 3090 | |
| 3091 | size_t Context::getExtensionStringCount() const |
| 3092 | { |
| 3093 | return mExtensionStrings.size(); |
| 3094 | } |
| 3095 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3096 | bool Context::isExtensionRequestable(const char *name) |
| 3097 | { |
| 3098 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3099 | auto extension = extensionInfos.find(name); |
| 3100 | |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3101 | return extension != extensionInfos.end() && extension->second.Requestable && |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3102 | mSupportedExtensions.*(extension->second.ExtensionsMember); |
Geoff Lang | 111a99e | 2017-10-17 10:58:41 -0400 | [diff] [blame] | 3103 | } |
| 3104 | |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3105 | void Context::requestExtension(const char *name) |
| 3106 | { |
| 3107 | const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap(); |
| 3108 | ASSERT(extensionInfos.find(name) != extensionInfos.end()); |
| 3109 | const auto &extension = extensionInfos.at(name); |
| 3110 | ASSERT(extension.Requestable); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3111 | ASSERT(isExtensionRequestable(name)); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3112 | |
| 3113 | if (mExtensions.*(extension.ExtensionsMember)) |
| 3114 | { |
| 3115 | // Extension already enabled |
| 3116 | return; |
| 3117 | } |
| 3118 | |
| 3119 | mExtensions.*(extension.ExtensionsMember) = true; |
| 3120 | updateCaps(); |
| 3121 | initExtensionStrings(); |
Bryan Bernhart | 5880656 | 2017-01-05 13:09:31 -0800 | [diff] [blame] | 3122 | |
Jamie Madill | 2f348d2 | 2017-06-05 10:50:59 -0400 | [diff] [blame] | 3123 | // Release the shader compiler so it will be re-created with the requested extensions enabled. |
| 3124 | releaseShaderCompiler(); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3125 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 3126 | // Invalidate all textures and framebuffer. Some extensions make new formats renderable or |
| 3127 | // sampleable. |
Jamie Madill | d444255 | 2018-02-27 22:03:47 -0500 | [diff] [blame] | 3128 | mState.mTextures->signalAllTexturesDirty(this); |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3129 | for (auto &zeroTexture : mZeroTextures) |
| 3130 | { |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3131 | if (zeroTexture.get() != nullptr) |
| 3132 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3133 | zeroTexture->signalDirtyStorage(this, InitState::Initialized); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3134 | } |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 3135 | } |
| 3136 | |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 3137 | mState.mFramebuffers->invalidateFramebufferComplenessCache(this); |
Geoff Lang | c339c4e | 2016-11-29 10:37:36 -0500 | [diff] [blame] | 3138 | } |
| 3139 | |
| 3140 | size_t Context::getRequestableExtensionStringCount() const |
| 3141 | { |
| 3142 | return mRequestableExtensionStrings.size(); |
| 3143 | } |
| 3144 | |
Jamie Madill | 493f957 | 2018-05-24 19:52:15 -0400 | [diff] [blame] | 3145 | void Context::beginTransformFeedback(PrimitiveMode primitiveMode) |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3146 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3147 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3148 | ASSERT(transformFeedback != nullptr); |
| 3149 | ASSERT(!transformFeedback->isPaused()); |
| 3150 | |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 3151 | ANGLE_CONTEXT_TRY(transformFeedback->begin(this, primitiveMode, mGLState.getProgram())); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 3152 | mStateCache.onActiveTransformFeedbackChange(this); |
Olli Etuaho | c3e55a4 | 2016-03-09 16:29:18 +0200 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | bool Context::hasActiveTransformFeedback(GLuint program) const |
| 3156 | { |
| 3157 | for (auto pair : mTransformFeedbackMap) |
| 3158 | { |
| 3159 | if (pair.second != nullptr && pair.second->hasBoundProgram(program)) |
| 3160 | { |
| 3161 | return true; |
| 3162 | } |
| 3163 | } |
| 3164 | return false; |
| 3165 | } |
| 3166 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3167 | Extensions Context::generateSupportedExtensions() const |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3168 | { |
| 3169 | Extensions supportedExtensions = mImplementation->getNativeExtensions(); |
| 3170 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3171 | // Explicitly enable GL_KHR_parallel_shader_compile |
| 3172 | supportedExtensions.parallelShaderCompile = true; |
| 3173 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3174 | if (getClientVersion() < ES_2_0) |
| 3175 | { |
| 3176 | // Default extensions for GLES1 |
Lingfeng Yang | 0df813c | 2018-07-12 12:52:06 -0700 | [diff] [blame] | 3177 | supportedExtensions.pointSizeArray = true; |
| 3178 | supportedExtensions.textureCubeMap = true; |
| 3179 | supportedExtensions.pointSprite = true; |
| 3180 | supportedExtensions.drawTexture = true; |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 3181 | supportedExtensions.parallelShaderCompile = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3182 | } |
| 3183 | |
| 3184 | if (getClientVersion() < ES_3_0) |
| 3185 | { |
| 3186 | // Disable ES3+ extensions |
| 3187 | supportedExtensions.colorBufferFloat = false; |
| 3188 | supportedExtensions.eglImageExternalEssl3 = false; |
| 3189 | supportedExtensions.textureNorm16 = false; |
| 3190 | supportedExtensions.multiview = false; |
| 3191 | supportedExtensions.maxViews = 1u; |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 3192 | supportedExtensions.copyTexture3d = false; |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 3193 | supportedExtensions.textureMultisample = false; |
Geoff Lang | 7198ebc | 2018-11-22 14:36:06 -0500 | [diff] [blame] | 3194 | |
| 3195 | // Don't expose GL_EXT_texture_sRGB_decode without sRGB texture support |
| 3196 | if (!supportedExtensions.sRGB) |
| 3197 | { |
| 3198 | supportedExtensions.textureSRGBDecode = false; |
| 3199 | } |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | if (getClientVersion() < ES_3_1) |
| 3203 | { |
| 3204 | // Disable ES3.1+ extensions |
| 3205 | supportedExtensions.geometryShader = false; |
Olli Etuaho | d310a43 | 2018-08-24 15:40:23 +0300 | [diff] [blame] | 3206 | |
| 3207 | // TODO(http://anglebug.com/2775): Multisample arrays could be supported on ES 3.0 as well |
| 3208 | // once 2D multisample texture extension is exposed there. |
Olli Etuaho | 064458a | 2018-08-30 14:02:02 +0300 | [diff] [blame] | 3209 | supportedExtensions.textureStorageMultisample2DArray = false; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3210 | } |
| 3211 | |
| 3212 | if (getClientVersion() > ES_2_0) |
| 3213 | { |
| 3214 | // FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts |
| 3215 | // supportedExtensions.sRGB = false; |
| 3216 | } |
| 3217 | |
| 3218 | // Some extensions are always available because they are implemented in the GL layer. |
| 3219 | supportedExtensions.bindUniformLocation = true; |
| 3220 | supportedExtensions.vertexArrayObject = true; |
| 3221 | supportedExtensions.bindGeneratesResource = true; |
| 3222 | supportedExtensions.clientArrays = true; |
| 3223 | supportedExtensions.requestExtension = true; |
Austin Eng | 7cf9cd2 | 2018-10-09 15:27:32 -0700 | [diff] [blame] | 3224 | supportedExtensions.multiDraw = true; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3225 | |
| 3226 | // Enable the no error extension if the context was created with the flag. |
| 3227 | supportedExtensions.noError = mSkipValidation; |
| 3228 | |
| 3229 | // 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] | 3230 | supportedExtensions.surfacelessContext = mSurfacelessSupported; |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3231 | |
| 3232 | // Explicitly enable GL_KHR_debug |
| 3233 | supportedExtensions.debug = true; |
| 3234 | supportedExtensions.maxDebugMessageLength = 1024; |
| 3235 | supportedExtensions.maxDebugLoggedMessages = 1024; |
| 3236 | supportedExtensions.maxDebugGroupStackDepth = 1024; |
| 3237 | supportedExtensions.maxLabelLength = 1024; |
| 3238 | |
| 3239 | // Explicitly enable GL_ANGLE_robust_client_memory |
| 3240 | supportedExtensions.robustClientMemory = true; |
| 3241 | |
| 3242 | // Determine robust resource init availability from EGL. |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3243 | supportedExtensions.robustResourceInitialization = mGLState.isRobustResourceInitEnabled(); |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3244 | |
| 3245 | // mExtensions.robustBufferAccessBehavior is true only if robust access is true and the backend |
| 3246 | // supports it. |
| 3247 | supportedExtensions.robustBufferAccessBehavior = |
| 3248 | mRobustAccess && supportedExtensions.robustBufferAccessBehavior; |
| 3249 | |
| 3250 | // Enable the cache control query unconditionally. |
| 3251 | supportedExtensions.programCacheControl = true; |
| 3252 | |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3253 | // Enable EGL_ANGLE_explicit_context subextensions |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3254 | if (mExplicitContextAvailable) |
Brandon Jones | 2b0cdcc | 2018-05-02 08:02:50 -0700 | [diff] [blame] | 3255 | { |
| 3256 | // GL_ANGLE_explicit_context_gles1 |
| 3257 | supportedExtensions.explicitContextGles1 = true; |
| 3258 | // GL_ANGLE_explicit_context |
| 3259 | supportedExtensions.explicitContext = true; |
| 3260 | } |
| 3261 | |
Geoff Lang | 79b9140 | 2018-10-04 15:11:30 -0400 | [diff] [blame] | 3262 | supportedExtensions.memorySize = true; |
| 3263 | |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3264 | return supportedExtensions; |
| 3265 | } |
| 3266 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3267 | void Context::initCaps() |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3268 | { |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 3269 | mCaps = mImplementation->getNativeCaps(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3270 | |
Geoff Lang | 33f11fb | 2018-05-07 13:42:47 -0400 | [diff] [blame] | 3271 | mSupportedExtensions = generateSupportedExtensions(); |
| 3272 | mExtensions = mSupportedExtensions; |
Lingfeng Yang | 0107443 | 2018-04-16 10:19:51 -0700 | [diff] [blame] | 3273 | |
| 3274 | mLimitations = mImplementation->getNativeLimitations(); |
| 3275 | |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3276 | // GLES1 emulation: Initialize caps (Table 6.20 / 6.22 in the ES 1.1 spec) |
| 3277 | if (getClientVersion() < Version(2, 0)) |
| 3278 | { |
| 3279 | mCaps.maxMultitextureUnits = 4; |
| 3280 | mCaps.maxClipPlanes = 6; |
| 3281 | mCaps.maxLights = 8; |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 3282 | mCaps.maxModelviewMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3283 | mCaps.maxProjectionMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
| 3284 | mCaps.maxTextureMatrixStackDepth = Caps::GlobalMatrixStackDepth; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 3285 | mCaps.minSmoothPointSize = 1.0f; |
| 3286 | mCaps.maxSmoothPointSize = 1.0f; |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 3287 | mCaps.minSmoothLineWidth = 1.0f; |
| 3288 | mCaps.maxSmoothLineWidth = 1.0f; |
Lingfeng Yang | b27b03a | 2018-02-19 13:38:48 -0800 | [diff] [blame] | 3289 | } |
| 3290 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3291 | // Apply/Verify implementation limits |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3292 | LimitCap(&mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 3293 | |
Luc Ferron | ad2ae93 | 2018-06-11 15:31:17 -0400 | [diff] [blame] | 3294 | ASSERT(mCaps.minAliasedPointSize >= 1.0f); |
| 3295 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3296 | if (getClientVersion() < ES_3_1) |
| 3297 | { |
| 3298 | mCaps.maxVertexAttribBindings = mCaps.maxVertexAttributes; |
| 3299 | } |
| 3300 | else |
| 3301 | { |
| 3302 | LimitCap(&mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS); |
| 3303 | } |
Geoff Lang | 301d161 | 2014-07-09 10:34:37 -0400 | [diff] [blame] | 3304 | |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3305 | LimitCap(&mCaps.maxShaderUniformBlocks[ShaderType::Vertex], |
| 3306 | IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 3307 | LimitCap(&mCaps.maxUniformBufferBindings, IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS); |
| 3308 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 3309 | LimitCap(&mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3310 | LimitCap(&mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4); |
| 3311 | |
| 3312 | // Limit textures as well, so we can use fast bitsets with texture bindings. |
| 3313 | LimitCap(&mCaps.maxCombinedTextureImageUnits, IMPLEMENTATION_MAX_ACTIVE_TEXTURES); |
Jiawei Shao | 54aafe5 | 2018-04-27 14:54:57 +0800 | [diff] [blame] | 3314 | LimitCap(&mCaps.maxShaderTextureImageUnits[ShaderType::Vertex], |
| 3315 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
| 3316 | LimitCap(&mCaps.maxShaderTextureImageUnits[ShaderType::Fragment], |
| 3317 | IMPLEMENTATION_MAX_ACTIVE_TEXTURES / 2); |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 3318 | |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 3319 | LimitCap(&mCaps.maxImageUnits, IMPLEMENTATION_MAX_IMAGE_UNITS); |
| 3320 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 3321 | mCaps.maxSampleMaskWords = std::min<GLuint>(mCaps.maxSampleMaskWords, MAX_SAMPLE_MASK_WORDS); |
| 3322 | |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3323 | // WebGL compatibility |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 3324 | mExtensions.webglCompatibility = mWebGLContext; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3325 | for (const auto &extensionInfo : GetExtensionInfoMap()) |
| 3326 | { |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 3327 | // If the user has requested that extensions start disabled and they are requestable, |
| 3328 | // disable them. |
| 3329 | if (!mExtensionsEnabled && extensionInfo.second.Requestable) |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3330 | { |
| 3331 | mExtensions.*(extensionInfo.second.ExtensionsMember) = false; |
| 3332 | } |
| 3333 | } |
| 3334 | |
| 3335 | // Generate texture caps |
| 3336 | updateCaps(); |
| 3337 | } |
| 3338 | |
| 3339 | void Context::updateCaps() |
| 3340 | { |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3341 | mCaps.compressedTextureFormats.clear(); |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame] | 3342 | mTextureCaps.clear(); |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3343 | |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3344 | for (GLenum sizedInternalFormat : GetAllSizedInternalFormats()) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3345 | { |
Jamie Madill | 7b62cf9 | 2017-11-02 15:20:49 -0400 | [diff] [blame] | 3346 | TextureCaps formatCaps = mImplementation->getNativeTextureCaps().get(sizedInternalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3347 | const InternalFormat &formatInfo = GetSizedInternalFormatInfo(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3348 | |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3349 | // Update the format caps based on the client version and extensions. |
| 3350 | // Caps are AND'd with the renderer caps because some core formats are still unsupported in |
| 3351 | // ES3. |
| 3352 | formatCaps.texturable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 3353 | formatCaps.texturable && formatInfo.textureSupport(getClientVersion(), mExtensions); |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 3354 | formatCaps.filterable = |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 3355 | formatCaps.filterable && formatInfo.filterSupport(getClientVersion(), mExtensions); |
Yuly Novikov | f15f886 | 2018-06-04 18:59:41 -0400 | [diff] [blame] | 3356 | formatCaps.textureAttachment = |
| 3357 | formatCaps.textureAttachment && |
| 3358 | formatInfo.textureAttachmentSupport(getClientVersion(), mExtensions); |
| 3359 | formatCaps.renderbuffer = formatCaps.renderbuffer && |
| 3360 | formatInfo.renderbufferSupport(getClientVersion(), mExtensions); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3361 | |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3362 | // OpenGL ES does not support multisampling with non-rendererable formats |
| 3363 | // 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] | 3364 | if (!formatCaps.renderbuffer || |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3365 | (getClientVersion() < ES_3_1 && !mSupportedExtensions.textureMultisample && |
He Yunchao | ccd8c9b | 2017-01-18 17:36:14 +0800 | [diff] [blame] | 3366 | (formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT))) |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3367 | { |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3368 | formatCaps.sampleCounts.clear(); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3369 | } |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3370 | else |
| 3371 | { |
| 3372 | // We may have limited the max samples for some required renderbuffer formats due to |
| 3373 | // non-conformant formats. In this case MAX_SAMPLES needs to be lowered accordingly. |
| 3374 | GLuint formatMaxSamples = formatCaps.getMaxSamples(); |
| 3375 | |
| 3376 | // GLES 3.0.5 section 4.4.2.2: "Implementations must support creation of renderbuffers |
| 3377 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with the |
| 3378 | // exception of signed and unsigned integer formats." |
| 3379 | if (formatInfo.componentType != GL_INT && formatInfo.componentType != GL_UNSIGNED_INT && |
| 3380 | formatInfo.isRequiredRenderbufferFormat(getClientVersion())) |
| 3381 | { |
| 3382 | ASSERT(getClientVersion() < ES_3_0 || formatMaxSamples >= 4); |
| 3383 | mCaps.maxSamples = std::min(mCaps.maxSamples, formatMaxSamples); |
| 3384 | } |
| 3385 | |
| 3386 | // Handle GLES 3.1 MAX_*_SAMPLES values similarly to MAX_SAMPLES. |
Yizhou Jiang | 2fa2147 | 2018-11-06 15:52:33 +0800 | [diff] [blame] | 3387 | if (getClientVersion() >= ES_3_1 || mSupportedExtensions.textureMultisample) |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 3388 | { |
| 3389 | // GLES 3.1 section 9.2.5: "Implementations must support creation of renderbuffers |
| 3390 | // in these required formats with up to the value of MAX_SAMPLES multisamples, with |
| 3391 | // the exception that the signed and unsigned integer formats are required only to |
| 3392 | // support creation of renderbuffers with up to the value of MAX_INTEGER_SAMPLES |
| 3393 | // multisamples, which must be at least one." |
| 3394 | if (formatInfo.componentType == GL_INT || |
| 3395 | formatInfo.componentType == GL_UNSIGNED_INT) |
| 3396 | { |
| 3397 | mCaps.maxIntegerSamples = std::min(mCaps.maxIntegerSamples, formatMaxSamples); |
| 3398 | } |
| 3399 | |
| 3400 | // GLES 3.1 section 19.3.1. |
| 3401 | if (formatCaps.texturable) |
| 3402 | { |
| 3403 | if (formatInfo.depthBits > 0) |
| 3404 | { |
| 3405 | mCaps.maxDepthTextureSamples = |
| 3406 | std::min(mCaps.maxDepthTextureSamples, formatMaxSamples); |
| 3407 | } |
| 3408 | else if (formatInfo.redBits > 0) |
| 3409 | { |
| 3410 | mCaps.maxColorTextureSamples = |
| 3411 | std::min(mCaps.maxColorTextureSamples, formatMaxSamples); |
| 3412 | } |
| 3413 | } |
| 3414 | } |
| 3415 | } |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3416 | |
| 3417 | if (formatCaps.texturable && formatInfo.compressed) |
| 3418 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3419 | mCaps.compressedTextureFormats.push_back(sizedInternalFormat); |
Geoff Lang | d87878e | 2014-09-19 15:42:59 -0400 | [diff] [blame] | 3420 | } |
| 3421 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 3422 | mTextureCaps.insert(sizedInternalFormat, formatCaps); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3423 | } |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3424 | |
| 3425 | // If program binary is disabled, blank out the memory cache pointer. |
Geoff Lang | b0f917f | 2017-12-05 13:41:54 -0500 | [diff] [blame] | 3426 | if (!mSupportedExtensions.getProgramBinary) |
Jamie Madill | 3244736 | 2017-06-28 14:53:52 -0400 | [diff] [blame] | 3427 | { |
| 3428 | mMemoryProgramCache = nullptr; |
| 3429 | } |
Corentin Wallez | e447700 | 2017-12-01 14:39:58 -0500 | [diff] [blame] | 3430 | |
| 3431 | // Compute which buffer types are allowed |
| 3432 | mValidBufferBindings.reset(); |
| 3433 | mValidBufferBindings.set(BufferBinding::ElementArray); |
| 3434 | mValidBufferBindings.set(BufferBinding::Array); |
| 3435 | |
| 3436 | if (mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0) |
| 3437 | { |
| 3438 | mValidBufferBindings.set(BufferBinding::PixelPack); |
| 3439 | mValidBufferBindings.set(BufferBinding::PixelUnpack); |
| 3440 | } |
| 3441 | |
| 3442 | if (getClientVersion() >= ES_3_0) |
| 3443 | { |
| 3444 | mValidBufferBindings.set(BufferBinding::CopyRead); |
| 3445 | mValidBufferBindings.set(BufferBinding::CopyWrite); |
| 3446 | mValidBufferBindings.set(BufferBinding::TransformFeedback); |
| 3447 | mValidBufferBindings.set(BufferBinding::Uniform); |
| 3448 | } |
| 3449 | |
| 3450 | if (getClientVersion() >= ES_3_1) |
| 3451 | { |
| 3452 | mValidBufferBindings.set(BufferBinding::AtomicCounter); |
| 3453 | mValidBufferBindings.set(BufferBinding::ShaderStorage); |
| 3454 | mValidBufferBindings.set(BufferBinding::DrawIndirect); |
| 3455 | mValidBufferBindings.set(BufferBinding::DispatchIndirect); |
| 3456 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 3457 | |
| 3458 | mThreadPool = angle::WorkerThreadPool::Create(mExtensions.parallelShaderCompile); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3459 | |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3460 | // Reinitialize some dirty bits that depend on extensions. |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3461 | bool robustInit = mGLState.isRobustResourceInitEnabled(); |
| 3462 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3463 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3464 | mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
| 3465 | mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS, robustInit); |
| 3466 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES_INIT, robustInit); |
| 3467 | mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES_INIT, robustInit); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3468 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 3469 | // Reinitialize state cache after extension changes. |
| 3470 | mStateCache.initialize(this); |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 3471 | } |
| 3472 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3473 | void Context::initWorkarounds() |
| 3474 | { |
Jamie Madill | 761b02c | 2017-06-23 16:27:06 -0400 | [diff] [blame] | 3475 | // Apply back-end workarounds. |
| 3476 | mImplementation->applyNativeWorkarounds(&mWorkarounds); |
| 3477 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3478 | // Lose the context upon out of memory error if the application is |
| 3479 | // expecting to watch for those events. |
| 3480 | mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); |
Jamie Madill | d4f0776 | 2018-10-19 19:24:07 -0400 | [diff] [blame] | 3481 | |
| 3482 | if (mWorkarounds.syncFramebufferBindingsOnTexImage) |
| 3483 | { |
| 3484 | // Update the Framebuffer bindings on TexImage to work around an Intel bug. |
| 3485 | mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 3486 | mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 3487 | } |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 3488 | } |
| 3489 | |
Tobin Ehlis | d7890bc | 2018-06-29 11:57:22 -0600 | [diff] [blame] | 3490 | // Return true if the draw is a no-op, else return false. |
| 3491 | // A no-op draw occurs if the count of vertices is less than the minimum required to |
| 3492 | // have a valid primitive for this mode (0 for points, 0-1 for lines, 0-2 for tris). |
| 3493 | bool Context::noopDraw(PrimitiveMode mode, GLsizei count) |
| 3494 | { |
| 3495 | return count < kMinimumPrimitiveCounts[mode]; |
| 3496 | } |
| 3497 | |
| 3498 | bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) |
| 3499 | { |
| 3500 | return (instanceCount == 0) || noopDraw(mode, count); |
| 3501 | } |
| 3502 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3503 | angle::Result Context::prepareForClear(GLbitfield mask) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3504 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3505 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3506 | ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3507 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3508 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3509 | } |
| 3510 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3511 | angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer) |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3512 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3513 | ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects)); |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3514 | ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer, |
| 3515 | drawbuffer)); |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3516 | ANGLE_TRY(syncDirtyBits(mClearDirtyBits)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3517 | return angle::Result::Continue; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3518 | } |
| 3519 | |
Jamie Madill | 132d15c | 2018-11-30 15:25:38 -0500 | [diff] [blame] | 3520 | ANGLE_INLINE angle::Result Context::prepareForDispatch() |
| 3521 | { |
| 3522 | ANGLE_TRY(syncDirtyObjects(mComputeDirtyObjects)); |
| 3523 | return syncDirtyBits(mComputeDirtyBits); |
| 3524 | } |
| 3525 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 3526 | angle::Result Context::syncState(const State::DirtyBits &bitMask, |
| 3527 | const State::DirtyObjects &objectMask) |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 3528 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 3529 | ANGLE_TRY(syncDirtyObjects(objectMask)); |
| 3530 | ANGLE_TRY(syncDirtyBits(bitMask)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 3531 | return angle::Result::Continue; |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3532 | } |
| 3533 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3534 | void Context::blitFramebuffer(GLint srcX0, |
| 3535 | GLint srcY0, |
| 3536 | GLint srcX1, |
| 3537 | GLint srcY1, |
| 3538 | GLint dstX0, |
| 3539 | GLint dstY0, |
| 3540 | GLint dstX1, |
| 3541 | GLint dstY1, |
| 3542 | GLbitfield mask, |
| 3543 | GLenum filter) |
| 3544 | { |
Qin Jiajia | aef9216 | 2018-02-27 13:51:44 +0800 | [diff] [blame] | 3545 | if (mask == 0) |
| 3546 | { |
| 3547 | // ES3.0 spec, section 4.3.2 specifies that a mask of zero is valid and no |
| 3548 | // buffers are copied. |
| 3549 | return; |
| 3550 | } |
| 3551 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3552 | Framebuffer *drawFramebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3553 | ASSERT(drawFramebuffer); |
| 3554 | |
| 3555 | Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0); |
| 3556 | Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0); |
| 3557 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3558 | ANGLE_CONTEXT_TRY(syncStateForBlit()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3559 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3560 | ANGLE_CONTEXT_TRY(drawFramebuffer->blit(this, srcArea, dstArea, mask, filter)); |
apatrick@chromium.org | 144f280 | 2012-07-12 01:42:34 +0000 | [diff] [blame] | 3561 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3562 | |
| 3563 | void Context::clear(GLbitfield mask) |
| 3564 | { |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3565 | ANGLE_CONTEXT_TRY(prepareForClear(mask)); |
| 3566 | ANGLE_CONTEXT_TRY(mGLState.getDrawFramebuffer()->clear(this, mask)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3567 | } |
| 3568 | |
| 3569 | void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) |
| 3570 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3571 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3572 | const FramebufferAttachment *attachment = nullptr; |
| 3573 | if (buffer == GL_DEPTH) |
| 3574 | { |
| 3575 | attachment = framebufferObject->getDepthbuffer(); |
| 3576 | } |
| 3577 | if (buffer == GL_COLOR && |
| 3578 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3579 | { |
| 3580 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3581 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3582 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3583 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3584 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3585 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3586 | return; |
| 3587 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3588 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3589 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3590 | } |
| 3591 | |
| 3592 | void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) |
| 3593 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3594 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3595 | const FramebufferAttachment *attachment = nullptr; |
| 3596 | if (buffer == GL_COLOR && |
| 3597 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3598 | { |
| 3599 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3600 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3601 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3602 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3603 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3604 | { |
| 3605 | return; |
| 3606 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3607 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3608 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferuiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3609 | } |
| 3610 | |
| 3611 | void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) |
| 3612 | { |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3613 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
| 3614 | const FramebufferAttachment *attachment = nullptr; |
| 3615 | if (buffer == GL_STENCIL) |
| 3616 | { |
| 3617 | attachment = framebufferObject->getStencilbuffer(); |
| 3618 | } |
| 3619 | if (buffer == GL_COLOR && |
| 3620 | static_cast<size_t>(drawbuffer) < framebufferObject->getNumColorBuffers()) |
| 3621 | { |
| 3622 | attachment = framebufferObject->getColorbuffer(drawbuffer); |
| 3623 | } |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3624 | // It's not an error to try to clear a non-existent buffer, but it's a no-op. We early out so |
| 3625 | // that the backend doesn't need to take this case into account. |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3626 | if (!attachment) |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 3627 | { |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 3628 | return; |
| 3629 | } |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3630 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
Olli Etuaho | 78df336 | 2018-10-05 16:43:27 +0300 | [diff] [blame] | 3631 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferiv(this, buffer, drawbuffer, values)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3632 | } |
| 3633 | |
| 3634 | void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 3635 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3636 | Framebuffer *framebufferObject = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3637 | ASSERT(framebufferObject); |
| 3638 | |
| 3639 | // If a buffer is not present, the clear has no effect |
| 3640 | if (framebufferObject->getDepthbuffer() == nullptr && |
| 3641 | framebufferObject->getStencilbuffer() == nullptr) |
| 3642 | { |
| 3643 | return; |
| 3644 | } |
| 3645 | |
Geoff Lang | d4fff50 | 2017-09-22 11:28:28 -0400 | [diff] [blame] | 3646 | ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer)); |
| 3647 | ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | void Context::readPixels(GLint x, |
| 3651 | GLint y, |
| 3652 | GLsizei width, |
| 3653 | GLsizei height, |
| 3654 | GLenum format, |
| 3655 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 3656 | void *pixels) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3657 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3658 | if (width == 0 || height == 0) |
| 3659 | { |
| 3660 | return; |
| 3661 | } |
| 3662 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3663 | ANGLE_CONTEXT_TRY(syncStateForReadPixels()); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3664 | |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 3665 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
| 3666 | ASSERT(readFBO); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3667 | |
| 3668 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3669 | ANGLE_CONTEXT_TRY(readFBO->readPixels(this, area, format, type, pixels)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3670 | } |
| 3671 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3672 | void Context::readPixelsRobust(GLint x, |
| 3673 | GLint y, |
| 3674 | GLsizei width, |
| 3675 | GLsizei height, |
| 3676 | GLenum format, |
| 3677 | GLenum type, |
| 3678 | GLsizei bufSize, |
| 3679 | GLsizei *length, |
| 3680 | GLsizei *columns, |
| 3681 | GLsizei *rows, |
| 3682 | void *pixels) |
| 3683 | { |
| 3684 | readPixels(x, y, width, height, format, type, pixels); |
| 3685 | } |
| 3686 | |
| 3687 | void Context::readnPixelsRobust(GLint x, |
| 3688 | GLint y, |
| 3689 | GLsizei width, |
| 3690 | GLsizei height, |
| 3691 | GLenum format, |
| 3692 | GLenum type, |
| 3693 | GLsizei bufSize, |
| 3694 | GLsizei *length, |
| 3695 | GLsizei *columns, |
| 3696 | GLsizei *rows, |
| 3697 | void *data) |
| 3698 | { |
| 3699 | readPixels(x, y, width, height, format, type, data); |
| 3700 | } |
| 3701 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3702 | void Context::copyTexImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3703 | GLint level, |
| 3704 | GLenum internalformat, |
| 3705 | GLint x, |
| 3706 | GLint y, |
| 3707 | GLsizei width, |
| 3708 | GLsizei height, |
| 3709 | GLint border) |
| 3710 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3711 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3712 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3713 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3714 | Rectangle sourceArea(x, y, width, height); |
| 3715 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3716 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3717 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3718 | ANGLE_CONTEXT_TRY( |
| 3719 | texture->copyImage(this, target, level, sourceArea, internalformat, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3720 | } |
| 3721 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3722 | void Context::copyTexSubImage2D(TextureTarget target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3723 | GLint level, |
| 3724 | GLint xoffset, |
| 3725 | GLint yoffset, |
| 3726 | GLint x, |
| 3727 | GLint y, |
| 3728 | GLsizei width, |
| 3729 | GLsizei height) |
| 3730 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3731 | if (width == 0 || height == 0) |
| 3732 | { |
| 3733 | return; |
| 3734 | } |
| 3735 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3736 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3737 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3738 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3739 | Offset destOffset(xoffset, yoffset, 0); |
| 3740 | Rectangle sourceArea(x, y, width, height); |
| 3741 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3742 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3743 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3744 | ANGLE_CONTEXT_TRY( |
| 3745 | texture->copySubImage(this, target, level, destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3746 | } |
| 3747 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3748 | void Context::copyTexSubImage3D(TextureType target, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3749 | GLint level, |
| 3750 | GLint xoffset, |
| 3751 | GLint yoffset, |
| 3752 | GLint zoffset, |
| 3753 | GLint x, |
| 3754 | GLint y, |
| 3755 | GLsizei width, |
| 3756 | GLsizei height) |
| 3757 | { |
Corentin Wallez | 9a8d366 | 2016-09-22 12:18:29 -0400 | [diff] [blame] | 3758 | if (width == 0 || height == 0) |
| 3759 | { |
| 3760 | return; |
| 3761 | } |
| 3762 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3763 | // Only sync the read FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3764 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_READ_FRAMEBUFFER)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3765 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3766 | Offset destOffset(xoffset, yoffset, zoffset); |
| 3767 | Rectangle sourceArea(x, y, width, height); |
| 3768 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 3769 | Framebuffer *framebuffer = mGLState.getReadFramebuffer(); |
| 3770 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3771 | ANGLE_CONTEXT_TRY(texture->copySubImage(this, NonCubeTextureTypeToTarget(target), level, |
| 3772 | destOffset, sourceArea, framebuffer)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | void Context::framebufferTexture2D(GLenum target, |
| 3776 | GLenum attachment, |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3777 | TextureTarget textarget, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3778 | GLuint texture, |
| 3779 | GLint level) |
| 3780 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3781 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3782 | ASSERT(framebuffer); |
| 3783 | |
| 3784 | if (texture != 0) |
| 3785 | { |
| 3786 | Texture *textureObj = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3787 | ImageIndex index = ImageIndex::MakeFromTarget(textarget, level); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3788 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3789 | } |
| 3790 | else |
| 3791 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3792 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3793 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3794 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3795 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3796 | } |
| 3797 | |
| 3798 | void Context::framebufferRenderbuffer(GLenum target, |
| 3799 | GLenum attachment, |
| 3800 | GLenum renderbuffertarget, |
| 3801 | GLuint renderbuffer) |
| 3802 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3803 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3804 | ASSERT(framebuffer); |
| 3805 | |
| 3806 | if (renderbuffer != 0) |
| 3807 | { |
| 3808 | Renderbuffer *renderbufferObject = getRenderbuffer(renderbuffer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3809 | |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3810 | framebuffer->setAttachment(this, GL_RENDERBUFFER, attachment, gl::ImageIndex(), |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3811 | renderbufferObject); |
| 3812 | } |
| 3813 | else |
| 3814 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3815 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3816 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3817 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3818 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3819 | } |
| 3820 | |
| 3821 | void Context::framebufferTextureLayer(GLenum target, |
| 3822 | GLenum attachment, |
| 3823 | GLuint texture, |
| 3824 | GLint level, |
| 3825 | GLint layer) |
| 3826 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3827 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3828 | ASSERT(framebuffer); |
| 3829 | |
| 3830 | if (texture != 0) |
| 3831 | { |
| 3832 | Texture *textureObject = getTexture(texture); |
Jamie Madill | cc12937 | 2018-04-12 09:13:18 -0400 | [diff] [blame] | 3833 | ImageIndex index = ImageIndex::MakeFromType(textureObject->getType(), level, layer); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3834 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObject); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3835 | } |
| 3836 | else |
| 3837 | { |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 3838 | framebuffer->resetAttachment(this, attachment); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3839 | } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3840 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3841 | mGLState.setObjectDirty(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3842 | } |
| 3843 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3844 | void Context::framebufferTextureMultiviewLayered(GLenum target, |
| 3845 | GLenum attachment, |
| 3846 | GLuint texture, |
| 3847 | GLint level, |
| 3848 | GLint baseViewIndex, |
| 3849 | GLsizei numViews) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3850 | { |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3851 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3852 | ASSERT(framebuffer); |
| 3853 | |
| 3854 | if (texture != 0) |
| 3855 | { |
| 3856 | Texture *textureObj = getTexture(texture); |
| 3857 | |
Olli Etuaho | 2c8f084 | 2018-09-12 14:44:55 +0300 | [diff] [blame] | 3858 | ImageIndex index; |
| 3859 | if (textureObj->getType() == TextureType::_2DArray) |
| 3860 | { |
| 3861 | index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews); |
| 3862 | } |
| 3863 | else |
| 3864 | { |
| 3865 | ASSERT(textureObj->getType() == TextureType::_2DMultisampleArray); |
| 3866 | ASSERT(level == 0); |
| 3867 | index = ImageIndex::Make2DMultisampleArrayRange(baseViewIndex, numViews); |
| 3868 | } |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 3869 | framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, |
| 3870 | numViews, baseViewIndex); |
| 3871 | } |
| 3872 | else |
| 3873 | { |
| 3874 | framebuffer->resetAttachment(this, attachment); |
| 3875 | } |
| 3876 | |
| 3877 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3878 | } |
| 3879 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 3880 | void Context::framebufferTextureMultiviewSideBySide(GLenum target, |
| 3881 | GLenum attachment, |
| 3882 | GLuint texture, |
| 3883 | GLint level, |
| 3884 | GLsizei numViews, |
| 3885 | const GLint *viewportOffsets) |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3886 | { |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 3887 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3888 | ASSERT(framebuffer); |
| 3889 | |
| 3890 | if (texture != 0) |
| 3891 | { |
| 3892 | Texture *textureObj = getTexture(texture); |
| 3893 | |
| 3894 | ImageIndex index = ImageIndex::Make2D(level); |
| 3895 | framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index, |
| 3896 | textureObj, numViews, viewportOffsets); |
| 3897 | } |
| 3898 | else |
| 3899 | { |
| 3900 | framebuffer->resetAttachment(this, attachment); |
| 3901 | } |
| 3902 | |
| 3903 | mGLState.setObjectDirty(target); |
Martin Radev | 137032d | 2017-07-13 10:11:12 +0300 | [diff] [blame] | 3904 | } |
| 3905 | |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3906 | void Context::framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) |
| 3907 | { |
Jiawei Shao | a880247 | 2018-05-28 11:17:47 +0800 | [diff] [blame] | 3908 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 3909 | ASSERT(framebuffer); |
| 3910 | |
| 3911 | if (texture != 0) |
| 3912 | { |
| 3913 | Texture *textureObj = getTexture(texture); |
| 3914 | |
| 3915 | ImageIndex index = ImageIndex::MakeFromType( |
| 3916 | textureObj->getType(), level, ImageIndex::kEntireLevel, ImageIndex::kEntireLevel); |
| 3917 | framebuffer->setAttachment(this, GL_TEXTURE, attachment, index, textureObj); |
| 3918 | } |
| 3919 | else |
| 3920 | { |
| 3921 | framebuffer->resetAttachment(this, attachment); |
| 3922 | } |
| 3923 | |
| 3924 | mGLState.setObjectDirty(target); |
Jiawei Shao | 5f9482f | 2018-05-18 09:00:09 +0800 | [diff] [blame] | 3925 | } |
| 3926 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3927 | void Context::drawBuffers(GLsizei n, const GLenum *bufs) |
| 3928 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3929 | Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3930 | ASSERT(framebuffer); |
| 3931 | framebuffer->setDrawBuffers(n, bufs); |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 3932 | mGLState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 3933 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3934 | } |
| 3935 | |
| 3936 | void Context::readBuffer(GLenum mode) |
| 3937 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3938 | Framebuffer *readFBO = mGLState.getReadFramebuffer(); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3939 | readFBO->setReadBuffer(mode); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3940 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3941 | } |
| 3942 | |
| 3943 | void Context::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) |
| 3944 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3945 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3946 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3947 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3948 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3949 | ASSERT(framebuffer); |
| 3950 | |
| 3951 | // The specification isn't clear what should be done when the framebuffer isn't complete. |
| 3952 | // 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] | 3953 | ANGLE_CONTEXT_TRY(framebuffer->discard(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3954 | } |
| 3955 | |
| 3956 | void Context::invalidateFramebuffer(GLenum target, |
| 3957 | GLsizei numAttachments, |
| 3958 | const GLenum *attachments) |
| 3959 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3960 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3961 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3962 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3963 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3964 | ASSERT(framebuffer); |
| 3965 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3966 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3967 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3968 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3969 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3970 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3971 | ANGLE_CONTEXT_TRY(framebuffer->invalidate(this, numAttachments, attachments)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3972 | } |
| 3973 | |
| 3974 | void Context::invalidateSubFramebuffer(GLenum target, |
| 3975 | GLsizei numAttachments, |
| 3976 | const GLenum *attachments, |
| 3977 | GLint x, |
| 3978 | GLint y, |
| 3979 | GLsizei width, |
| 3980 | GLsizei height) |
| 3981 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3982 | // Only sync the FBO |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 3983 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, target)); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 3984 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 3985 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3986 | ASSERT(framebuffer); |
| 3987 | |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 3988 | if (!framebuffer->isComplete(this)) |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3989 | { |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3990 | return; |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3991 | } |
Jamie Madill | 437fa65 | 2016-05-03 15:13:24 -0400 | [diff] [blame] | 3992 | |
| 3993 | Rectangle area(x, y, width, height); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 3994 | ANGLE_CONTEXT_TRY(framebuffer->invalidateSub(this, numAttachments, attachments, area)); |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 3995 | } |
| 3996 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 3997 | void Context::texImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 3998 | GLint level, |
| 3999 | GLint internalformat, |
| 4000 | GLsizei width, |
| 4001 | GLsizei height, |
| 4002 | GLint border, |
| 4003 | GLenum format, |
| 4004 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4005 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4006 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4007 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4008 | |
| 4009 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4010 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4011 | ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(), target, level, |
| 4012 | internalformat, size, format, type, |
| 4013 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4014 | } |
| 4015 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4016 | void Context::texImage2DRobust(TextureTarget target, |
| 4017 | GLint level, |
| 4018 | GLint internalformat, |
| 4019 | GLsizei width, |
| 4020 | GLsizei height, |
| 4021 | GLint border, |
| 4022 | GLenum format, |
| 4023 | GLenum type, |
| 4024 | GLsizei bufSize, |
| 4025 | const void *pixels) |
| 4026 | { |
| 4027 | texImage2D(target, level, internalformat, width, height, border, format, type, pixels); |
| 4028 | } |
| 4029 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4030 | void Context::texImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4031 | GLint level, |
| 4032 | GLint internalformat, |
| 4033 | GLsizei width, |
| 4034 | GLsizei height, |
| 4035 | GLsizei depth, |
| 4036 | GLint border, |
| 4037 | GLenum format, |
| 4038 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4039 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4040 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4041 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4042 | |
| 4043 | Extents size(width, height, depth); |
| 4044 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4045 | ANGLE_CONTEXT_TRY(texture->setImage(this, mGLState.getUnpackState(), |
| 4046 | NonCubeTextureTypeToTarget(target), level, internalformat, |
| 4047 | size, format, type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4048 | } |
| 4049 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4050 | void Context::texImage3DRobust(TextureType target, |
| 4051 | GLint level, |
| 4052 | GLint internalformat, |
| 4053 | GLsizei width, |
| 4054 | GLsizei height, |
| 4055 | GLsizei depth, |
| 4056 | GLint border, |
| 4057 | GLenum format, |
| 4058 | GLenum type, |
| 4059 | GLsizei bufSize, |
| 4060 | const void *pixels) |
| 4061 | { |
| 4062 | texImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4063 | } |
| 4064 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4065 | void Context::texSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4066 | GLint level, |
| 4067 | GLint xoffset, |
| 4068 | GLint yoffset, |
| 4069 | GLsizei width, |
| 4070 | GLsizei height, |
| 4071 | GLenum format, |
| 4072 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4073 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4074 | { |
| 4075 | // Zero sized uploads are valid but no-ops |
| 4076 | if (width == 0 || height == 0) |
| 4077 | { |
| 4078 | return; |
| 4079 | } |
| 4080 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4081 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4082 | |
| 4083 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4084 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4085 | |
| 4086 | gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
| 4087 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4088 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, target, |
| 4089 | level, area, format, type, |
| 4090 | static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4091 | } |
| 4092 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4093 | void Context::texSubImage2DRobust(TextureTarget target, |
| 4094 | GLint level, |
| 4095 | GLint xoffset, |
| 4096 | GLint yoffset, |
| 4097 | GLsizei width, |
| 4098 | GLsizei height, |
| 4099 | GLenum format, |
| 4100 | GLenum type, |
| 4101 | GLsizei bufSize, |
| 4102 | const void *pixels) |
| 4103 | { |
| 4104 | texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4105 | } |
| 4106 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4107 | void Context::texSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4108 | GLint level, |
| 4109 | GLint xoffset, |
| 4110 | GLint yoffset, |
| 4111 | GLint zoffset, |
| 4112 | GLsizei width, |
| 4113 | GLsizei height, |
| 4114 | GLsizei depth, |
| 4115 | GLenum format, |
| 4116 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4117 | const void *pixels) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4118 | { |
| 4119 | // Zero sized uploads are valid but no-ops |
| 4120 | if (width == 0 || height == 0 || depth == 0) |
| 4121 | { |
| 4122 | return; |
| 4123 | } |
| 4124 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4125 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4126 | |
| 4127 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4128 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 0d0fb43 | 2018-09-07 17:43:32 -0400 | [diff] [blame] | 4129 | |
| 4130 | gl::Buffer *unpackBuffer = mGLState.getTargetBuffer(gl::BufferBinding::PixelUnpack); |
| 4131 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4132 | ANGLE_CONTEXT_TRY(texture->setSubImage(this, mGLState.getUnpackState(), unpackBuffer, |
| 4133 | NonCubeTextureTypeToTarget(target), level, area, format, |
| 4134 | type, static_cast<const uint8_t *>(pixels))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4135 | } |
| 4136 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4137 | void Context::texSubImage3DRobust(TextureType target, |
| 4138 | GLint level, |
| 4139 | GLint xoffset, |
| 4140 | GLint yoffset, |
| 4141 | GLint zoffset, |
| 4142 | GLsizei width, |
| 4143 | GLsizei height, |
| 4144 | GLsizei depth, |
| 4145 | GLenum format, |
| 4146 | GLenum type, |
| 4147 | GLsizei bufSize, |
| 4148 | const void *pixels) |
| 4149 | { |
| 4150 | texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, |
| 4151 | pixels); |
| 4152 | } |
| 4153 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4154 | void Context::compressedTexImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4155 | GLint level, |
| 4156 | GLenum internalformat, |
| 4157 | GLsizei width, |
| 4158 | GLsizei height, |
| 4159 | GLint border, |
| 4160 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4161 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4162 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4163 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4164 | |
| 4165 | Extents size(width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4166 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4167 | ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level, |
| 4168 | internalformat, size, imageSize, |
| 4169 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4170 | } |
| 4171 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4172 | void Context::compressedTexImage2DRobust(TextureTarget target, |
| 4173 | GLint level, |
| 4174 | GLenum internalformat, |
| 4175 | GLsizei width, |
| 4176 | GLsizei height, |
| 4177 | GLint border, |
| 4178 | GLsizei imageSize, |
| 4179 | GLsizei dataSize, |
| 4180 | const GLvoid *data) |
| 4181 | { |
| 4182 | compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); |
| 4183 | } |
| 4184 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4185 | void Context::compressedTexImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4186 | GLint level, |
| 4187 | GLenum internalformat, |
| 4188 | GLsizei width, |
| 4189 | GLsizei height, |
| 4190 | GLsizei depth, |
| 4191 | GLint border, |
| 4192 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4193 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4194 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4195 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4196 | |
| 4197 | Extents size(width, height, depth); |
| 4198 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4199 | ANGLE_CONTEXT_TRY(texture->setCompressedImage( |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4200 | this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4201 | size, imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4202 | } |
| 4203 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4204 | void Context::compressedTexImage3DRobust(TextureType target, |
| 4205 | GLint level, |
| 4206 | GLenum internalformat, |
| 4207 | GLsizei width, |
| 4208 | GLsizei height, |
| 4209 | GLsizei depth, |
| 4210 | GLint border, |
| 4211 | GLsizei imageSize, |
| 4212 | GLsizei dataSize, |
| 4213 | const GLvoid *data) |
| 4214 | { |
| 4215 | compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, |
| 4216 | data); |
| 4217 | } |
| 4218 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4219 | void Context::compressedTexSubImage2D(TextureTarget target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4220 | GLint level, |
| 4221 | GLint xoffset, |
| 4222 | GLint yoffset, |
| 4223 | GLsizei width, |
| 4224 | GLsizei height, |
| 4225 | GLenum format, |
| 4226 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4227 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4228 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4229 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4230 | |
| 4231 | Box area(xoffset, yoffset, 0, width, height, 1); |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4232 | Texture *texture = getTargetTexture(TextureTargetToType(target)); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4233 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, |
| 4234 | area, format, imageSize, |
| 4235 | static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4236 | } |
| 4237 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4238 | void Context::compressedTexSubImage2DRobust(TextureTarget target, |
| 4239 | GLint level, |
| 4240 | GLint xoffset, |
| 4241 | GLint yoffset, |
| 4242 | GLsizei width, |
| 4243 | GLsizei height, |
| 4244 | GLenum format, |
| 4245 | GLsizei imageSize, |
| 4246 | GLsizei dataSize, |
| 4247 | const GLvoid *data) |
| 4248 | { |
| 4249 | compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, |
| 4250 | data); |
| 4251 | } |
| 4252 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4253 | void Context::compressedTexSubImage3D(TextureType target, |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4254 | GLint level, |
| 4255 | GLint xoffset, |
| 4256 | GLint yoffset, |
| 4257 | GLint zoffset, |
| 4258 | GLsizei width, |
| 4259 | GLsizei height, |
| 4260 | GLsizei depth, |
| 4261 | GLenum format, |
| 4262 | GLsizei imageSize, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4263 | const void *data) |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4264 | { |
| 4265 | // Zero sized uploads are valid but no-ops |
| 4266 | if (width == 0 || height == 0) |
| 4267 | { |
| 4268 | return; |
| 4269 | } |
| 4270 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4271 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4272 | |
| 4273 | Box area(xoffset, yoffset, zoffset, width, height, depth); |
| 4274 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4275 | ANGLE_CONTEXT_TRY(texture->setCompressedSubImage( |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4276 | this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format, |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 4277 | imageSize, static_cast<const uint8_t *>(data))); |
Jamie Madill | 73a8496 | 2016-02-12 09:27:23 -0500 | [diff] [blame] | 4278 | } |
| 4279 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4280 | void Context::compressedTexSubImage3DRobust(TextureType target, |
| 4281 | GLint level, |
| 4282 | GLint xoffset, |
| 4283 | GLint yoffset, |
| 4284 | GLint zoffset, |
| 4285 | GLsizei width, |
| 4286 | GLsizei height, |
| 4287 | GLsizei depth, |
| 4288 | GLenum format, |
| 4289 | GLsizei imageSize, |
| 4290 | GLsizei dataSize, |
| 4291 | const GLvoid *data) |
| 4292 | { |
| 4293 | compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, |
| 4294 | imageSize, data); |
| 4295 | } |
| 4296 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 4297 | void Context::generateMipmap(TextureType target) |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4298 | { |
| 4299 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4300 | ANGLE_CONTEXT_TRY(texture->generateMipmap(this)); |
Olli Etuaho | 0f2b156 | 2016-05-13 16:15:35 +0300 | [diff] [blame] | 4301 | } |
| 4302 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4303 | void Context::copyTexture(GLuint sourceId, |
| 4304 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4305 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4306 | GLuint destId, |
| 4307 | GLint destLevel, |
| 4308 | GLint internalFormat, |
| 4309 | GLenum destType, |
| 4310 | GLboolean unpackFlipY, |
| 4311 | GLboolean unpackPremultiplyAlpha, |
| 4312 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4313 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4314 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4315 | |
| 4316 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4317 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4318 | ANGLE_CONTEXT_TRY( |
| 4319 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4320 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4321 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4322 | } |
| 4323 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4324 | void Context::copySubTexture(GLuint sourceId, |
| 4325 | GLint sourceLevel, |
Corentin Wallez | 99d492c | 2018-02-27 15:17:10 -0500 | [diff] [blame] | 4326 | TextureTarget destTarget, |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4327 | GLuint destId, |
| 4328 | GLint destLevel, |
| 4329 | GLint xoffset, |
| 4330 | GLint yoffset, |
| 4331 | GLint x, |
| 4332 | GLint y, |
| 4333 | GLsizei width, |
| 4334 | GLsizei height, |
| 4335 | GLboolean unpackFlipY, |
| 4336 | GLboolean unpackPremultiplyAlpha, |
| 4337 | GLboolean unpackUnmultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4338 | { |
| 4339 | // Zero sized copies are valid but no-ops |
| 4340 | if (width == 0 || height == 0) |
| 4341 | { |
| 4342 | return; |
| 4343 | } |
| 4344 | |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4345 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4346 | |
| 4347 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4348 | gl::Texture *destTexture = getTexture(destId); |
| 4349 | Offset offset(xoffset, yoffset, 0); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4350 | Box box(x, y, 0, width, height, 1); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4351 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4352 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4353 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4354 | sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4355 | } |
| 4356 | |
| 4357 | void Context::copyTexture3D(GLuint sourceId, |
| 4358 | GLint sourceLevel, |
| 4359 | TextureTarget destTarget, |
| 4360 | GLuint destId, |
| 4361 | GLint destLevel, |
| 4362 | GLint internalFormat, |
| 4363 | GLenum destType, |
| 4364 | GLboolean unpackFlipY, |
| 4365 | GLboolean unpackPremultiplyAlpha, |
| 4366 | GLboolean unpackUnmultiplyAlpha) |
| 4367 | { |
| 4368 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4369 | |
| 4370 | Texture *sourceTexture = getTexture(sourceId); |
| 4371 | Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4372 | ANGLE_CONTEXT_TRY( |
| 4373 | destTexture->copyTexture(this, destTarget, destLevel, internalFormat, destType, sourceLevel, |
| 4374 | ConvertToBool(unpackFlipY), ConvertToBool(unpackPremultiplyAlpha), |
| 4375 | ConvertToBool(unpackUnmultiplyAlpha), sourceTexture)); |
Brandon Jones | 4e6f2ae | 2018-09-19 11:09:51 -0700 | [diff] [blame] | 4376 | } |
| 4377 | |
| 4378 | void Context::copySubTexture3D(GLuint sourceId, |
| 4379 | GLint sourceLevel, |
| 4380 | TextureTarget destTarget, |
| 4381 | GLuint destId, |
| 4382 | GLint destLevel, |
| 4383 | GLint xoffset, |
| 4384 | GLint yoffset, |
| 4385 | GLint zoffset, |
| 4386 | GLint x, |
| 4387 | GLint y, |
| 4388 | GLint z, |
| 4389 | GLsizei width, |
| 4390 | GLsizei height, |
| 4391 | GLsizei depth, |
| 4392 | GLboolean unpackFlipY, |
| 4393 | GLboolean unpackPremultiplyAlpha, |
| 4394 | GLboolean unpackUnmultiplyAlpha) |
| 4395 | { |
| 4396 | // Zero sized copies are valid but no-ops |
| 4397 | if (width == 0 || height == 0 || depth == 0) |
| 4398 | { |
| 4399 | return; |
| 4400 | } |
| 4401 | |
| 4402 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
| 4403 | |
| 4404 | Texture *sourceTexture = getTexture(sourceId); |
| 4405 | Texture *destTexture = getTexture(destId); |
| 4406 | Offset offset(xoffset, yoffset, zoffset); |
| 4407 | Box box(x, y, z, width, height, depth); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4408 | ANGLE_CONTEXT_TRY(destTexture->copySubTexture( |
| 4409 | this, destTarget, destLevel, offset, sourceLevel, box, ConvertToBool(unpackFlipY), |
| 4410 | ConvertToBool(unpackPremultiplyAlpha), ConvertToBool(unpackUnmultiplyAlpha), |
| 4411 | sourceTexture)); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 4412 | } |
| 4413 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 4414 | void Context::compressedCopyTexture(GLuint sourceId, GLuint destId) |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4415 | { |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 4416 | ANGLE_CONTEXT_TRY(syncStateForTexImage()); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4417 | |
| 4418 | gl::Texture *sourceTexture = getTexture(sourceId); |
| 4419 | gl::Texture *destTexture = getTexture(destId); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 4420 | ANGLE_CONTEXT_TRY(destTexture->copyCompressedTexture(this, sourceTexture)); |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 4421 | } |
| 4422 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4423 | void Context::getBufferPointerv(BufferBinding target, GLenum pname, void **params) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4424 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4425 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4426 | ASSERT(buffer); |
| 4427 | |
Geoff Lang | 496c02d | 2016-10-20 11:38:11 -0700 | [diff] [blame] | 4428 | QueryBufferPointerv(buffer, pname, params); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4429 | } |
| 4430 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4431 | void Context::getBufferPointervRobust(BufferBinding target, |
| 4432 | GLenum pname, |
| 4433 | GLsizei bufSize, |
| 4434 | GLsizei *length, |
| 4435 | void **params) |
| 4436 | { |
| 4437 | getBufferPointerv(target, pname, params); |
| 4438 | } |
| 4439 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4440 | void *Context::mapBuffer(BufferBinding target, GLenum access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4441 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4442 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4443 | ASSERT(buffer); |
| 4444 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4445 | if (buffer->map(this, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4446 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4447 | return nullptr; |
| 4448 | } |
| 4449 | |
| 4450 | return buffer->getMapPointer(); |
| 4451 | } |
| 4452 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4453 | GLboolean Context::unmapBuffer(BufferBinding target) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4454 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4455 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4456 | ASSERT(buffer); |
| 4457 | |
| 4458 | GLboolean result; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4459 | if (buffer->unmap(this, &result) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4460 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4461 | return GL_FALSE; |
| 4462 | } |
| 4463 | |
| 4464 | return result; |
| 4465 | } |
| 4466 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4467 | void *Context::mapBufferRange(BufferBinding target, |
| 4468 | GLintptr offset, |
| 4469 | GLsizeiptr length, |
| 4470 | GLbitfield access) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4471 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4472 | Buffer *buffer = mGLState.getTargetBuffer(target); |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4473 | ASSERT(buffer); |
| 4474 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4475 | if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4476 | { |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4477 | return nullptr; |
| 4478 | } |
| 4479 | |
| 4480 | return buffer->getMapPointer(); |
| 4481 | } |
| 4482 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4483 | void Context::flushMappedBufferRange(BufferBinding /*target*/, |
| 4484 | GLintptr /*offset*/, |
| 4485 | GLsizeiptr /*length*/) |
Olli Etuaho | 4f66748 | 2016-03-30 15:56:35 +0300 | [diff] [blame] | 4486 | { |
| 4487 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
| 4488 | } |
| 4489 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4490 | angle::Result Context::syncStateForReadPixels() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4491 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4492 | return syncState(mReadPixelsDirtyBits, mReadPixelsDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4493 | } |
| 4494 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4495 | angle::Result Context::syncStateForTexImage() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4496 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4497 | return syncState(mTexImageDirtyBits, mTexImageDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4498 | } |
| 4499 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4500 | angle::Result Context::syncStateForBlit() |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4501 | { |
Geoff Lang | a8cb287 | 2018-03-09 16:09:40 -0500 | [diff] [blame] | 4502 | return syncState(mBlitDirtyBits, mBlitDirtyObjects); |
Jamie Madill | ad9f24e | 2016-02-12 09:27:24 -0500 | [diff] [blame] | 4503 | } |
| 4504 | |
Jamie Madill | 526392d | 2018-11-16 09:35:14 -0500 | [diff] [blame] | 4505 | angle::Result Context::syncStateForPathOperation() |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4506 | { |
| 4507 | ANGLE_TRY(syncDirtyObjects(mPathOperationDirtyObjects)); |
| 4508 | |
| 4509 | // TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering? |
| 4510 | ANGLE_TRY(syncDirtyBits()); |
| 4511 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 4512 | return angle::Result::Continue; |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 4513 | } |
| 4514 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4515 | void Context::activeShaderProgram(GLuint pipeline, GLuint program) |
| 4516 | { |
| 4517 | UNIMPLEMENTED(); |
| 4518 | } |
| 4519 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4520 | void Context::activeTexture(GLenum texture) |
| 4521 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4522 | mGLState.setActiveSampler(texture - GL_TEXTURE0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4523 | } |
| 4524 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4525 | void Context::blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4526 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4527 | mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4528 | } |
| 4529 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4530 | void Context::blendEquation(GLenum mode) |
| 4531 | { |
| 4532 | mGLState.setBlendEquation(mode, mode); |
| 4533 | } |
| 4534 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4535 | void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 4536 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4537 | mGLState.setBlendEquation(modeRGB, modeAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4538 | } |
| 4539 | |
Jamie Madill | 8a9e4bc | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 4540 | void Context::blendFunc(GLenum sfactor, GLenum dfactor) |
| 4541 | { |
| 4542 | mGLState.setBlendFactors(sfactor, dfactor, sfactor, dfactor); |
| 4543 | } |
| 4544 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4545 | void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 4546 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4547 | mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4548 | } |
| 4549 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4550 | void Context::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4551 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4552 | mGLState.setColorClearValue(red, green, blue, alpha); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4553 | } |
| 4554 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4555 | void Context::clearDepthf(GLfloat depth) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4556 | { |
Joonatan Saarhelo | 945dea3 | 2018-10-17 20:49:06 +0300 | [diff] [blame] | 4557 | mGLState.setDepthClearValue(clamp01(depth)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4558 | } |
| 4559 | |
| 4560 | void Context::clearStencil(GLint s) |
| 4561 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4562 | mGLState.setStencilClearValue(s); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4563 | } |
| 4564 | |
| 4565 | void Context::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 4566 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4567 | mGLState.setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue), |
| 4568 | ConvertToBool(alpha)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4569 | } |
| 4570 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 4571 | void Context::cullFace(CullFaceMode mode) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4572 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4573 | mGLState.setCullMode(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4574 | } |
| 4575 | |
| 4576 | void Context::depthFunc(GLenum func) |
| 4577 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4578 | mGLState.setDepthFunc(func); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4579 | } |
| 4580 | |
| 4581 | void Context::depthMask(GLboolean flag) |
| 4582 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4583 | mGLState.setDepthMask(ConvertToBool(flag)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4584 | } |
| 4585 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4586 | void Context::depthRangef(GLfloat zNear, GLfloat zFar) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4587 | { |
Joonatan Saarhelo | 945dea3 | 2018-10-17 20:49:06 +0300 | [diff] [blame] | 4588 | mGLState.setDepthRange(clamp01(zNear), clamp01(zFar)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4589 | } |
| 4590 | |
| 4591 | void Context::disable(GLenum cap) |
| 4592 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4593 | mGLState.setEnableFeature(cap, false); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4594 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4595 | } |
| 4596 | |
| 4597 | void Context::disableVertexAttribArray(GLuint index) |
| 4598 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4599 | mGLState.setEnableVertexAttribArray(index, false); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4600 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4601 | } |
| 4602 | |
| 4603 | void Context::enable(GLenum cap) |
| 4604 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4605 | mGLState.setEnableFeature(cap, true); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4606 | mStateCache.onContextCapChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | void Context::enableVertexAttribArray(GLuint index) |
| 4610 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4611 | mGLState.setEnableVertexAttribArray(index, true); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4612 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4613 | } |
| 4614 | |
| 4615 | void Context::frontFace(GLenum mode) |
| 4616 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4617 | mGLState.setFrontFace(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4618 | } |
| 4619 | |
| 4620 | void Context::hint(GLenum target, GLenum mode) |
| 4621 | { |
| 4622 | switch (target) |
| 4623 | { |
| 4624 | case GL_GENERATE_MIPMAP_HINT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4625 | mGLState.setGenerateMipmapHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4626 | break; |
| 4627 | |
| 4628 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4629 | mGLState.setFragmentShaderDerivativeHint(mode); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4630 | break; |
| 4631 | |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 4632 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 4633 | case GL_POINT_SMOOTH_HINT: |
| 4634 | case GL_LINE_SMOOTH_HINT: |
| 4635 | case GL_FOG_HINT: |
| 4636 | mGLState.gles1().setHint(target, mode); |
| 4637 | break; |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4638 | default: |
| 4639 | UNREACHABLE(); |
| 4640 | return; |
| 4641 | } |
| 4642 | } |
| 4643 | |
| 4644 | void Context::lineWidth(GLfloat width) |
| 4645 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4646 | mGLState.setLineWidth(width); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4647 | } |
| 4648 | |
| 4649 | void Context::pixelStorei(GLenum pname, GLint param) |
| 4650 | { |
| 4651 | switch (pname) |
| 4652 | { |
| 4653 | case GL_UNPACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4654 | mGLState.setUnpackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4655 | break; |
| 4656 | |
| 4657 | case GL_PACK_ALIGNMENT: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4658 | mGLState.setPackAlignment(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4659 | break; |
| 4660 | |
| 4661 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4662 | mGLState.setPackReverseRowOrder(param != 0); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4663 | break; |
| 4664 | |
| 4665 | case GL_UNPACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4666 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4667 | mGLState.setUnpackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4668 | break; |
| 4669 | |
| 4670 | case GL_UNPACK_IMAGE_HEIGHT: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4671 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4672 | mGLState.setUnpackImageHeight(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4673 | break; |
| 4674 | |
| 4675 | case GL_UNPACK_SKIP_IMAGES: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4676 | ASSERT(getClientMajorVersion() >= 3); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4677 | mGLState.setUnpackSkipImages(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4678 | break; |
| 4679 | |
| 4680 | case GL_UNPACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4681 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4682 | mGLState.setUnpackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4683 | break; |
| 4684 | |
| 4685 | case GL_UNPACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4686 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().unpackSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4687 | mGLState.setUnpackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4688 | break; |
| 4689 | |
| 4690 | case GL_PACK_ROW_LENGTH: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4691 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4692 | mGLState.setPackRowLength(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4693 | break; |
| 4694 | |
| 4695 | case GL_PACK_SKIP_ROWS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4696 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4697 | mGLState.setPackSkipRows(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4698 | break; |
| 4699 | |
| 4700 | case GL_PACK_SKIP_PIXELS: |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 4701 | ASSERT((getClientMajorVersion() >= 3) || getExtensions().packSubimage); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4702 | mGLState.setPackSkipPixels(param); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4703 | break; |
| 4704 | |
| 4705 | default: |
| 4706 | UNREACHABLE(); |
| 4707 | return; |
| 4708 | } |
| 4709 | } |
| 4710 | |
| 4711 | void Context::polygonOffset(GLfloat factor, GLfloat units) |
| 4712 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4713 | mGLState.setPolygonOffsetParams(factor, units); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4714 | } |
| 4715 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4716 | void Context::sampleCoverage(GLfloat value, GLboolean invert) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4717 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4718 | mGLState.setSampleCoverageParams(clamp01(value), ConvertToBool(invert)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4719 | } |
| 4720 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 4721 | void Context::sampleMaski(GLuint maskNumber, GLbitfield mask) |
| 4722 | { |
| 4723 | mGLState.setSampleMaskParams(maskNumber, mask); |
| 4724 | } |
| 4725 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4726 | void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4727 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4728 | mGLState.setScissorParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4729 | } |
| 4730 | |
| 4731 | void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 4732 | { |
| 4733 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4734 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4735 | mGLState.setStencilParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4736 | } |
| 4737 | |
| 4738 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4739 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4740 | mGLState.setStencilBackParams(func, ref, mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4741 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4742 | |
| 4743 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4744 | } |
| 4745 | |
| 4746 | void Context::stencilMaskSeparate(GLenum face, GLuint mask) |
| 4747 | { |
| 4748 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4749 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4750 | mGLState.setStencilWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4751 | } |
| 4752 | |
| 4753 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4754 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4755 | mGLState.setStencilBackWritemask(mask); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4756 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4757 | |
| 4758 | mStateCache.onStencilStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4759 | } |
| 4760 | |
| 4761 | void Context::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4762 | { |
| 4763 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4764 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4765 | mGLState.setStencilOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4766 | } |
| 4767 | |
| 4768 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4769 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4770 | mGLState.setStencilBackOperations(fail, zfail, zpass); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4771 | } |
| 4772 | } |
| 4773 | |
| 4774 | void Context::vertexAttrib1f(GLuint index, GLfloat x) |
| 4775 | { |
| 4776 | GLfloat vals[4] = {x, 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4777 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4778 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4779 | } |
| 4780 | |
| 4781 | void Context::vertexAttrib1fv(GLuint index, const GLfloat *values) |
| 4782 | { |
| 4783 | GLfloat vals[4] = {values[0], 0, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4784 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4785 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4786 | } |
| 4787 | |
| 4788 | void Context::vertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4789 | { |
| 4790 | GLfloat vals[4] = {x, y, 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4791 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4792 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4793 | } |
| 4794 | |
| 4795 | void Context::vertexAttrib2fv(GLuint index, const GLfloat *values) |
| 4796 | { |
| 4797 | GLfloat vals[4] = {values[0], values[1], 0, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4798 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4799 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4800 | } |
| 4801 | |
| 4802 | void Context::vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4803 | { |
| 4804 | GLfloat vals[4] = {x, y, z, 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4805 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4806 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4807 | } |
| 4808 | |
| 4809 | void Context::vertexAttrib3fv(GLuint index, const GLfloat *values) |
| 4810 | { |
| 4811 | GLfloat vals[4] = {values[0], values[1], values[2], 1}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4812 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4813 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4814 | } |
| 4815 | |
| 4816 | void Context::vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4817 | { |
| 4818 | GLfloat vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4819 | mGLState.setVertexAttribf(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4820 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4821 | } |
| 4822 | |
| 4823 | void Context::vertexAttrib4fv(GLuint index, const GLfloat *values) |
| 4824 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4825 | mGLState.setVertexAttribf(index, values); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4826 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4827 | } |
| 4828 | |
| 4829 | void Context::vertexAttribPointer(GLuint index, |
| 4830 | GLint size, |
| 4831 | GLenum type, |
| 4832 | GLboolean normalized, |
| 4833 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4834 | const void *ptr) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4835 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4836 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(BufferBinding::Array), |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4837 | size, type, ConvertToBool(normalized), false, stride, ptr); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4838 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4839 | } |
| 4840 | |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4841 | void Context::vertexAttribFormat(GLuint attribIndex, |
| 4842 | GLint size, |
| 4843 | GLenum type, |
| 4844 | GLboolean normalized, |
| 4845 | GLuint relativeOffset) |
| 4846 | { |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 4847 | mGLState.setVertexAttribFormat(attribIndex, size, type, ConvertToBool(normalized), false, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4848 | relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4849 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4850 | } |
| 4851 | |
| 4852 | void Context::vertexAttribIFormat(GLuint attribIndex, |
| 4853 | GLint size, |
| 4854 | GLenum type, |
| 4855 | GLuint relativeOffset) |
| 4856 | { |
| 4857 | mGLState.setVertexAttribFormat(attribIndex, size, type, false, true, relativeOffset); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4858 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4859 | } |
| 4860 | |
| 4861 | void Context::vertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) |
| 4862 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 4863 | mGLState.setVertexAttribBinding(this, attribIndex, bindingIndex); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4864 | mStateCache.onVertexArrayStateChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4865 | } |
| 4866 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 4867 | void Context::vertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4868 | { |
| 4869 | mGLState.setVertexBindingDivisor(bindingIndex, divisor); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4870 | mStateCache.onVertexArrayFormatChange(this); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 4871 | } |
| 4872 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4873 | void Context::viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4874 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4875 | mGLState.setViewportParams(x, y, width, height); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4876 | } |
| 4877 | |
| 4878 | void Context::vertexAttribIPointer(GLuint index, |
| 4879 | GLint size, |
| 4880 | GLenum type, |
| 4881 | GLsizei stride, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4882 | const void *pointer) |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4883 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 4884 | mGLState.setVertexAttribPointer(this, index, mGLState.getTargetBuffer(BufferBinding::Array), |
| 4885 | size, type, false, true, stride, pointer); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 4886 | mStateCache.onVertexArrayStateChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4887 | } |
| 4888 | |
| 4889 | void Context::vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 4890 | { |
| 4891 | GLint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4892 | mGLState.setVertexAttribi(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4893 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4894 | } |
| 4895 | |
| 4896 | void Context::vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 4897 | { |
| 4898 | GLuint vals[4] = {x, y, z, w}; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4899 | mGLState.setVertexAttribu(index, vals); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4900 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4901 | } |
| 4902 | |
| 4903 | void Context::vertexAttribI4iv(GLuint index, const GLint *v) |
| 4904 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4905 | mGLState.setVertexAttribi(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4906 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4907 | } |
| 4908 | |
| 4909 | void Context::vertexAttribI4uiv(GLuint index, const GLuint *v) |
| 4910 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 4911 | mGLState.setVertexAttribu(index, v); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 4912 | mStateCache.onDefaultVertexAttributeChange(this); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 4913 | } |
| 4914 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4915 | void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
| 4916 | { |
| 4917 | const VertexAttribCurrentValueData ¤tValues = |
| 4918 | getGLState().getVertexAttribCurrentValue(index); |
| 4919 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4920 | QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4921 | currentValues, pname, params); |
| 4922 | } |
| 4923 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4924 | void Context::getVertexAttribivRobust(GLuint index, |
| 4925 | GLenum pname, |
| 4926 | GLsizei bufSize, |
| 4927 | GLsizei *length, |
| 4928 | GLint *params) |
| 4929 | { |
| 4930 | getVertexAttribiv(index, pname, params); |
| 4931 | } |
| 4932 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4933 | void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
| 4934 | { |
| 4935 | const VertexAttribCurrentValueData ¤tValues = |
| 4936 | getGLState().getVertexAttribCurrentValue(index); |
| 4937 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4938 | QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4939 | currentValues, pname, params); |
| 4940 | } |
| 4941 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4942 | void Context::getVertexAttribfvRobust(GLuint index, |
| 4943 | GLenum pname, |
| 4944 | GLsizei bufSize, |
| 4945 | GLsizei *length, |
| 4946 | GLfloat *params) |
| 4947 | { |
| 4948 | getVertexAttribfv(index, pname, params); |
| 4949 | } |
| 4950 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4951 | void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params) |
| 4952 | { |
| 4953 | const VertexAttribCurrentValueData ¤tValues = |
| 4954 | getGLState().getVertexAttribCurrentValue(index); |
| 4955 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4956 | QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4957 | currentValues, pname, params); |
| 4958 | } |
| 4959 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4960 | void Context::getVertexAttribIivRobust(GLuint index, |
| 4961 | GLenum pname, |
| 4962 | GLsizei bufSize, |
| 4963 | GLsizei *length, |
| 4964 | GLint *params) |
| 4965 | { |
| 4966 | getVertexAttribIiv(index, pname, params); |
| 4967 | } |
| 4968 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4969 | void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) |
| 4970 | { |
| 4971 | const VertexAttribCurrentValueData ¤tValues = |
| 4972 | getGLState().getVertexAttribCurrentValue(index); |
| 4973 | const VertexArray *vao = getGLState().getVertexArray(); |
| 4974 | QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index), |
| 4975 | currentValues, pname, params); |
| 4976 | } |
| 4977 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4978 | void Context::getVertexAttribIuivRobust(GLuint index, |
| 4979 | GLenum pname, |
| 4980 | GLsizei bufSize, |
| 4981 | GLsizei *length, |
| 4982 | GLuint *params) |
| 4983 | { |
| 4984 | getVertexAttribIuiv(index, pname, params); |
| 4985 | } |
| 4986 | |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 4987 | void Context::getVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 4988 | { |
| 4989 | const VertexAttribute &attrib = getGLState().getVertexArray()->getVertexAttribute(index); |
| 4990 | QueryVertexAttribPointerv(attrib, pname, pointer); |
| 4991 | } |
| 4992 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 4993 | void Context::getVertexAttribPointervRobust(GLuint index, |
| 4994 | GLenum pname, |
| 4995 | GLsizei bufSize, |
| 4996 | GLsizei *length, |
| 4997 | void **pointer) |
| 4998 | { |
| 4999 | getVertexAttribPointerv(index, pname, pointer); |
| 5000 | } |
| 5001 | |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5002 | void Context::debugMessageControl(GLenum source, |
| 5003 | GLenum type, |
| 5004 | GLenum severity, |
| 5005 | GLsizei count, |
| 5006 | const GLuint *ids, |
| 5007 | GLboolean enabled) |
| 5008 | { |
| 5009 | std::vector<GLuint> idVector(ids, ids + count); |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5010 | mGLState.getDebug().setMessageControl(source, type, severity, std::move(idVector), |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 5011 | ConvertToBool(enabled)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5012 | } |
| 5013 | |
| 5014 | void Context::debugMessageInsert(GLenum source, |
| 5015 | GLenum type, |
| 5016 | GLuint id, |
| 5017 | GLenum severity, |
| 5018 | GLsizei length, |
| 5019 | const GLchar *buf) |
| 5020 | { |
| 5021 | 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] | 5022 | mGLState.getDebug().insertMessage(source, type, id, severity, std::move(msg)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5023 | } |
| 5024 | |
| 5025 | void Context::debugMessageCallback(GLDEBUGPROCKHR callback, const void *userParam) |
| 5026 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5027 | mGLState.getDebug().setCallback(callback, userParam); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5028 | } |
| 5029 | |
| 5030 | GLuint Context::getDebugMessageLog(GLuint count, |
| 5031 | GLsizei bufSize, |
| 5032 | GLenum *sources, |
| 5033 | GLenum *types, |
| 5034 | GLuint *ids, |
| 5035 | GLenum *severities, |
| 5036 | GLsizei *lengths, |
| 5037 | GLchar *messageLog) |
| 5038 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5039 | return static_cast<GLuint>(mGLState.getDebug().getMessages(count, bufSize, sources, types, ids, |
| 5040 | severities, lengths, messageLog)); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5041 | } |
| 5042 | |
| 5043 | void Context::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message) |
| 5044 | { |
| 5045 | 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] | 5046 | mGLState.getDebug().pushGroup(source, id, std::move(msg)); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5047 | mImplementation->pushDebugGroup(source, id, length, message); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5048 | } |
| 5049 | |
| 5050 | void Context::popDebugGroup() |
| 5051 | { |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 5052 | mGLState.getDebug().popGroup(); |
Geoff Lang | 5d5253a | 2017-11-22 14:51:12 -0500 | [diff] [blame] | 5053 | mImplementation->popDebugGroup(); |
Jamie Madill | c20ab27 | 2016-06-09 07:20:46 -0700 | [diff] [blame] | 5054 | } |
| 5055 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5056 | void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5057 | { |
| 5058 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 5059 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5060 | ANGLE_CONTEXT_TRY(buffer->bufferData(this, target, data, size, usage)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5061 | } |
| 5062 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5063 | void Context::bufferSubData(BufferBinding target, |
| 5064 | GLintptr offset, |
| 5065 | GLsizeiptr size, |
| 5066 | const void *data) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5067 | { |
Courtney Goeltzenleuchter | 62114aa | 2018-08-28 09:36:46 -0600 | [diff] [blame] | 5068 | if (data == nullptr || size == 0) |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5069 | { |
| 5070 | return; |
| 5071 | } |
| 5072 | |
| 5073 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 5074 | ASSERT(buffer); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5075 | ANGLE_CONTEXT_TRY(buffer->bufferSubData(this, target, data, size, offset)); |
Jamie Madill | 2963985 | 2016-09-02 15:00:09 -0400 | [diff] [blame] | 5076 | } |
| 5077 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5078 | void Context::attachShader(GLuint program, GLuint shader) |
| 5079 | { |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 5080 | Program *programObject = mState.mShaderPrograms->getProgram(program); |
| 5081 | Shader *shaderObject = mState.mShaderPrograms->getShader(shader); |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 5082 | ASSERT(programObject && shaderObject); |
| 5083 | programObject->attachShader(shaderObject); |
| 5084 | } |
| 5085 | |
Kenneth Russell | f2f6f65 | 2016-10-05 19:53:23 -0700 | [diff] [blame] | 5086 | const Workarounds &Context::getWorkarounds() const |
| 5087 | { |
| 5088 | return mWorkarounds; |
| 5089 | } |
| 5090 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5091 | void Context::copyBufferSubData(BufferBinding readTarget, |
| 5092 | BufferBinding writeTarget, |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5093 | GLintptr readOffset, |
| 5094 | GLintptr writeOffset, |
| 5095 | GLsizeiptr size) |
| 5096 | { |
| 5097 | // if size is zero, the copy is a successful no-op |
| 5098 | if (size == 0) |
| 5099 | { |
| 5100 | return; |
| 5101 | } |
| 5102 | |
| 5103 | // TODO(jmadill): cache these. |
| 5104 | Buffer *readBuffer = mGLState.getTargetBuffer(readTarget); |
| 5105 | Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget); |
| 5106 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5107 | ANGLE_CONTEXT_TRY( |
| 5108 | writeBuffer->copyBufferSubData(this, readBuffer, readOffset, writeOffset, size)); |
Jamie Madill | b0817d1 | 2016-11-01 15:48:31 -0400 | [diff] [blame] | 5109 | } |
| 5110 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5111 | void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name) |
| 5112 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5113 | // Ideally we could share the program query with the validation layer if possible. |
| 5114 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5115 | ASSERT(programObject); |
| 5116 | programObject->bindAttributeLocation(index, name); |
| 5117 | } |
| 5118 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5119 | void Context::bindBuffer(BufferBinding target, GLuint buffer) |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5120 | { |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5121 | Buffer *bufferObject = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); |
| 5122 | mGLState.setBufferBinding(this, target, bufferObject); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5123 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5124 | } |
| 5125 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5126 | void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5127 | { |
| 5128 | bindBufferRange(target, index, buffer, 0, 0); |
| 5129 | } |
| 5130 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 5131 | void Context::bindBufferRange(BufferBinding target, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5132 | GLuint index, |
| 5133 | GLuint buffer, |
| 5134 | GLintptr offset, |
| 5135 | GLsizeiptr size) |
| 5136 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5137 | Buffer *object = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 5138 | ANGLE_CONTEXT_TRY(mGLState.setIndexedBufferBinding(this, target, index, object, offset, size)); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5139 | if (target == BufferBinding::Uniform) |
| 5140 | { |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 5141 | mUniformBufferObserverBindings[index].bind(object); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 5142 | mStateCache.onUniformBufferStateChange(this); |
| 5143 | } |
| 5144 | else |
| 5145 | { |
| 5146 | mStateCache.onBufferBindingChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 5147 | } |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 5148 | } |
| 5149 | |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5150 | void Context::bindFramebuffer(GLenum target, GLuint framebuffer) |
| 5151 | { |
| 5152 | if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5153 | { |
| 5154 | bindReadFramebuffer(framebuffer); |
| 5155 | } |
| 5156 | |
| 5157 | if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) |
| 5158 | { |
| 5159 | bindDrawFramebuffer(framebuffer); |
| 5160 | } |
| 5161 | } |
| 5162 | |
| 5163 | void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 5164 | { |
| 5165 | ASSERT(target == GL_RENDERBUFFER); |
| 5166 | Renderbuffer *object = |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 5167 | mState.mRenderbuffers->checkRenderbufferAllocation(mImplementation.get(), renderbuffer); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5168 | mGLState.setRenderbufferBinding(this, object); |
Jamie Madill | 01a80ee | 2016-11-07 12:06:18 -0500 | [diff] [blame] | 5169 | } |
| 5170 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5171 | void Context::texStorage2DMultisample(TextureType target, |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5172 | GLsizei samples, |
| 5173 | GLenum internalformat, |
| 5174 | GLsizei width, |
| 5175 | GLsizei height, |
| 5176 | GLboolean fixedsamplelocations) |
| 5177 | { |
| 5178 | Extents size(width, height, 1); |
| 5179 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5180 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5181 | ConvertToBool(fixedsamplelocations))); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5182 | } |
| 5183 | |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5184 | void Context::texStorage3DMultisample(TextureType target, |
| 5185 | GLsizei samples, |
| 5186 | GLenum internalformat, |
| 5187 | GLsizei width, |
| 5188 | GLsizei height, |
| 5189 | GLsizei depth, |
| 5190 | GLboolean fixedsamplelocations) |
| 5191 | { |
Olli Etuaho | 0c5a9e2 | 2018-08-27 14:36:23 +0300 | [diff] [blame] | 5192 | Extents size(width, height, depth); |
| 5193 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5194 | ANGLE_CONTEXT_TRY(texture->setStorageMultisample(this, target, samples, internalformat, size, |
| 5195 | ConvertToBool(fixedsamplelocations))); |
Olli Etuaho | 8966484 | 2018-08-24 14:45:36 +0300 | [diff] [blame] | 5196 | } |
| 5197 | |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5198 | void Context::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val) |
| 5199 | { |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5200 | // According to spec 3.1 Table 20.49: Framebuffer Dependent Values, |
| 5201 | // the sample position should be queried by DRAW_FRAMEBUFFER. |
Jamie Madill | bc918e7 | 2018-03-08 09:47:21 -0500 | [diff] [blame] | 5202 | ANGLE_CONTEXT_TRY(mGLState.syncDirtyObject(this, GL_DRAW_FRAMEBUFFER)); |
JiangYizhou | 5b03f47 | 2017-01-09 10:22:53 +0800 | [diff] [blame] | 5203 | const Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5204 | |
| 5205 | switch (pname) |
| 5206 | { |
| 5207 | case GL_SAMPLE_POSITION: |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5208 | ANGLE_CONTEXT_TRY(framebuffer->getSamplePosition(this, index, val)); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 5209 | break; |
| 5210 | default: |
| 5211 | UNREACHABLE(); |
| 5212 | } |
| 5213 | } |
| 5214 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5215 | void Context::getMultisamplefvRobust(GLenum pname, |
| 5216 | GLuint index, |
| 5217 | GLsizei bufSize, |
| 5218 | GLsizei *length, |
| 5219 | GLfloat *val) |
| 5220 | { |
| 5221 | UNIMPLEMENTED(); |
| 5222 | } |
| 5223 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5224 | void Context::renderbufferStorage(GLenum target, |
| 5225 | GLenum internalformat, |
| 5226 | GLsizei width, |
| 5227 | GLsizei height) |
| 5228 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5229 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5230 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
| 5231 | |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5232 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5233 | ANGLE_CONTEXT_TRY(renderbuffer->setStorage(this, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5234 | } |
| 5235 | |
| 5236 | void Context::renderbufferStorageMultisample(GLenum target, |
| 5237 | GLsizei samples, |
| 5238 | GLenum internalformat, |
| 5239 | GLsizei width, |
| 5240 | GLsizei height) |
| 5241 | { |
Jamie Madill | 4e0e6f8 | 2017-02-17 11:06:03 -0500 | [diff] [blame] | 5242 | // Hack for the special WebGL 1 "DEPTH_STENCIL" internal format. |
| 5243 | GLenum convertedInternalFormat = getConvertedRenderbufferFormat(internalformat); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5244 | |
| 5245 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5246 | ANGLE_CONTEXT_TRY( |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5247 | renderbuffer->setStorageMultisample(this, samples, convertedInternalFormat, width, height)); |
Jamie Madill | e8fb640 | 2017-02-14 17:56:40 -0500 | [diff] [blame] | 5248 | } |
| 5249 | |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5250 | void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) |
| 5251 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 5252 | const Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5253 | ANGLE_CONTEXT_TRY(QuerySynciv(this, syncObject, pname, bufSize, length, values)); |
Geoff Lang | 38f2cfb | 2017-04-11 15:23:08 -0400 | [diff] [blame] | 5254 | } |
| 5255 | |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5256 | void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| 5257 | { |
| 5258 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 5259 | QueryFramebufferParameteriv(framebuffer, pname, params); |
| 5260 | } |
| 5261 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 5262 | void Context::getFramebufferParameterivRobust(GLenum target, |
| 5263 | GLenum pname, |
| 5264 | GLsizei bufSize, |
| 5265 | GLsizei *length, |
| 5266 | GLint *params) |
| 5267 | { |
| 5268 | UNIMPLEMENTED(); |
| 5269 | } |
| 5270 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5271 | void Context::framebufferParameteri(GLenum target, GLenum pname, GLint param) |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5272 | { |
| 5273 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
Jamie Madill | b983a4b | 2018-08-01 11:34:51 -0400 | [diff] [blame] | 5274 | SetFramebufferParameteri(this, framebuffer, pname, param); |
JiangYizhou | e18e639 | 2017-02-20 10:32:23 +0800 | [diff] [blame] | 5275 | } |
| 5276 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5277 | bool Context::getScratchBuffer(size_t requstedSizeBytes, |
| 5278 | angle::MemoryBuffer **scratchBufferOut) const |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5279 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5280 | return mScratchBuffer.get(requstedSizeBytes, scratchBufferOut); |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5281 | } |
| 5282 | |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5283 | bool Context::getZeroFilledBuffer(size_t requstedSizeBytes, |
| 5284 | angle::MemoryBuffer **zeroBufferOut) const |
Jamie Madill | b3f26b9 | 2017-07-19 15:07:41 -0400 | [diff] [blame] | 5285 | { |
Jamie Madill | dec8623 | 2018-07-11 09:01:18 -0400 | [diff] [blame] | 5286 | return mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0); |
Jamie Madill | e14951e | 2017-03-09 18:55:16 -0500 | [diff] [blame] | 5287 | } |
| 5288 | |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5289 | void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) |
| 5290 | { |
| 5291 | if (numGroupsX == 0u || numGroupsY == 0u || numGroupsZ == 0u) |
| 5292 | { |
| 5293 | return; |
| 5294 | } |
| 5295 | |
Xinghua Cao | 10a4d43 | 2017-11-28 14:46:26 +0800 | [diff] [blame] | 5296 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5297 | ANGLE_CONTEXT_TRY(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 5298 | } |
| 5299 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5300 | void Context::dispatchComputeIndirect(GLintptr indirect) |
| 5301 | { |
Qin Jiajia | 62fcf62 | 2017-11-30 16:16:12 +0800 | [diff] [blame] | 5302 | ANGLE_CONTEXT_TRY(prepareForDispatch()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5303 | ANGLE_CONTEXT_TRY(mImplementation->dispatchComputeIndirect(this, indirect)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5304 | } |
| 5305 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5306 | void Context::texStorage2D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5307 | GLsizei levels, |
| 5308 | GLenum internalFormat, |
| 5309 | GLsizei width, |
| 5310 | GLsizei height) |
| 5311 | { |
| 5312 | Extents size(width, height, 1); |
| 5313 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5314 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5315 | } |
| 5316 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 5317 | void Context::texStorage3D(TextureType target, |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5318 | GLsizei levels, |
| 5319 | GLenum internalFormat, |
| 5320 | GLsizei width, |
| 5321 | GLsizei height, |
| 5322 | GLsizei depth) |
| 5323 | { |
| 5324 | Extents size(width, height, depth); |
| 5325 | Texture *texture = getTargetTexture(target); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5326 | ANGLE_CONTEXT_TRY(texture->setStorage(this, target, levels, internalFormat, size)); |
JiangYizhou | 165361c | 2017-06-07 14:56:57 +0800 | [diff] [blame] | 5327 | } |
| 5328 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5329 | void Context::memoryBarrier(GLbitfield barriers) |
| 5330 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5331 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrier(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5332 | } |
| 5333 | |
| 5334 | void Context::memoryBarrierByRegion(GLbitfield barriers) |
| 5335 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5336 | ANGLE_CONTEXT_TRY(mImplementation->memoryBarrierByRegion(this, barriers)); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5337 | } |
| 5338 | |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5339 | void Context::multiDrawArrays(PrimitiveMode mode, |
| 5340 | const GLint *firsts, |
| 5341 | const GLsizei *counts, |
| 5342 | GLsizei drawcount) |
| 5343 | { |
| 5344 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5345 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5346 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5347 | if (hasDrawID) |
| 5348 | { |
| 5349 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5350 | { |
| 5351 | if (noopDraw(mode, counts[drawID])) |
| 5352 | { |
| 5353 | continue; |
| 5354 | } |
| 5355 | programObject->setDrawIDUniform(drawID); |
| 5356 | ANGLE_CONTEXT_TRY( |
| 5357 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5358 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5359 | } |
| 5360 | } |
| 5361 | else |
| 5362 | { |
| 5363 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5364 | { |
| 5365 | if (noopDraw(mode, counts[drawID])) |
| 5366 | { |
| 5367 | continue; |
| 5368 | } |
| 5369 | ANGLE_CONTEXT_TRY( |
| 5370 | mImplementation->drawArrays(this, mode, firsts[drawID], counts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5371 | MarkTransformFeedbackBufferUsage(this, counts[drawID], 1); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5372 | } |
| 5373 | } |
| 5374 | } |
| 5375 | |
| 5376 | void Context::multiDrawArraysInstanced(PrimitiveMode mode, |
| 5377 | const GLint *firsts, |
| 5378 | const GLsizei *counts, |
| 5379 | const GLsizei *instanceCounts, |
| 5380 | GLsizei drawcount) |
| 5381 | { |
| 5382 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5383 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5384 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5385 | if (hasDrawID) |
| 5386 | { |
| 5387 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5388 | { |
| 5389 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5390 | { |
| 5391 | continue; |
| 5392 | } |
| 5393 | programObject->setDrawIDUniform(drawID); |
| 5394 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5395 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5396 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5397 | } |
| 5398 | } |
| 5399 | else |
| 5400 | { |
| 5401 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5402 | { |
| 5403 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5404 | { |
| 5405 | continue; |
| 5406 | } |
| 5407 | ANGLE_CONTEXT_TRY(mImplementation->drawArraysInstanced( |
| 5408 | this, mode, firsts[drawID], counts[drawID], instanceCounts[drawID])); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 5409 | MarkTransformFeedbackBufferUsage(this, counts[drawID], instanceCounts[drawID]); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5410 | } |
| 5411 | } |
| 5412 | } |
| 5413 | |
| 5414 | void Context::multiDrawElements(PrimitiveMode mode, |
| 5415 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5416 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5417 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5418 | GLsizei drawcount) |
| 5419 | { |
| 5420 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5421 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5422 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5423 | if (hasDrawID) |
| 5424 | { |
| 5425 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5426 | { |
| 5427 | if (noopDraw(mode, counts[drawID])) |
| 5428 | { |
| 5429 | continue; |
| 5430 | } |
| 5431 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5432 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5433 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5434 | } |
| 5435 | } |
| 5436 | else |
| 5437 | { |
| 5438 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5439 | { |
| 5440 | if (noopDraw(mode, counts[drawID])) |
| 5441 | { |
| 5442 | continue; |
| 5443 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5444 | ANGLE_CONTEXT_TRY( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5445 | mImplementation->drawElements(this, mode, counts[drawID], type, indices[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5446 | } |
| 5447 | } |
| 5448 | } |
| 5449 | |
| 5450 | void Context::multiDrawElementsInstanced(PrimitiveMode mode, |
| 5451 | const GLsizei *counts, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 5452 | DrawElementsType type, |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5453 | const GLvoid *const *indices, |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5454 | const GLsizei *instanceCounts, |
| 5455 | GLsizei drawcount) |
| 5456 | { |
| 5457 | ANGLE_CONTEXT_TRY(prepareForDraw(mode)); |
| 5458 | Program *programObject = mGLState.getLinkedProgram(this); |
| 5459 | const bool hasDrawID = programObject && programObject->hasDrawIDUniform(); |
| 5460 | if (hasDrawID) |
| 5461 | { |
| 5462 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5463 | { |
| 5464 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5465 | { |
| 5466 | continue; |
| 5467 | } |
| 5468 | programObject->setDrawIDUniform(drawID); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5469 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5470 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5471 | } |
| 5472 | } |
| 5473 | else |
| 5474 | { |
| 5475 | for (GLsizei drawID = 0; drawID < drawcount; ++drawID) |
| 5476 | { |
| 5477 | if (noopDrawInstanced(mode, counts[drawID], instanceCounts[drawID])) |
| 5478 | { |
| 5479 | continue; |
| 5480 | } |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5481 | ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstanced( |
Austin Eng | 3b7c9d0 | 2018-11-21 18:09:05 -0800 | [diff] [blame] | 5482 | this, mode, counts[drawID], type, indices[drawID], instanceCounts[drawID])); |
Austin Eng | 1bf18ce | 2018-10-19 15:34:02 -0700 | [diff] [blame] | 5483 | } |
| 5484 | } |
| 5485 | } |
| 5486 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5487 | GLenum Context::checkFramebufferStatus(GLenum target) |
| 5488 | { |
| 5489 | Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); |
| 5490 | ASSERT(framebuffer); |
Jamie Madill | 427064d | 2018-04-13 16:20:34 -0400 | [diff] [blame] | 5491 | return framebuffer->checkStatus(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5492 | } |
| 5493 | |
| 5494 | void Context::compileShader(GLuint shader) |
| 5495 | { |
| 5496 | Shader *shaderObject = GetValidShader(this, shader); |
| 5497 | if (!shaderObject) |
| 5498 | { |
| 5499 | return; |
| 5500 | } |
| 5501 | shaderObject->compile(this); |
| 5502 | } |
| 5503 | |
| 5504 | void Context::deleteBuffers(GLsizei n, const GLuint *buffers) |
| 5505 | { |
| 5506 | for (int i = 0; i < n; i++) |
| 5507 | { |
| 5508 | deleteBuffer(buffers[i]); |
| 5509 | } |
| 5510 | } |
| 5511 | |
| 5512 | void Context::deleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
| 5513 | { |
| 5514 | for (int i = 0; i < n; i++) |
| 5515 | { |
| 5516 | if (framebuffers[i] != 0) |
| 5517 | { |
| 5518 | deleteFramebuffer(framebuffers[i]); |
| 5519 | } |
| 5520 | } |
| 5521 | } |
| 5522 | |
| 5523 | void Context::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
| 5524 | { |
| 5525 | for (int i = 0; i < n; i++) |
| 5526 | { |
| 5527 | deleteRenderbuffer(renderbuffers[i]); |
| 5528 | } |
| 5529 | } |
| 5530 | |
| 5531 | void Context::deleteTextures(GLsizei n, const GLuint *textures) |
| 5532 | { |
| 5533 | for (int i = 0; i < n; i++) |
| 5534 | { |
| 5535 | if (textures[i] != 0) |
| 5536 | { |
| 5537 | deleteTexture(textures[i]); |
| 5538 | } |
| 5539 | } |
| 5540 | } |
| 5541 | |
| 5542 | void Context::detachShader(GLuint program, GLuint shader) |
| 5543 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5544 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5545 | ASSERT(programObject); |
| 5546 | |
| 5547 | Shader *shaderObject = getShader(shader); |
| 5548 | ASSERT(shaderObject); |
| 5549 | |
| 5550 | programObject->detachShader(this, shaderObject); |
| 5551 | } |
| 5552 | |
| 5553 | void Context::genBuffers(GLsizei n, GLuint *buffers) |
| 5554 | { |
| 5555 | for (int i = 0; i < n; i++) |
| 5556 | { |
| 5557 | buffers[i] = createBuffer(); |
| 5558 | } |
| 5559 | } |
| 5560 | |
| 5561 | void Context::genFramebuffers(GLsizei n, GLuint *framebuffers) |
| 5562 | { |
| 5563 | for (int i = 0; i < n; i++) |
| 5564 | { |
| 5565 | framebuffers[i] = createFramebuffer(); |
| 5566 | } |
| 5567 | } |
| 5568 | |
| 5569 | void Context::genRenderbuffers(GLsizei n, GLuint *renderbuffers) |
| 5570 | { |
| 5571 | for (int i = 0; i < n; i++) |
| 5572 | { |
| 5573 | renderbuffers[i] = createRenderbuffer(); |
| 5574 | } |
| 5575 | } |
| 5576 | |
| 5577 | void Context::genTextures(GLsizei n, GLuint *textures) |
| 5578 | { |
| 5579 | for (int i = 0; i < n; i++) |
| 5580 | { |
| 5581 | textures[i] = createTexture(); |
| 5582 | } |
| 5583 | } |
| 5584 | |
| 5585 | void Context::getActiveAttrib(GLuint program, |
| 5586 | GLuint index, |
| 5587 | GLsizei bufsize, |
| 5588 | GLsizei *length, |
| 5589 | GLint *size, |
| 5590 | GLenum *type, |
| 5591 | GLchar *name) |
| 5592 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5593 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5594 | ASSERT(programObject); |
| 5595 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 5596 | } |
| 5597 | |
| 5598 | void Context::getActiveUniform(GLuint program, |
| 5599 | GLuint index, |
| 5600 | GLsizei bufsize, |
| 5601 | GLsizei *length, |
| 5602 | GLint *size, |
| 5603 | GLenum *type, |
| 5604 | GLchar *name) |
| 5605 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5606 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5607 | ASSERT(programObject); |
| 5608 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 5609 | } |
| 5610 | |
| 5611 | void Context::getAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
| 5612 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5613 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5614 | ASSERT(programObject); |
| 5615 | programObject->getAttachedShaders(maxcount, count, shaders); |
| 5616 | } |
| 5617 | |
| 5618 | GLint Context::getAttribLocation(GLuint program, const GLchar *name) |
| 5619 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5620 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5621 | ASSERT(programObject); |
| 5622 | return programObject->getAttributeLocation(name); |
| 5623 | } |
| 5624 | |
| 5625 | void Context::getBooleanv(GLenum pname, GLboolean *params) |
| 5626 | { |
| 5627 | GLenum nativeType; |
| 5628 | unsigned int numParams = 0; |
| 5629 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5630 | |
| 5631 | if (nativeType == GL_BOOL) |
| 5632 | { |
| 5633 | getBooleanvImpl(pname, params); |
| 5634 | } |
| 5635 | else |
| 5636 | { |
| 5637 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5638 | } |
| 5639 | } |
| 5640 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5641 | void Context::getBooleanvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLboolean *params) |
| 5642 | { |
| 5643 | getBooleanv(pname, params); |
| 5644 | } |
| 5645 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5646 | void Context::getFloatv(GLenum pname, GLfloat *params) |
| 5647 | { |
| 5648 | GLenum nativeType; |
| 5649 | unsigned int numParams = 0; |
| 5650 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5651 | |
| 5652 | if (nativeType == GL_FLOAT) |
| 5653 | { |
| 5654 | getFloatvImpl(pname, params); |
| 5655 | } |
| 5656 | else |
| 5657 | { |
| 5658 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5659 | } |
| 5660 | } |
| 5661 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5662 | void Context::getFloatvRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLfloat *params) |
| 5663 | { |
| 5664 | getFloatv(pname, params); |
| 5665 | } |
| 5666 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5667 | void Context::getIntegerv(GLenum pname, GLint *params) |
| 5668 | { |
| 5669 | GLenum nativeType; |
| 5670 | unsigned int numParams = 0; |
| 5671 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 5672 | |
| 5673 | if (nativeType == GL_INT) |
| 5674 | { |
| 5675 | getIntegervImpl(pname, params); |
| 5676 | } |
| 5677 | else |
| 5678 | { |
| 5679 | CastStateValues(this, nativeType, pname, numParams, params); |
| 5680 | } |
| 5681 | } |
| 5682 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5683 | void Context::getIntegervRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint *data) |
| 5684 | { |
| 5685 | getIntegerv(pname, data); |
| 5686 | } |
| 5687 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5688 | void Context::getProgramiv(GLuint program, GLenum pname, GLint *params) |
| 5689 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5690 | // Don't resolve link if checking the link completion status. |
| 5691 | Program *programObject = (pname == GL_COMPLETION_STATUS_KHR ? getProgramNoResolveLink(program) |
| 5692 | : getProgramResolveLink(program)); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5693 | ASSERT(programObject); |
Jamie Madill | ffe00c0 | 2017-06-27 16:26:55 -0400 | [diff] [blame] | 5694 | QueryProgramiv(this, programObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5695 | } |
| 5696 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5697 | void Context::getProgramivRobust(GLuint program, |
| 5698 | GLenum pname, |
| 5699 | GLsizei bufSize, |
| 5700 | GLsizei *length, |
| 5701 | GLint *params) |
| 5702 | { |
| 5703 | getProgramiv(program, pname, params); |
| 5704 | } |
| 5705 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5706 | void Context::getProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) |
| 5707 | { |
| 5708 | UNIMPLEMENTED(); |
| 5709 | } |
| 5710 | |
Jamie Madill | be849e4 | 2017-05-02 15:49:00 -0400 | [diff] [blame] | 5711 | void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5712 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5713 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5714 | ASSERT(programObject); |
| 5715 | programObject->getInfoLog(bufsize, length, infolog); |
| 5716 | } |
| 5717 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 5718 | void Context::getProgramPipelineInfoLog(GLuint pipeline, |
| 5719 | GLsizei bufSize, |
| 5720 | GLsizei *length, |
| 5721 | GLchar *infoLog) |
| 5722 | { |
| 5723 | UNIMPLEMENTED(); |
| 5724 | } |
| 5725 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5726 | void Context::getShaderiv(GLuint shader, GLenum pname, GLint *params) |
| 5727 | { |
| 5728 | Shader *shaderObject = getShader(shader); |
| 5729 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5730 | QueryShaderiv(shaderObject, pname, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5731 | } |
| 5732 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5733 | void Context::getShaderivRobust(GLuint shader, |
| 5734 | GLenum pname, |
| 5735 | GLsizei bufSize, |
| 5736 | GLsizei *length, |
| 5737 | GLint *params) |
| 5738 | { |
| 5739 | getShaderiv(shader, pname, params); |
| 5740 | } |
| 5741 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5742 | void Context::getShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) |
| 5743 | { |
| 5744 | Shader *shaderObject = getShader(shader); |
| 5745 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 5746 | shaderObject->getInfoLog(bufsize, length, infolog); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5747 | } |
| 5748 | |
| 5749 | void Context::getShaderPrecisionFormat(GLenum shadertype, |
| 5750 | GLenum precisiontype, |
| 5751 | GLint *range, |
| 5752 | GLint *precision) |
| 5753 | { |
| 5754 | // TODO(jmadill): Compute shaders. |
| 5755 | |
| 5756 | switch (shadertype) |
| 5757 | { |
| 5758 | case GL_VERTEX_SHADER: |
| 5759 | switch (precisiontype) |
| 5760 | { |
| 5761 | case GL_LOW_FLOAT: |
| 5762 | mCaps.vertexLowpFloat.get(range, precision); |
| 5763 | break; |
| 5764 | case GL_MEDIUM_FLOAT: |
| 5765 | mCaps.vertexMediumpFloat.get(range, precision); |
| 5766 | break; |
| 5767 | case GL_HIGH_FLOAT: |
| 5768 | mCaps.vertexHighpFloat.get(range, precision); |
| 5769 | break; |
| 5770 | |
| 5771 | case GL_LOW_INT: |
| 5772 | mCaps.vertexLowpInt.get(range, precision); |
| 5773 | break; |
| 5774 | case GL_MEDIUM_INT: |
| 5775 | mCaps.vertexMediumpInt.get(range, precision); |
| 5776 | break; |
| 5777 | case GL_HIGH_INT: |
| 5778 | mCaps.vertexHighpInt.get(range, precision); |
| 5779 | break; |
| 5780 | |
| 5781 | default: |
| 5782 | UNREACHABLE(); |
| 5783 | return; |
| 5784 | } |
| 5785 | break; |
| 5786 | |
| 5787 | case GL_FRAGMENT_SHADER: |
| 5788 | switch (precisiontype) |
| 5789 | { |
| 5790 | case GL_LOW_FLOAT: |
| 5791 | mCaps.fragmentLowpFloat.get(range, precision); |
| 5792 | break; |
| 5793 | case GL_MEDIUM_FLOAT: |
| 5794 | mCaps.fragmentMediumpFloat.get(range, precision); |
| 5795 | break; |
| 5796 | case GL_HIGH_FLOAT: |
| 5797 | mCaps.fragmentHighpFloat.get(range, precision); |
| 5798 | break; |
| 5799 | |
| 5800 | case GL_LOW_INT: |
| 5801 | mCaps.fragmentLowpInt.get(range, precision); |
| 5802 | break; |
| 5803 | case GL_MEDIUM_INT: |
| 5804 | mCaps.fragmentMediumpInt.get(range, precision); |
| 5805 | break; |
| 5806 | case GL_HIGH_INT: |
| 5807 | mCaps.fragmentHighpInt.get(range, precision); |
| 5808 | break; |
| 5809 | |
| 5810 | default: |
| 5811 | UNREACHABLE(); |
| 5812 | return; |
| 5813 | } |
| 5814 | break; |
| 5815 | |
| 5816 | default: |
| 5817 | UNREACHABLE(); |
| 5818 | return; |
| 5819 | } |
| 5820 | } |
| 5821 | |
| 5822 | void Context::getShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) |
| 5823 | { |
| 5824 | Shader *shaderObject = getShader(shader); |
| 5825 | ASSERT(shaderObject); |
| 5826 | shaderObject->getSource(bufsize, length, source); |
| 5827 | } |
| 5828 | |
| 5829 | void Context::getUniformfv(GLuint program, GLint location, GLfloat *params) |
| 5830 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5831 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5832 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5833 | programObject->getUniformfv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5834 | } |
| 5835 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5836 | void Context::getUniformfvRobust(GLuint program, |
| 5837 | GLint location, |
| 5838 | GLsizei bufSize, |
| 5839 | GLsizei *length, |
| 5840 | GLfloat *params) |
| 5841 | { |
| 5842 | getUniformfv(program, location, params); |
| 5843 | } |
| 5844 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5845 | void Context::getUniformiv(GLuint program, GLint location, GLint *params) |
| 5846 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5847 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5848 | ASSERT(programObject); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 5849 | programObject->getUniformiv(this, location, params); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5850 | } |
| 5851 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 5852 | void Context::getUniformivRobust(GLuint program, |
| 5853 | GLint location, |
| 5854 | GLsizei bufSize, |
| 5855 | GLsizei *length, |
| 5856 | GLint *params) |
| 5857 | { |
| 5858 | getUniformiv(program, location, params); |
| 5859 | } |
| 5860 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5861 | GLint Context::getUniformLocation(GLuint program, const GLchar *name) |
| 5862 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5863 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5864 | ASSERT(programObject); |
| 5865 | return programObject->getUniformLocation(name); |
| 5866 | } |
| 5867 | |
| 5868 | GLboolean Context::isBuffer(GLuint buffer) |
| 5869 | { |
| 5870 | if (buffer == 0) |
| 5871 | { |
| 5872 | return GL_FALSE; |
| 5873 | } |
| 5874 | |
| 5875 | return (getBuffer(buffer) ? GL_TRUE : GL_FALSE); |
| 5876 | } |
| 5877 | |
| 5878 | GLboolean Context::isEnabled(GLenum cap) |
| 5879 | { |
| 5880 | return mGLState.getEnableFeature(cap); |
| 5881 | } |
| 5882 | |
| 5883 | GLboolean Context::isFramebuffer(GLuint framebuffer) |
| 5884 | { |
| 5885 | if (framebuffer == 0) |
| 5886 | { |
| 5887 | return GL_FALSE; |
| 5888 | } |
| 5889 | |
| 5890 | return (getFramebuffer(framebuffer) ? GL_TRUE : GL_FALSE); |
| 5891 | } |
| 5892 | |
| 5893 | GLboolean Context::isProgram(GLuint program) |
| 5894 | { |
| 5895 | if (program == 0) |
| 5896 | { |
| 5897 | return GL_FALSE; |
| 5898 | } |
| 5899 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5900 | return (getProgramNoResolveLink(program) ? GL_TRUE : GL_FALSE); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5901 | } |
| 5902 | |
| 5903 | GLboolean Context::isRenderbuffer(GLuint renderbuffer) |
| 5904 | { |
| 5905 | if (renderbuffer == 0) |
| 5906 | { |
| 5907 | return GL_FALSE; |
| 5908 | } |
| 5909 | |
| 5910 | return (getRenderbuffer(renderbuffer) ? GL_TRUE : GL_FALSE); |
| 5911 | } |
| 5912 | |
| 5913 | GLboolean Context::isShader(GLuint shader) |
| 5914 | { |
| 5915 | if (shader == 0) |
| 5916 | { |
| 5917 | return GL_FALSE; |
| 5918 | } |
| 5919 | |
| 5920 | return (getShader(shader) ? GL_TRUE : GL_FALSE); |
| 5921 | } |
| 5922 | |
| 5923 | GLboolean Context::isTexture(GLuint texture) |
| 5924 | { |
| 5925 | if (texture == 0) |
| 5926 | { |
| 5927 | return GL_FALSE; |
| 5928 | } |
| 5929 | |
| 5930 | return (getTexture(texture) ? GL_TRUE : GL_FALSE); |
| 5931 | } |
| 5932 | |
| 5933 | void Context::linkProgram(GLuint program) |
| 5934 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 5935 | Program *programObject = getProgramNoResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5936 | ASSERT(programObject); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 5937 | ANGLE_CONTEXT_TRY(programObject->link(this)); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5938 | |
| 5939 | // Don't parallel link a program which is active in any GL contexts. With this assumption, we |
| 5940 | // don't need to worry that: |
| 5941 | // 1. Draw calls after link use the new executable code or the old one depending on the link |
| 5942 | // result. |
| 5943 | // 2. When a backend program, e.g., ProgramD3D is linking, other backend classes like |
| 5944 | // StateManager11, Renderer11, etc., may have a chance to make unexpected calls to |
| 5945 | // ProgramD3D. |
| 5946 | if (programObject->isInUse()) |
| 5947 | { |
Jamie Madill | 785e8a0 | 2018-10-04 17:42:00 -0400 | [diff] [blame] | 5948 | programObject->resolveLink(this); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5949 | if (programObject->isLinked()) |
| 5950 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 5951 | ANGLE_CONTEXT_TRY(mGLState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 5952 | } |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 5953 | mStateCache.onProgramExecutableChange(this); |
| 5954 | } |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5955 | } |
| 5956 | |
| 5957 | void Context::releaseShaderCompiler() |
| 5958 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 5959 | mCompiler.set(this, nullptr); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5960 | } |
| 5961 | |
| 5962 | void Context::shaderBinary(GLsizei n, |
| 5963 | const GLuint *shaders, |
| 5964 | GLenum binaryformat, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 5965 | const void *binary, |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 5966 | GLsizei length) |
| 5967 | { |
| 5968 | // No binary shader formats are supported. |
| 5969 | UNIMPLEMENTED(); |
| 5970 | } |
| 5971 | |
Olli Etuaho | 0ca0975 | 2018-09-24 11:00:50 +0300 | [diff] [blame] | 5972 | void Context::bindFragDataLocationIndexed(GLuint program, |
| 5973 | GLuint colorNumber, |
| 5974 | GLuint index, |
| 5975 | const char *name) |
| 5976 | { |
| 5977 | Program *programObject = getProgramNoResolveLink(program); |
| 5978 | programObject->bindFragmentOutputLocation(colorNumber, name); |
| 5979 | programObject->bindFragmentOutputIndex(index, name); |
| 5980 | } |
| 5981 | |
| 5982 | void Context::bindFragDataLocation(GLuint program, GLuint colorNumber, const char *name) |
| 5983 | { |
| 5984 | bindFragDataLocationIndexed(program, colorNumber, 0u, name); |
| 5985 | } |
| 5986 | |
| 5987 | int Context::getFragDataIndex(GLuint program, const char *name) |
| 5988 | { |
| 5989 | Program *programObject = getProgramResolveLink(program); |
| 5990 | return programObject->getFragDataIndex(name); |
| 5991 | } |
| 5992 | |
| 5993 | int Context::getProgramResourceLocationIndex(GLuint program, |
| 5994 | GLenum programInterface, |
| 5995 | const char *name) |
| 5996 | { |
| 5997 | Program *programObject = getProgramResolveLink(program); |
| 5998 | ASSERT(programInterface == GL_PROGRAM_OUTPUT); |
| 5999 | return programObject->getFragDataIndex(name); |
| 6000 | } |
| 6001 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6002 | void Context::shaderSource(GLuint shader, |
| 6003 | GLsizei count, |
| 6004 | const GLchar *const *string, |
| 6005 | const GLint *length) |
| 6006 | { |
| 6007 | Shader *shaderObject = getShader(shader); |
| 6008 | ASSERT(shaderObject); |
| 6009 | shaderObject->setSource(count, string, length); |
| 6010 | } |
| 6011 | |
| 6012 | void Context::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6013 | { |
| 6014 | stencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
| 6015 | } |
| 6016 | |
| 6017 | void Context::stencilMask(GLuint mask) |
| 6018 | { |
| 6019 | stencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6020 | } |
| 6021 | |
| 6022 | void Context::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6023 | { |
| 6024 | stencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6025 | } |
| 6026 | |
| 6027 | void Context::uniform1f(GLint location, GLfloat x) |
| 6028 | { |
| 6029 | Program *program = mGLState.getProgram(); |
| 6030 | program->setUniform1fv(location, 1, &x); |
| 6031 | } |
| 6032 | |
| 6033 | void Context::uniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 6034 | { |
| 6035 | Program *program = mGLState.getProgram(); |
| 6036 | program->setUniform1fv(location, count, v); |
| 6037 | } |
| 6038 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6039 | void Context::setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v) |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6040 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 6041 | program->setUniform1iv(this, location, count, v); |
| 6042 | } |
| 6043 | |
| 6044 | void Context::onSamplerUniformChange(size_t textureUnitIndex) |
| 6045 | { |
| 6046 | mGLState.onActiveTextureChange(this, textureUnitIndex); |
| 6047 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6048 | } |
| 6049 | |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6050 | void Context::uniform1i(GLint location, GLint x) |
| 6051 | { |
| 6052 | setUniform1iImpl(mGLState.getProgram(), location, 1, &x); |
| 6053 | } |
| 6054 | |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6055 | void Context::uniform1iv(GLint location, GLsizei count, const GLint *v) |
| 6056 | { |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6057 | setUniform1iImpl(mGLState.getProgram(), location, count, v); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6058 | } |
| 6059 | |
| 6060 | void Context::uniform2f(GLint location, GLfloat x, GLfloat y) |
| 6061 | { |
| 6062 | GLfloat xy[2] = {x, y}; |
| 6063 | Program *program = mGLState.getProgram(); |
| 6064 | program->setUniform2fv(location, 1, xy); |
| 6065 | } |
| 6066 | |
| 6067 | void Context::uniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 6068 | { |
| 6069 | Program *program = mGLState.getProgram(); |
| 6070 | program->setUniform2fv(location, count, v); |
| 6071 | } |
| 6072 | |
| 6073 | void Context::uniform2i(GLint location, GLint x, GLint y) |
| 6074 | { |
| 6075 | GLint xy[2] = {x, y}; |
| 6076 | Program *program = mGLState.getProgram(); |
| 6077 | program->setUniform2iv(location, 1, xy); |
| 6078 | } |
| 6079 | |
| 6080 | void Context::uniform2iv(GLint location, GLsizei count, const GLint *v) |
| 6081 | { |
| 6082 | Program *program = mGLState.getProgram(); |
| 6083 | program->setUniform2iv(location, count, v); |
| 6084 | } |
| 6085 | |
| 6086 | void Context::uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 6087 | { |
| 6088 | GLfloat xyz[3] = {x, y, z}; |
| 6089 | Program *program = mGLState.getProgram(); |
| 6090 | program->setUniform3fv(location, 1, xyz); |
| 6091 | } |
| 6092 | |
| 6093 | void Context::uniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 6094 | { |
| 6095 | Program *program = mGLState.getProgram(); |
| 6096 | program->setUniform3fv(location, count, v); |
| 6097 | } |
| 6098 | |
| 6099 | void Context::uniform3i(GLint location, GLint x, GLint y, GLint z) |
| 6100 | { |
| 6101 | GLint xyz[3] = {x, y, z}; |
| 6102 | Program *program = mGLState.getProgram(); |
| 6103 | program->setUniform3iv(location, 1, xyz); |
| 6104 | } |
| 6105 | |
| 6106 | void Context::uniform3iv(GLint location, GLsizei count, const GLint *v) |
| 6107 | { |
| 6108 | Program *program = mGLState.getProgram(); |
| 6109 | program->setUniform3iv(location, count, v); |
| 6110 | } |
| 6111 | |
| 6112 | void Context::uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 6113 | { |
| 6114 | GLfloat xyzw[4] = {x, y, z, w}; |
| 6115 | Program *program = mGLState.getProgram(); |
| 6116 | program->setUniform4fv(location, 1, xyzw); |
| 6117 | } |
| 6118 | |
| 6119 | void Context::uniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 6120 | { |
| 6121 | Program *program = mGLState.getProgram(); |
| 6122 | program->setUniform4fv(location, count, v); |
| 6123 | } |
| 6124 | |
| 6125 | void Context::uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 6126 | { |
| 6127 | GLint xyzw[4] = {x, y, z, w}; |
| 6128 | Program *program = mGLState.getProgram(); |
| 6129 | program->setUniform4iv(location, 1, xyzw); |
| 6130 | } |
| 6131 | |
| 6132 | void Context::uniform4iv(GLint location, GLsizei count, const GLint *v) |
| 6133 | { |
| 6134 | Program *program = mGLState.getProgram(); |
| 6135 | program->setUniform4iv(location, count, v); |
| 6136 | } |
| 6137 | |
| 6138 | void Context::uniformMatrix2fv(GLint location, |
| 6139 | GLsizei count, |
| 6140 | GLboolean transpose, |
| 6141 | const GLfloat *value) |
| 6142 | { |
| 6143 | Program *program = mGLState.getProgram(); |
| 6144 | program->setUniformMatrix2fv(location, count, transpose, value); |
| 6145 | } |
| 6146 | |
| 6147 | void Context::uniformMatrix3fv(GLint location, |
| 6148 | GLsizei count, |
| 6149 | GLboolean transpose, |
| 6150 | const GLfloat *value) |
| 6151 | { |
| 6152 | Program *program = mGLState.getProgram(); |
| 6153 | program->setUniformMatrix3fv(location, count, transpose, value); |
| 6154 | } |
| 6155 | |
| 6156 | void Context::uniformMatrix4fv(GLint location, |
| 6157 | GLsizei count, |
| 6158 | GLboolean transpose, |
| 6159 | const GLfloat *value) |
| 6160 | { |
| 6161 | Program *program = mGLState.getProgram(); |
| 6162 | program->setUniformMatrix4fv(location, count, transpose, value); |
| 6163 | } |
| 6164 | |
| 6165 | void Context::validateProgram(GLuint program) |
| 6166 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6167 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 6168 | ASSERT(programObject); |
| 6169 | programObject->validate(mCaps); |
| 6170 | } |
| 6171 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6172 | void Context::validateProgramPipeline(GLuint pipeline) |
| 6173 | { |
| 6174 | UNIMPLEMENTED(); |
| 6175 | } |
| 6176 | |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6177 | void Context::getProgramBinary(GLuint program, |
| 6178 | GLsizei bufSize, |
| 6179 | GLsizei *length, |
| 6180 | GLenum *binaryFormat, |
| 6181 | void *binary) |
| 6182 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6183 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6184 | ASSERT(programObject != nullptr); |
| 6185 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6186 | ANGLE_CONTEXT_TRY(programObject->saveBinary(this, binaryFormat, binary, bufSize, length)); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6187 | } |
| 6188 | |
| 6189 | void Context::programBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length) |
| 6190 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6191 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6192 | ASSERT(programObject != nullptr); |
Jamie Madill | b666492 | 2017-07-25 12:55:04 -0400 | [diff] [blame] | 6193 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6194 | ANGLE_CONTEXT_TRY(programObject->loadBinary(this, binaryFormat, binary, length)); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6195 | if (programObject->isInUse()) |
| 6196 | { |
Jamie Madill | e3bb6b7 | 2018-10-03 17:51:15 -0400 | [diff] [blame] | 6197 | ANGLE_CONTEXT_TRY(mGLState.onProgramExecutableChange(this, programObject)); |
Jamie Madill | df836ff | 2018-10-01 10:36:24 -0400 | [diff] [blame] | 6198 | mStateCache.onProgramExecutableChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6199 | } |
Jamie Madill | d04908b | 2017-06-09 14:15:35 -0400 | [diff] [blame] | 6200 | } |
| 6201 | |
Jamie Madill | ff325f1 | 2017-08-26 15:06:05 -0400 | [diff] [blame] | 6202 | void Context::uniform1ui(GLint location, GLuint v0) |
| 6203 | { |
| 6204 | Program *program = mGLState.getProgram(); |
| 6205 | program->setUniform1uiv(location, 1, &v0); |
| 6206 | } |
| 6207 | |
| 6208 | void Context::uniform2ui(GLint location, GLuint v0, GLuint v1) |
| 6209 | { |
| 6210 | Program *program = mGLState.getProgram(); |
| 6211 | const GLuint xy[] = {v0, v1}; |
| 6212 | program->setUniform2uiv(location, 1, xy); |
| 6213 | } |
| 6214 | |
| 6215 | void Context::uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6216 | { |
| 6217 | Program *program = mGLState.getProgram(); |
| 6218 | const GLuint xyz[] = {v0, v1, v2}; |
| 6219 | program->setUniform3uiv(location, 1, xyz); |
| 6220 | } |
| 6221 | |
| 6222 | void Context::uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6223 | { |
| 6224 | Program *program = mGLState.getProgram(); |
| 6225 | const GLuint xyzw[] = {v0, v1, v2, v3}; |
| 6226 | program->setUniform4uiv(location, 1, xyzw); |
| 6227 | } |
| 6228 | |
| 6229 | void Context::uniform1uiv(GLint location, GLsizei count, const GLuint *value) |
| 6230 | { |
| 6231 | Program *program = mGLState.getProgram(); |
| 6232 | program->setUniform1uiv(location, count, value); |
| 6233 | } |
| 6234 | void Context::uniform2uiv(GLint location, GLsizei count, const GLuint *value) |
| 6235 | { |
| 6236 | Program *program = mGLState.getProgram(); |
| 6237 | program->setUniform2uiv(location, count, value); |
| 6238 | } |
| 6239 | |
| 6240 | void Context::uniform3uiv(GLint location, GLsizei count, const GLuint *value) |
| 6241 | { |
| 6242 | Program *program = mGLState.getProgram(); |
| 6243 | program->setUniform3uiv(location, count, value); |
| 6244 | } |
| 6245 | |
| 6246 | void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) |
| 6247 | { |
| 6248 | Program *program = mGLState.getProgram(); |
| 6249 | program->setUniform4uiv(location, count, value); |
| 6250 | } |
| 6251 | |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6252 | void Context::genQueries(GLsizei n, GLuint *ids) |
| 6253 | { |
| 6254 | for (GLsizei i = 0; i < n; i++) |
| 6255 | { |
| 6256 | GLuint handle = mQueryHandleAllocator.allocate(); |
| 6257 | mQueryMap.assign(handle, nullptr); |
| 6258 | ids[i] = handle; |
| 6259 | } |
| 6260 | } |
| 6261 | |
| 6262 | void Context::deleteQueries(GLsizei n, const GLuint *ids) |
| 6263 | { |
| 6264 | for (int i = 0; i < n; i++) |
| 6265 | { |
| 6266 | GLuint query = ids[i]; |
| 6267 | |
| 6268 | Query *queryObject = nullptr; |
| 6269 | if (mQueryMap.erase(query, &queryObject)) |
| 6270 | { |
| 6271 | mQueryHandleAllocator.release(query); |
| 6272 | if (queryObject) |
| 6273 | { |
| 6274 | queryObject->release(this); |
| 6275 | } |
| 6276 | } |
| 6277 | } |
| 6278 | } |
| 6279 | |
| 6280 | GLboolean Context::isQuery(GLuint id) |
| 6281 | { |
Corentin Wallez | ad3ae90 | 2018-03-09 13:40:42 -0500 | [diff] [blame] | 6282 | return (getQuery(id, false, QueryType::InvalidEnum) != nullptr) ? GL_TRUE : GL_FALSE; |
Jamie Madill | f0e0449 | 2017-08-26 15:28:42 -0400 | [diff] [blame] | 6283 | } |
| 6284 | |
Jamie Madill | c8c9581 | 2017-08-26 18:40:09 -0400 | [diff] [blame] | 6285 | void Context::uniformMatrix2x3fv(GLint location, |
| 6286 | GLsizei count, |
| 6287 | GLboolean transpose, |
| 6288 | const GLfloat *value) |
| 6289 | { |
| 6290 | Program *program = mGLState.getProgram(); |
| 6291 | program->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6292 | } |
| 6293 | |
| 6294 | void Context::uniformMatrix3x2fv(GLint location, |
| 6295 | GLsizei count, |
| 6296 | GLboolean transpose, |
| 6297 | const GLfloat *value) |
| 6298 | { |
| 6299 | Program *program = mGLState.getProgram(); |
| 6300 | program->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6301 | } |
| 6302 | |
| 6303 | void Context::uniformMatrix2x4fv(GLint location, |
| 6304 | GLsizei count, |
| 6305 | GLboolean transpose, |
| 6306 | const GLfloat *value) |
| 6307 | { |
| 6308 | Program *program = mGLState.getProgram(); |
| 6309 | program->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6310 | } |
| 6311 | |
| 6312 | void Context::uniformMatrix4x2fv(GLint location, |
| 6313 | GLsizei count, |
| 6314 | GLboolean transpose, |
| 6315 | const GLfloat *value) |
| 6316 | { |
| 6317 | Program *program = mGLState.getProgram(); |
| 6318 | program->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6319 | } |
| 6320 | |
| 6321 | void Context::uniformMatrix3x4fv(GLint location, |
| 6322 | GLsizei count, |
| 6323 | GLboolean transpose, |
| 6324 | const GLfloat *value) |
| 6325 | { |
| 6326 | Program *program = mGLState.getProgram(); |
| 6327 | program->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6328 | } |
| 6329 | |
| 6330 | void Context::uniformMatrix4x3fv(GLint location, |
| 6331 | GLsizei count, |
| 6332 | GLboolean transpose, |
| 6333 | const GLfloat *value) |
| 6334 | { |
| 6335 | Program *program = mGLState.getProgram(); |
| 6336 | program->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6337 | } |
| 6338 | |
Jamie Madill | d757673 | 2017-08-26 18:49:50 -0400 | [diff] [blame] | 6339 | void Context::deleteVertexArrays(GLsizei n, const GLuint *arrays) |
| 6340 | { |
| 6341 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6342 | { |
| 6343 | GLuint vertexArray = arrays[arrayIndex]; |
| 6344 | |
| 6345 | if (arrays[arrayIndex] != 0) |
| 6346 | { |
| 6347 | VertexArray *vertexArrayObject = nullptr; |
| 6348 | if (mVertexArrayMap.erase(vertexArray, &vertexArrayObject)) |
| 6349 | { |
| 6350 | if (vertexArrayObject != nullptr) |
| 6351 | { |
| 6352 | detachVertexArray(vertexArray); |
| 6353 | vertexArrayObject->onDestroy(this); |
| 6354 | } |
| 6355 | |
| 6356 | mVertexArrayHandleAllocator.release(vertexArray); |
| 6357 | } |
| 6358 | } |
| 6359 | } |
| 6360 | } |
| 6361 | |
| 6362 | void Context::genVertexArrays(GLsizei n, GLuint *arrays) |
| 6363 | { |
| 6364 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 6365 | { |
| 6366 | GLuint vertexArray = mVertexArrayHandleAllocator.allocate(); |
| 6367 | mVertexArrayMap.assign(vertexArray, nullptr); |
| 6368 | arrays[arrayIndex] = vertexArray; |
| 6369 | } |
| 6370 | } |
| 6371 | |
| 6372 | bool Context::isVertexArray(GLuint array) |
| 6373 | { |
| 6374 | if (array == 0) |
| 6375 | { |
| 6376 | return GL_FALSE; |
| 6377 | } |
| 6378 | |
| 6379 | VertexArray *vao = getVertexArray(array); |
| 6380 | return (vao != nullptr ? GL_TRUE : GL_FALSE); |
| 6381 | } |
| 6382 | |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6383 | void Context::endTransformFeedback() |
| 6384 | { |
| 6385 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6386 | ANGLE_CONTEXT_TRY(transformFeedback->end(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6387 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6388 | } |
| 6389 | |
| 6390 | void Context::transformFeedbackVaryings(GLuint program, |
| 6391 | GLsizei count, |
| 6392 | const GLchar *const *varyings, |
| 6393 | GLenum bufferMode) |
| 6394 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6395 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6396 | ASSERT(programObject); |
| 6397 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
| 6398 | } |
| 6399 | |
| 6400 | void Context::getTransformFeedbackVarying(GLuint program, |
| 6401 | GLuint index, |
| 6402 | GLsizei bufSize, |
| 6403 | GLsizei *length, |
| 6404 | GLsizei *size, |
| 6405 | GLenum *type, |
| 6406 | GLchar *name) |
| 6407 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6408 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6409 | ASSERT(programObject); |
| 6410 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
| 6411 | } |
| 6412 | |
| 6413 | void Context::deleteTransformFeedbacks(GLsizei n, const GLuint *ids) |
| 6414 | { |
| 6415 | for (int i = 0; i < n; i++) |
| 6416 | { |
| 6417 | GLuint transformFeedback = ids[i]; |
| 6418 | if (transformFeedback == 0) |
| 6419 | { |
| 6420 | continue; |
| 6421 | } |
| 6422 | |
| 6423 | TransformFeedback *transformFeedbackObject = nullptr; |
| 6424 | if (mTransformFeedbackMap.erase(transformFeedback, &transformFeedbackObject)) |
| 6425 | { |
| 6426 | if (transformFeedbackObject != nullptr) |
| 6427 | { |
| 6428 | detachTransformFeedback(transformFeedback); |
| 6429 | transformFeedbackObject->release(this); |
| 6430 | } |
| 6431 | |
| 6432 | mTransformFeedbackHandleAllocator.release(transformFeedback); |
| 6433 | } |
| 6434 | } |
| 6435 | } |
| 6436 | |
| 6437 | void Context::genTransformFeedbacks(GLsizei n, GLuint *ids) |
| 6438 | { |
| 6439 | for (int i = 0; i < n; i++) |
| 6440 | { |
| 6441 | GLuint transformFeedback = mTransformFeedbackHandleAllocator.allocate(); |
| 6442 | mTransformFeedbackMap.assign(transformFeedback, nullptr); |
| 6443 | ids[i] = transformFeedback; |
| 6444 | } |
| 6445 | } |
| 6446 | |
| 6447 | bool Context::isTransformFeedback(GLuint id) |
| 6448 | { |
| 6449 | if (id == 0) |
| 6450 | { |
| 6451 | // The 3.0.4 spec [section 6.1.11] states that if ID is zero, IsTransformFeedback |
| 6452 | // returns FALSE |
| 6453 | return GL_FALSE; |
| 6454 | } |
| 6455 | |
| 6456 | const TransformFeedback *transformFeedback = getTransformFeedback(id); |
| 6457 | return ((transformFeedback != nullptr) ? GL_TRUE : GL_FALSE); |
| 6458 | } |
| 6459 | |
| 6460 | void Context::pauseTransformFeedback() |
| 6461 | { |
| 6462 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6463 | ANGLE_CONTEXT_TRY(transformFeedback->pause(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6464 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6465 | } |
| 6466 | |
| 6467 | void Context::resumeTransformFeedback() |
| 6468 | { |
| 6469 | TransformFeedback *transformFeedback = mGLState.getCurrentTransformFeedback(); |
Geoff Lang | 9100226 | 2018-12-12 16:05:24 -0500 | [diff] [blame] | 6470 | ANGLE_CONTEXT_TRY(transformFeedback->resume(this)); |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 6471 | mStateCache.onActiveTransformFeedbackChange(this); |
Jamie Madill | f0dcb8b | 2017-08-26 19:05:13 -0400 | [diff] [blame] | 6472 | } |
| 6473 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6474 | void Context::getUniformuiv(GLuint program, GLint location, GLuint *params) |
| 6475 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6476 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 54164b0 | 2017-08-28 15:17:37 -0400 | [diff] [blame] | 6477 | programObject->getUniformuiv(this, location, params); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6478 | } |
| 6479 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6480 | void Context::getUniformuivRobust(GLuint program, |
| 6481 | GLint location, |
| 6482 | GLsizei bufSize, |
| 6483 | GLsizei *length, |
| 6484 | GLuint *params) |
| 6485 | { |
| 6486 | getUniformuiv(program, location, params); |
| 6487 | } |
| 6488 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6489 | GLint Context::getFragDataLocation(GLuint program, const GLchar *name) |
| 6490 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6491 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6492 | return programObject->getFragDataLocation(name); |
| 6493 | } |
| 6494 | |
| 6495 | void Context::getUniformIndices(GLuint program, |
| 6496 | GLsizei uniformCount, |
| 6497 | const GLchar *const *uniformNames, |
| 6498 | GLuint *uniformIndices) |
| 6499 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6500 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6501 | if (!programObject->isLinked()) |
| 6502 | { |
| 6503 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6504 | { |
| 6505 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 6506 | } |
| 6507 | } |
| 6508 | else |
| 6509 | { |
| 6510 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6511 | { |
| 6512 | uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]); |
| 6513 | } |
| 6514 | } |
| 6515 | } |
| 6516 | |
| 6517 | void Context::getActiveUniformsiv(GLuint program, |
| 6518 | GLsizei uniformCount, |
| 6519 | const GLuint *uniformIndices, |
| 6520 | GLenum pname, |
| 6521 | GLint *params) |
| 6522 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6523 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6524 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6525 | { |
| 6526 | const GLuint index = uniformIndices[uniformId]; |
jchen10 | baf5d94 | 2017-08-28 20:45:48 +0800 | [diff] [blame] | 6527 | params[uniformId] = GetUniformResourceProperty(programObject, index, pname); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6528 | } |
| 6529 | } |
| 6530 | |
| 6531 | GLuint Context::getUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) |
| 6532 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6533 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6534 | return programObject->getUniformBlockIndex(uniformBlockName); |
| 6535 | } |
| 6536 | |
| 6537 | void Context::getActiveUniformBlockiv(GLuint program, |
| 6538 | GLuint uniformBlockIndex, |
| 6539 | GLenum pname, |
| 6540 | GLint *params) |
| 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 | QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); |
| 6544 | } |
| 6545 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6546 | void Context::getActiveUniformBlockivRobust(GLuint program, |
| 6547 | GLuint uniformBlockIndex, |
| 6548 | GLenum pname, |
| 6549 | GLsizei bufSize, |
| 6550 | GLsizei *length, |
| 6551 | GLint *params) |
| 6552 | { |
| 6553 | getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); |
| 6554 | } |
| 6555 | |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6556 | void Context::getActiveUniformBlockName(GLuint program, |
| 6557 | GLuint uniformBlockIndex, |
| 6558 | GLsizei bufSize, |
| 6559 | GLsizei *length, |
| 6560 | GLchar *uniformBlockName) |
| 6561 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6562 | const Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6563 | programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6564 | } |
| 6565 | |
| 6566 | void Context::uniformBlockBinding(GLuint program, |
| 6567 | GLuint uniformBlockIndex, |
| 6568 | GLuint uniformBlockBinding) |
| 6569 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6570 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6571 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6572 | |
Jamie Madill | 956ab4d | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 6573 | // 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] | 6574 | if (programObject->isInUse()) |
| 6575 | { |
| 6576 | mGLState.setObjectDirty(GL_PROGRAM); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 6577 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 70aeda4 | 2018-08-20 12:17:40 -0400 | [diff] [blame] | 6578 | } |
Jamie Madill | 12e957f | 2017-08-26 21:42:26 -0400 | [diff] [blame] | 6579 | } |
| 6580 | |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6581 | GLsync Context::fenceSync(GLenum condition, GLbitfield flags) |
| 6582 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6583 | GLuint handle = mState.mSyncs->createSync(mImplementation.get()); |
| 6584 | GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6585 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6586 | Sync *syncObject = getSync(syncHandle); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6587 | if (syncObject->set(this, condition, flags) == angle::Result::Stop) |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6588 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6589 | deleteSync(syncHandle); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6590 | return nullptr; |
| 6591 | } |
| 6592 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6593 | return syncHandle; |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6594 | } |
| 6595 | |
| 6596 | GLboolean Context::isSync(GLsync sync) |
| 6597 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6598 | return (getSync(sync) != nullptr); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6599 | } |
| 6600 | |
| 6601 | GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6602 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6603 | Sync *syncObject = getSync(sync); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6604 | |
| 6605 | GLenum result = GL_WAIT_FAILED; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 6606 | if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop) |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6607 | { |
| 6608 | return GL_WAIT_FAILED; |
| 6609 | } |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6610 | return result; |
| 6611 | } |
| 6612 | |
| 6613 | void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6614 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 6615 | Sync *syncObject = getSync(sync); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 6616 | ANGLE_CONTEXT_TRY(syncObject->serverWait(this, flags, timeout)); |
Jamie Madill | 7f0c5a4 | 2017-08-26 22:43:26 -0400 | [diff] [blame] | 6617 | } |
| 6618 | |
| 6619 | void Context::getInteger64v(GLenum pname, GLint64 *params) |
| 6620 | { |
| 6621 | GLenum nativeType = GL_NONE; |
| 6622 | unsigned int numParams = 0; |
| 6623 | getQueryParameterInfo(pname, &nativeType, &numParams); |
| 6624 | |
| 6625 | if (nativeType == GL_INT_64_ANGLEX) |
| 6626 | { |
| 6627 | getInteger64vImpl(pname, params); |
| 6628 | } |
| 6629 | else |
| 6630 | { |
| 6631 | CastStateValues(this, nativeType, pname, numParams, params); |
| 6632 | } |
| 6633 | } |
| 6634 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6635 | void Context::getInteger64vRobust(GLenum pname, GLsizei bufSize, GLsizei *length, GLint64 *data) |
| 6636 | { |
| 6637 | getInteger64v(pname, data); |
| 6638 | } |
| 6639 | |
Corentin Wallez | 336129f | 2017-10-17 15:55:40 -0400 | [diff] [blame] | 6640 | void Context::getBufferParameteri64v(BufferBinding target, GLenum pname, GLint64 *params) |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6641 | { |
| 6642 | Buffer *buffer = mGLState.getTargetBuffer(target); |
| 6643 | QueryBufferParameteri64v(buffer, pname, params); |
| 6644 | } |
| 6645 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6646 | void Context::getBufferParameteri64vRobust(BufferBinding target, |
| 6647 | GLenum pname, |
| 6648 | GLsizei bufSize, |
| 6649 | GLsizei *length, |
| 6650 | GLint64 *params) |
| 6651 | { |
| 6652 | getBufferParameteri64v(target, pname, params); |
| 6653 | } |
| 6654 | |
Jamie Madill | 3ef140a | 2017-08-26 23:11:21 -0400 | [diff] [blame] | 6655 | void Context::genSamplers(GLsizei count, GLuint *samplers) |
| 6656 | { |
| 6657 | for (int i = 0; i < count; i++) |
| 6658 | { |
| 6659 | samplers[i] = mState.mSamplers->createSampler(); |
| 6660 | } |
| 6661 | } |
| 6662 | |
| 6663 | void Context::deleteSamplers(GLsizei count, const GLuint *samplers) |
| 6664 | { |
| 6665 | for (int i = 0; i < count; i++) |
| 6666 | { |
| 6667 | GLuint sampler = samplers[i]; |
| 6668 | |
| 6669 | if (mState.mSamplers->getSampler(sampler)) |
| 6670 | { |
| 6671 | detachSampler(sampler); |
| 6672 | } |
| 6673 | |
| 6674 | mState.mSamplers->deleteObject(this, sampler); |
| 6675 | } |
| 6676 | } |
| 6677 | |
| 6678 | void Context::getInternalformativ(GLenum target, |
| 6679 | GLenum internalformat, |
| 6680 | GLenum pname, |
| 6681 | GLsizei bufSize, |
| 6682 | GLint *params) |
| 6683 | { |
| 6684 | const TextureCaps &formatCaps = mTextureCaps.get(internalformat); |
| 6685 | QueryInternalFormativ(formatCaps, pname, bufSize, params); |
| 6686 | } |
| 6687 | |
Brandon Jones | 5977080 | 2018-04-02 13:18:42 -0700 | [diff] [blame] | 6688 | void Context::getInternalformativRobust(GLenum target, |
| 6689 | GLenum internalformat, |
| 6690 | GLenum pname, |
| 6691 | GLsizei bufSize, |
| 6692 | GLsizei *length, |
| 6693 | GLint *params) |
| 6694 | { |
| 6695 | getInternalformativ(target, internalformat, pname, bufSize, params); |
| 6696 | } |
| 6697 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6698 | void Context::programUniform1i(GLuint program, GLint location, GLint v0) |
| 6699 | { |
| 6700 | programUniform1iv(program, location, 1, &v0); |
| 6701 | } |
| 6702 | |
| 6703 | void Context::programUniform2i(GLuint program, GLint location, GLint v0, GLint v1) |
| 6704 | { |
| 6705 | GLint xy[2] = {v0, v1}; |
| 6706 | programUniform2iv(program, location, 1, xy); |
| 6707 | } |
| 6708 | |
| 6709 | void Context::programUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2) |
| 6710 | { |
| 6711 | GLint xyz[3] = {v0, v1, v2}; |
| 6712 | programUniform3iv(program, location, 1, xyz); |
| 6713 | } |
| 6714 | |
| 6715 | void Context::programUniform4i(GLuint program, |
| 6716 | GLint location, |
| 6717 | GLint v0, |
| 6718 | GLint v1, |
| 6719 | GLint v2, |
| 6720 | GLint v3) |
| 6721 | { |
| 6722 | GLint xyzw[4] = {v0, v1, v2, v3}; |
| 6723 | programUniform4iv(program, location, 1, xyzw); |
| 6724 | } |
| 6725 | |
| 6726 | void Context::programUniform1ui(GLuint program, GLint location, GLuint v0) |
| 6727 | { |
| 6728 | programUniform1uiv(program, location, 1, &v0); |
| 6729 | } |
| 6730 | |
| 6731 | void Context::programUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1) |
| 6732 | { |
| 6733 | GLuint xy[2] = {v0, v1}; |
| 6734 | programUniform2uiv(program, location, 1, xy); |
| 6735 | } |
| 6736 | |
| 6737 | void Context::programUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6738 | { |
| 6739 | GLuint xyz[3] = {v0, v1, v2}; |
| 6740 | programUniform3uiv(program, location, 1, xyz); |
| 6741 | } |
| 6742 | |
| 6743 | void Context::programUniform4ui(GLuint program, |
| 6744 | GLint location, |
| 6745 | GLuint v0, |
| 6746 | GLuint v1, |
| 6747 | GLuint v2, |
| 6748 | GLuint v3) |
| 6749 | { |
| 6750 | GLuint xyzw[4] = {v0, v1, v2, v3}; |
| 6751 | programUniform4uiv(program, location, 1, xyzw); |
| 6752 | } |
| 6753 | |
| 6754 | void Context::programUniform1f(GLuint program, GLint location, GLfloat v0) |
| 6755 | { |
| 6756 | programUniform1fv(program, location, 1, &v0); |
| 6757 | } |
| 6758 | |
| 6759 | void Context::programUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1) |
| 6760 | { |
| 6761 | GLfloat xy[2] = {v0, v1}; |
| 6762 | programUniform2fv(program, location, 1, xy); |
| 6763 | } |
| 6764 | |
| 6765 | void Context::programUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) |
| 6766 | { |
| 6767 | GLfloat xyz[3] = {v0, v1, v2}; |
| 6768 | programUniform3fv(program, location, 1, xyz); |
| 6769 | } |
| 6770 | |
| 6771 | void Context::programUniform4f(GLuint program, |
| 6772 | GLint location, |
| 6773 | GLfloat v0, |
| 6774 | GLfloat v1, |
| 6775 | GLfloat v2, |
| 6776 | GLfloat v3) |
| 6777 | { |
| 6778 | GLfloat xyzw[4] = {v0, v1, v2, v3}; |
| 6779 | programUniform4fv(program, location, 1, xyzw); |
| 6780 | } |
| 6781 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6782 | void Context::programUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6783 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6784 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6785 | ASSERT(programObject); |
Jamie Madill | 7e4eff1 | 2018-08-08 15:49:26 -0400 | [diff] [blame] | 6786 | setUniform1iImpl(programObject, location, count, value); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 6787 | } |
| 6788 | |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6789 | void Context::programUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6790 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6791 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6792 | ASSERT(programObject); |
| 6793 | programObject->setUniform2iv(location, count, value); |
| 6794 | } |
| 6795 | |
| 6796 | void Context::programUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6797 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6798 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6799 | ASSERT(programObject); |
| 6800 | programObject->setUniform3iv(location, count, value); |
| 6801 | } |
| 6802 | |
| 6803 | void Context::programUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value) |
| 6804 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6805 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6806 | ASSERT(programObject); |
| 6807 | programObject->setUniform4iv(location, count, value); |
| 6808 | } |
| 6809 | |
| 6810 | void Context::programUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6811 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6812 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6813 | ASSERT(programObject); |
| 6814 | programObject->setUniform1uiv(location, count, value); |
| 6815 | } |
| 6816 | |
| 6817 | void Context::programUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6818 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6819 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6820 | ASSERT(programObject); |
| 6821 | programObject->setUniform2uiv(location, count, value); |
| 6822 | } |
| 6823 | |
| 6824 | void Context::programUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6825 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6826 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6827 | ASSERT(programObject); |
| 6828 | programObject->setUniform3uiv(location, count, value); |
| 6829 | } |
| 6830 | |
| 6831 | void Context::programUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value) |
| 6832 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6833 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6834 | ASSERT(programObject); |
| 6835 | programObject->setUniform4uiv(location, count, value); |
| 6836 | } |
| 6837 | |
| 6838 | void Context::programUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6839 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6840 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6841 | ASSERT(programObject); |
| 6842 | programObject->setUniform1fv(location, count, value); |
| 6843 | } |
| 6844 | |
| 6845 | void Context::programUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6846 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6847 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6848 | ASSERT(programObject); |
| 6849 | programObject->setUniform2fv(location, count, value); |
| 6850 | } |
| 6851 | |
| 6852 | void Context::programUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6853 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6854 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6855 | ASSERT(programObject); |
| 6856 | programObject->setUniform3fv(location, count, value); |
| 6857 | } |
| 6858 | |
| 6859 | void Context::programUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value) |
| 6860 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6861 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6862 | ASSERT(programObject); |
| 6863 | programObject->setUniform4fv(location, count, value); |
| 6864 | } |
| 6865 | |
| 6866 | void Context::programUniformMatrix2fv(GLuint program, |
| 6867 | GLint location, |
| 6868 | GLsizei count, |
| 6869 | GLboolean transpose, |
| 6870 | const GLfloat *value) |
| 6871 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6872 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6873 | ASSERT(programObject); |
| 6874 | programObject->setUniformMatrix2fv(location, count, transpose, value); |
| 6875 | } |
| 6876 | |
| 6877 | void Context::programUniformMatrix3fv(GLuint program, |
| 6878 | GLint location, |
| 6879 | GLsizei count, |
| 6880 | GLboolean transpose, |
| 6881 | const GLfloat *value) |
| 6882 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6883 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6884 | ASSERT(programObject); |
| 6885 | programObject->setUniformMatrix3fv(location, count, transpose, value); |
| 6886 | } |
| 6887 | |
| 6888 | void Context::programUniformMatrix4fv(GLuint program, |
| 6889 | GLint location, |
| 6890 | GLsizei count, |
| 6891 | GLboolean transpose, |
| 6892 | const GLfloat *value) |
| 6893 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6894 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6895 | ASSERT(programObject); |
| 6896 | programObject->setUniformMatrix4fv(location, count, transpose, value); |
| 6897 | } |
| 6898 | |
| 6899 | void Context::programUniformMatrix2x3fv(GLuint program, |
| 6900 | GLint location, |
| 6901 | GLsizei count, |
| 6902 | GLboolean transpose, |
| 6903 | 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->setUniformMatrix2x3fv(location, count, transpose, value); |
| 6908 | } |
| 6909 | |
| 6910 | void Context::programUniformMatrix3x2fv(GLuint program, |
| 6911 | GLint location, |
| 6912 | GLsizei count, |
| 6913 | GLboolean transpose, |
| 6914 | const GLfloat *value) |
| 6915 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6916 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6917 | ASSERT(programObject); |
| 6918 | programObject->setUniformMatrix3x2fv(location, count, transpose, value); |
| 6919 | } |
| 6920 | |
| 6921 | void Context::programUniformMatrix2x4fv(GLuint program, |
| 6922 | GLint location, |
| 6923 | GLsizei count, |
| 6924 | GLboolean transpose, |
| 6925 | const GLfloat *value) |
| 6926 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6927 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6928 | ASSERT(programObject); |
| 6929 | programObject->setUniformMatrix2x4fv(location, count, transpose, value); |
| 6930 | } |
| 6931 | |
| 6932 | void Context::programUniformMatrix4x2fv(GLuint program, |
| 6933 | GLint location, |
| 6934 | GLsizei count, |
| 6935 | GLboolean transpose, |
| 6936 | const GLfloat *value) |
| 6937 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6938 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6939 | ASSERT(programObject); |
| 6940 | programObject->setUniformMatrix4x2fv(location, count, transpose, value); |
| 6941 | } |
| 6942 | |
| 6943 | void Context::programUniformMatrix3x4fv(GLuint program, |
| 6944 | GLint location, |
| 6945 | GLsizei count, |
| 6946 | GLboolean transpose, |
| 6947 | const GLfloat *value) |
| 6948 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6949 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6950 | ASSERT(programObject); |
| 6951 | programObject->setUniformMatrix3x4fv(location, count, transpose, value); |
| 6952 | } |
| 6953 | |
| 6954 | void Context::programUniformMatrix4x3fv(GLuint program, |
| 6955 | GLint location, |
| 6956 | GLsizei count, |
| 6957 | GLboolean transpose, |
| 6958 | const GLfloat *value) |
| 6959 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 6960 | Program *programObject = getProgramResolveLink(program); |
Jiajia Qin | 5451d53 | 2017-11-16 17:16:34 +0800 | [diff] [blame] | 6961 | ASSERT(programObject); |
| 6962 | programObject->setUniformMatrix4x3fv(location, count, transpose, value); |
| 6963 | } |
| 6964 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6965 | bool Context::isCurrentTransformFeedback(const TransformFeedback *tf) const |
| 6966 | { |
| 6967 | return mGLState.isCurrentTransformFeedback(tf); |
| 6968 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 6969 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 6970 | void Context::genProgramPipelines(GLsizei count, GLuint *pipelines) |
| 6971 | { |
| 6972 | for (int i = 0; i < count; i++) |
| 6973 | { |
| 6974 | pipelines[i] = createProgramPipeline(); |
| 6975 | } |
| 6976 | } |
| 6977 | |
| 6978 | void Context::deleteProgramPipelines(GLsizei count, const GLuint *pipelines) |
| 6979 | { |
| 6980 | for (int i = 0; i < count; i++) |
| 6981 | { |
| 6982 | if (pipelines[i] != 0) |
| 6983 | { |
| 6984 | deleteProgramPipeline(pipelines[i]); |
| 6985 | } |
| 6986 | } |
| 6987 | } |
| 6988 | |
| 6989 | GLboolean Context::isProgramPipeline(GLuint pipeline) |
| 6990 | { |
| 6991 | if (pipeline == 0) |
| 6992 | { |
| 6993 | return GL_FALSE; |
| 6994 | } |
| 6995 | |
| 6996 | return (getProgramPipeline(pipeline) ? GL_TRUE : GL_FALSE); |
| 6997 | } |
| 6998 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 6999 | void Context::finishFenceNV(GLuint fence) |
| 7000 | { |
| 7001 | FenceNV *fenceObject = getFenceNV(fence); |
| 7002 | |
| 7003 | ASSERT(fenceObject && fenceObject->isSet()); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7004 | ANGLE_CONTEXT_TRY(fenceObject->finish(this)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7005 | } |
| 7006 | |
| 7007 | void Context::getFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 7008 | { |
| 7009 | FenceNV *fenceObject = getFenceNV(fence); |
| 7010 | |
| 7011 | ASSERT(fenceObject && fenceObject->isSet()); |
| 7012 | |
| 7013 | switch (pname) |
| 7014 | { |
| 7015 | case GL_FENCE_STATUS_NV: |
| 7016 | { |
| 7017 | // GL_NV_fence spec: |
| 7018 | // Once the status of a fence has been finished (via FinishFenceNV) or tested and |
| 7019 | // the returned status is TRUE (via either TestFenceNV or GetFenceivNV querying the |
| 7020 | // FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence. |
| 7021 | GLboolean status = GL_TRUE; |
| 7022 | if (fenceObject->getStatus() != GL_TRUE) |
| 7023 | { |
Jamie Madill | a0691b7 | 2018-07-25 10:41:22 -0400 | [diff] [blame] | 7024 | ANGLE_CONTEXT_TRY(fenceObject->test(this, &status)); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7025 | } |
| 7026 | *params = status; |
| 7027 | break; |
| 7028 | } |
| 7029 | |
| 7030 | case GL_FENCE_CONDITION_NV: |
| 7031 | { |
| 7032 | *params = static_cast<GLint>(fenceObject->getCondition()); |
| 7033 | break; |
| 7034 | } |
| 7035 | |
| 7036 | default: |
| 7037 | UNREACHABLE(); |
| 7038 | } |
| 7039 | } |
| 7040 | |
| 7041 | void Context::getTranslatedShaderSource(GLuint shader, |
| 7042 | GLsizei bufsize, |
| 7043 | GLsizei *length, |
| 7044 | GLchar *source) |
| 7045 | { |
| 7046 | Shader *shaderObject = getShader(shader); |
| 7047 | ASSERT(shaderObject); |
jchen10 | 3fd614d | 2018-08-13 12:21:58 +0800 | [diff] [blame] | 7048 | shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7049 | } |
| 7050 | |
| 7051 | void Context::getnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) |
| 7052 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7053 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7054 | ASSERT(programObject); |
| 7055 | |
| 7056 | programObject->getUniformfv(this, location, params); |
| 7057 | } |
| 7058 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7059 | void Context::getnUniformfvRobust(GLuint program, |
| 7060 | GLint location, |
| 7061 | GLsizei bufSize, |
| 7062 | GLsizei *length, |
| 7063 | GLfloat *params) |
| 7064 | { |
| 7065 | UNIMPLEMENTED(); |
| 7066 | } |
| 7067 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7068 | void Context::getnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint *params) |
| 7069 | { |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7070 | Program *programObject = getProgramResolveLink(program); |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7071 | ASSERT(programObject); |
| 7072 | |
| 7073 | programObject->getUniformiv(this, location, params); |
| 7074 | } |
| 7075 | |
Brandon Jones | fe4bbe6 | 2018-04-06 13:50:14 -0700 | [diff] [blame] | 7076 | void Context::getnUniformivRobust(GLuint program, |
| 7077 | GLint location, |
| 7078 | GLsizei bufSize, |
| 7079 | GLsizei *length, |
| 7080 | GLint *params) |
| 7081 | { |
| 7082 | UNIMPLEMENTED(); |
| 7083 | } |
| 7084 | |
| 7085 | void Context::getnUniformuivRobust(GLuint program, |
| 7086 | GLint location, |
| 7087 | GLsizei bufSize, |
| 7088 | GLsizei *length, |
| 7089 | GLuint *params) |
| 7090 | { |
| 7091 | UNIMPLEMENTED(); |
| 7092 | } |
| 7093 | |
Jamie Madill | 2b7bbc2 | 2017-12-21 17:30:38 -0500 | [diff] [blame] | 7094 | GLboolean Context::isFenceNV(GLuint fence) |
| 7095 | { |
| 7096 | FenceNV *fenceObject = getFenceNV(fence); |
| 7097 | |
| 7098 | if (fenceObject == nullptr) |
| 7099 | { |
| 7100 | return GL_FALSE; |
| 7101 | } |
| 7102 | |
| 7103 | // GL_NV_fence spec: |
| 7104 | // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an |
| 7105 | // existing fence. |
| 7106 | return fenceObject->isSet(); |
| 7107 | } |
| 7108 | |
| 7109 | void Context::readnPixels(GLint x, |
| 7110 | GLint y, |
| 7111 | GLsizei width, |
| 7112 | GLsizei height, |
| 7113 | GLenum format, |
| 7114 | GLenum type, |
| 7115 | GLsizei bufSize, |
| 7116 | void *data) |
| 7117 | { |
| 7118 | return readPixels(x, y, width, height, format, type, data); |
| 7119 | } |
| 7120 | |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7121 | void Context::setFenceNV(GLuint fence, GLenum condition) |
| 7122 | { |
| 7123 | ASSERT(condition == GL_ALL_COMPLETED_NV); |
| 7124 | |
| 7125 | FenceNV *fenceObject = getFenceNV(fence); |
| 7126 | ASSERT(fenceObject != nullptr); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7127 | ANGLE_CONTEXT_TRY(fenceObject->set(this, condition)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7128 | } |
| 7129 | |
| 7130 | GLboolean Context::testFenceNV(GLuint fence) |
| 7131 | { |
| 7132 | FenceNV *fenceObject = getFenceNV(fence); |
| 7133 | |
| 7134 | ASSERT(fenceObject != nullptr); |
| 7135 | ASSERT(fenceObject->isSet() == GL_TRUE); |
| 7136 | |
| 7137 | GLboolean result = GL_TRUE; |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 7138 | if (fenceObject->test(this, &result) == angle::Result::Stop) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7139 | { |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7140 | return GL_TRUE; |
| 7141 | } |
| 7142 | |
| 7143 | return result; |
| 7144 | } |
| 7145 | |
Corentin Wallez | f0e89be | 2017-11-08 14:00:32 -0800 | [diff] [blame] | 7146 | void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7147 | { |
| 7148 | Texture *texture = getTargetTexture(target); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7149 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7150 | ANGLE_CONTEXT_TRY(texture->setEGLImageTarget(this, target, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7151 | } |
| 7152 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7153 | void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image) |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7154 | { |
| 7155 | Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer(); |
Rafael Cintron | 05a449a | 2018-06-20 18:08:04 -0700 | [diff] [blame] | 7156 | egl::Image *imageObject = static_cast<egl::Image *>(image); |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 7157 | ANGLE_CONTEXT_TRY(renderbuffer->setStorageEGLImageTarget(this, imageObject)); |
Jamie Madill | 007530e | 2017-12-28 14:27:04 -0500 | [diff] [blame] | 7158 | } |
| 7159 | |
Jamie Madill | fa920eb | 2018-01-04 11:45:50 -0500 | [diff] [blame] | 7160 | void Context::texStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) |
| 7161 | { |
| 7162 | UNIMPLEMENTED(); |
| 7163 | } |
| 7164 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7165 | bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) |
| 7166 | { |
| 7167 | // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation |
| 7168 | // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due |
| 7169 | // to the fact that it is stored internally as a float, and so would require conversion |
| 7170 | // if returned from Context::getIntegerv. Since this conversion is already implemented |
| 7171 | // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we |
| 7172 | // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling |
| 7173 | // application. |
| 7174 | switch (pname) |
| 7175 | { |
| 7176 | case GL_COMPRESSED_TEXTURE_FORMATS: |
| 7177 | { |
| 7178 | *type = GL_INT; |
| 7179 | *numParams = static_cast<unsigned int>(getCaps().compressedTextureFormats.size()); |
| 7180 | return true; |
| 7181 | } |
| 7182 | case GL_SHADER_BINARY_FORMATS: |
| 7183 | { |
| 7184 | *type = GL_INT; |
| 7185 | *numParams = static_cast<unsigned int>(getCaps().shaderBinaryFormats.size()); |
| 7186 | return true; |
| 7187 | } |
| 7188 | |
| 7189 | case GL_MAX_VERTEX_ATTRIBS: |
| 7190 | case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 7191 | case GL_MAX_VARYING_VECTORS: |
| 7192 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 7193 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 7194 | case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 7195 | case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 7196 | case GL_MAX_RENDERBUFFER_SIZE: |
| 7197 | case GL_NUM_SHADER_BINARY_FORMATS: |
| 7198 | case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 7199 | case GL_ARRAY_BUFFER_BINDING: |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7200 | case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to |
| 7201 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7202 | case GL_RENDERBUFFER_BINDING: |
| 7203 | case GL_CURRENT_PROGRAM: |
| 7204 | case GL_PACK_ALIGNMENT: |
| 7205 | case GL_UNPACK_ALIGNMENT: |
| 7206 | case GL_GENERATE_MIPMAP_HINT: |
| 7207 | case GL_RED_BITS: |
| 7208 | case GL_GREEN_BITS: |
| 7209 | case GL_BLUE_BITS: |
| 7210 | case GL_ALPHA_BITS: |
| 7211 | case GL_DEPTH_BITS: |
| 7212 | case GL_STENCIL_BITS: |
| 7213 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 7214 | case GL_CULL_FACE_MODE: |
| 7215 | case GL_FRONT_FACE: |
| 7216 | case GL_ACTIVE_TEXTURE: |
| 7217 | case GL_STENCIL_FUNC: |
| 7218 | case GL_STENCIL_VALUE_MASK: |
| 7219 | case GL_STENCIL_REF: |
| 7220 | case GL_STENCIL_FAIL: |
| 7221 | case GL_STENCIL_PASS_DEPTH_FAIL: |
| 7222 | case GL_STENCIL_PASS_DEPTH_PASS: |
| 7223 | case GL_STENCIL_BACK_FUNC: |
| 7224 | case GL_STENCIL_BACK_VALUE_MASK: |
| 7225 | case GL_STENCIL_BACK_REF: |
| 7226 | case GL_STENCIL_BACK_FAIL: |
| 7227 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 7228 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 7229 | case GL_DEPTH_FUNC: |
| 7230 | case GL_BLEND_SRC_RGB: |
| 7231 | case GL_BLEND_SRC_ALPHA: |
| 7232 | case GL_BLEND_DST_RGB: |
| 7233 | case GL_BLEND_DST_ALPHA: |
| 7234 | case GL_BLEND_EQUATION_RGB: |
| 7235 | case GL_BLEND_EQUATION_ALPHA: |
| 7236 | case GL_STENCIL_WRITEMASK: |
| 7237 | case GL_STENCIL_BACK_WRITEMASK: |
| 7238 | case GL_STENCIL_CLEAR_VALUE: |
| 7239 | case GL_SUBPIXEL_BITS: |
| 7240 | case GL_MAX_TEXTURE_SIZE: |
| 7241 | case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 7242 | case GL_SAMPLE_BUFFERS: |
| 7243 | case GL_SAMPLES: |
| 7244 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 7245 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 7246 | case GL_TEXTURE_BINDING_2D: |
| 7247 | case GL_TEXTURE_BINDING_CUBE_MAP: |
| 7248 | case GL_RESET_NOTIFICATION_STRATEGY_EXT: |
| 7249 | { |
| 7250 | *type = GL_INT; |
| 7251 | *numParams = 1; |
| 7252 | return true; |
| 7253 | } |
| 7254 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 7255 | { |
| 7256 | if (!getExtensions().packReverseRowOrder) |
| 7257 | { |
| 7258 | return false; |
| 7259 | } |
| 7260 | *type = GL_INT; |
| 7261 | *numParams = 1; |
| 7262 | return true; |
| 7263 | } |
| 7264 | case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE: |
| 7265 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 7266 | { |
| 7267 | if (!getExtensions().textureRectangle) |
| 7268 | { |
| 7269 | return false; |
| 7270 | } |
| 7271 | *type = GL_INT; |
| 7272 | *numParams = 1; |
| 7273 | return true; |
| 7274 | } |
| 7275 | case GL_MAX_DRAW_BUFFERS_EXT: |
| 7276 | case GL_MAX_COLOR_ATTACHMENTS_EXT: |
| 7277 | { |
| 7278 | if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers) |
| 7279 | { |
| 7280 | return false; |
| 7281 | } |
| 7282 | *type = GL_INT; |
| 7283 | *numParams = 1; |
| 7284 | return true; |
| 7285 | } |
| 7286 | case GL_MAX_VIEWPORT_DIMS: |
| 7287 | { |
| 7288 | *type = GL_INT; |
| 7289 | *numParams = 2; |
| 7290 | return true; |
| 7291 | } |
| 7292 | case GL_VIEWPORT: |
| 7293 | case GL_SCISSOR_BOX: |
| 7294 | { |
| 7295 | *type = GL_INT; |
| 7296 | *numParams = 4; |
| 7297 | return true; |
| 7298 | } |
| 7299 | case GL_SHADER_COMPILER: |
| 7300 | case GL_SAMPLE_COVERAGE_INVERT: |
| 7301 | case GL_DEPTH_WRITEMASK: |
| 7302 | case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled, |
| 7303 | case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries. |
| 7304 | case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as |
| 7305 | // bool-natural |
| 7306 | case GL_SAMPLE_COVERAGE: |
| 7307 | case GL_SCISSOR_TEST: |
| 7308 | case GL_STENCIL_TEST: |
| 7309 | case GL_DEPTH_TEST: |
| 7310 | case GL_BLEND: |
| 7311 | case GL_DITHER: |
| 7312 | case GL_CONTEXT_ROBUST_ACCESS_EXT: |
| 7313 | { |
| 7314 | *type = GL_BOOL; |
| 7315 | *numParams = 1; |
| 7316 | return true; |
| 7317 | } |
| 7318 | case GL_COLOR_WRITEMASK: |
| 7319 | { |
| 7320 | *type = GL_BOOL; |
| 7321 | *numParams = 4; |
| 7322 | return true; |
| 7323 | } |
| 7324 | case GL_POLYGON_OFFSET_FACTOR: |
| 7325 | case GL_POLYGON_OFFSET_UNITS: |
| 7326 | case GL_SAMPLE_COVERAGE_VALUE: |
| 7327 | case GL_DEPTH_CLEAR_VALUE: |
| 7328 | case GL_LINE_WIDTH: |
| 7329 | { |
| 7330 | *type = GL_FLOAT; |
| 7331 | *numParams = 1; |
| 7332 | return true; |
| 7333 | } |
| 7334 | case GL_ALIASED_LINE_WIDTH_RANGE: |
| 7335 | case GL_ALIASED_POINT_SIZE_RANGE: |
| 7336 | case GL_DEPTH_RANGE: |
| 7337 | { |
| 7338 | *type = GL_FLOAT; |
| 7339 | *numParams = 2; |
| 7340 | return true; |
| 7341 | } |
| 7342 | case GL_COLOR_CLEAR_VALUE: |
| 7343 | case GL_BLEND_COLOR: |
| 7344 | { |
| 7345 | *type = GL_FLOAT; |
| 7346 | *numParams = 4; |
| 7347 | return true; |
| 7348 | } |
| 7349 | case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7350 | if (!getExtensions().textureFilterAnisotropic) |
| 7351 | { |
| 7352 | return false; |
| 7353 | } |
| 7354 | *type = GL_FLOAT; |
| 7355 | *numParams = 1; |
| 7356 | return true; |
| 7357 | case GL_TIMESTAMP_EXT: |
| 7358 | if (!getExtensions().disjointTimerQuery) |
| 7359 | { |
| 7360 | return false; |
| 7361 | } |
| 7362 | *type = GL_INT_64_ANGLEX; |
| 7363 | *numParams = 1; |
| 7364 | return true; |
| 7365 | case GL_GPU_DISJOINT_EXT: |
| 7366 | if (!getExtensions().disjointTimerQuery) |
| 7367 | { |
| 7368 | return false; |
| 7369 | } |
| 7370 | *type = GL_INT; |
| 7371 | *numParams = 1; |
| 7372 | return true; |
| 7373 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 7374 | if (!getExtensions().framebufferMixedSamples) |
| 7375 | { |
| 7376 | return false; |
| 7377 | } |
| 7378 | *type = GL_INT; |
| 7379 | *numParams = 1; |
| 7380 | return true; |
| 7381 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 7382 | if (!getExtensions().eglStreamConsumerExternal && !getExtensions().eglImageExternal) |
| 7383 | { |
| 7384 | return false; |
| 7385 | } |
| 7386 | *type = GL_INT; |
| 7387 | *numParams = 1; |
| 7388 | return true; |
| 7389 | } |
| 7390 | |
| 7391 | if (getExtensions().debug) |
| 7392 | { |
| 7393 | switch (pname) |
| 7394 | { |
| 7395 | case GL_DEBUG_LOGGED_MESSAGES: |
| 7396 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 7397 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 7398 | case GL_MAX_DEBUG_MESSAGE_LENGTH: |
| 7399 | case GL_MAX_DEBUG_LOGGED_MESSAGES: |
| 7400 | case GL_MAX_DEBUG_GROUP_STACK_DEPTH: |
| 7401 | case GL_MAX_LABEL_LENGTH: |
| 7402 | *type = GL_INT; |
| 7403 | *numParams = 1; |
| 7404 | return true; |
| 7405 | |
| 7406 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 7407 | case GL_DEBUG_OUTPUT: |
| 7408 | *type = GL_BOOL; |
| 7409 | *numParams = 1; |
| 7410 | return true; |
| 7411 | } |
| 7412 | } |
| 7413 | |
| 7414 | if (getExtensions().multisampleCompatibility) |
| 7415 | { |
| 7416 | switch (pname) |
| 7417 | { |
| 7418 | case GL_MULTISAMPLE_EXT: |
| 7419 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 7420 | *type = GL_BOOL; |
| 7421 | *numParams = 1; |
| 7422 | return true; |
| 7423 | } |
| 7424 | } |
| 7425 | |
| 7426 | if (getExtensions().pathRendering) |
| 7427 | { |
| 7428 | switch (pname) |
| 7429 | { |
| 7430 | case GL_PATH_MODELVIEW_MATRIX_CHROMIUM: |
| 7431 | case GL_PATH_PROJECTION_MATRIX_CHROMIUM: |
| 7432 | *type = GL_FLOAT; |
| 7433 | *numParams = 16; |
| 7434 | return true; |
| 7435 | } |
| 7436 | } |
| 7437 | |
| 7438 | if (getExtensions().bindGeneratesResource) |
| 7439 | { |
| 7440 | switch (pname) |
| 7441 | { |
| 7442 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 7443 | *type = GL_BOOL; |
| 7444 | *numParams = 1; |
| 7445 | return true; |
| 7446 | } |
| 7447 | } |
| 7448 | |
| 7449 | if (getExtensions().clientArrays) |
| 7450 | { |
| 7451 | switch (pname) |
| 7452 | { |
| 7453 | case GL_CLIENT_ARRAYS_ANGLE: |
| 7454 | *type = GL_BOOL; |
| 7455 | *numParams = 1; |
| 7456 | return true; |
| 7457 | } |
| 7458 | } |
| 7459 | |
| 7460 | if (getExtensions().sRGBWriteControl) |
| 7461 | { |
| 7462 | switch (pname) |
| 7463 | { |
| 7464 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 7465 | *type = GL_BOOL; |
| 7466 | *numParams = 1; |
| 7467 | return true; |
| 7468 | } |
| 7469 | } |
| 7470 | |
| 7471 | if (getExtensions().robustResourceInitialization && |
| 7472 | pname == GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE) |
| 7473 | { |
| 7474 | *type = GL_BOOL; |
| 7475 | *numParams = 1; |
| 7476 | return true; |
| 7477 | } |
| 7478 | |
| 7479 | if (getExtensions().programCacheControl && pname == GL_PROGRAM_CACHE_ENABLED_ANGLE) |
| 7480 | { |
| 7481 | *type = GL_BOOL; |
| 7482 | *numParams = 1; |
| 7483 | return true; |
| 7484 | } |
| 7485 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 7486 | if (getExtensions().parallelShaderCompile && pname == GL_MAX_SHADER_COMPILER_THREADS_KHR) |
| 7487 | { |
| 7488 | *type = GL_INT; |
| 7489 | *numParams = 1; |
| 7490 | return true; |
| 7491 | } |
| 7492 | |
Olli Etuaho | ab5fb5e | 2018-09-18 17:23:28 +0300 | [diff] [blame] | 7493 | if (getExtensions().blendFuncExtended && pname == GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT) |
| 7494 | { |
| 7495 | *type = GL_INT; |
| 7496 | *numParams = 1; |
| 7497 | return true; |
| 7498 | } |
| 7499 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7500 | // Check for ES3.0+ parameter names which are also exposed as ES2 extensions |
| 7501 | switch (pname) |
| 7502 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 7503 | // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7504 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: |
| 7505 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) |
| 7506 | { |
| 7507 | return false; |
| 7508 | } |
| 7509 | *type = GL_INT; |
| 7510 | *numParams = 1; |
| 7511 | return true; |
| 7512 | |
| 7513 | case GL_NUM_PROGRAM_BINARY_FORMATS_OES: |
| 7514 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7515 | { |
| 7516 | return false; |
| 7517 | } |
| 7518 | *type = GL_INT; |
| 7519 | *numParams = 1; |
| 7520 | return true; |
| 7521 | |
| 7522 | case GL_PROGRAM_BINARY_FORMATS_OES: |
| 7523 | if ((getClientMajorVersion() < 3) && !getExtensions().getProgramBinary) |
| 7524 | { |
| 7525 | return false; |
| 7526 | } |
| 7527 | *type = GL_INT; |
| 7528 | *numParams = static_cast<unsigned int>(getCaps().programBinaryFormats.size()); |
| 7529 | return true; |
| 7530 | |
| 7531 | case GL_PACK_ROW_LENGTH: |
| 7532 | case GL_PACK_SKIP_ROWS: |
| 7533 | case GL_PACK_SKIP_PIXELS: |
| 7534 | if ((getClientMajorVersion() < 3) && !getExtensions().packSubimage) |
| 7535 | { |
| 7536 | return false; |
| 7537 | } |
| 7538 | *type = GL_INT; |
| 7539 | *numParams = 1; |
| 7540 | return true; |
| 7541 | case GL_UNPACK_ROW_LENGTH: |
| 7542 | case GL_UNPACK_SKIP_ROWS: |
| 7543 | case GL_UNPACK_SKIP_PIXELS: |
| 7544 | if ((getClientMajorVersion() < 3) && !getExtensions().unpackSubimage) |
| 7545 | { |
| 7546 | return false; |
| 7547 | } |
| 7548 | *type = GL_INT; |
| 7549 | *numParams = 1; |
| 7550 | return true; |
| 7551 | case GL_VERTEX_ARRAY_BINDING: |
| 7552 | if ((getClientMajorVersion() < 3) && !getExtensions().vertexArrayObject) |
| 7553 | { |
| 7554 | return false; |
| 7555 | } |
| 7556 | *type = GL_INT; |
| 7557 | *numParams = 1; |
| 7558 | return true; |
| 7559 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 7560 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 7561 | if ((getClientMajorVersion() < 3) && !getExtensions().pixelBufferObject) |
| 7562 | { |
| 7563 | return false; |
| 7564 | } |
| 7565 | *type = GL_INT; |
| 7566 | *numParams = 1; |
| 7567 | return true; |
| 7568 | case GL_MAX_SAMPLES: |
| 7569 | { |
| 7570 | static_assert(GL_MAX_SAMPLES_ANGLE == GL_MAX_SAMPLES, |
| 7571 | "GL_MAX_SAMPLES_ANGLE not equal to GL_MAX_SAMPLES"); |
| 7572 | if ((getClientMajorVersion() < 3) && !getExtensions().framebufferMultisample) |
| 7573 | { |
| 7574 | return false; |
| 7575 | } |
| 7576 | *type = GL_INT; |
| 7577 | *numParams = 1; |
| 7578 | return true; |
| 7579 | |
| 7580 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 7581 | if ((getClientMajorVersion() < 3) && !getExtensions().standardDerivatives) |
| 7582 | { |
| 7583 | return false; |
| 7584 | } |
| 7585 | *type = GL_INT; |
| 7586 | *numParams = 1; |
| 7587 | return true; |
| 7588 | } |
| 7589 | } |
| 7590 | |
| 7591 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 7592 | { |
| 7593 | if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers) |
| 7594 | { |
| 7595 | return false; |
| 7596 | } |
| 7597 | *type = GL_INT; |
| 7598 | *numParams = 1; |
| 7599 | return true; |
| 7600 | } |
| 7601 | |
| 7602 | if (getExtensions().multiview && pname == GL_MAX_VIEWS_ANGLE) |
| 7603 | { |
| 7604 | *type = GL_INT; |
| 7605 | *numParams = 1; |
| 7606 | return true; |
| 7607 | } |
| 7608 | |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7609 | if (getClientVersion() < Version(2, 0)) |
| 7610 | { |
| 7611 | switch (pname) |
| 7612 | { |
| 7613 | case GL_ALPHA_TEST_FUNC: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7614 | case GL_CLIENT_ACTIVE_TEXTURE: |
| 7615 | case GL_MATRIX_MODE: |
| 7616 | case GL_MAX_TEXTURE_UNITS: |
| 7617 | case GL_MAX_MODELVIEW_STACK_DEPTH: |
| 7618 | case GL_MAX_PROJECTION_STACK_DEPTH: |
| 7619 | case GL_MAX_TEXTURE_STACK_DEPTH: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7620 | case GL_MAX_LIGHTS: |
Lingfeng Yang | 060088a | 2018-05-30 20:40:57 -0700 | [diff] [blame] | 7621 | case GL_MAX_CLIP_PLANES: |
Lingfeng Yang | abb09f1 | 2018-04-16 10:43:53 -0700 | [diff] [blame] | 7622 | case GL_VERTEX_ARRAY_STRIDE: |
| 7623 | case GL_NORMAL_ARRAY_STRIDE: |
| 7624 | case GL_COLOR_ARRAY_STRIDE: |
| 7625 | case GL_TEXTURE_COORD_ARRAY_STRIDE: |
| 7626 | case GL_VERTEX_ARRAY_SIZE: |
| 7627 | case GL_COLOR_ARRAY_SIZE: |
| 7628 | case GL_TEXTURE_COORD_ARRAY_SIZE: |
| 7629 | case GL_VERTEX_ARRAY_TYPE: |
| 7630 | case GL_NORMAL_ARRAY_TYPE: |
| 7631 | case GL_COLOR_ARRAY_TYPE: |
| 7632 | case GL_TEXTURE_COORD_ARRAY_TYPE: |
| 7633 | case GL_VERTEX_ARRAY_BUFFER_BINDING: |
| 7634 | case GL_NORMAL_ARRAY_BUFFER_BINDING: |
| 7635 | case GL_COLOR_ARRAY_BUFFER_BINDING: |
| 7636 | case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: |
| 7637 | case GL_POINT_SIZE_ARRAY_STRIDE_OES: |
| 7638 | case GL_POINT_SIZE_ARRAY_TYPE_OES: |
| 7639 | case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: |
Lingfeng Yang | a0cfa87 | 2018-05-30 21:12:17 -0700 | [diff] [blame] | 7640 | case GL_SHADE_MODEL: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7641 | case GL_MODELVIEW_STACK_DEPTH: |
| 7642 | case GL_PROJECTION_STACK_DEPTH: |
| 7643 | case GL_TEXTURE_STACK_DEPTH: |
| 7644 | case GL_LOGIC_OP_MODE: |
| 7645 | case GL_BLEND_SRC: |
| 7646 | case GL_BLEND_DST: |
| 7647 | case GL_PERSPECTIVE_CORRECTION_HINT: |
| 7648 | case GL_POINT_SMOOTH_HINT: |
| 7649 | case GL_LINE_SMOOTH_HINT: |
| 7650 | case GL_FOG_HINT: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7651 | *type = GL_INT; |
| 7652 | *numParams = 1; |
| 7653 | return true; |
| 7654 | case GL_ALPHA_TEST_REF: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7655 | case GL_FOG_DENSITY: |
| 7656 | case GL_FOG_START: |
| 7657 | case GL_FOG_END: |
| 7658 | case GL_FOG_MODE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7659 | case GL_POINT_SIZE: |
| 7660 | case GL_POINT_SIZE_MIN: |
| 7661 | case GL_POINT_SIZE_MAX: |
| 7662 | case GL_POINT_FADE_THRESHOLD_SIZE: |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7663 | *type = GL_FLOAT; |
| 7664 | *numParams = 1; |
| 7665 | return true; |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7666 | case GL_SMOOTH_POINT_SIZE_RANGE: |
Lingfeng Yang | 6e5bf36 | 2018-08-15 09:53:17 -0700 | [diff] [blame] | 7667 | case GL_SMOOTH_LINE_WIDTH_RANGE: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7668 | *type = GL_FLOAT; |
| 7669 | *numParams = 2; |
| 7670 | return true; |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7671 | case GL_CURRENT_COLOR: |
Lingfeng Yang | e547aac | 2018-04-05 09:39:20 -0700 | [diff] [blame] | 7672 | case GL_CURRENT_TEXTURE_COORDS: |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7673 | case GL_LIGHT_MODEL_AMBIENT: |
Lingfeng Yang | 7ba3f42 | 2018-06-01 09:43:04 -0700 | [diff] [blame] | 7674 | case GL_FOG_COLOR: |
Lingfeng Yang | a43994c | 2018-03-29 07:21:41 -0700 | [diff] [blame] | 7675 | *type = GL_FLOAT; |
| 7676 | *numParams = 4; |
| 7677 | return true; |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7678 | case GL_CURRENT_NORMAL: |
Lingfeng Yang | 9c4c092 | 2018-06-13 09:29:00 -0700 | [diff] [blame] | 7679 | case GL_POINT_DISTANCE_ATTENUATION: |
Lingfeng Yang | 5a7e61b | 2018-03-29 16:50:32 -0700 | [diff] [blame] | 7680 | *type = GL_FLOAT; |
| 7681 | *numParams = 3; |
| 7682 | return true; |
Lingfeng Yang | 3a41af6 | 2018-04-09 07:28:56 -0700 | [diff] [blame] | 7683 | case GL_MODELVIEW_MATRIX: |
| 7684 | case GL_PROJECTION_MATRIX: |
| 7685 | case GL_TEXTURE_MATRIX: |
| 7686 | *type = GL_FLOAT; |
| 7687 | *numParams = 16; |
| 7688 | return true; |
Lingfeng Yang | d0febe7 | 2018-05-17 22:36:52 -0700 | [diff] [blame] | 7689 | case GL_LIGHT_MODEL_TWO_SIDE: |
| 7690 | *type = GL_BOOL; |
| 7691 | *numParams = 1; |
| 7692 | return true; |
Lingfeng Yang | 13b708f | 2018-03-21 12:14:10 -0700 | [diff] [blame] | 7693 | } |
| 7694 | } |
| 7695 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7696 | if (getClientVersion() < Version(3, 0)) |
| 7697 | { |
| 7698 | return false; |
| 7699 | } |
| 7700 | |
| 7701 | // Check for ES3.0+ parameter names |
| 7702 | switch (pname) |
| 7703 | { |
| 7704 | case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 7705 | case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 7706 | case GL_UNIFORM_BUFFER_BINDING: |
| 7707 | case GL_TRANSFORM_FEEDBACK_BINDING: |
| 7708 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7709 | case GL_COPY_READ_BUFFER_BINDING: |
| 7710 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 7711 | case GL_SAMPLER_BINDING: |
| 7712 | case GL_READ_BUFFER: |
| 7713 | case GL_TEXTURE_BINDING_3D: |
| 7714 | case GL_TEXTURE_BINDING_2D_ARRAY: |
| 7715 | case GL_MAX_3D_TEXTURE_SIZE: |
| 7716 | case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 7717 | case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 7718 | case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 7719 | case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 7720 | case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 7721 | case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 7722 | case GL_MAX_VARYING_COMPONENTS: |
| 7723 | case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 7724 | case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 7725 | case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 7726 | case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 7727 | case GL_NUM_EXTENSIONS: |
| 7728 | case GL_MAJOR_VERSION: |
| 7729 | case GL_MINOR_VERSION: |
| 7730 | case GL_MAX_ELEMENTS_INDICES: |
| 7731 | case GL_MAX_ELEMENTS_VERTICES: |
| 7732 | case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 7733 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 7734 | case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 7735 | case GL_UNPACK_IMAGE_HEIGHT: |
| 7736 | case GL_UNPACK_SKIP_IMAGES: |
| 7737 | { |
| 7738 | *type = GL_INT; |
| 7739 | *numParams = 1; |
| 7740 | return true; |
| 7741 | } |
| 7742 | |
| 7743 | case GL_MAX_ELEMENT_INDEX: |
| 7744 | case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 7745 | case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 7746 | case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 7747 | case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 7748 | { |
| 7749 | *type = GL_INT_64_ANGLEX; |
| 7750 | *numParams = 1; |
| 7751 | return true; |
| 7752 | } |
| 7753 | |
| 7754 | case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 7755 | case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 7756 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 7757 | case GL_RASTERIZER_DISCARD: |
| 7758 | { |
| 7759 | *type = GL_BOOL; |
| 7760 | *numParams = 1; |
| 7761 | return true; |
| 7762 | } |
| 7763 | |
| 7764 | case GL_MAX_TEXTURE_LOD_BIAS: |
| 7765 | { |
| 7766 | *type = GL_FLOAT; |
| 7767 | *numParams = 1; |
| 7768 | return true; |
| 7769 | } |
| 7770 | } |
| 7771 | |
| 7772 | if (getExtensions().requestExtension) |
| 7773 | { |
| 7774 | switch (pname) |
| 7775 | { |
| 7776 | case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE: |
| 7777 | *type = GL_INT; |
| 7778 | *numParams = 1; |
| 7779 | return true; |
| 7780 | } |
| 7781 | } |
| 7782 | |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7783 | if (getExtensions().textureMultisample) |
| 7784 | { |
| 7785 | switch (pname) |
| 7786 | { |
| 7787 | case GL_MAX_COLOR_TEXTURE_SAMPLES_ANGLE: |
| 7788 | case GL_MAX_INTEGER_SAMPLES_ANGLE: |
| 7789 | case GL_MAX_DEPTH_TEXTURE_SAMPLES_ANGLE: |
| 7790 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ANGLE: |
Yizhou Jiang | 7310da3 | 2018-11-05 14:40:01 +0800 | [diff] [blame] | 7791 | case GL_MAX_SAMPLE_MASK_WORDS: |
Yizhou Jiang | 7818a85 | 2018-09-06 15:02:04 +0800 | [diff] [blame] | 7792 | *type = GL_INT; |
| 7793 | *numParams = 1; |
| 7794 | return true; |
| 7795 | } |
| 7796 | } |
| 7797 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7798 | if (getClientVersion() < Version(3, 1)) |
| 7799 | { |
| 7800 | return false; |
| 7801 | } |
| 7802 | |
| 7803 | switch (pname) |
| 7804 | { |
| 7805 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7806 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 7807 | case GL_DISPATCH_INDIRECT_BUFFER_BINDING: |
| 7808 | case GL_MAX_FRAMEBUFFER_WIDTH: |
| 7809 | case GL_MAX_FRAMEBUFFER_HEIGHT: |
| 7810 | case GL_MAX_FRAMEBUFFER_SAMPLES: |
| 7811 | case GL_MAX_SAMPLE_MASK_WORDS: |
| 7812 | case GL_MAX_COLOR_TEXTURE_SAMPLES: |
| 7813 | case GL_MAX_DEPTH_TEXTURE_SAMPLES: |
| 7814 | case GL_MAX_INTEGER_SAMPLES: |
| 7815 | case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET: |
| 7816 | case GL_MAX_VERTEX_ATTRIB_BINDINGS: |
| 7817 | case GL_MAX_VERTEX_ATTRIB_STRIDE: |
| 7818 | case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS: |
| 7819 | case GL_MAX_VERTEX_ATOMIC_COUNTERS: |
| 7820 | case GL_MAX_VERTEX_IMAGE_UNIFORMS: |
| 7821 | case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS: |
| 7822 | case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS: |
| 7823 | case GL_MAX_FRAGMENT_ATOMIC_COUNTERS: |
| 7824 | case GL_MAX_FRAGMENT_IMAGE_UNIFORMS: |
| 7825 | case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: |
| 7826 | case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7827 | case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET: |
| 7828 | case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: |
| 7829 | case GL_MAX_COMPUTE_UNIFORM_BLOCKS: |
| 7830 | case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: |
| 7831 | case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE: |
| 7832 | case GL_MAX_COMPUTE_UNIFORM_COMPONENTS: |
| 7833 | case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS: |
| 7834 | case GL_MAX_COMPUTE_ATOMIC_COUNTERS: |
| 7835 | case GL_MAX_COMPUTE_IMAGE_UNIFORMS: |
| 7836 | case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS: |
| 7837 | case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: |
| 7838 | case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES: |
| 7839 | case GL_MAX_UNIFORM_LOCATIONS: |
| 7840 | case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: |
| 7841 | case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7842 | case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS: |
| 7843 | case GL_MAX_COMBINED_ATOMIC_COUNTERS: |
| 7844 | case GL_MAX_IMAGE_UNITS: |
| 7845 | case GL_MAX_COMBINED_IMAGE_UNIFORMS: |
| 7846 | case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: |
| 7847 | case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: |
| 7848 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7849 | case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: |
| 7850 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
Olli Etuaho | dff32a0 | 2018-08-28 14:35:50 +0300 | [diff] [blame] | 7851 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7852 | *type = GL_INT; |
| 7853 | *numParams = 1; |
| 7854 | return true; |
| 7855 | case GL_MAX_SHADER_STORAGE_BLOCK_SIZE: |
| 7856 | *type = GL_INT_64_ANGLEX; |
| 7857 | *numParams = 1; |
| 7858 | return true; |
| 7859 | case GL_SAMPLE_MASK: |
| 7860 | *type = GL_BOOL; |
| 7861 | *numParams = 1; |
| 7862 | return true; |
| 7863 | } |
| 7864 | |
| 7865 | if (getExtensions().geometryShader) |
| 7866 | { |
| 7867 | switch (pname) |
| 7868 | { |
| 7869 | case GL_MAX_FRAMEBUFFER_LAYERS_EXT: |
| 7870 | case GL_LAYER_PROVOKING_VERTEX_EXT: |
| 7871 | case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7872 | case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT: |
| 7873 | case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT: |
| 7874 | case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT: |
| 7875 | case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT: |
| 7876 | case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: |
| 7877 | case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT: |
| 7878 | case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT: |
| 7879 | case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT: |
| 7880 | case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT: |
| 7881 | case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT: |
| 7882 | case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT: |
| 7883 | case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: |
| 7884 | *type = GL_INT; |
| 7885 | *numParams = 1; |
| 7886 | return true; |
| 7887 | } |
| 7888 | } |
| 7889 | |
| 7890 | return false; |
| 7891 | } |
| 7892 | |
| 7893 | bool Context::getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams) |
| 7894 | { |
| 7895 | if (getClientVersion() < Version(3, 0)) |
| 7896 | { |
| 7897 | return false; |
| 7898 | } |
| 7899 | |
| 7900 | switch (target) |
| 7901 | { |
| 7902 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7903 | case GL_UNIFORM_BUFFER_BINDING: |
| 7904 | { |
| 7905 | *type = GL_INT; |
| 7906 | *numParams = 1; |
| 7907 | return true; |
| 7908 | } |
| 7909 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7910 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7911 | case GL_UNIFORM_BUFFER_START: |
| 7912 | case GL_UNIFORM_BUFFER_SIZE: |
| 7913 | { |
| 7914 | *type = GL_INT_64_ANGLEX; |
| 7915 | *numParams = 1; |
| 7916 | return true; |
| 7917 | } |
| 7918 | } |
| 7919 | |
| 7920 | if (getClientVersion() < Version(3, 1)) |
| 7921 | { |
| 7922 | return false; |
| 7923 | } |
| 7924 | |
| 7925 | switch (target) |
| 7926 | { |
| 7927 | case GL_IMAGE_BINDING_LAYERED: |
| 7928 | { |
| 7929 | *type = GL_BOOL; |
| 7930 | *numParams = 1; |
| 7931 | return true; |
| 7932 | } |
| 7933 | case GL_MAX_COMPUTE_WORK_GROUP_COUNT: |
| 7934 | case GL_MAX_COMPUTE_WORK_GROUP_SIZE: |
| 7935 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 7936 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 7937 | case GL_VERTEX_BINDING_BUFFER: |
| 7938 | case GL_VERTEX_BINDING_DIVISOR: |
| 7939 | case GL_VERTEX_BINDING_OFFSET: |
| 7940 | case GL_VERTEX_BINDING_STRIDE: |
| 7941 | case GL_SAMPLE_MASK_VALUE: |
| 7942 | case GL_IMAGE_BINDING_NAME: |
| 7943 | case GL_IMAGE_BINDING_LEVEL: |
| 7944 | case GL_IMAGE_BINDING_LAYER: |
| 7945 | case GL_IMAGE_BINDING_ACCESS: |
| 7946 | case GL_IMAGE_BINDING_FORMAT: |
| 7947 | { |
| 7948 | *type = GL_INT; |
| 7949 | *numParams = 1; |
| 7950 | return true; |
| 7951 | } |
| 7952 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 7953 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 7954 | case GL_SHADER_STORAGE_BUFFER_START: |
| 7955 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 7956 | { |
| 7957 | *type = GL_INT_64_ANGLEX; |
| 7958 | *numParams = 1; |
| 7959 | return true; |
| 7960 | } |
| 7961 | } |
| 7962 | |
| 7963 | return false; |
| 7964 | } |
| 7965 | |
Jamie Madill | 44a6fbf | 2018-10-02 13:38:56 -0400 | [diff] [blame] | 7966 | Program *Context::getProgramNoResolveLink(GLuint handle) const |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7967 | { |
| 7968 | return mState.mShaderPrograms->getProgram(handle); |
| 7969 | } |
| 7970 | |
| 7971 | Shader *Context::getShader(GLuint handle) const |
| 7972 | { |
| 7973 | return mState.mShaderPrograms->getShader(handle); |
| 7974 | } |
| 7975 | |
Jamie Madill | 5b77231 | 2018-03-08 20:28:32 -0500 | [diff] [blame] | 7976 | bool Context::isRenderbufferGenerated(GLuint renderbuffer) const |
| 7977 | { |
| 7978 | return mState.mRenderbuffers->isHandleGenerated(renderbuffer); |
| 7979 | } |
| 7980 | |
| 7981 | bool Context::isFramebufferGenerated(GLuint framebuffer) const |
| 7982 | { |
| 7983 | return mState.mFramebuffers->isHandleGenerated(framebuffer); |
| 7984 | } |
| 7985 | |
| 7986 | bool Context::isProgramPipelineGenerated(GLuint pipeline) const |
| 7987 | { |
| 7988 | return mState.mPipelines->isHandleGenerated(pipeline); |
| 7989 | } |
| 7990 | |
| 7991 | bool Context::usingDisplayTextureShareGroup() const |
| 7992 | { |
| 7993 | return mDisplayTextureShareGroup; |
| 7994 | } |
| 7995 | |
| 7996 | GLenum Context::getConvertedRenderbufferFormat(GLenum internalformat) const |
| 7997 | { |
| 7998 | return mState.mExtensions.webglCompatibility && mState.mClientVersion.major == 2 && |
| 7999 | internalformat == GL_DEPTH_STENCIL |
| 8000 | ? GL_DEPTH24_STENCIL8 |
| 8001 | : internalformat; |
| 8002 | } |
| 8003 | |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8004 | void Context::maxShaderCompilerThreads(GLuint count) |
| 8005 | { |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 8006 | GLuint oldCount = mGLState.getMaxShaderCompilerThreads(); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8007 | mGLState.setMaxShaderCompilerThreads(count); |
jchen10 | 7ae70d8 | 2018-07-06 13:47:01 +0800 | [diff] [blame] | 8008 | // A count of zero specifies a request for no parallel compiling or linking. |
| 8009 | if ((oldCount == 0 || count == 0) && (oldCount != 0 || count != 0)) |
| 8010 | { |
| 8011 | mThreadPool = angle::WorkerThreadPool::Create(count > 0); |
| 8012 | } |
| 8013 | mThreadPool->setMaxThreads(count); |
jchen10 | 82af620 | 2018-06-22 10:59:52 +0800 | [diff] [blame] | 8014 | } |
| 8015 | |
Jamie Madill | 2eb6503 | 2018-07-30 10:25:57 -0400 | [diff] [blame] | 8016 | bool Context::isGLES1() const |
| 8017 | { |
| 8018 | return mState.getClientVersion() < Version(2, 0); |
| 8019 | } |
| 8020 | |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8021 | void Context::onSubjectStateChange(const Context *context, |
| 8022 | angle::SubjectIndex index, |
| 8023 | angle::SubjectMessage message) |
| 8024 | { |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8025 | switch (index) |
| 8026 | { |
| 8027 | case kVertexArraySubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8028 | switch (message) |
| 8029 | { |
| 8030 | case angle::SubjectMessage::CONTENTS_CHANGED: |
| 8031 | mGLState.setObjectDirty(GL_VERTEX_ARRAY); |
| 8032 | mStateCache.onVertexArrayBufferContentsChange(this); |
| 8033 | break; |
| 8034 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 8035 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 8036 | case angle::SubjectMessage::BINDING_CHANGED: |
| 8037 | mStateCache.onVertexArrayBufferStateChange(this); |
| 8038 | break; |
| 8039 | default: |
| 8040 | break; |
| 8041 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8042 | break; |
| 8043 | |
| 8044 | case kReadFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8045 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8046 | { |
| 8047 | mGLState.setObjectDirty(GL_READ_FRAMEBUFFER); |
| 8048 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8049 | break; |
| 8050 | |
| 8051 | case kDrawFramebufferSubjectIndex: |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8052 | if (message == angle::SubjectMessage::STORAGE_CHANGED) |
| 8053 | { |
Jamie Madill | ef9fcd9 | 2018-11-28 14:03:59 -0500 | [diff] [blame] | 8054 | mGLState.setDrawFramebufferDirty(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8055 | } |
| 8056 | mStateCache.onDrawFramebufferChange(this); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8057 | break; |
| 8058 | |
| 8059 | default: |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8060 | if (index < kTextureMaxSubjectIndex) |
| 8061 | { |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 8062 | mGLState.onActiveTextureStateChange(this, index); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8063 | mStateCache.onActiveTextureChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8064 | } |
Jamie Madill | e3e680c | 2018-12-03 17:49:08 -0500 | [diff] [blame] | 8065 | else if (index < kImageMaxSubjectIndex) |
| 8066 | { |
| 8067 | mGLState.onImageStateChange(this, index - kImage0SubjectIndex); |
| 8068 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8069 | else if (index < kUniformBufferMaxSubjectIndex) |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8070 | { |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8071 | mGLState.onUniformBufferStateChange(index - kUniformBuffer0SubjectIndex); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8072 | mStateCache.onUniformBufferStateChange(this); |
Jamie Madill | 6d32cef | 2018-08-14 02:34:28 -0400 | [diff] [blame] | 8073 | } |
Jamie Madill | e25b800 | 2018-09-20 13:39:49 -0400 | [diff] [blame] | 8074 | else |
| 8075 | { |
| 8076 | ASSERT(index < kSamplerMaxSubjectIndex); |
| 8077 | mGLState.setSamplerDirty(index - kSampler0SubjectIndex); |
| 8078 | } |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 8079 | break; |
| 8080 | } |
| 8081 | } |
| 8082 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8083 | // ErrorSet implementation. |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8084 | ErrorSet::ErrorSet(Context *context) : mContext(context) {} |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8085 | |
| 8086 | ErrorSet::~ErrorSet() = default; |
| 8087 | |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8088 | void ErrorSet::handleError(GLenum errorCode, |
| 8089 | const char *message, |
| 8090 | const char *file, |
| 8091 | const char *function, |
| 8092 | unsigned int line) |
| 8093 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8094 | if (errorCode == GL_OUT_OF_MEMORY && mContext->getWorkarounds().loseContextOnOutOfMemory) |
| 8095 | { |
| 8096 | mContext->markContextLost(); |
| 8097 | } |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8098 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8099 | std::stringstream errorStream; |
| 8100 | errorStream << "Error: " << gl::FmtHex(errorCode) << ", in " << file << ", " << function << ":" |
| 8101 | << line << ". " << message; |
| 8102 | |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8103 | std::string formattedMessage = errorStream.str(); |
| 8104 | |
| 8105 | // Always log a warning, this function is only called on unexpected internal errors. |
| 8106 | WARN() << formattedMessage; |
| 8107 | |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8108 | // validationError does the necessary work to process the error. |
Geoff Lang | 7139b43 | 2018-12-14 16:57:28 -0500 | [diff] [blame] | 8109 | validationError(errorCode, formattedMessage.c_str()); |
Jamie Madill | abfbc0f | 2018-10-09 12:48:52 -0400 | [diff] [blame] | 8110 | } |
| 8111 | |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8112 | void ErrorSet::validationError(GLenum errorCode, const char *message) |
| 8113 | { |
Jamie Madill | 4f6592f | 2018-11-27 16:37:45 -0500 | [diff] [blame] | 8114 | ASSERT(errorCode != GL_NO_ERROR); |
| 8115 | mErrors.insert(errorCode); |
| 8116 | |
| 8117 | mContext->getGLState().getDebug().insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, |
| 8118 | errorCode, GL_DEBUG_SEVERITY_HIGH, message); |
Jamie Madill | a139f01 | 2018-10-10 16:13:03 -0400 | [diff] [blame] | 8119 | } |
| 8120 | |
Jamie Madill | 6b873dd | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 8121 | bool ErrorSet::empty() const |
| 8122 | { |
| 8123 | return mErrors.empty(); |
| 8124 | } |
| 8125 | |
| 8126 | GLenum ErrorSet::popError() |
| 8127 | { |
| 8128 | ASSERT(!empty()); |
| 8129 | GLenum error = *mErrors.begin(); |
| 8130 | mErrors.erase(mErrors.begin()); |
| 8131 | return error; |
| 8132 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8133 | |
| 8134 | // StateCache implementation. |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8135 | StateCache::StateCache() |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8136 | : mCachedHasAnyEnabledClientAttrib(false), |
| 8137 | mCachedNonInstancedVertexElementLimit(0), |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8138 | mCachedInstancedVertexElementLimit(0), |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8139 | mCachedBasicDrawStatesError(kInvalidPointer), |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8140 | mCachedBasicDrawElementsError(kInvalidPointer), |
| 8141 | mCachedTransformFeedbackActiveUnpaused(false) |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 8142 | {} |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8143 | |
| 8144 | StateCache::~StateCache() = default; |
| 8145 | |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8146 | void StateCache::initialize(Context *context) |
| 8147 | { |
| 8148 | updateValidDrawModes(context); |
| 8149 | updateValidBindTextureTypes(context); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8150 | updateValidDrawElementsTypes(context); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8151 | updateBasicDrawStatesError(); |
| 8152 | updateBasicDrawElementsError(); |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8153 | } |
| 8154 | |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8155 | void StateCache::updateActiveAttribsMask(Context *context) |
| 8156 | { |
| 8157 | bool isGLES1 = context->isGLES1(); |
| 8158 | const State &glState = context->getGLState(); |
| 8159 | |
| 8160 | if (!isGLES1 && !glState.getProgram()) |
| 8161 | { |
| 8162 | mCachedActiveBufferedAttribsMask = AttributesMask(); |
| 8163 | mCachedActiveClientAttribsMask = AttributesMask(); |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8164 | mCachedActiveDefaultAttribsMask = AttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8165 | return; |
| 8166 | } |
| 8167 | |
| 8168 | AttributesMask activeAttribs = isGLES1 ? glState.gles1().getVertexArraysAttributeMask() |
| 8169 | : glState.getProgram()->getActiveAttribLocationsMask(); |
| 8170 | |
| 8171 | const VertexArray *vao = glState.getVertexArray(); |
| 8172 | ASSERT(vao); |
| 8173 | |
| 8174 | const AttributesMask &clientAttribs = vao->getClientAttribsMask(); |
| 8175 | const AttributesMask &enabledAttribs = vao->getEnabledAttributesMask(); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8176 | const AttributesMask &activeEnabled = activeAttribs & enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8177 | |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 8178 | mCachedActiveClientAttribsMask = activeEnabled & clientAttribs; |
| 8179 | mCachedActiveBufferedAttribsMask = activeEnabled & ~clientAttribs; |
Jamie Madill | 86792f4 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 8180 | mCachedActiveDefaultAttribsMask = activeAttribs & ~enabledAttribs; |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 8181 | mCachedHasAnyEnabledClientAttrib = (clientAttribs & enabledAttribs).any(); |
| 8182 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 8183 | |
| 8184 | void StateCache::updateVertexElementLimits(Context *context) |
| 8185 | { |
| 8186 | const VertexArray *vao = context->getGLState().getVertexArray(); |
| 8187 | |
| 8188 | mCachedNonInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8189 | mCachedInstancedVertexElementLimit = std::numeric_limits<GLint64>::max(); |
| 8190 | |
| 8191 | // VAO can be null on Context startup. If we make this computation lazier we could ASSERT. |
| 8192 | // If there are no buffered attributes then we should not limit the draw call count. |
| 8193 | if (!vao || !mCachedActiveBufferedAttribsMask.any()) |
| 8194 | { |
| 8195 | return; |
| 8196 | } |
| 8197 | |
| 8198 | const auto &vertexAttribs = vao->getVertexAttributes(); |
| 8199 | const auto &vertexBindings = vao->getVertexBindings(); |
| 8200 | |
| 8201 | for (size_t attributeIndex : mCachedActiveBufferedAttribsMask) |
| 8202 | { |
| 8203 | const VertexAttribute &attrib = vertexAttribs[attributeIndex]; |
| 8204 | ASSERT(attrib.enabled); |
| 8205 | |
| 8206 | const VertexBinding &binding = vertexBindings[attrib.bindingIndex]; |
| 8207 | ASSERT(context->isGLES1() || |
| 8208 | context->getGLState().getProgram()->isAttribLocationActive(attributeIndex)); |
| 8209 | |
| 8210 | GLint64 limit = attrib.getCachedElementLimit(); |
| 8211 | if (binding.getDivisor() > 0) |
| 8212 | { |
| 8213 | mCachedInstancedVertexElementLimit = |
| 8214 | std::min(mCachedInstancedVertexElementLimit, limit); |
| 8215 | } |
| 8216 | else |
| 8217 | { |
| 8218 | mCachedNonInstancedVertexElementLimit = |
| 8219 | std::min(mCachedNonInstancedVertexElementLimit, limit); |
| 8220 | } |
| 8221 | } |
| 8222 | } |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8223 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8224 | void StateCache::updateBasicDrawStatesError() |
| 8225 | { |
| 8226 | mCachedBasicDrawStatesError = kInvalidPointer; |
| 8227 | } |
| 8228 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8229 | void StateCache::updateBasicDrawElementsError() |
| 8230 | { |
| 8231 | mCachedBasicDrawElementsError = kInvalidPointer; |
| 8232 | } |
| 8233 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8234 | intptr_t StateCache::getBasicDrawStatesErrorImpl(Context *context) const |
| 8235 | { |
| 8236 | ASSERT(mCachedBasicDrawStatesError == kInvalidPointer); |
| 8237 | mCachedBasicDrawStatesError = reinterpret_cast<intptr_t>(ValidateDrawStates(context)); |
| 8238 | return mCachedBasicDrawStatesError; |
| 8239 | } |
| 8240 | |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8241 | intptr_t StateCache::getBasicDrawElementsErrorImpl(Context *context) const |
| 8242 | { |
| 8243 | ASSERT(mCachedBasicDrawElementsError == kInvalidPointer); |
| 8244 | mCachedBasicDrawElementsError = reinterpret_cast<intptr_t>(ValidateDrawElementsStates(context)); |
| 8245 | return mCachedBasicDrawElementsError; |
| 8246 | } |
| 8247 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8248 | void StateCache::onVertexArrayBindingChange(Context *context) |
| 8249 | { |
| 8250 | updateActiveAttribsMask(context); |
| 8251 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8252 | updateBasicDrawStatesError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8253 | } |
| 8254 | |
| 8255 | void StateCache::onProgramExecutableChange(Context *context) |
| 8256 | { |
| 8257 | updateActiveAttribsMask(context); |
| 8258 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8259 | updateBasicDrawStatesError(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8260 | updateValidDrawModes(context); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8261 | } |
| 8262 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8263 | void StateCache::onVertexArrayFormatChange(Context *context) |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8264 | { |
| 8265 | updateVertexElementLimits(context); |
| 8266 | } |
| 8267 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8268 | void StateCache::onVertexArrayBufferContentsChange(Context *context) |
| 8269 | { |
| 8270 | updateVertexElementLimits(context); |
| 8271 | updateBasicDrawStatesError(); |
| 8272 | } |
| 8273 | |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8274 | void StateCache::onVertexArrayStateChange(Context *context) |
| 8275 | { |
| 8276 | updateActiveAttribsMask(context); |
| 8277 | updateVertexElementLimits(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8278 | updateBasicDrawStatesError(); |
| 8279 | } |
| 8280 | |
| 8281 | void StateCache::onVertexArrayBufferStateChange(Context *context) |
| 8282 | { |
| 8283 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8284 | updateBasicDrawElementsError(); |
Jamie Madill | c43cdad | 2018-08-08 15:49:25 -0400 | [diff] [blame] | 8285 | } |
| 8286 | |
| 8287 | void StateCache::onGLES1ClientStateChange(Context *context) |
| 8288 | { |
| 8289 | updateActiveAttribsMask(context); |
| 8290 | } |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8291 | |
| 8292 | void StateCache::onDrawFramebufferChange(Context *context) |
| 8293 | { |
| 8294 | updateBasicDrawStatesError(); |
| 8295 | } |
| 8296 | |
| 8297 | void StateCache::onContextCapChange(Context *context) |
| 8298 | { |
| 8299 | updateBasicDrawStatesError(); |
| 8300 | } |
| 8301 | |
| 8302 | void StateCache::onStencilStateChange(Context *context) |
| 8303 | { |
| 8304 | updateBasicDrawStatesError(); |
| 8305 | } |
| 8306 | |
| 8307 | void StateCache::onDefaultVertexAttributeChange(Context *context) |
| 8308 | { |
| 8309 | updateBasicDrawStatesError(); |
| 8310 | } |
| 8311 | |
| 8312 | void StateCache::onActiveTextureChange(Context *context) |
| 8313 | { |
| 8314 | updateBasicDrawStatesError(); |
| 8315 | } |
| 8316 | |
| 8317 | void StateCache::onQueryChange(Context *context) |
| 8318 | { |
| 8319 | updateBasicDrawStatesError(); |
| 8320 | } |
| 8321 | |
Jamie Madill | 3a25622 | 2018-12-08 09:56:39 -0500 | [diff] [blame] | 8322 | void StateCache::onActiveTransformFeedbackChange(Context *context) |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8323 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8324 | updateTransformFeedbackActiveUnpaused(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8325 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8326 | updateBasicDrawElementsError(); |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8327 | updateValidDrawModes(context); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8328 | } |
| 8329 | |
| 8330 | void StateCache::onUniformBufferStateChange(Context *context) |
| 8331 | { |
| 8332 | updateBasicDrawStatesError(); |
| 8333 | } |
| 8334 | |
| 8335 | void StateCache::onBufferBindingChange(Context *context) |
| 8336 | { |
| 8337 | updateBasicDrawStatesError(); |
Jamie Madill | 1e85326 | 2018-12-21 09:07:38 -0500 | [diff] [blame] | 8338 | updateBasicDrawElementsError(); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 8339 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8340 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8341 | void StateCache::setValidDrawModes(bool pointsOK, |
| 8342 | bool linesOK, |
| 8343 | bool trisOK, |
| 8344 | bool lineAdjOK, |
| 8345 | bool triAdjOK) |
| 8346 | { |
| 8347 | mCachedValidDrawModes[PrimitiveMode::Points] = pointsOK; |
| 8348 | mCachedValidDrawModes[PrimitiveMode::Lines] = linesOK; |
| 8349 | mCachedValidDrawModes[PrimitiveMode::LineStrip] = linesOK; |
| 8350 | mCachedValidDrawModes[PrimitiveMode::LineLoop] = linesOK; |
| 8351 | mCachedValidDrawModes[PrimitiveMode::Triangles] = trisOK; |
| 8352 | mCachedValidDrawModes[PrimitiveMode::TriangleFan] = trisOK; |
| 8353 | mCachedValidDrawModes[PrimitiveMode::TriangleStrip] = trisOK; |
| 8354 | mCachedValidDrawModes[PrimitiveMode::LinesAdjacency] = lineAdjOK; |
| 8355 | mCachedValidDrawModes[PrimitiveMode::LineStripAdjacency] = lineAdjOK; |
| 8356 | mCachedValidDrawModes[PrimitiveMode::TrianglesAdjacency] = triAdjOK; |
| 8357 | mCachedValidDrawModes[PrimitiveMode::TriangleStripAdjacency] = triAdjOK; |
| 8358 | } |
| 8359 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8360 | void StateCache::updateValidDrawModes(Context *context) |
| 8361 | { |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8362 | const State &state = context->getGLState(); |
| 8363 | Program *program = state.getProgram(); |
| 8364 | |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8365 | if (mCachedTransformFeedbackActiveUnpaused) |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8366 | { |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8367 | TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); |
| 8368 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8369 | // ES Spec 3.0 validation text: |
| 8370 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8371 | // match the value of primitiveMode passed to BeginTransformFeedback. The error |
| 8372 | // INVALID_OPERATION is generated by DrawArrays and DrawArraysInstanced if mode is not |
| 8373 | // identical to primitiveMode. The error INVALID_OPERATION is also generated by |
| 8374 | // DrawElements, DrawElementsInstanced, and DrawRangeElements while transform feedback is |
| 8375 | // active and not paused, regardless of mode. Any primitive type may be used while transform |
| 8376 | // feedback is paused. |
| 8377 | if (!context->getExtensions().geometryShader) |
| 8378 | { |
| 8379 | mCachedValidDrawModes.fill(false); |
| 8380 | mCachedValidDrawModes[curTransformFeedback->getPrimitiveMode()] = true; |
| 8381 | return; |
| 8382 | } |
| 8383 | |
| 8384 | // EXT_geometry_shader validation text: |
| 8385 | // When transform feedback is active and not paused, all geometric primitives generated must |
| 8386 | // be compatible with the value of <primitiveMode> passed to BeginTransformFeedback. If a |
| 8387 | // geometry shader is active, the type of primitive emitted by that shader is used instead |
| 8388 | // of the <mode> parameter passed to drawing commands for the purposes of this error check. |
| 8389 | // Any primitive type may be used while transform feedback is paused. |
| 8390 | bool pointsOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Points; |
| 8391 | bool linesOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Lines; |
| 8392 | bool trisOK = curTransformFeedback->getPrimitiveMode() == PrimitiveMode::Triangles; |
| 8393 | |
| 8394 | setValidDrawModes(pointsOK, linesOK, trisOK, false, false); |
| 8395 | return; |
| 8396 | } |
| 8397 | |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8398 | if (!program || !program->hasLinkedShaderStage(ShaderType::Geometry)) |
| 8399 | { |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8400 | mCachedValidDrawModes = kValidBasicDrawModes; |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8401 | return; |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8402 | } |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8403 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8404 | ASSERT(program && program->hasLinkedShaderStage(ShaderType::Geometry)); |
| 8405 | PrimitiveMode gsMode = program->getGeometryShaderInputPrimitiveType(); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8406 | |
Jamie Madill | 9b02506 | 2018-12-12 15:44:12 -0500 | [diff] [blame] | 8407 | bool pointsOK = gsMode == PrimitiveMode::Points; |
| 8408 | bool linesOK = gsMode == PrimitiveMode::Lines; |
| 8409 | bool trisOK = gsMode == PrimitiveMode::Triangles; |
| 8410 | bool lineAdjOK = gsMode == PrimitiveMode::LinesAdjacency; |
| 8411 | bool triAdjOK = gsMode == PrimitiveMode::TrianglesAdjacency; |
| 8412 | |
| 8413 | setValidDrawModes(pointsOK, linesOK, trisOK, lineAdjOK, triAdjOK); |
Jamie Madill | 526a6f6 | 2018-09-12 11:03:05 -0400 | [diff] [blame] | 8414 | } |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8415 | |
| 8416 | void StateCache::updateValidBindTextureTypes(Context *context) |
| 8417 | { |
| 8418 | const Extensions &exts = context->getExtensions(); |
| 8419 | bool isGLES3 = context->getClientMajorVersion() >= 3; |
| 8420 | bool isGLES31 = context->getClientVersion() >= Version(3, 1); |
| 8421 | |
| 8422 | mCachedValidBindTextureTypes = {{ |
Jamie Madill | 752d220 | 2018-11-27 13:29:48 -0500 | [diff] [blame] | 8423 | {TextureType::_2D, true}, |
| 8424 | {TextureType::_2DArray, isGLES3}, |
| 8425 | {TextureType::_2DMultisample, isGLES31 || exts.textureMultisample}, |
| 8426 | {TextureType::_2DMultisampleArray, exts.textureStorageMultisample2DArray}, |
| 8427 | {TextureType::_3D, isGLES3}, |
| 8428 | {TextureType::External, exts.eglImageExternal || exts.eglStreamConsumerExternal}, |
| 8429 | {TextureType::Rectangle, exts.textureRectangle}, |
| 8430 | {TextureType::CubeMap, true}, |
Jamie Madill | ac66f98 | 2018-10-09 18:30:01 -0400 | [diff] [blame] | 8431 | }}; |
| 8432 | } |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 8433 | |
| 8434 | void StateCache::updateValidDrawElementsTypes(Context *context) |
| 8435 | { |
| 8436 | bool supportsUint = |
| 8437 | (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint); |
| 8438 | |
| 8439 | mCachedValidDrawElementsTypes = {{ |
| 8440 | {DrawElementsType::UnsignedByte, true}, |
| 8441 | {DrawElementsType::UnsignedShort, true}, |
| 8442 | {DrawElementsType::UnsignedInt, supportsUint}, |
| 8443 | }}; |
| 8444 | } |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8445 | |
| 8446 | void StateCache::updateTransformFeedbackActiveUnpaused(Context *context) |
| 8447 | { |
Markus Tavenrath | cb9609f | 2018-12-26 00:52:44 +0900 | [diff] [blame^] | 8448 | TransformFeedback *xfb = context->getGLState().getCurrentTransformFeedback(); |
Jamie Madill | ae6ba9f | 2018-12-21 23:00:04 -0500 | [diff] [blame] | 8449 | mCachedTransformFeedbackActiveUnpaused = xfb && xfb->isActive() && !xfb->isPaused(); |
| 8450 | } |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 8451 | } // namespace gl |