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