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