Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
| 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 | // State.cpp: Implements the State class, encapsulating raw GL state. |
| 8 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 9 | #include "libANGLE/State.h" |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 10 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 11 | #include <limits> |
| 12 | #include <string.h> |
| 13 | |
Jamie Madill | 20e005b | 2017-04-07 14:19:22 -0400 | [diff] [blame] | 14 | #include "common/bitset_utils.h" |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 15 | #include "common/mathutil.h" |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 16 | #include "common/matrix_utils.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 17 | #include "libANGLE/Caps.h" |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 18 | #include "libANGLE/Context.h" |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 19 | #include "libANGLE/Debug.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 20 | #include "libANGLE/Framebuffer.h" |
| 21 | #include "libANGLE/FramebufferAttachment.h" |
| 22 | #include "libANGLE/Query.h" |
| 23 | #include "libANGLE/VertexArray.h" |
| 24 | #include "libANGLE/formatutils.h" |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 25 | #include "libANGLE/queryconversions.h" |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 26 | |
Olli Etuaho | bbf1c10 | 2016-06-28 13:31:33 +0300 | [diff] [blame] | 27 | namespace |
| 28 | { |
| 29 | |
| 30 | GLenum ActiveQueryType(const GLenum type) |
| 31 | { |
| 32 | return (type == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) ? GL_ANY_SAMPLES_PASSED : type; |
| 33 | } |
| 34 | |
| 35 | } // anonymous namepace |
| 36 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 37 | namespace gl |
| 38 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 39 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 40 | State::State() |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 41 | : mMaxDrawBuffers(0), |
| 42 | mMaxCombinedTextureImageUnits(0), |
| 43 | mDepthClearValue(0), |
| 44 | mStencilClearValue(0), |
| 45 | mScissorTest(false), |
| 46 | mSampleCoverage(false), |
| 47 | mSampleCoverageValue(0), |
| 48 | mSampleCoverageInvert(false), |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 49 | mSampleMask(false), |
| 50 | mMaxSampleMaskWords(0), |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 51 | mStencilRef(0), |
| 52 | mStencilBackRef(0), |
| 53 | mLineWidth(0), |
| 54 | mGenerateMipmapHint(GL_NONE), |
| 55 | mFragmentShaderDerivativeHint(GL_NONE), |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 56 | mBindGeneratesResource(true), |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 57 | mClientArraysEnabled(true), |
Jamie Madill | e79b1e1 | 2015-11-04 16:36:37 -0500 | [diff] [blame] | 58 | mNearZ(0), |
| 59 | mFarZ(0), |
| 60 | mReadFramebuffer(nullptr), |
| 61 | mDrawFramebuffer(nullptr), |
| 62 | mProgram(nullptr), |
| 63 | mVertexArray(nullptr), |
| 64 | mActiveSampler(0), |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 65 | mPrimitiveRestart(false), |
| 66 | mMultiSampling(false), |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 67 | mSampleAlphaToOne(false), |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 68 | mFramebufferSRGB(true), |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 69 | mRobustResourceInit(false), |
| 70 | mProgramBinaryCacheEnabled(false) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 71 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | State::~State() |
| 75 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 76 | } |
| 77 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 78 | void State::initialize(const Context *context, |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 79 | bool debug, |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 80 | bool bindGeneratesResource, |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 81 | bool clientArraysEnabled, |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 82 | bool robustResourceInit, |
| 83 | bool programBinaryCacheEnabled) |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 84 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 85 | const Caps &caps = context->getCaps(); |
| 86 | const Extensions &extensions = context->getExtensions(); |
| 87 | const Version &clientVersion = context->getClientVersion(); |
| 88 | |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 89 | mMaxDrawBuffers = caps.maxDrawBuffers; |
| 90 | mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 91 | |
Jamie Madill | f75ab35 | 2015-03-16 10:46:52 -0400 | [diff] [blame] | 92 | setColorClearValue(0.0f, 0.0f, 0.0f, 0.0f); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 93 | |
| 94 | mDepthClearValue = 1.0f; |
| 95 | mStencilClearValue = 0; |
| 96 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 97 | mScissorTest = false; |
| 98 | mScissor.x = 0; |
| 99 | mScissor.y = 0; |
| 100 | mScissor.width = 0; |
| 101 | mScissor.height = 0; |
| 102 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 103 | mBlendColor.red = 0; |
| 104 | mBlendColor.green = 0; |
| 105 | mBlendColor.blue = 0; |
| 106 | mBlendColor.alpha = 0; |
| 107 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 108 | mStencilRef = 0; |
| 109 | mStencilBackRef = 0; |
| 110 | |
| 111 | mSampleCoverage = false; |
| 112 | mSampleCoverageValue = 1.0f; |
| 113 | mSampleCoverageInvert = false; |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 114 | |
| 115 | mMaxSampleMaskWords = caps.maxSampleMaskWords; |
| 116 | mSampleMask = false; |
| 117 | mSampleMaskValues.fill(~GLbitfield(0)); |
| 118 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 119 | mGenerateMipmapHint = GL_DONT_CARE; |
| 120 | mFragmentShaderDerivativeHint = GL_DONT_CARE; |
| 121 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 122 | mBindGeneratesResource = bindGeneratesResource; |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 123 | mClientArraysEnabled = clientArraysEnabled; |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 124 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 125 | mLineWidth = 1.0f; |
| 126 | |
| 127 | mViewport.x = 0; |
| 128 | mViewport.y = 0; |
| 129 | mViewport.width = 0; |
| 130 | mViewport.height = 0; |
| 131 | mNearZ = 0.0f; |
| 132 | mFarZ = 1.0f; |
| 133 | |
| 134 | mBlend.colorMaskRed = true; |
| 135 | mBlend.colorMaskGreen = true; |
| 136 | mBlend.colorMaskBlue = true; |
| 137 | mBlend.colorMaskAlpha = true; |
| 138 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 139 | mActiveSampler = 0; |
| 140 | |
Shannon Woods | 23e0500 | 2014-09-22 19:07:27 -0400 | [diff] [blame] | 141 | mVertexAttribCurrentValues.resize(caps.maxVertexAttributes); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 142 | |
Geoff Lang | 4dc3af0 | 2016-11-18 14:09:27 -0500 | [diff] [blame] | 143 | mUniformBuffers.resize(caps.maxUniformBufferBindings); |
Shannon Woods | f3acaf9 | 2014-09-23 18:07:11 -0400 | [diff] [blame] | 144 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 145 | mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits); |
| 146 | mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits); |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 147 | if (clientVersion >= Version(3, 0)) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 148 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 149 | // TODO: These could also be enabled via extension |
| 150 | mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits); |
| 151 | mSamplerTextures[GL_TEXTURE_3D].resize(caps.maxCombinedTextureImageUnits); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 152 | } |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 153 | if (clientVersion >= Version(3, 1)) |
| 154 | { |
| 155 | mSamplerTextures[GL_TEXTURE_2D_MULTISAMPLE].resize(caps.maxCombinedTextureImageUnits); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 156 | |
| 157 | mAtomicCounterBuffers.resize(caps.maxAtomicCounterBufferBindings); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 158 | mShaderStorageBuffers.resize(caps.maxShaderStorageBufferBindings); |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 159 | mImageUnits.resize(caps.maxImageUnits); |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 160 | } |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 161 | if (extensions.textureRectangle) |
| 162 | { |
| 163 | mSamplerTextures[GL_TEXTURE_RECTANGLE_ANGLE].resize(caps.maxCombinedTextureImageUnits); |
| 164 | } |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 165 | if (extensions.eglImageExternal || extensions.eglStreamConsumerExternal) |
| 166 | { |
| 167 | mSamplerTextures[GL_TEXTURE_EXTERNAL_OES].resize(caps.maxCombinedTextureImageUnits); |
| 168 | } |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 169 | mCompleteTextureCache.resize(caps.maxCombinedTextureImageUnits, nullptr); |
| 170 | mCompleteTextureBindings.reserve(caps.maxCombinedTextureImageUnits); |
| 171 | for (uint32_t textureIndex = 0; textureIndex < caps.maxCombinedTextureImageUnits; |
| 172 | ++textureIndex) |
| 173 | { |
| 174 | mCompleteTextureBindings.emplace_back(OnAttachmentDirtyBinding(this, textureIndex)); |
| 175 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 176 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 177 | mSamplers.resize(caps.maxCombinedTextureImageUnits); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 178 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 179 | mActiveQueries[GL_ANY_SAMPLES_PASSED].set(context, nullptr); |
| 180 | mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(context, nullptr); |
| 181 | mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(context, nullptr); |
| 182 | mActiveQueries[GL_TIME_ELAPSED_EXT].set(context, nullptr); |
| 183 | mActiveQueries[GL_COMMANDS_COMPLETED_CHROMIUM].set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 184 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 185 | mProgram = nullptr; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 186 | |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 187 | mReadFramebuffer = nullptr; |
| 188 | mDrawFramebuffer = nullptr; |
Jamie Madill | b4b53c5 | 2015-02-03 15:22:48 -0500 | [diff] [blame] | 189 | |
| 190 | mPrimitiveRestart = false; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 191 | |
| 192 | mDebug.setOutputEnabled(debug); |
| 193 | mDebug.setMaxLoggedMessages(extensions.maxDebugLoggedMessages); |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 194 | |
Geoff Lang | 488130e | 2017-09-27 13:53:11 -0400 | [diff] [blame] | 195 | mMultiSampling = true; |
| 196 | mSampleAlphaToOne = false; |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 197 | |
| 198 | mCoverageModulation = GL_NONE; |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 199 | |
| 200 | angle::Matrix<GLfloat>::setToIdentity(mPathMatrixProj); |
| 201 | angle::Matrix<GLfloat>::setToIdentity(mPathMatrixMV); |
| 202 | mPathStencilFunc = GL_ALWAYS; |
| 203 | mPathStencilRef = 0; |
| 204 | mPathStencilMask = std::numeric_limits<GLuint>::max(); |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 205 | |
| 206 | mRobustResourceInit = robustResourceInit; |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 207 | mProgramBinaryCacheEnabled = programBinaryCacheEnabled; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 208 | } |
| 209 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 210 | void State::reset(const Context *context) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 211 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 212 | for (auto &bindingVec : mSamplerTextures) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 213 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 214 | TextureBindingVector &textureVector = bindingVec.second; |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 215 | for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 216 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 217 | textureVector[textureIdx].set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 218 | } |
| 219 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 220 | for (size_t samplerIdx = 0; samplerIdx < mSamplers.size(); samplerIdx++) |
| 221 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 222 | mSamplers[samplerIdx].set(context, nullptr); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 223 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 224 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 225 | for (auto &imageUnit : mImageUnits) |
| 226 | { |
| 227 | imageUnit.texture.set(context, nullptr); |
| 228 | imageUnit.level = 0; |
| 229 | imageUnit.layered = false; |
| 230 | imageUnit.layer = 0; |
| 231 | imageUnit.access = GL_READ_ONLY; |
| 232 | imageUnit.format = GL_R32UI; |
| 233 | } |
| 234 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 235 | mArrayBuffer.set(context, nullptr); |
| 236 | mDrawIndirectBuffer.set(context, nullptr); |
| 237 | mRenderbuffer.set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 238 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 239 | if (mProgram) |
| 240 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 241 | mProgram->release(context); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 242 | } |
Yunchao He | d7297bf | 2017-04-19 15:27:10 +0800 | [diff] [blame] | 243 | mProgram = nullptr; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 244 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 245 | mProgramPipeline.set(context, nullptr); |
| 246 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 247 | mTransformFeedback.set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 248 | |
| 249 | for (State::ActiveQueryMap::iterator i = mActiveQueries.begin(); i != mActiveQueries.end(); i++) |
| 250 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 251 | i->second.set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 252 | } |
| 253 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 254 | mGenericUniformBuffer.set(context, nullptr); |
Shannon Woods | 8299bb0 | 2014-09-26 18:55:43 -0400 | [diff] [blame] | 255 | for (BufferVector::iterator bufItr = mUniformBuffers.begin(); bufItr != mUniformBuffers.end(); ++bufItr) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 256 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 257 | bufItr->set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 258 | } |
| 259 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 260 | mCopyReadBuffer.set(context, nullptr); |
| 261 | mCopyWriteBuffer.set(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 262 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 263 | mPack.pixelBuffer.set(context, nullptr); |
| 264 | mUnpack.pixelBuffer.set(context, nullptr); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 265 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 266 | mGenericAtomicCounterBuffer.set(context, nullptr); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 267 | for (auto &buf : mAtomicCounterBuffers) |
| 268 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 269 | buf.set(context, nullptr); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 270 | } |
| 271 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 272 | mGenericShaderStorageBuffer.set(context, nullptr); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 273 | for (auto &buf : mShaderStorageBuffers) |
| 274 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 275 | buf.set(context, nullptr); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 276 | } |
| 277 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 278 | angle::Matrix<GLfloat>::setToIdentity(mPathMatrixProj); |
| 279 | angle::Matrix<GLfloat>::setToIdentity(mPathMatrixMV); |
| 280 | mPathStencilFunc = GL_ALWAYS; |
| 281 | mPathStencilRef = 0; |
| 282 | mPathStencilMask = std::numeric_limits<GLuint>::max(); |
| 283 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 284 | // TODO(jmadill): Is this necessary? |
| 285 | setAllDirtyBits(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | const RasterizerState &State::getRasterizerState() const |
| 289 | { |
| 290 | return mRasterizer; |
| 291 | } |
| 292 | |
| 293 | const BlendState &State::getBlendState() const |
| 294 | { |
| 295 | return mBlend; |
| 296 | } |
| 297 | |
| 298 | const DepthStencilState &State::getDepthStencilState() const |
| 299 | { |
| 300 | return mDepthStencil; |
| 301 | } |
| 302 | |
Jamie Madill | f75ab35 | 2015-03-16 10:46:52 -0400 | [diff] [blame] | 303 | void State::setColorClearValue(float red, float green, float blue, float alpha) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 304 | { |
| 305 | mColorClearValue.red = red; |
| 306 | mColorClearValue.green = green; |
| 307 | mColorClearValue.blue = blue; |
| 308 | mColorClearValue.alpha = alpha; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 309 | mDirtyBits.set(DIRTY_BIT_CLEAR_COLOR); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 310 | } |
| 311 | |
Jamie Madill | f75ab35 | 2015-03-16 10:46:52 -0400 | [diff] [blame] | 312 | void State::setDepthClearValue(float depth) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 313 | { |
| 314 | mDepthClearValue = depth; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 315 | mDirtyBits.set(DIRTY_BIT_CLEAR_DEPTH); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 316 | } |
| 317 | |
Jamie Madill | f75ab35 | 2015-03-16 10:46:52 -0400 | [diff] [blame] | 318 | void State::setStencilClearValue(int stencil) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 319 | { |
| 320 | mStencilClearValue = stencil; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 321 | mDirtyBits.set(DIRTY_BIT_CLEAR_STENCIL); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 322 | } |
| 323 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 324 | void State::setColorMask(bool red, bool green, bool blue, bool alpha) |
| 325 | { |
| 326 | mBlend.colorMaskRed = red; |
| 327 | mBlend.colorMaskGreen = green; |
| 328 | mBlend.colorMaskBlue = blue; |
| 329 | mBlend.colorMaskAlpha = alpha; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 330 | mDirtyBits.set(DIRTY_BIT_COLOR_MASK); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | void State::setDepthMask(bool mask) |
| 334 | { |
| 335 | mDepthStencil.depthMask = mask; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 336 | mDirtyBits.set(DIRTY_BIT_DEPTH_MASK); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | bool State::isRasterizerDiscardEnabled() const |
| 340 | { |
| 341 | return mRasterizer.rasterizerDiscard; |
| 342 | } |
| 343 | |
| 344 | void State::setRasterizerDiscard(bool enabled) |
| 345 | { |
| 346 | mRasterizer.rasterizerDiscard = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 347 | mDirtyBits.set(DIRTY_BIT_RASTERIZER_DISCARD_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | bool State::isCullFaceEnabled() const |
| 351 | { |
| 352 | return mRasterizer.cullFace; |
| 353 | } |
| 354 | |
| 355 | void State::setCullFace(bool enabled) |
| 356 | { |
| 357 | mRasterizer.cullFace = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 358 | mDirtyBits.set(DIRTY_BIT_CULL_FACE_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 359 | } |
| 360 | |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 361 | void State::setCullMode(CullFaceMode mode) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 362 | { |
| 363 | mRasterizer.cullMode = mode; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 364 | mDirtyBits.set(DIRTY_BIT_CULL_FACE); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | void State::setFrontFace(GLenum front) |
| 368 | { |
| 369 | mRasterizer.frontFace = front; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 370 | mDirtyBits.set(DIRTY_BIT_FRONT_FACE); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | bool State::isDepthTestEnabled() const |
| 374 | { |
| 375 | return mDepthStencil.depthTest; |
| 376 | } |
| 377 | |
| 378 | void State::setDepthTest(bool enabled) |
| 379 | { |
| 380 | mDepthStencil.depthTest = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 381 | mDirtyBits.set(DIRTY_BIT_DEPTH_TEST_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | void State::setDepthFunc(GLenum depthFunc) |
| 385 | { |
| 386 | mDepthStencil.depthFunc = depthFunc; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 387 | mDirtyBits.set(DIRTY_BIT_DEPTH_FUNC); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | void State::setDepthRange(float zNear, float zFar) |
| 391 | { |
| 392 | mNearZ = zNear; |
| 393 | mFarZ = zFar; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 394 | mDirtyBits.set(DIRTY_BIT_DEPTH_RANGE); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 395 | } |
| 396 | |
Geoff Lang | d42f5b8 | 2015-04-16 14:03:29 -0400 | [diff] [blame] | 397 | float State::getNearPlane() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 398 | { |
Geoff Lang | d42f5b8 | 2015-04-16 14:03:29 -0400 | [diff] [blame] | 399 | return mNearZ; |
| 400 | } |
| 401 | |
| 402 | float State::getFarPlane() const |
| 403 | { |
| 404 | return mFarZ; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | bool State::isBlendEnabled() const |
| 408 | { |
| 409 | return mBlend.blend; |
| 410 | } |
| 411 | |
| 412 | void State::setBlend(bool enabled) |
| 413 | { |
| 414 | mBlend.blend = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 415 | mDirtyBits.set(DIRTY_BIT_BLEND_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | void State::setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha) |
| 419 | { |
| 420 | mBlend.sourceBlendRGB = sourceRGB; |
| 421 | mBlend.destBlendRGB = destRGB; |
| 422 | mBlend.sourceBlendAlpha = sourceAlpha; |
| 423 | mBlend.destBlendAlpha = destAlpha; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 424 | mDirtyBits.set(DIRTY_BIT_BLEND_FUNCS); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | void State::setBlendColor(float red, float green, float blue, float alpha) |
| 428 | { |
| 429 | mBlendColor.red = red; |
| 430 | mBlendColor.green = green; |
| 431 | mBlendColor.blue = blue; |
| 432 | mBlendColor.alpha = alpha; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 433 | mDirtyBits.set(DIRTY_BIT_BLEND_COLOR); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | void State::setBlendEquation(GLenum rgbEquation, GLenum alphaEquation) |
| 437 | { |
| 438 | mBlend.blendEquationRGB = rgbEquation; |
| 439 | mBlend.blendEquationAlpha = alphaEquation; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 440 | mDirtyBits.set(DIRTY_BIT_BLEND_EQUATIONS); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | const ColorF &State::getBlendColor() const |
| 444 | { |
| 445 | return mBlendColor; |
| 446 | } |
| 447 | |
| 448 | bool State::isStencilTestEnabled() const |
| 449 | { |
| 450 | return mDepthStencil.stencilTest; |
| 451 | } |
| 452 | |
| 453 | void State::setStencilTest(bool enabled) |
| 454 | { |
| 455 | mDepthStencil.stencilTest = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 456 | mDirtyBits.set(DIRTY_BIT_STENCIL_TEST_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | void State::setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask) |
| 460 | { |
| 461 | mDepthStencil.stencilFunc = stencilFunc; |
| 462 | mStencilRef = (stencilRef > 0) ? stencilRef : 0; |
| 463 | mDepthStencil.stencilMask = stencilMask; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 464 | mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_FRONT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | void State::setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask) |
| 468 | { |
| 469 | mDepthStencil.stencilBackFunc = stencilBackFunc; |
| 470 | mStencilBackRef = (stencilBackRef > 0) ? stencilBackRef : 0; |
| 471 | mDepthStencil.stencilBackMask = stencilBackMask; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 472 | mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_BACK); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | void State::setStencilWritemask(GLuint stencilWritemask) |
| 476 | { |
| 477 | mDepthStencil.stencilWritemask = stencilWritemask; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 478 | mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_FRONT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | void State::setStencilBackWritemask(GLuint stencilBackWritemask) |
| 482 | { |
| 483 | mDepthStencil.stencilBackWritemask = stencilBackWritemask; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 484 | mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_BACK); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | void State::setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass) |
| 488 | { |
| 489 | mDepthStencil.stencilFail = stencilFail; |
| 490 | mDepthStencil.stencilPassDepthFail = stencilPassDepthFail; |
| 491 | mDepthStencil.stencilPassDepthPass = stencilPassDepthPass; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 492 | mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_FRONT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | void State::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass) |
| 496 | { |
| 497 | mDepthStencil.stencilBackFail = stencilBackFail; |
| 498 | mDepthStencil.stencilBackPassDepthFail = stencilBackPassDepthFail; |
| 499 | mDepthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 500 | mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_BACK); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | GLint State::getStencilRef() const |
| 504 | { |
| 505 | return mStencilRef; |
| 506 | } |
| 507 | |
| 508 | GLint State::getStencilBackRef() const |
| 509 | { |
| 510 | return mStencilBackRef; |
| 511 | } |
| 512 | |
| 513 | bool State::isPolygonOffsetFillEnabled() const |
| 514 | { |
| 515 | return mRasterizer.polygonOffsetFill; |
| 516 | } |
| 517 | |
| 518 | void State::setPolygonOffsetFill(bool enabled) |
| 519 | { |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 520 | mRasterizer.polygonOffsetFill = enabled; |
| 521 | mDirtyBits.set(DIRTY_BIT_POLYGON_OFFSET_FILL_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | void State::setPolygonOffsetParams(GLfloat factor, GLfloat units) |
| 525 | { |
| 526 | // An application can pass NaN values here, so handle this gracefully |
| 527 | mRasterizer.polygonOffsetFactor = factor != factor ? 0.0f : factor; |
| 528 | mRasterizer.polygonOffsetUnits = units != units ? 0.0f : units; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 529 | mDirtyBits.set(DIRTY_BIT_POLYGON_OFFSET); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | bool State::isSampleAlphaToCoverageEnabled() const |
| 533 | { |
| 534 | return mBlend.sampleAlphaToCoverage; |
| 535 | } |
| 536 | |
| 537 | void State::setSampleAlphaToCoverage(bool enabled) |
| 538 | { |
| 539 | mBlend.sampleAlphaToCoverage = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 540 | mDirtyBits.set(DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | bool State::isSampleCoverageEnabled() const |
| 544 | { |
| 545 | return mSampleCoverage; |
| 546 | } |
| 547 | |
| 548 | void State::setSampleCoverage(bool enabled) |
| 549 | { |
| 550 | mSampleCoverage = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 551 | mDirtyBits.set(DIRTY_BIT_SAMPLE_COVERAGE_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | void State::setSampleCoverageParams(GLclampf value, bool invert) |
| 555 | { |
| 556 | mSampleCoverageValue = value; |
| 557 | mSampleCoverageInvert = invert; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 558 | mDirtyBits.set(DIRTY_BIT_SAMPLE_COVERAGE); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 559 | } |
| 560 | |
Geoff Lang | 0fbb600 | 2015-04-16 11:11:53 -0400 | [diff] [blame] | 561 | GLclampf State::getSampleCoverageValue() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 562 | { |
Geoff Lang | 0fbb600 | 2015-04-16 11:11:53 -0400 | [diff] [blame] | 563 | return mSampleCoverageValue; |
| 564 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 565 | |
Geoff Lang | 0fbb600 | 2015-04-16 11:11:53 -0400 | [diff] [blame] | 566 | bool State::getSampleCoverageInvert() const |
| 567 | { |
| 568 | return mSampleCoverageInvert; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 569 | } |
| 570 | |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 571 | bool State::isSampleMaskEnabled() const |
| 572 | { |
| 573 | return mSampleMask; |
| 574 | } |
| 575 | |
| 576 | void State::setSampleMaskEnabled(bool enabled) |
| 577 | { |
| 578 | mSampleMask = enabled; |
| 579 | mDirtyBits.set(DIRTY_BIT_SAMPLE_MASK_ENABLED); |
| 580 | } |
| 581 | |
| 582 | void State::setSampleMaskParams(GLuint maskNumber, GLbitfield mask) |
| 583 | { |
| 584 | ASSERT(maskNumber < mMaxSampleMaskWords); |
| 585 | mSampleMaskValues[maskNumber] = mask; |
| 586 | mDirtyBits.set(DIRTY_BIT_SAMPLE_MASK_WORD_0 + maskNumber); |
| 587 | } |
| 588 | |
| 589 | GLbitfield State::getSampleMaskWord(GLuint maskNumber) const |
| 590 | { |
| 591 | ASSERT(maskNumber < mMaxSampleMaskWords); |
| 592 | return mSampleMaskValues[maskNumber]; |
| 593 | } |
| 594 | |
| 595 | GLuint State::getMaxSampleMaskWords() const |
| 596 | { |
| 597 | return mMaxSampleMaskWords; |
| 598 | } |
| 599 | |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 600 | void State::setSampleAlphaToOne(bool enabled) |
| 601 | { |
| 602 | mSampleAlphaToOne = enabled; |
| 603 | mDirtyBits.set(DIRTY_BIT_SAMPLE_ALPHA_TO_ONE); |
| 604 | } |
| 605 | |
| 606 | bool State::isSampleAlphaToOneEnabled() const |
| 607 | { |
| 608 | return mSampleAlphaToOne; |
| 609 | } |
| 610 | |
| 611 | void State::setMultisampling(bool enabled) |
| 612 | { |
| 613 | mMultiSampling = enabled; |
| 614 | mDirtyBits.set(DIRTY_BIT_MULTISAMPLING); |
| 615 | } |
| 616 | |
| 617 | bool State::isMultisamplingEnabled() const |
| 618 | { |
| 619 | return mMultiSampling; |
| 620 | } |
| 621 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 622 | bool State::isScissorTestEnabled() const |
| 623 | { |
| 624 | return mScissorTest; |
| 625 | } |
| 626 | |
| 627 | void State::setScissorTest(bool enabled) |
| 628 | { |
| 629 | mScissorTest = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 630 | mDirtyBits.set(DIRTY_BIT_SCISSOR_TEST_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | void State::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height) |
| 634 | { |
| 635 | mScissor.x = x; |
| 636 | mScissor.y = y; |
| 637 | mScissor.width = width; |
| 638 | mScissor.height = height; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 639 | mDirtyBits.set(DIRTY_BIT_SCISSOR); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | const Rectangle &State::getScissor() const |
| 643 | { |
| 644 | return mScissor; |
| 645 | } |
| 646 | |
| 647 | bool State::isDitherEnabled() const |
| 648 | { |
| 649 | return mBlend.dither; |
| 650 | } |
| 651 | |
| 652 | void State::setDither(bool enabled) |
| 653 | { |
| 654 | mBlend.dither = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 655 | mDirtyBits.set(DIRTY_BIT_DITHER_ENABLED); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 656 | } |
| 657 | |
Jamie Madill | b4b53c5 | 2015-02-03 15:22:48 -0500 | [diff] [blame] | 658 | bool State::isPrimitiveRestartEnabled() const |
| 659 | { |
| 660 | return mPrimitiveRestart; |
| 661 | } |
| 662 | |
| 663 | void State::setPrimitiveRestart(bool enabled) |
| 664 | { |
| 665 | mPrimitiveRestart = enabled; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 666 | mDirtyBits.set(DIRTY_BIT_PRIMITIVE_RESTART_ENABLED); |
Jamie Madill | b4b53c5 | 2015-02-03 15:22:48 -0500 | [diff] [blame] | 667 | } |
| 668 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 669 | void State::setEnableFeature(GLenum feature, bool enabled) |
| 670 | { |
| 671 | switch (feature) |
| 672 | { |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 673 | case GL_MULTISAMPLE_EXT: setMultisampling(enabled); break; |
| 674 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: setSampleAlphaToOne(enabled); break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 675 | case GL_CULL_FACE: setCullFace(enabled); break; |
| 676 | case GL_POLYGON_OFFSET_FILL: setPolygonOffsetFill(enabled); break; |
| 677 | case GL_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(enabled); break; |
| 678 | case GL_SAMPLE_COVERAGE: setSampleCoverage(enabled); break; |
| 679 | case GL_SCISSOR_TEST: setScissorTest(enabled); break; |
| 680 | case GL_STENCIL_TEST: setStencilTest(enabled); break; |
| 681 | case GL_DEPTH_TEST: setDepthTest(enabled); break; |
| 682 | case GL_BLEND: setBlend(enabled); break; |
| 683 | case GL_DITHER: setDither(enabled); break; |
Jamie Madill | b4b53c5 | 2015-02-03 15:22:48 -0500 | [diff] [blame] | 684 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: setPrimitiveRestart(enabled); break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 685 | case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break; |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 686 | case GL_SAMPLE_MASK: |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 687 | setSampleMaskEnabled(enabled); |
Geoff Lang | 3b57361 | 2016-10-31 14:08:10 -0400 | [diff] [blame] | 688 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 689 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 690 | mDebug.setOutputSynchronous(enabled); |
| 691 | break; |
| 692 | case GL_DEBUG_OUTPUT: |
| 693 | mDebug.setOutputEnabled(enabled); |
| 694 | break; |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 695 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 696 | setFramebufferSRGB(enabled); |
| 697 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 698 | default: UNREACHABLE(); |
| 699 | } |
| 700 | } |
| 701 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 702 | bool State::getEnableFeature(GLenum feature) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 703 | { |
| 704 | switch (feature) |
| 705 | { |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 706 | case GL_MULTISAMPLE_EXT: return isMultisamplingEnabled(); |
| 707 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: return isSampleAlphaToOneEnabled(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 708 | case GL_CULL_FACE: return isCullFaceEnabled(); |
| 709 | case GL_POLYGON_OFFSET_FILL: return isPolygonOffsetFillEnabled(); |
| 710 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return isSampleAlphaToCoverageEnabled(); |
| 711 | case GL_SAMPLE_COVERAGE: return isSampleCoverageEnabled(); |
| 712 | case GL_SCISSOR_TEST: return isScissorTestEnabled(); |
| 713 | case GL_STENCIL_TEST: return isStencilTestEnabled(); |
| 714 | case GL_DEPTH_TEST: return isDepthTestEnabled(); |
| 715 | case GL_BLEND: return isBlendEnabled(); |
| 716 | case GL_DITHER: return isDitherEnabled(); |
Jamie Madill | b4b53c5 | 2015-02-03 15:22:48 -0500 | [diff] [blame] | 717 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: return isPrimitiveRestartEnabled(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 718 | case GL_RASTERIZER_DISCARD: return isRasterizerDiscardEnabled(); |
Geoff Lang | b5e997f | 2016-12-06 10:55:34 -0500 | [diff] [blame] | 719 | case GL_SAMPLE_MASK: |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 720 | return isSampleMaskEnabled(); |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 721 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 722 | return mDebug.isOutputSynchronous(); |
| 723 | case GL_DEBUG_OUTPUT: |
| 724 | return mDebug.isOutputEnabled(); |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 725 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 726 | return isBindGeneratesResourceEnabled(); |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 727 | case GL_CLIENT_ARRAYS_ANGLE: |
| 728 | return areClientArraysEnabled(); |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 729 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 730 | return getFramebufferSRGB(); |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 731 | case GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 732 | return mRobustResourceInit; |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 733 | case GL_PROGRAM_CACHE_ENABLED_ANGLE: |
| 734 | return mProgramBinaryCacheEnabled; |
| 735 | |
| 736 | default: |
| 737 | UNREACHABLE(); |
| 738 | return false; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 739 | } |
| 740 | } |
| 741 | |
| 742 | void State::setLineWidth(GLfloat width) |
| 743 | { |
| 744 | mLineWidth = width; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 745 | mDirtyBits.set(DIRTY_BIT_LINE_WIDTH); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 746 | } |
| 747 | |
Geoff Lang | 4b3f416 | 2015-04-16 13:22:05 -0400 | [diff] [blame] | 748 | float State::getLineWidth() const |
| 749 | { |
| 750 | return mLineWidth; |
| 751 | } |
| 752 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 753 | void State::setGenerateMipmapHint(GLenum hint) |
| 754 | { |
| 755 | mGenerateMipmapHint = hint; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 756 | mDirtyBits.set(DIRTY_BIT_GENERATE_MIPMAP_HINT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | void State::setFragmentShaderDerivativeHint(GLenum hint) |
| 760 | { |
| 761 | mFragmentShaderDerivativeHint = hint; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 762 | mDirtyBits.set(DIRTY_BIT_SHADER_DERIVATIVE_HINT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 763 | // TODO: Propagate the hint to shader translator so we can write |
| 764 | // ddx, ddx_coarse, or ddx_fine depending on the hint. |
| 765 | // Ignore for now. It is valid for implementations to ignore hint. |
| 766 | } |
| 767 | |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 768 | bool State::isBindGeneratesResourceEnabled() const |
| 769 | { |
| 770 | return mBindGeneratesResource; |
| 771 | } |
| 772 | |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 773 | bool State::areClientArraysEnabled() const |
| 774 | { |
| 775 | return mClientArraysEnabled; |
| 776 | } |
| 777 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 778 | void State::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height) |
| 779 | { |
| 780 | mViewport.x = x; |
| 781 | mViewport.y = y; |
| 782 | mViewport.width = width; |
| 783 | mViewport.height = height; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 784 | mDirtyBits.set(DIRTY_BIT_VIEWPORT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | const Rectangle &State::getViewport() const |
| 788 | { |
| 789 | return mViewport; |
| 790 | } |
| 791 | |
| 792 | void State::setActiveSampler(unsigned int active) |
| 793 | { |
| 794 | mActiveSampler = active; |
| 795 | } |
| 796 | |
| 797 | unsigned int State::getActiveSampler() const |
| 798 | { |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 799 | return static_cast<unsigned int>(mActiveSampler); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 800 | } |
| 801 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 802 | void State::setSamplerTexture(const Context *context, GLenum type, Texture *texture) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 803 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 804 | mSamplerTextures[type][mActiveSampler].set(context, texture); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 805 | mDirtyBits.set(DIRTY_BIT_TEXTURE_BINDINGS); |
| 806 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 807 | } |
| 808 | |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 809 | Texture *State::getTargetTexture(GLenum target) const |
| 810 | { |
| 811 | return getSamplerTexture(static_cast<unsigned int>(mActiveSampler), target); |
| 812 | } |
| 813 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 814 | Texture *State::getSamplerTexture(unsigned int sampler, GLenum type) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 815 | { |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 816 | const auto it = mSamplerTextures.find(type); |
| 817 | ASSERT(it != mSamplerTextures.end()); |
Jamie Madill | 3d3d2f2 | 2015-09-23 16:47:51 -0400 | [diff] [blame] | 818 | ASSERT(sampler < it->second.size()); |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 819 | return it->second[sampler].get(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 820 | } |
| 821 | |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 822 | GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 823 | { |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 824 | const auto it = mSamplerTextures.find(type); |
| 825 | ASSERT(it != mSamplerTextures.end()); |
Jamie Madill | 3d3d2f2 | 2015-09-23 16:47:51 -0400 | [diff] [blame] | 826 | ASSERT(sampler < it->second.size()); |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 827 | return it->second[sampler].id(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 828 | } |
| 829 | |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 830 | void State::detachTexture(const Context *context, const TextureMap &zeroTextures, GLuint texture) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 831 | { |
| 832 | // Textures have a detach method on State rather than a simple |
| 833 | // removeBinding, because the zero/null texture objects are managed |
| 834 | // separately, and don't have to go through the Context's maps or |
| 835 | // the ResourceManager. |
| 836 | |
| 837 | // [OpenGL ES 2.0.24] section 3.8 page 84: |
| 838 | // If a texture object is deleted, it is as if all texture units which are bound to that texture object are |
| 839 | // rebound to texture object zero |
| 840 | |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 841 | for (auto &bindingVec : mSamplerTextures) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 842 | { |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 843 | GLenum textureType = bindingVec.first; |
| 844 | TextureBindingVector &textureVector = bindingVec.second; |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 845 | for (BindingPointer<Texture> &binding : textureVector) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 846 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 847 | if (binding.id() == texture) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 848 | { |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 849 | auto it = zeroTextures.find(textureType); |
| 850 | ASSERT(it != zeroTextures.end()); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 851 | // Zero textures are the "default" textures instead of NULL |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 852 | binding.set(context, it->second.get()); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 853 | mDirtyBits.set(DIRTY_BIT_TEXTURE_BINDINGS); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 854 | } |
| 855 | } |
| 856 | } |
| 857 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 858 | for (auto &bindingImageUnit : mImageUnits) |
| 859 | { |
| 860 | if (bindingImageUnit.texture.id() == texture) |
| 861 | { |
| 862 | bindingImageUnit.texture.set(context, nullptr); |
| 863 | bindingImageUnit.level = 0; |
| 864 | bindingImageUnit.layered = false; |
| 865 | bindingImageUnit.layer = 0; |
| 866 | bindingImageUnit.access = GL_READ_ONLY; |
| 867 | bindingImageUnit.format = GL_R32UI; |
| 868 | break; |
| 869 | } |
| 870 | } |
| 871 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 872 | // [OpenGL ES 2.0.24] section 4.4 page 112: |
| 873 | // If a texture object is deleted while its image is attached to the currently bound framebuffer, then it is |
| 874 | // as if Texture2DAttachment had been called, with a texture of 0, for each attachment point to which this |
| 875 | // image was attached in the currently bound framebuffer. |
| 876 | |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 877 | if (mReadFramebuffer && mReadFramebuffer->detachTexture(context, texture)) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 878 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 879 | mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 880 | } |
| 881 | |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 882 | if (mDrawFramebuffer && mDrawFramebuffer->detachTexture(context, texture)) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 883 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 884 | mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 885 | } |
| 886 | } |
| 887 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 888 | void State::initializeZeroTextures(const Context *context, const TextureMap &zeroTextures) |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 889 | { |
| 890 | for (const auto &zeroTexture : zeroTextures) |
| 891 | { |
| 892 | auto &samplerTextureArray = mSamplerTextures[zeroTexture.first]; |
| 893 | |
| 894 | for (size_t textureUnit = 0; textureUnit < samplerTextureArray.size(); ++textureUnit) |
| 895 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 896 | samplerTextureArray[textureUnit].set(context, zeroTexture.second.get()); |
Jamie Madill | e6382c3 | 2014-11-07 15:05:26 -0500 | [diff] [blame] | 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 901 | void State::setSamplerBinding(const Context *context, GLuint textureUnit, Sampler *sampler) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 902 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 903 | mSamplers[textureUnit].set(context, sampler); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 904 | mDirtyBits.set(DIRTY_BIT_SAMPLER_BINDINGS); |
| 905 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | GLuint State::getSamplerId(GLuint textureUnit) const |
| 909 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 910 | ASSERT(textureUnit < mSamplers.size()); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 911 | return mSamplers[textureUnit].id(); |
| 912 | } |
| 913 | |
| 914 | Sampler *State::getSampler(GLuint textureUnit) const |
| 915 | { |
| 916 | return mSamplers[textureUnit].get(); |
| 917 | } |
| 918 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 919 | void State::detachSampler(const Context *context, GLuint sampler) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 920 | { |
| 921 | // [OpenGL ES 3.0.2] section 3.8.2 pages 123-124: |
| 922 | // If a sampler object that is currently bound to one or more texture units is |
| 923 | // deleted, it is as though BindSampler is called once for each texture unit to |
| 924 | // which the sampler is bound, with unit set to the texture unit and sampler set to zero. |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 925 | for (BindingPointer<Sampler> &samplerBinding : mSamplers) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 926 | { |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 927 | if (samplerBinding.id() == sampler) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 928 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 929 | samplerBinding.set(context, nullptr); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 930 | mDirtyBits.set(DIRTY_BIT_SAMPLER_BINDINGS); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 931 | } |
| 932 | } |
| 933 | } |
| 934 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 935 | void State::setRenderbufferBinding(const Context *context, Renderbuffer *renderbuffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 936 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 937 | mRenderbuffer.set(context, renderbuffer); |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 938 | mDirtyBits.set(DIRTY_BIT_RENDERBUFFER_BINDING); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | GLuint State::getRenderbufferId() const |
| 942 | { |
| 943 | return mRenderbuffer.id(); |
| 944 | } |
| 945 | |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 946 | Renderbuffer *State::getCurrentRenderbuffer() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 947 | { |
| 948 | return mRenderbuffer.get(); |
| 949 | } |
| 950 | |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 951 | void State::detachRenderbuffer(const Context *context, GLuint renderbuffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 952 | { |
| 953 | // [OpenGL ES 2.0.24] section 4.4 page 109: |
| 954 | // If a renderbuffer that is currently bound to RENDERBUFFER is deleted, it is as though BindRenderbuffer |
| 955 | // had been executed with the target RENDERBUFFER and name of zero. |
| 956 | |
| 957 | if (mRenderbuffer.id() == renderbuffer) |
| 958 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 959 | setRenderbufferBinding(context, nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | // [OpenGL ES 2.0.24] section 4.4 page 111: |
| 963 | // If a renderbuffer object is deleted while its image is attached to the currently bound framebuffer, |
| 964 | // then it is as if FramebufferRenderbuffer had been called, with a renderbuffer of 0, for each attachment |
| 965 | // point to which this image was attached in the currently bound framebuffer. |
| 966 | |
| 967 | Framebuffer *readFramebuffer = mReadFramebuffer; |
| 968 | Framebuffer *drawFramebuffer = mDrawFramebuffer; |
| 969 | |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 970 | if (readFramebuffer && readFramebuffer->detachRenderbuffer(context, renderbuffer)) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 971 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 972 | mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | if (drawFramebuffer && drawFramebuffer != readFramebuffer) |
| 976 | { |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 977 | if (drawFramebuffer->detachRenderbuffer(context, renderbuffer)) |
| 978 | { |
| 979 | mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 980 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | } |
| 984 | |
| 985 | void State::setReadFramebufferBinding(Framebuffer *framebuffer) |
| 986 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 987 | if (mReadFramebuffer == framebuffer) |
| 988 | return; |
| 989 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 990 | mReadFramebuffer = framebuffer; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 991 | mDirtyBits.set(DIRTY_BIT_READ_FRAMEBUFFER_BINDING); |
| 992 | |
| 993 | if (mReadFramebuffer && mReadFramebuffer->hasAnyDirtyBit()) |
| 994 | { |
| 995 | mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 996 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | void State::setDrawFramebufferBinding(Framebuffer *framebuffer) |
| 1000 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 1001 | if (mDrawFramebuffer == framebuffer) |
| 1002 | return; |
| 1003 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1004 | mDrawFramebuffer = framebuffer; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 1005 | mDirtyBits.set(DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); |
| 1006 | |
| 1007 | if (mDrawFramebuffer && mDrawFramebuffer->hasAnyDirtyBit()) |
| 1008 | { |
| 1009 | mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 1010 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | Framebuffer *State::getTargetFramebuffer(GLenum target) const |
| 1014 | { |
| 1015 | switch (target) |
| 1016 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 1017 | case GL_READ_FRAMEBUFFER_ANGLE: |
| 1018 | return mReadFramebuffer; |
| 1019 | case GL_DRAW_FRAMEBUFFER_ANGLE: |
| 1020 | case GL_FRAMEBUFFER: |
| 1021 | return mDrawFramebuffer; |
| 1022 | default: |
| 1023 | UNREACHABLE(); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1024 | return nullptr; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1025 | } |
| 1026 | } |
| 1027 | |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 1028 | Framebuffer *State::getReadFramebuffer() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1029 | { |
| 1030 | return mReadFramebuffer; |
| 1031 | } |
| 1032 | |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 1033 | Framebuffer *State::getDrawFramebuffer() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1034 | { |
| 1035 | return mDrawFramebuffer; |
| 1036 | } |
| 1037 | |
| 1038 | bool State::removeReadFramebufferBinding(GLuint framebuffer) |
| 1039 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 1040 | if (mReadFramebuffer != nullptr && |
| 1041 | mReadFramebuffer->id() == framebuffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1042 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 1043 | setReadFramebufferBinding(nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1044 | return true; |
| 1045 | } |
| 1046 | |
| 1047 | return false; |
| 1048 | } |
| 1049 | |
| 1050 | bool State::removeDrawFramebufferBinding(GLuint framebuffer) |
| 1051 | { |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 1052 | if (mReadFramebuffer != nullptr && |
| 1053 | mDrawFramebuffer->id() == framebuffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1054 | { |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 1055 | setDrawFramebufferBinding(nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1056 | return true; |
| 1057 | } |
| 1058 | |
| 1059 | return false; |
| 1060 | } |
| 1061 | |
| 1062 | void State::setVertexArrayBinding(VertexArray *vertexArray) |
| 1063 | { |
| 1064 | mVertexArray = vertexArray; |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 1065 | mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_BINDING); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 1066 | |
| 1067 | if (mVertexArray && mVertexArray->hasAnyDirtyBit()) |
| 1068 | { |
| 1069 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1070 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | GLuint State::getVertexArrayId() const |
| 1074 | { |
Yunchao He | 4f28544 | 2017-04-21 12:15:49 +0800 | [diff] [blame] | 1075 | ASSERT(mVertexArray != nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1076 | return mVertexArray->id(); |
| 1077 | } |
| 1078 | |
| 1079 | VertexArray *State::getVertexArray() const |
| 1080 | { |
Yunchao He | 4f28544 | 2017-04-21 12:15:49 +0800 | [diff] [blame] | 1081 | ASSERT(mVertexArray != nullptr); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1082 | return mVertexArray; |
| 1083 | } |
| 1084 | |
| 1085 | bool State::removeVertexArrayBinding(GLuint vertexArray) |
| 1086 | { |
| 1087 | if (mVertexArray->id() == vertexArray) |
| 1088 | { |
Yunchao He | d7297bf | 2017-04-19 15:27:10 +0800 | [diff] [blame] | 1089 | mVertexArray = nullptr; |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 1090 | mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_BINDING); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 1091 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1092 | return true; |
| 1093 | } |
| 1094 | |
| 1095 | return false; |
| 1096 | } |
| 1097 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1098 | void State::setElementArrayBuffer(const Context *context, Buffer *buffer) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1099 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1100 | getVertexArray()->setElementArrayBuffer(context, buffer); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1101 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1102 | } |
| 1103 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1104 | void State::bindVertexBuffer(const Context *context, |
| 1105 | GLuint bindingIndex, |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1106 | Buffer *boundBuffer, |
| 1107 | GLintptr offset, |
| 1108 | GLsizei stride) |
| 1109 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1110 | getVertexArray()->bindVertexBuffer(context, bindingIndex, boundBuffer, offset, stride); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1111 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1112 | } |
| 1113 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1114 | void State::setVertexAttribBinding(const Context *context, GLuint attribIndex, GLuint bindingIndex) |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1115 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1116 | getVertexArray()->setVertexAttribBinding(context, attribIndex, bindingIndex); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 1117 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1118 | } |
| 1119 | |
| 1120 | void State::setVertexAttribFormat(GLuint attribIndex, |
| 1121 | GLint size, |
| 1122 | GLenum type, |
| 1123 | bool normalized, |
| 1124 | bool pureInteger, |
| 1125 | GLuint relativeOffset) |
| 1126 | { |
| 1127 | getVertexArray()->setVertexAttribFormat(attribIndex, size, type, normalized, pureInteger, |
| 1128 | relativeOffset); |
| 1129 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1130 | } |
| 1131 | |
| 1132 | void State::setVertexBindingDivisor(GLuint bindingIndex, GLuint divisor) |
| 1133 | { |
| 1134 | getVertexArray()->setVertexBindingDivisor(bindingIndex, divisor); |
| 1135 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 1136 | } |
| 1137 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 1138 | void State::setProgram(const Context *context, Program *newProgram) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1139 | { |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1140 | if (mProgram != newProgram) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1141 | { |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1142 | if (mProgram) |
| 1143 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 1144 | mProgram->release(context); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1145 | } |
| 1146 | |
| 1147 | mProgram = newProgram; |
| 1148 | |
| 1149 | if (mProgram) |
| 1150 | { |
| 1151 | newProgram->addRef(); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1152 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1153 | } |
Jamie Madill | a779b61 | 2017-07-24 11:46:05 -0400 | [diff] [blame] | 1154 | mDirtyBits.set(DIRTY_BIT_PROGRAM_EXECUTABLE); |
| 1155 | mDirtyBits.set(DIRTY_BIT_PROGRAM_BINDING); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1156 | } |
| 1157 | } |
| 1158 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1159 | Program *State::getProgram() const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1160 | { |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1161 | return mProgram; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1162 | } |
| 1163 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1164 | void State::setTransformFeedbackBinding(const Context *context, |
| 1165 | TransformFeedback *transformFeedback) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1166 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1167 | mTransformFeedback.set(context, transformFeedback); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1168 | } |
| 1169 | |
| 1170 | TransformFeedback *State::getCurrentTransformFeedback() const |
| 1171 | { |
| 1172 | return mTransformFeedback.get(); |
| 1173 | } |
| 1174 | |
Gregoire Payen de La Garanderie | 5274202 | 2015-02-04 14:55:39 +0000 | [diff] [blame] | 1175 | bool State::isTransformFeedbackActiveUnpaused() const |
| 1176 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1177 | TransformFeedback *curTransformFeedback = getCurrentTransformFeedback(); |
Geoff Lang | bb0a0bb | 2015-03-27 12:16:57 -0400 | [diff] [blame] | 1178 | return curTransformFeedback && curTransformFeedback->isActive() && !curTransformFeedback->isPaused(); |
Gregoire Payen de La Garanderie | 5274202 | 2015-02-04 14:55:39 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1181 | bool State::removeTransformFeedbackBinding(const Context *context, GLuint transformFeedback) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1182 | { |
| 1183 | if (mTransformFeedback.id() == transformFeedback) |
| 1184 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1185 | mTransformFeedback.set(context, nullptr); |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 1186 | return true; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1187 | } |
Corentin Wallez | a2257da | 2016-04-19 16:43:12 -0400 | [diff] [blame] | 1188 | |
| 1189 | return false; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1190 | } |
| 1191 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 1192 | void State::setProgramPipelineBinding(const Context *context, ProgramPipeline *pipeline) |
| 1193 | { |
| 1194 | mProgramPipeline.set(context, pipeline); |
| 1195 | } |
| 1196 | |
| 1197 | void State::detachProgramPipeline(const Context *context, GLuint pipeline) |
| 1198 | { |
| 1199 | mProgramPipeline.set(context, nullptr); |
| 1200 | } |
| 1201 | |
Olli Etuaho | bbf1c10 | 2016-06-28 13:31:33 +0300 | [diff] [blame] | 1202 | bool State::isQueryActive(const GLenum type) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1203 | { |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1204 | for (auto &iter : mActiveQueries) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1205 | { |
Olli Etuaho | bbf1c10 | 2016-06-28 13:31:33 +0300 | [diff] [blame] | 1206 | const Query *query = iter.second.get(); |
| 1207 | if (query != nullptr && ActiveQueryType(query->getType()) == ActiveQueryType(type)) |
Ian Ewell | 3ffd78b | 2016-01-22 16:09:42 -0500 | [diff] [blame] | 1208 | { |
| 1209 | return true; |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | return false; |
| 1214 | } |
| 1215 | |
| 1216 | bool State::isQueryActive(Query *query) const |
| 1217 | { |
| 1218 | for (auto &iter : mActiveQueries) |
| 1219 | { |
| 1220 | if (iter.second.get() == query) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1221 | { |
| 1222 | return true; |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | return false; |
| 1227 | } |
| 1228 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1229 | void State::setActiveQuery(const Context *context, GLenum target, Query *query) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1230 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1231 | mActiveQueries[target].set(context, query); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | GLuint State::getActiveQueryId(GLenum target) const |
| 1235 | { |
| 1236 | const Query *query = getActiveQuery(target); |
| 1237 | return (query ? query->id() : 0u); |
| 1238 | } |
| 1239 | |
| 1240 | Query *State::getActiveQuery(GLenum target) const |
| 1241 | { |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 1242 | const auto it = mActiveQueries.find(target); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1243 | |
Jamie Madill | 5864ac2 | 2015-01-12 14:43:07 -0500 | [diff] [blame] | 1244 | // All query types should already exist in the activeQueries map |
| 1245 | ASSERT(it != mActiveQueries.end()); |
| 1246 | |
| 1247 | return it->second.get(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1248 | } |
| 1249 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1250 | void State::setArrayBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1251 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1252 | mArrayBuffer.set(context, buffer); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | GLuint State::getArrayBufferId() const |
| 1256 | { |
| 1257 | return mArrayBuffer.id(); |
| 1258 | } |
| 1259 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1260 | void State::setDrawIndirectBufferBinding(const Context *context, Buffer *buffer) |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1261 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1262 | mDrawIndirectBuffer.set(context, buffer); |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1263 | mDirtyBits.set(DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING); |
| 1264 | } |
| 1265 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1266 | void State::setGenericUniformBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1267 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1268 | mGenericUniformBuffer.set(context, buffer); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1269 | } |
| 1270 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1271 | void State::setIndexedUniformBufferBinding(const Context *context, |
| 1272 | GLuint index, |
| 1273 | Buffer *buffer, |
| 1274 | GLintptr offset, |
| 1275 | GLsizeiptr size) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1276 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1277 | mUniformBuffers[index].set(context, buffer, offset, size); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1278 | } |
| 1279 | |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 1280 | const OffsetBindingPointer<Buffer> &State::getIndexedUniformBuffer(size_t index) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1281 | { |
Shannon Woods | f3acaf9 | 2014-09-23 18:07:11 -0400 | [diff] [blame] | 1282 | ASSERT(static_cast<size_t>(index) < mUniformBuffers.size()); |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 1283 | return mUniformBuffers[index]; |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 1284 | } |
| 1285 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1286 | void State::setGenericAtomicCounterBufferBinding(const Context *context, Buffer *buffer) |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1287 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1288 | mGenericAtomicCounterBuffer.set(context, buffer); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1289 | } |
| 1290 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1291 | void State::setIndexedAtomicCounterBufferBinding(const Context *context, |
| 1292 | GLuint index, |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1293 | Buffer *buffer, |
| 1294 | GLintptr offset, |
| 1295 | GLsizeiptr size) |
| 1296 | { |
| 1297 | ASSERT(static_cast<size_t>(index) < mAtomicCounterBuffers.size()); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1298 | mAtomicCounterBuffers[index].set(context, buffer, offset, size); |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | const OffsetBindingPointer<Buffer> &State::getIndexedAtomicCounterBuffer(size_t index) const |
| 1302 | { |
| 1303 | ASSERT(static_cast<size_t>(index) < mAtomicCounterBuffers.size()); |
| 1304 | return mAtomicCounterBuffers[index]; |
| 1305 | } |
| 1306 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1307 | void State::setGenericShaderStorageBufferBinding(const Context *context, Buffer *buffer) |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1308 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1309 | mGenericShaderStorageBuffer.set(context, buffer); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1310 | } |
| 1311 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1312 | void State::setIndexedShaderStorageBufferBinding(const Context *context, |
| 1313 | GLuint index, |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1314 | Buffer *buffer, |
| 1315 | GLintptr offset, |
| 1316 | GLsizeiptr size) |
| 1317 | { |
| 1318 | ASSERT(static_cast<size_t>(index) < mShaderStorageBuffers.size()); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1319 | mShaderStorageBuffers[index].set(context, buffer, offset, size); |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1320 | } |
| 1321 | |
| 1322 | const OffsetBindingPointer<Buffer> &State::getIndexedShaderStorageBuffer(size_t index) const |
| 1323 | { |
| 1324 | ASSERT(static_cast<size_t>(index) < mShaderStorageBuffers.size()); |
| 1325 | return mShaderStorageBuffers[index]; |
| 1326 | } |
| 1327 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1328 | void State::setCopyReadBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1329 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1330 | mCopyReadBuffer.set(context, buffer); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1331 | } |
| 1332 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1333 | void State::setCopyWriteBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1334 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1335 | mCopyWriteBuffer.set(context, buffer); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1336 | } |
| 1337 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1338 | void State::setPixelPackBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1339 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1340 | mPack.pixelBuffer.set(context, buffer); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 1341 | mDirtyBits.set(DIRTY_BIT_PACK_BUFFER_BINDING); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1342 | } |
| 1343 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1344 | void State::setPixelUnpackBufferBinding(const Context *context, Buffer *buffer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1345 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1346 | mUnpack.pixelBuffer.set(context, buffer); |
Corentin Wallez | bbd663a | 2016-04-20 17:49:17 -0400 | [diff] [blame] | 1347 | mDirtyBits.set(DIRTY_BIT_UNPACK_BUFFER_BINDING); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | Buffer *State::getTargetBuffer(GLenum target) const |
| 1351 | { |
| 1352 | switch (target) |
| 1353 | { |
| 1354 | case GL_ARRAY_BUFFER: return mArrayBuffer.get(); |
| 1355 | case GL_COPY_READ_BUFFER: return mCopyReadBuffer.get(); |
| 1356 | case GL_COPY_WRITE_BUFFER: return mCopyWriteBuffer.get(); |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 1357 | case GL_ELEMENT_ARRAY_BUFFER: return getVertexArray()->getElementArrayBuffer().get(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1358 | case GL_PIXEL_PACK_BUFFER: return mPack.pixelBuffer.get(); |
| 1359 | case GL_PIXEL_UNPACK_BUFFER: return mUnpack.pixelBuffer.get(); |
Geoff Lang | 045536b | 2015-03-27 15:17:18 -0400 | [diff] [blame] | 1360 | case GL_TRANSFORM_FEEDBACK_BUFFER: return mTransformFeedback->getGenericBuffer().get(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1361 | case GL_UNIFORM_BUFFER: return mGenericUniformBuffer.get(); |
Geoff Lang | b5e997f | 2016-12-06 10:55:34 -0500 | [diff] [blame] | 1362 | case GL_ATOMIC_COUNTER_BUFFER: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 1363 | return mGenericAtomicCounterBuffer.get(); |
Geoff Lang | b5e997f | 2016-12-06 10:55:34 -0500 | [diff] [blame] | 1364 | case GL_SHADER_STORAGE_BUFFER: |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1365 | return mGenericShaderStorageBuffer.get(); |
Geoff Lang | b5e997f | 2016-12-06 10:55:34 -0500 | [diff] [blame] | 1366 | case GL_DRAW_INDIRECT_BUFFER: |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1367 | return mDrawIndirectBuffer.get(); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 1368 | default: |
| 1369 | UNREACHABLE(); |
| 1370 | return nullptr; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1371 | } |
| 1372 | } |
| 1373 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1374 | void State::detachBuffer(const Context *context, GLuint bufferName) |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 1375 | { |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 1376 | BindingPointer<Buffer> *buffers[] = { |
| 1377 | &mArrayBuffer, &mGenericAtomicCounterBuffer, &mCopyReadBuffer, |
| 1378 | &mCopyWriteBuffer, &mDrawIndirectBuffer, &mPack.pixelBuffer, |
| 1379 | &mUnpack.pixelBuffer, &mGenericUniformBuffer, &mGenericShaderStorageBuffer}; |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 1380 | for (auto buffer : buffers) |
| 1381 | { |
| 1382 | if (buffer->id() == bufferName) |
| 1383 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1384 | buffer->set(context, nullptr); |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | TransformFeedback *curTransformFeedback = getCurrentTransformFeedback(); |
| 1389 | if (curTransformFeedback) |
| 1390 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1391 | curTransformFeedback->detachBuffer(context, bufferName); |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 1392 | } |
| 1393 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1394 | getVertexArray()->detachBuffer(context, bufferName); |
Yuly Novikov | 5807a53 | 2015-12-03 13:01:22 -0500 | [diff] [blame] | 1395 | } |
| 1396 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1397 | void State::setEnableVertexAttribArray(unsigned int attribNum, bool enabled) |
| 1398 | { |
| 1399 | getVertexArray()->enableAttribute(attribNum, enabled); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 1400 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | void State::setVertexAttribf(GLuint index, const GLfloat values[4]) |
| 1404 | { |
Shannon Woods | 23e0500 | 2014-09-22 19:07:27 -0400 | [diff] [blame] | 1405 | ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size()); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1406 | mVertexAttribCurrentValues[index].setFloatValues(values); |
Jamie Madill | 1e0bc3a | 2015-08-11 08:12:21 -0400 | [diff] [blame] | 1407 | mDirtyBits.set(DIRTY_BIT_CURRENT_VALUE_0 + index); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | void State::setVertexAttribu(GLuint index, const GLuint values[4]) |
| 1411 | { |
Shannon Woods | 23e0500 | 2014-09-22 19:07:27 -0400 | [diff] [blame] | 1412 | ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size()); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1413 | mVertexAttribCurrentValues[index].setUnsignedIntValues(values); |
Jamie Madill | 1e0bc3a | 2015-08-11 08:12:21 -0400 | [diff] [blame] | 1414 | mDirtyBits.set(DIRTY_BIT_CURRENT_VALUE_0 + index); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | void State::setVertexAttribi(GLuint index, const GLint values[4]) |
| 1418 | { |
Shannon Woods | 23e0500 | 2014-09-22 19:07:27 -0400 | [diff] [blame] | 1419 | ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size()); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1420 | mVertexAttribCurrentValues[index].setIntValues(values); |
Jamie Madill | 1e0bc3a | 2015-08-11 08:12:21 -0400 | [diff] [blame] | 1421 | mDirtyBits.set(DIRTY_BIT_CURRENT_VALUE_0 + index); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1422 | } |
| 1423 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1424 | void State::setVertexAttribPointer(const Context *context, |
| 1425 | unsigned int attribNum, |
| 1426 | Buffer *boundBuffer, |
| 1427 | GLint size, |
| 1428 | GLenum type, |
| 1429 | bool normalized, |
| 1430 | bool pureInteger, |
| 1431 | GLsizei stride, |
| 1432 | const void *pointer) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1433 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1434 | getVertexArray()->setVertexAttribPointer(context, attribNum, boundBuffer, size, type, |
| 1435 | normalized, pureInteger, stride, pointer); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 1436 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 1437 | } |
| 1438 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1439 | void State::setVertexAttribDivisor(const Context *context, GLuint index, GLuint divisor) |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 1440 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 1441 | getVertexArray()->setVertexAttribDivisor(context, index, divisor); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 1442 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1443 | } |
| 1444 | |
Jamie Madill | 6de5185 | 2017-04-12 09:53:01 -0400 | [diff] [blame] | 1445 | const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(size_t attribNum) const |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1446 | { |
Jamie Madill | 6de5185 | 2017-04-12 09:53:01 -0400 | [diff] [blame] | 1447 | ASSERT(attribNum < mVertexAttribCurrentValues.size()); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1448 | return mVertexAttribCurrentValues[attribNum]; |
| 1449 | } |
| 1450 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1451 | const void *State::getVertexAttribPointer(unsigned int attribNum) const |
| 1452 | { |
| 1453 | return getVertexArray()->getVertexAttribute(attribNum).pointer; |
| 1454 | } |
| 1455 | |
| 1456 | void State::setPackAlignment(GLint alignment) |
| 1457 | { |
| 1458 | mPack.alignment = alignment; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1459 | mDirtyBits.set(DIRTY_BIT_PACK_ALIGNMENT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | GLint State::getPackAlignment() const |
| 1463 | { |
| 1464 | return mPack.alignment; |
| 1465 | } |
| 1466 | |
| 1467 | void State::setPackReverseRowOrder(bool reverseRowOrder) |
| 1468 | { |
| 1469 | mPack.reverseRowOrder = reverseRowOrder; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1470 | mDirtyBits.set(DIRTY_BIT_PACK_REVERSE_ROW_ORDER); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1471 | } |
| 1472 | |
| 1473 | bool State::getPackReverseRowOrder() const |
| 1474 | { |
| 1475 | return mPack.reverseRowOrder; |
| 1476 | } |
| 1477 | |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1478 | void State::setPackRowLength(GLint rowLength) |
| 1479 | { |
| 1480 | mPack.rowLength = rowLength; |
| 1481 | mDirtyBits.set(DIRTY_BIT_PACK_ROW_LENGTH); |
| 1482 | } |
| 1483 | |
| 1484 | GLint State::getPackRowLength() const |
| 1485 | { |
| 1486 | return mPack.rowLength; |
| 1487 | } |
| 1488 | |
| 1489 | void State::setPackSkipRows(GLint skipRows) |
| 1490 | { |
| 1491 | mPack.skipRows = skipRows; |
| 1492 | mDirtyBits.set(DIRTY_BIT_PACK_SKIP_ROWS); |
| 1493 | } |
| 1494 | |
| 1495 | GLint State::getPackSkipRows() const |
| 1496 | { |
| 1497 | return mPack.skipRows; |
| 1498 | } |
| 1499 | |
| 1500 | void State::setPackSkipPixels(GLint skipPixels) |
| 1501 | { |
| 1502 | mPack.skipPixels = skipPixels; |
| 1503 | mDirtyBits.set(DIRTY_BIT_PACK_SKIP_PIXELS); |
| 1504 | } |
| 1505 | |
| 1506 | GLint State::getPackSkipPixels() const |
| 1507 | { |
| 1508 | return mPack.skipPixels; |
| 1509 | } |
| 1510 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1511 | const PixelPackState &State::getPackState() const |
| 1512 | { |
| 1513 | return mPack; |
| 1514 | } |
| 1515 | |
Jamie Madill | 87de362 | 2015-03-16 10:41:44 -0400 | [diff] [blame] | 1516 | PixelPackState &State::getPackState() |
| 1517 | { |
| 1518 | return mPack; |
| 1519 | } |
| 1520 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1521 | void State::setUnpackAlignment(GLint alignment) |
| 1522 | { |
| 1523 | mUnpack.alignment = alignment; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1524 | mDirtyBits.set(DIRTY_BIT_UNPACK_ALIGNMENT); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1525 | } |
| 1526 | |
| 1527 | GLint State::getUnpackAlignment() const |
| 1528 | { |
| 1529 | return mUnpack.alignment; |
| 1530 | } |
| 1531 | |
Minmin Gong | b8aee3b | 2015-01-27 14:42:36 -0800 | [diff] [blame] | 1532 | void State::setUnpackRowLength(GLint rowLength) |
| 1533 | { |
| 1534 | mUnpack.rowLength = rowLength; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 1535 | mDirtyBits.set(DIRTY_BIT_UNPACK_ROW_LENGTH); |
Minmin Gong | b8aee3b | 2015-01-27 14:42:36 -0800 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | GLint State::getUnpackRowLength() const |
| 1539 | { |
| 1540 | return mUnpack.rowLength; |
| 1541 | } |
| 1542 | |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1543 | void State::setUnpackImageHeight(GLint imageHeight) |
| 1544 | { |
| 1545 | mUnpack.imageHeight = imageHeight; |
| 1546 | mDirtyBits.set(DIRTY_BIT_UNPACK_IMAGE_HEIGHT); |
| 1547 | } |
| 1548 | |
| 1549 | GLint State::getUnpackImageHeight() const |
| 1550 | { |
| 1551 | return mUnpack.imageHeight; |
| 1552 | } |
| 1553 | |
| 1554 | void State::setUnpackSkipImages(GLint skipImages) |
| 1555 | { |
| 1556 | mUnpack.skipImages = skipImages; |
| 1557 | mDirtyBits.set(DIRTY_BIT_UNPACK_SKIP_IMAGES); |
| 1558 | } |
| 1559 | |
| 1560 | GLint State::getUnpackSkipImages() const |
| 1561 | { |
| 1562 | return mUnpack.skipImages; |
| 1563 | } |
| 1564 | |
| 1565 | void State::setUnpackSkipRows(GLint skipRows) |
| 1566 | { |
| 1567 | mUnpack.skipRows = skipRows; |
| 1568 | mDirtyBits.set(DIRTY_BIT_UNPACK_SKIP_ROWS); |
| 1569 | } |
| 1570 | |
| 1571 | GLint State::getUnpackSkipRows() const |
| 1572 | { |
| 1573 | return mUnpack.skipRows; |
| 1574 | } |
| 1575 | |
| 1576 | void State::setUnpackSkipPixels(GLint skipPixels) |
| 1577 | { |
| 1578 | mUnpack.skipPixels = skipPixels; |
| 1579 | mDirtyBits.set(DIRTY_BIT_UNPACK_SKIP_PIXELS); |
| 1580 | } |
| 1581 | |
| 1582 | GLint State::getUnpackSkipPixels() const |
| 1583 | { |
| 1584 | return mUnpack.skipPixels; |
| 1585 | } |
| 1586 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1587 | const PixelUnpackState &State::getUnpackState() const |
| 1588 | { |
| 1589 | return mUnpack; |
| 1590 | } |
| 1591 | |
Jamie Madill | 67102f0 | 2015-03-16 10:41:42 -0400 | [diff] [blame] | 1592 | PixelUnpackState &State::getUnpackState() |
| 1593 | { |
| 1594 | return mUnpack; |
| 1595 | } |
| 1596 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1597 | const Debug &State::getDebug() const |
| 1598 | { |
| 1599 | return mDebug; |
| 1600 | } |
| 1601 | |
| 1602 | Debug &State::getDebug() |
| 1603 | { |
| 1604 | return mDebug; |
| 1605 | } |
| 1606 | |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1607 | void State::setCoverageModulation(GLenum components) |
| 1608 | { |
| 1609 | mCoverageModulation = components; |
| 1610 | mDirtyBits.set(DIRTY_BIT_COVERAGE_MODULATION); |
| 1611 | } |
| 1612 | |
| 1613 | GLenum State::getCoverageModulation() const |
| 1614 | { |
| 1615 | return mCoverageModulation; |
| 1616 | } |
| 1617 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 1618 | void State::loadPathRenderingMatrix(GLenum matrixMode, const GLfloat *matrix) |
| 1619 | { |
| 1620 | if (matrixMode == GL_PATH_MODELVIEW_CHROMIUM) |
| 1621 | { |
| 1622 | memcpy(mPathMatrixMV, matrix, 16 * sizeof(GLfloat)); |
| 1623 | mDirtyBits.set(DIRTY_BIT_PATH_RENDERING_MATRIX_MV); |
| 1624 | } |
| 1625 | else if (matrixMode == GL_PATH_PROJECTION_CHROMIUM) |
| 1626 | { |
| 1627 | memcpy(mPathMatrixProj, matrix, 16 * sizeof(GLfloat)); |
| 1628 | mDirtyBits.set(DIRTY_BIT_PATH_RENDERING_MATRIX_PROJ); |
| 1629 | } |
| 1630 | else |
| 1631 | { |
| 1632 | UNREACHABLE(); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | const GLfloat *State::getPathRenderingMatrix(GLenum which) const |
| 1637 | { |
| 1638 | if (which == GL_PATH_MODELVIEW_MATRIX_CHROMIUM) |
| 1639 | { |
| 1640 | return mPathMatrixMV; |
| 1641 | } |
| 1642 | else if (which == GL_PATH_PROJECTION_MATRIX_CHROMIUM) |
| 1643 | { |
| 1644 | return mPathMatrixProj; |
| 1645 | } |
| 1646 | |
| 1647 | UNREACHABLE(); |
| 1648 | return nullptr; |
| 1649 | } |
| 1650 | |
| 1651 | void State::setPathStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 1652 | { |
| 1653 | mPathStencilFunc = func; |
| 1654 | mPathStencilRef = ref; |
| 1655 | mPathStencilMask = mask; |
| 1656 | mDirtyBits.set(DIRTY_BIT_PATH_RENDERING_STENCIL_STATE); |
| 1657 | } |
| 1658 | |
| 1659 | GLenum State::getPathStencilFunc() const |
| 1660 | { |
| 1661 | return mPathStencilFunc; |
| 1662 | } |
| 1663 | |
| 1664 | GLint State::getPathStencilRef() const |
| 1665 | { |
| 1666 | return mPathStencilRef; |
| 1667 | } |
| 1668 | |
| 1669 | GLuint State::getPathStencilMask() const |
| 1670 | { |
| 1671 | return mPathStencilMask; |
| 1672 | } |
| 1673 | |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 1674 | void State::setFramebufferSRGB(bool sRGB) |
| 1675 | { |
| 1676 | mFramebufferSRGB = sRGB; |
| 1677 | mDirtyBits.set(DIRTY_BIT_FRAMEBUFFER_SRGB); |
| 1678 | } |
| 1679 | |
| 1680 | bool State::getFramebufferSRGB() const |
| 1681 | { |
| 1682 | return mFramebufferSRGB; |
| 1683 | } |
| 1684 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1685 | void State::getBooleanv(GLenum pname, GLboolean *params) |
| 1686 | { |
| 1687 | switch (pname) |
| 1688 | { |
| 1689 | case GL_SAMPLE_COVERAGE_INVERT: *params = mSampleCoverageInvert; break; |
| 1690 | case GL_DEPTH_WRITEMASK: *params = mDepthStencil.depthMask; break; |
| 1691 | case GL_COLOR_WRITEMASK: |
| 1692 | params[0] = mBlend.colorMaskRed; |
| 1693 | params[1] = mBlend.colorMaskGreen; |
| 1694 | params[2] = mBlend.colorMaskBlue; |
| 1695 | params[3] = mBlend.colorMaskAlpha; |
| 1696 | break; |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 1697 | case GL_CULL_FACE: |
| 1698 | *params = mRasterizer.cullFace; |
| 1699 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1700 | case GL_POLYGON_OFFSET_FILL: *params = mRasterizer.polygonOffsetFill; break; |
| 1701 | case GL_SAMPLE_ALPHA_TO_COVERAGE: *params = mBlend.sampleAlphaToCoverage; break; |
| 1702 | case GL_SAMPLE_COVERAGE: *params = mSampleCoverage; break; |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 1703 | case GL_SAMPLE_MASK: |
| 1704 | *params = mSampleMask; |
| 1705 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1706 | case GL_SCISSOR_TEST: *params = mScissorTest; break; |
| 1707 | case GL_STENCIL_TEST: *params = mDepthStencil.stencilTest; break; |
| 1708 | case GL_DEPTH_TEST: *params = mDepthStencil.depthTest; break; |
| 1709 | case GL_BLEND: *params = mBlend.blend; break; |
| 1710 | case GL_DITHER: *params = mBlend.dither; break; |
Geoff Lang | bb0a0bb | 2015-03-27 12:16:57 -0400 | [diff] [blame] | 1711 | case GL_TRANSFORM_FEEDBACK_ACTIVE: *params = getCurrentTransformFeedback()->isActive() ? GL_TRUE : GL_FALSE; break; |
| 1712 | case GL_TRANSFORM_FEEDBACK_PAUSED: *params = getCurrentTransformFeedback()->isPaused() ? GL_TRUE : GL_FALSE; break; |
Jamie Madill | e2cd53d | 2015-10-27 11:15:46 -0400 | [diff] [blame] | 1713 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 1714 | *params = mPrimitiveRestart; |
| 1715 | break; |
Geoff Lang | ab831f0 | 2015-12-01 09:39:10 -0500 | [diff] [blame] | 1716 | case GL_RASTERIZER_DISCARD: |
| 1717 | *params = isRasterizerDiscardEnabled() ? GL_TRUE : GL_FALSE; |
| 1718 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 1719 | case GL_DEBUG_OUTPUT_SYNCHRONOUS: |
| 1720 | *params = mDebug.isOutputSynchronous() ? GL_TRUE : GL_FALSE; |
| 1721 | break; |
| 1722 | case GL_DEBUG_OUTPUT: |
| 1723 | *params = mDebug.isOutputEnabled() ? GL_TRUE : GL_FALSE; |
| 1724 | break; |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 1725 | case GL_MULTISAMPLE_EXT: |
| 1726 | *params = mMultiSampling; |
| 1727 | break; |
| 1728 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 1729 | *params = mSampleAlphaToOne; |
| 1730 | break; |
Geoff Lang | f41a715 | 2016-09-19 15:11:17 -0400 | [diff] [blame] | 1731 | case GL_BIND_GENERATES_RESOURCE_CHROMIUM: |
| 1732 | *params = isBindGeneratesResourceEnabled() ? GL_TRUE : GL_FALSE; |
| 1733 | break; |
Geoff Lang | feb8c68 | 2017-02-13 16:07:35 -0500 | [diff] [blame] | 1734 | case GL_CLIENT_ARRAYS_ANGLE: |
| 1735 | *params = areClientArraysEnabled() ? GL_TRUE : GL_FALSE; |
| 1736 | break; |
Geoff Lang | 1d2c41d | 2016-10-19 16:14:46 -0700 | [diff] [blame] | 1737 | case GL_FRAMEBUFFER_SRGB_EXT: |
| 1738 | *params = getFramebufferSRGB() ? GL_TRUE : GL_FALSE; |
| 1739 | break; |
Geoff Lang | b433e87 | 2017-10-05 14:01:47 -0400 | [diff] [blame] | 1740 | case GL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: |
Jamie Madill | e08a1d3 | 2017-03-07 17:24:06 -0500 | [diff] [blame] | 1741 | *params = mRobustResourceInit ? GL_TRUE : GL_FALSE; |
| 1742 | break; |
Jamie Madill | c43be72 | 2017-07-13 16:22:14 -0400 | [diff] [blame] | 1743 | case GL_PROGRAM_CACHE_ENABLED_ANGLE: |
| 1744 | *params = mProgramBinaryCacheEnabled ? GL_TRUE : GL_FALSE; |
| 1745 | break; |
| 1746 | |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1747 | default: |
| 1748 | UNREACHABLE(); |
| 1749 | break; |
| 1750 | } |
| 1751 | } |
| 1752 | |
| 1753 | void State::getFloatv(GLenum pname, GLfloat *params) |
| 1754 | { |
| 1755 | // Please note: DEPTH_CLEAR_VALUE is included in our internal getFloatv implementation |
| 1756 | // because it is stored as a float, despite the fact that the GL ES 2.0 spec names |
| 1757 | // GetIntegerv as its native query function. As it would require conversion in any |
| 1758 | // case, this should make no difference to the calling application. |
| 1759 | switch (pname) |
| 1760 | { |
| 1761 | case GL_LINE_WIDTH: *params = mLineWidth; break; |
| 1762 | case GL_SAMPLE_COVERAGE_VALUE: *params = mSampleCoverageValue; break; |
| 1763 | case GL_DEPTH_CLEAR_VALUE: *params = mDepthClearValue; break; |
| 1764 | case GL_POLYGON_OFFSET_FACTOR: *params = mRasterizer.polygonOffsetFactor; break; |
| 1765 | case GL_POLYGON_OFFSET_UNITS: *params = mRasterizer.polygonOffsetUnits; break; |
| 1766 | case GL_DEPTH_RANGE: |
| 1767 | params[0] = mNearZ; |
| 1768 | params[1] = mFarZ; |
| 1769 | break; |
| 1770 | case GL_COLOR_CLEAR_VALUE: |
| 1771 | params[0] = mColorClearValue.red; |
| 1772 | params[1] = mColorClearValue.green; |
| 1773 | params[2] = mColorClearValue.blue; |
| 1774 | params[3] = mColorClearValue.alpha; |
| 1775 | break; |
| 1776 | case GL_BLEND_COLOR: |
| 1777 | params[0] = mBlendColor.red; |
| 1778 | params[1] = mBlendColor.green; |
| 1779 | params[2] = mBlendColor.blue; |
| 1780 | params[3] = mBlendColor.alpha; |
| 1781 | break; |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 1782 | case GL_MULTISAMPLE_EXT: |
| 1783 | *params = static_cast<GLfloat>(mMultiSampling); |
| 1784 | break; |
| 1785 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 1786 | *params = static_cast<GLfloat>(mSampleAlphaToOne); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 1787 | case GL_COVERAGE_MODULATION_CHROMIUM: |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1788 | params[0] = static_cast<GLfloat>(mCoverageModulation); |
| 1789 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1790 | default: |
| 1791 | UNREACHABLE(); |
| 1792 | break; |
| 1793 | } |
| 1794 | } |
| 1795 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 1796 | void State::getIntegerv(const Context *context, GLenum pname, GLint *params) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1797 | { |
| 1798 | if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) |
| 1799 | { |
| 1800 | unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0_EXT); |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 1801 | ASSERT(colorAttachment < mMaxDrawBuffers); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1802 | Framebuffer *framebuffer = mDrawFramebuffer; |
| 1803 | *params = framebuffer->getDrawBufferState(colorAttachment); |
| 1804 | return; |
| 1805 | } |
| 1806 | |
| 1807 | // Please note: DEPTH_CLEAR_VALUE is not included in our internal getIntegerv implementation |
| 1808 | // because it is stored as a float, despite the fact that the GL ES 2.0 spec names |
| 1809 | // GetIntegerv as its native query function. As it would require conversion in any |
| 1810 | // case, this should make no difference to the calling application. You may find it in |
| 1811 | // State::getFloatv. |
| 1812 | switch (pname) |
| 1813 | { |
| 1814 | case GL_ARRAY_BUFFER_BINDING: *params = mArrayBuffer.id(); break; |
Jiajia Qin | 9d7d0b1 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 1815 | case GL_DRAW_INDIRECT_BUFFER_BINDING: |
| 1816 | *params = mDrawIndirectBuffer.id(); |
| 1817 | break; |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 1818 | case GL_ELEMENT_ARRAY_BUFFER_BINDING: *params = getVertexArray()->getElementArrayBuffer().id(); break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1819 | //case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE |
| 1820 | case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: *params = mDrawFramebuffer->id(); break; |
| 1821 | case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mReadFramebuffer->id(); break; |
| 1822 | case GL_RENDERBUFFER_BINDING: *params = mRenderbuffer.id(); break; |
| 1823 | case GL_VERTEX_ARRAY_BINDING: *params = mVertexArray->id(); break; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 1824 | case GL_CURRENT_PROGRAM: *params = mProgram ? mProgram->id() : 0; break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1825 | case GL_PACK_ALIGNMENT: *params = mPack.alignment; break; |
| 1826 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: *params = mPack.reverseRowOrder; break; |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1827 | case GL_PACK_ROW_LENGTH: |
| 1828 | *params = mPack.rowLength; |
| 1829 | break; |
| 1830 | case GL_PACK_SKIP_ROWS: |
| 1831 | *params = mPack.skipRows; |
| 1832 | break; |
| 1833 | case GL_PACK_SKIP_PIXELS: |
| 1834 | *params = mPack.skipPixels; |
| 1835 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1836 | case GL_UNPACK_ALIGNMENT: *params = mUnpack.alignment; break; |
Minmin Gong | b8aee3b | 2015-01-27 14:42:36 -0800 | [diff] [blame] | 1837 | case GL_UNPACK_ROW_LENGTH: *params = mUnpack.rowLength; break; |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1838 | case GL_UNPACK_IMAGE_HEIGHT: |
| 1839 | *params = mUnpack.imageHeight; |
| 1840 | break; |
| 1841 | case GL_UNPACK_SKIP_IMAGES: |
| 1842 | *params = mUnpack.skipImages; |
| 1843 | break; |
| 1844 | case GL_UNPACK_SKIP_ROWS: |
| 1845 | *params = mUnpack.skipRows; |
| 1846 | break; |
| 1847 | case GL_UNPACK_SKIP_PIXELS: |
| 1848 | *params = mUnpack.skipPixels; |
| 1849 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1850 | case GL_GENERATE_MIPMAP_HINT: *params = mGenerateMipmapHint; break; |
| 1851 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mFragmentShaderDerivativeHint; break; |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 1852 | case GL_ACTIVE_TEXTURE: |
| 1853 | *params = (static_cast<GLint>(mActiveSampler) + GL_TEXTURE0); |
| 1854 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1855 | case GL_STENCIL_FUNC: *params = mDepthStencil.stencilFunc; break; |
| 1856 | case GL_STENCIL_REF: *params = mStencilRef; break; |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 1857 | case GL_STENCIL_VALUE_MASK: |
| 1858 | *params = CastMaskValue(context, mDepthStencil.stencilMask); |
| 1859 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1860 | case GL_STENCIL_BACK_FUNC: *params = mDepthStencil.stencilBackFunc; break; |
| 1861 | case GL_STENCIL_BACK_REF: *params = mStencilBackRef; break; |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 1862 | case GL_STENCIL_BACK_VALUE_MASK: |
| 1863 | *params = CastMaskValue(context, mDepthStencil.stencilBackMask); |
| 1864 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1865 | case GL_STENCIL_FAIL: *params = mDepthStencil.stencilFail; break; |
| 1866 | case GL_STENCIL_PASS_DEPTH_FAIL: *params = mDepthStencil.stencilPassDepthFail; break; |
| 1867 | case GL_STENCIL_PASS_DEPTH_PASS: *params = mDepthStencil.stencilPassDepthPass; break; |
| 1868 | case GL_STENCIL_BACK_FAIL: *params = mDepthStencil.stencilBackFail; break; |
| 1869 | case GL_STENCIL_BACK_PASS_DEPTH_FAIL: *params = mDepthStencil.stencilBackPassDepthFail; break; |
| 1870 | case GL_STENCIL_BACK_PASS_DEPTH_PASS: *params = mDepthStencil.stencilBackPassDepthPass; break; |
| 1871 | case GL_DEPTH_FUNC: *params = mDepthStencil.depthFunc; break; |
| 1872 | case GL_BLEND_SRC_RGB: *params = mBlend.sourceBlendRGB; break; |
| 1873 | case GL_BLEND_SRC_ALPHA: *params = mBlend.sourceBlendAlpha; break; |
| 1874 | case GL_BLEND_DST_RGB: *params = mBlend.destBlendRGB; break; |
| 1875 | case GL_BLEND_DST_ALPHA: *params = mBlend.destBlendAlpha; break; |
| 1876 | case GL_BLEND_EQUATION_RGB: *params = mBlend.blendEquationRGB; break; |
| 1877 | case GL_BLEND_EQUATION_ALPHA: *params = mBlend.blendEquationAlpha; break; |
jchen10 | a99ed55 | 2017-09-22 08:10:32 +0800 | [diff] [blame] | 1878 | case GL_STENCIL_WRITEMASK: |
| 1879 | *params = CastMaskValue(context, mDepthStencil.stencilWritemask); |
| 1880 | break; |
| 1881 | case GL_STENCIL_BACK_WRITEMASK: |
| 1882 | *params = CastMaskValue(context, mDepthStencil.stencilBackWritemask); |
| 1883 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1884 | case GL_STENCIL_CLEAR_VALUE: *params = mStencilClearValue; break; |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 1885 | case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 1886 | *params = mReadFramebuffer->getImplementationColorReadType(context); |
| 1887 | break; |
| 1888 | case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 1889 | *params = mReadFramebuffer->getImplementationColorReadFormat(context); |
| 1890 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1891 | case GL_SAMPLE_BUFFERS: |
| 1892 | case GL_SAMPLES: |
| 1893 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1894 | Framebuffer *framebuffer = mDrawFramebuffer; |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 1895 | if (framebuffer->checkStatus(context) == GL_FRAMEBUFFER_COMPLETE) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1896 | { |
| 1897 | switch (pname) |
| 1898 | { |
Jamie Madill | a0016b7 | 2017-07-14 14:30:46 -0400 | [diff] [blame] | 1899 | case GL_SAMPLE_BUFFERS: |
| 1900 | if (framebuffer->getSamples(context) != 0) |
| 1901 | { |
| 1902 | *params = 1; |
| 1903 | } |
| 1904 | else |
| 1905 | { |
| 1906 | *params = 0; |
| 1907 | } |
| 1908 | break; |
| 1909 | case GL_SAMPLES: |
| 1910 | *params = framebuffer->getSamples(context); |
| 1911 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1912 | } |
| 1913 | } |
| 1914 | else |
| 1915 | { |
| 1916 | *params = 0; |
| 1917 | } |
| 1918 | } |
| 1919 | break; |
| 1920 | case GL_VIEWPORT: |
| 1921 | params[0] = mViewport.x; |
| 1922 | params[1] = mViewport.y; |
| 1923 | params[2] = mViewport.width; |
| 1924 | params[3] = mViewport.height; |
| 1925 | break; |
| 1926 | case GL_SCISSOR_BOX: |
| 1927 | params[0] = mScissor.x; |
| 1928 | params[1] = mScissor.y; |
| 1929 | params[2] = mScissor.width; |
| 1930 | params[3] = mScissor.height; |
| 1931 | break; |
Corentin Wallez | 2e568cf | 2017-09-18 17:05:22 -0400 | [diff] [blame] | 1932 | case GL_CULL_FACE_MODE: |
| 1933 | *params = ToGLenum(mRasterizer.cullMode); |
| 1934 | break; |
| 1935 | case GL_FRONT_FACE: |
| 1936 | *params = mRasterizer.frontFace; |
| 1937 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1938 | case GL_RED_BITS: |
| 1939 | case GL_GREEN_BITS: |
| 1940 | case GL_BLUE_BITS: |
| 1941 | case GL_ALPHA_BITS: |
| 1942 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1943 | Framebuffer *framebuffer = getDrawFramebuffer(); |
| 1944 | const FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1945 | |
| 1946 | if (colorbuffer) |
| 1947 | { |
| 1948 | switch (pname) |
| 1949 | { |
| 1950 | case GL_RED_BITS: *params = colorbuffer->getRedSize(); break; |
| 1951 | case GL_GREEN_BITS: *params = colorbuffer->getGreenSize(); break; |
| 1952 | case GL_BLUE_BITS: *params = colorbuffer->getBlueSize(); break; |
| 1953 | case GL_ALPHA_BITS: *params = colorbuffer->getAlphaSize(); break; |
| 1954 | } |
| 1955 | } |
| 1956 | else |
| 1957 | { |
| 1958 | *params = 0; |
| 1959 | } |
| 1960 | } |
| 1961 | break; |
| 1962 | case GL_DEPTH_BITS: |
| 1963 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1964 | const Framebuffer *framebuffer = getDrawFramebuffer(); |
| 1965 | const FramebufferAttachment *depthbuffer = framebuffer->getDepthbuffer(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1966 | |
| 1967 | if (depthbuffer) |
| 1968 | { |
| 1969 | *params = depthbuffer->getDepthSize(); |
| 1970 | } |
| 1971 | else |
| 1972 | { |
| 1973 | *params = 0; |
| 1974 | } |
| 1975 | } |
| 1976 | break; |
| 1977 | case GL_STENCIL_BITS: |
| 1978 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 1979 | const Framebuffer *framebuffer = getDrawFramebuffer(); |
| 1980 | const FramebufferAttachment *stencilbuffer = framebuffer->getStencilbuffer(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1981 | |
| 1982 | if (stencilbuffer) |
| 1983 | { |
| 1984 | *params = stencilbuffer->getStencilSize(); |
| 1985 | } |
| 1986 | else |
| 1987 | { |
| 1988 | *params = 0; |
| 1989 | } |
| 1990 | } |
| 1991 | break; |
| 1992 | case GL_TEXTURE_BINDING_2D: |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 1993 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 1994 | *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), GL_TEXTURE_2D); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 1995 | break; |
Corentin Wallez | 13c0dd4 | 2017-07-04 18:27:01 -0400 | [diff] [blame] | 1996 | case GL_TEXTURE_BINDING_RECTANGLE_ANGLE: |
| 1997 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
| 1998 | *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), |
| 1999 | GL_TEXTURE_RECTANGLE_ANGLE); |
| 2000 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2001 | case GL_TEXTURE_BINDING_CUBE_MAP: |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 2002 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 2003 | *params = |
| 2004 | getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), GL_TEXTURE_CUBE_MAP); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2005 | break; |
| 2006 | case GL_TEXTURE_BINDING_3D: |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 2007 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 2008 | *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), GL_TEXTURE_3D); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2009 | break; |
| 2010 | case GL_TEXTURE_BINDING_2D_ARRAY: |
Shannon Woods | 2df6a60 | 2014-09-26 16:12:07 -0400 | [diff] [blame] | 2011 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 2012 | *params = |
| 2013 | getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), GL_TEXTURE_2D_ARRAY); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2014 | break; |
JiangYizhou | 24fe74c | 2017-07-06 16:56:50 +0800 | [diff] [blame] | 2015 | case GL_TEXTURE_BINDING_2D_MULTISAMPLE: |
| 2016 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
| 2017 | *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), |
| 2018 | GL_TEXTURE_2D_MULTISAMPLE); |
| 2019 | break; |
John Bauman | 1831918 | 2016-09-28 14:22:27 -0700 | [diff] [blame] | 2020 | case GL_TEXTURE_BINDING_EXTERNAL_OES: |
| 2021 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
| 2022 | *params = getSamplerTextureId(static_cast<unsigned int>(mActiveSampler), |
| 2023 | GL_TEXTURE_EXTERNAL_OES); |
| 2024 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2025 | case GL_UNIFORM_BUFFER_BINDING: |
| 2026 | *params = mGenericUniformBuffer.id(); |
| 2027 | break; |
Frank Henigman | 22581ff | 2015-11-06 14:25:54 -0500 | [diff] [blame] | 2028 | case GL_TRANSFORM_FEEDBACK_BINDING: |
Frank Henigman | b0f0b81 | 2015-11-21 17:49:29 -0500 | [diff] [blame] | 2029 | *params = mTransformFeedback.id(); |
Frank Henigman | 22581ff | 2015-11-06 14:25:54 -0500 | [diff] [blame] | 2030 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2031 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
Geoff Lang | 045536b | 2015-03-27 15:17:18 -0400 | [diff] [blame] | 2032 | *params = mTransformFeedback->getGenericBuffer().id(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2033 | break; |
| 2034 | case GL_COPY_READ_BUFFER_BINDING: |
| 2035 | *params = mCopyReadBuffer.id(); |
| 2036 | break; |
| 2037 | case GL_COPY_WRITE_BUFFER_BINDING: |
| 2038 | *params = mCopyWriteBuffer.id(); |
| 2039 | break; |
| 2040 | case GL_PIXEL_PACK_BUFFER_BINDING: |
| 2041 | *params = mPack.pixelBuffer.id(); |
| 2042 | break; |
| 2043 | case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 2044 | *params = mUnpack.pixelBuffer.id(); |
| 2045 | break; |
Olli Etuaho | 86821db | 2016-03-04 12:05:47 +0200 | [diff] [blame] | 2046 | case GL_READ_BUFFER: |
| 2047 | *params = mReadFramebuffer->getReadBufferState(); |
| 2048 | break; |
| 2049 | case GL_SAMPLER_BINDING: |
| 2050 | ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); |
| 2051 | *params = getSamplerId(static_cast<GLuint>(mActiveSampler)); |
| 2052 | break; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2053 | case GL_DEBUG_LOGGED_MESSAGES: |
| 2054 | *params = static_cast<GLint>(mDebug.getMessageCount()); |
| 2055 | break; |
| 2056 | case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: |
| 2057 | *params = static_cast<GLint>(mDebug.getNextMessageLength()); |
| 2058 | break; |
| 2059 | case GL_DEBUG_GROUP_STACK_DEPTH: |
| 2060 | *params = static_cast<GLint>(mDebug.getGroupStackDepth()); |
| 2061 | break; |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 2062 | case GL_MULTISAMPLE_EXT: |
| 2063 | *params = static_cast<GLint>(mMultiSampling); |
| 2064 | break; |
| 2065 | case GL_SAMPLE_ALPHA_TO_ONE_EXT: |
| 2066 | *params = static_cast<GLint>(mSampleAlphaToOne); |
Sami Väisänen | a797e06 | 2016-05-12 15:23:40 +0300 | [diff] [blame] | 2067 | case GL_COVERAGE_MODULATION_CHROMIUM: |
| 2068 | *params = static_cast<GLint>(mCoverageModulation); |
Sami Väisänen | 74c2347 | 2016-05-09 17:30:30 +0300 | [diff] [blame] | 2069 | break; |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2070 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 2071 | *params = mGenericAtomicCounterBuffer.id(); |
| 2072 | break; |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2073 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 2074 | *params = mGenericShaderStorageBuffer.id(); |
| 2075 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2076 | default: |
| 2077 | UNREACHABLE(); |
| 2078 | break; |
| 2079 | } |
| 2080 | } |
| 2081 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 2082 | void State::getPointerv(GLenum pname, void **params) const |
| 2083 | { |
| 2084 | switch (pname) |
| 2085 | { |
| 2086 | case GL_DEBUG_CALLBACK_FUNCTION: |
| 2087 | *params = reinterpret_cast<void *>(mDebug.getCallback()); |
| 2088 | break; |
| 2089 | case GL_DEBUG_CALLBACK_USER_PARAM: |
| 2090 | *params = const_cast<void *>(mDebug.getUserParam()); |
| 2091 | break; |
| 2092 | default: |
| 2093 | UNREACHABLE(); |
| 2094 | break; |
| 2095 | } |
| 2096 | } |
| 2097 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2098 | void State::getIntegeri_v(GLenum target, GLuint index, GLint *data) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2099 | { |
| 2100 | switch (target) |
| 2101 | { |
| 2102 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2103 | ASSERT(static_cast<size_t>(index) < mTransformFeedback->getIndexedBufferCount()); |
| 2104 | *data = mTransformFeedback->getIndexedBuffer(index).id(); |
| 2105 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2106 | case GL_UNIFORM_BUFFER_BINDING: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2107 | ASSERT(static_cast<size_t>(index) < mUniformBuffers.size()); |
| 2108 | *data = mUniformBuffers[index].id(); |
| 2109 | break; |
| 2110 | case GL_ATOMIC_COUNTER_BUFFER_BINDING: |
| 2111 | ASSERT(static_cast<size_t>(index) < mAtomicCounterBuffers.size()); |
| 2112 | *data = mAtomicCounterBuffers[index].id(); |
| 2113 | break; |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2114 | case GL_SHADER_STORAGE_BUFFER_BINDING: |
| 2115 | ASSERT(static_cast<size_t>(index) < mShaderStorageBuffers.size()); |
| 2116 | *data = mShaderStorageBuffers[index].id(); |
| 2117 | break; |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2118 | case GL_VERTEX_BINDING_BUFFER: |
| 2119 | ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings()); |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 2120 | *data = mVertexArray->getVertexBinding(index).getBuffer().id(); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2121 | break; |
| 2122 | case GL_VERTEX_BINDING_DIVISOR: |
| 2123 | ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings()); |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 2124 | *data = mVertexArray->getVertexBinding(index).getDivisor(); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2125 | break; |
| 2126 | case GL_VERTEX_BINDING_OFFSET: |
| 2127 | ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings()); |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 2128 | *data = static_cast<GLuint>(mVertexArray->getVertexBinding(index).getOffset()); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2129 | break; |
| 2130 | case GL_VERTEX_BINDING_STRIDE: |
| 2131 | ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings()); |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 2132 | *data = mVertexArray->getVertexBinding(index).getStride(); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 2133 | break; |
Jiawei Shao | db34227 | 2017-09-27 10:21:45 +0800 | [diff] [blame] | 2134 | case GL_SAMPLE_MASK_VALUE: |
| 2135 | ASSERT(static_cast<size_t>(index) < mSampleMaskValues.size()); |
| 2136 | *data = mSampleMaskValues[index]; |
| 2137 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2138 | default: |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2139 | UNREACHABLE(); |
| 2140 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2141 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2142 | } |
| 2143 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2144 | void State::getInteger64i_v(GLenum target, GLuint index, GLint64 *data) |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2145 | { |
| 2146 | switch (target) |
| 2147 | { |
| 2148 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2149 | ASSERT(static_cast<size_t>(index) < mTransformFeedback->getIndexedBufferCount()); |
| 2150 | *data = mTransformFeedback->getIndexedBuffer(index).getOffset(); |
| 2151 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2152 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2153 | ASSERT(static_cast<size_t>(index) < mTransformFeedback->getIndexedBufferCount()); |
| 2154 | *data = mTransformFeedback->getIndexedBuffer(index).getSize(); |
| 2155 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2156 | case GL_UNIFORM_BUFFER_START: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2157 | ASSERT(static_cast<size_t>(index) < mUniformBuffers.size()); |
| 2158 | *data = mUniformBuffers[index].getOffset(); |
| 2159 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2160 | case GL_UNIFORM_BUFFER_SIZE: |
Jiajia Qin | 6eafb04 | 2016-12-27 17:04:07 +0800 | [diff] [blame] | 2161 | ASSERT(static_cast<size_t>(index) < mUniformBuffers.size()); |
| 2162 | *data = mUniformBuffers[index].getSize(); |
| 2163 | break; |
| 2164 | case GL_ATOMIC_COUNTER_BUFFER_START: |
| 2165 | ASSERT(static_cast<size_t>(index) < mAtomicCounterBuffers.size()); |
| 2166 | *data = mAtomicCounterBuffers[index].getOffset(); |
| 2167 | break; |
| 2168 | case GL_ATOMIC_COUNTER_BUFFER_SIZE: |
| 2169 | ASSERT(static_cast<size_t>(index) < mAtomicCounterBuffers.size()); |
| 2170 | *data = mAtomicCounterBuffers[index].getSize(); |
| 2171 | break; |
Jiajia Qin | f546e7d | 2017-03-27 14:12:59 +0800 | [diff] [blame] | 2172 | case GL_SHADER_STORAGE_BUFFER_START: |
| 2173 | ASSERT(static_cast<size_t>(index) < mShaderStorageBuffers.size()); |
| 2174 | *data = mShaderStorageBuffers[index].getOffset(); |
| 2175 | break; |
| 2176 | case GL_SHADER_STORAGE_BUFFER_SIZE: |
| 2177 | ASSERT(static_cast<size_t>(index) < mShaderStorageBuffers.size()); |
| 2178 | *data = mShaderStorageBuffers[index].getSize(); |
| 2179 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2180 | default: |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2181 | UNREACHABLE(); |
| 2182 | break; |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2183 | } |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2184 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2185 | |
Martin Radev | 66fb820 | 2016-07-28 11:45:20 +0300 | [diff] [blame] | 2186 | void State::getBooleani_v(GLenum target, GLuint index, GLboolean *data) |
| 2187 | { |
| 2188 | UNREACHABLE(); |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2189 | } |
| 2190 | |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 2191 | bool State::hasMappedBuffer(GLenum target) const |
| 2192 | { |
| 2193 | if (target == GL_ARRAY_BUFFER) |
| 2194 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2195 | const VertexArray *vao = getVertexArray(); |
Jamie Madill | eea3a6e | 2015-04-15 10:02:48 -0400 | [diff] [blame] | 2196 | const auto &vertexAttribs = vao->getVertexAttributes(); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 2197 | const auto &vertexBindings = vao->getVertexBindings(); |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 2198 | size_t maxEnabledAttrib = vao->getMaxEnabledAttribute(); |
Jamie Madill | aebf9dd | 2015-04-28 12:39:07 -0400 | [diff] [blame] | 2199 | for (size_t attribIndex = 0; attribIndex < maxEnabledAttrib; attribIndex++) |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 2200 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2201 | const VertexAttribute &vertexAttrib = vertexAttribs[attribIndex]; |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 2202 | auto *boundBuffer = vertexBindings[vertexAttrib.bindingIndex].getBuffer().get(); |
Jamie Madill | d9ba4f7 | 2014-08-04 10:47:59 -0400 | [diff] [blame] | 2203 | if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped()) |
| 2204 | { |
| 2205 | return true; |
| 2206 | } |
| 2207 | } |
| 2208 | |
| 2209 | return false; |
| 2210 | } |
| 2211 | else |
| 2212 | { |
| 2213 | Buffer *buffer = getTargetBuffer(target); |
| 2214 | return (buffer && buffer->isMapped()); |
| 2215 | } |
| 2216 | } |
| 2217 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2218 | void State::syncDirtyObjects(const Context *context) |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2219 | { |
| 2220 | if (!mDirtyObjects.any()) |
| 2221 | return; |
| 2222 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2223 | syncDirtyObjects(context, mDirtyObjects); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2224 | } |
| 2225 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2226 | void State::syncDirtyObjects(const Context *context, const DirtyObjects &bitset) |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2227 | { |
Jamie Madill | 6de5185 | 2017-04-12 09:53:01 -0400 | [diff] [blame] | 2228 | for (auto dirtyObject : bitset) |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2229 | { |
| 2230 | switch (dirtyObject) |
| 2231 | { |
| 2232 | case DIRTY_OBJECT_READ_FRAMEBUFFER: |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2233 | ASSERT(mReadFramebuffer); |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2234 | mReadFramebuffer->syncState(context); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2235 | break; |
| 2236 | case DIRTY_OBJECT_DRAW_FRAMEBUFFER: |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2237 | ASSERT(mDrawFramebuffer); |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2238 | mDrawFramebuffer->syncState(context); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2239 | break; |
| 2240 | case DIRTY_OBJECT_VERTEX_ARRAY: |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2241 | ASSERT(mVertexArray); |
Jamie Madill | 06ef36b | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2242 | mVertexArray->syncState(context); |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2243 | break; |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2244 | case DIRTY_OBJECT_PROGRAM_TEXTURES: |
| 2245 | syncProgramTextures(context); |
| 2246 | break; |
| 2247 | |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2248 | default: |
| 2249 | UNREACHABLE(); |
| 2250 | break; |
| 2251 | } |
| 2252 | } |
| 2253 | |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2254 | mDirtyObjects &= ~bitset; |
| 2255 | } |
| 2256 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2257 | void State::syncProgramTextures(const Context *context) |
| 2258 | { |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2259 | // TODO(jmadill): Fine-grained updates. |
| 2260 | if (!mProgram) |
| 2261 | { |
| 2262 | return; |
| 2263 | } |
| 2264 | |
| 2265 | ASSERT(mDirtyObjects[DIRTY_OBJECT_PROGRAM_TEXTURES]); |
| 2266 | mDirtyBits.set(DIRTY_BIT_TEXTURE_BINDINGS); |
| 2267 | |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 2268 | ActiveTextureMask newActiveTextures; |
| 2269 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2270 | for (const SamplerBinding &samplerBinding : mProgram->getSamplerBindings()) |
| 2271 | { |
| 2272 | if (samplerBinding.unreferenced) |
| 2273 | continue; |
| 2274 | |
| 2275 | GLenum textureType = samplerBinding.textureType; |
| 2276 | for (GLuint textureUnitIndex : samplerBinding.boundTextureUnits) |
| 2277 | { |
| 2278 | Texture *texture = getSamplerTexture(textureUnitIndex, textureType); |
Jamie Madill | 06ef36b | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2279 | Sampler *sampler = getSampler(textureUnitIndex); |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 2280 | ASSERT(static_cast<size_t>(textureUnitIndex) < mCompleteTextureCache.size()); |
| 2281 | ASSERT(static_cast<size_t>(textureUnitIndex) < newActiveTextures.size()); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2282 | |
Jamie Madill | 4297564 | 2017-10-12 12:31:51 -0400 | [diff] [blame] | 2283 | ASSERT(texture); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2284 | |
Jamie Madill | 4297564 | 2017-10-12 12:31:51 -0400 | [diff] [blame] | 2285 | // Mark the texture binding bit as dirty if the texture completeness changes. |
| 2286 | // TODO(jmadill): Use specific dirty bit for completeness change. |
| 2287 | if (texture->isSamplerComplete(context, sampler) && |
| 2288 | !mDrawFramebuffer->hasTextureAttachment(texture)) |
| 2289 | { |
| 2290 | texture->syncState(); |
| 2291 | mCompleteTextureCache[textureUnitIndex] = texture; |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2292 | } |
Jamie Madill | 4297564 | 2017-10-12 12:31:51 -0400 | [diff] [blame] | 2293 | else |
| 2294 | { |
| 2295 | mCompleteTextureCache[textureUnitIndex] = nullptr; |
| 2296 | } |
| 2297 | |
| 2298 | // Bind the texture unconditionally, to recieve completeness change notifications. |
| 2299 | mCompleteTextureBindings[textureUnitIndex].bind(texture->getDirtyChannel()); |
| 2300 | newActiveTextures.set(textureUnitIndex); |
| 2301 | mCompleteTexturesMask.set(textureUnitIndex); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2302 | |
Jamie Madill | 06ef36b | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2303 | if (sampler != nullptr) |
| 2304 | { |
| 2305 | sampler->syncState(context); |
| 2306 | } |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2307 | } |
| 2308 | } |
Jamie Madill | 0f80ed8 | 2017-09-19 00:24:56 -0400 | [diff] [blame] | 2309 | |
| 2310 | // Unset now missing textures. |
| 2311 | ActiveTextureMask negativeMask = mCompleteTexturesMask & ~newActiveTextures; |
| 2312 | if (negativeMask.any()) |
| 2313 | { |
| 2314 | for (auto textureIndex : negativeMask) |
| 2315 | { |
| 2316 | mCompleteTextureBindings[textureIndex].reset(); |
| 2317 | mCompleteTextureCache[textureIndex] = nullptr; |
| 2318 | mCompleteTexturesMask.reset(textureIndex); |
| 2319 | } |
| 2320 | } |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2321 | } |
| 2322 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2323 | void State::syncDirtyObject(const Context *context, GLenum target) |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2324 | { |
| 2325 | DirtyObjects localSet; |
| 2326 | |
| 2327 | switch (target) |
| 2328 | { |
| 2329 | case GL_READ_FRAMEBUFFER: |
| 2330 | localSet.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 2331 | break; |
| 2332 | case GL_DRAW_FRAMEBUFFER: |
| 2333 | localSet.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 2334 | break; |
| 2335 | case GL_FRAMEBUFFER: |
| 2336 | localSet.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 2337 | localSet.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 2338 | break; |
| 2339 | case GL_VERTEX_ARRAY: |
| 2340 | localSet.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 2341 | break; |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2342 | case GL_TEXTURE: |
| 2343 | case GL_SAMPLER: |
| 2344 | case GL_PROGRAM: |
| 2345 | localSet.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
| 2346 | break; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2347 | } |
| 2348 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 2349 | syncDirtyObjects(context, localSet); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2350 | } |
| 2351 | |
| 2352 | void State::setObjectDirty(GLenum target) |
| 2353 | { |
| 2354 | switch (target) |
| 2355 | { |
| 2356 | case GL_READ_FRAMEBUFFER: |
| 2357 | mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 2358 | break; |
| 2359 | case GL_DRAW_FRAMEBUFFER: |
| 2360 | mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 2361 | break; |
| 2362 | case GL_FRAMEBUFFER: |
| 2363 | mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); |
| 2364 | mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); |
| 2365 | break; |
| 2366 | case GL_VERTEX_ARRAY: |
| 2367 | mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); |
| 2368 | break; |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2369 | case GL_TEXTURE: |
| 2370 | case GL_SAMPLER: |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2371 | case GL_PROGRAM: |
| 2372 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
| 2373 | mDirtyBits.set(DIRTY_BIT_TEXTURE_BINDINGS); |
| 2374 | break; |
Jamie Madill | a779b61 | 2017-07-24 11:46:05 -0400 | [diff] [blame] | 2375 | } |
| 2376 | } |
| 2377 | |
| 2378 | void State::onProgramExecutableChange(Program *program) |
| 2379 | { |
| 2380 | // OpenGL Spec: |
| 2381 | // "If LinkProgram or ProgramBinary successfully re-links a program object |
| 2382 | // that was already in use as a result of a previous call to UseProgram, then the |
| 2383 | // generated executable code will be installed as part of the current rendering state." |
| 2384 | if (program->isLinked() && mProgram == program) |
| 2385 | { |
| 2386 | mDirtyBits.set(DIRTY_BIT_PROGRAM_EXECUTABLE); |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2387 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 2388 | } |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 2389 | } |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2390 | |
Xinghua Cao | 65ec0b2 | 2017-03-28 16:10:52 +0800 | [diff] [blame] | 2391 | void State::setImageUnit(const Context *context, |
| 2392 | GLuint unit, |
| 2393 | Texture *texture, |
| 2394 | GLint level, |
| 2395 | GLboolean layered, |
| 2396 | GLint layer, |
| 2397 | GLenum access, |
| 2398 | GLenum format) |
| 2399 | { |
| 2400 | mImageUnits[unit].texture.set(context, texture); |
| 2401 | mImageUnits[unit].level = level; |
| 2402 | mImageUnits[unit].layered = layered; |
| 2403 | mImageUnits[unit].layer = layer; |
| 2404 | mImageUnits[unit].access = access; |
| 2405 | mImageUnits[unit].format = format; |
| 2406 | } |
| 2407 | |
| 2408 | const ImageUnit &State::getImageUnit(GLuint unit) const |
| 2409 | { |
| 2410 | return mImageUnits[unit]; |
| 2411 | } |
| 2412 | |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2413 | // Handle a dirty texture event. |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 2414 | void State::signal(size_t textureIndex, InitState initState) |
Jamie Madill | 81c2e25 | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 2415 | { |
| 2416 | // Conservatively assume all textures are dirty. |
| 2417 | // TODO(jmadill): More fine-grained update. |
| 2418 | mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES); |
| 2419 | } |
| 2420 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 2421 | Error State::clearUnclearedActiveTextures(const Context *context) |
| 2422 | { |
| 2423 | if (!mRobustResourceInit) |
| 2424 | { |
| 2425 | return NoError(); |
| 2426 | } |
| 2427 | |
| 2428 | // TODO(jmadill): Investigate improving the speed here. |
| 2429 | for (Texture *texture : mCompleteTextureCache) |
| 2430 | { |
| 2431 | if (texture) |
| 2432 | { |
| 2433 | ANGLE_TRY(texture->ensureInitialized(context)); |
| 2434 | } |
| 2435 | } |
| 2436 | return NoError(); |
| 2437 | } |
| 2438 | |
Jamie Madill | c9d442d | 2016-01-20 11:17:24 -0500 | [diff] [blame] | 2439 | } // namespace gl |