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