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