Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2013 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 | // Implementation of the state class for mananging GLES 3 Vertex Array Objects. |
| 7 | // |
| 8 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 9 | #include "libANGLE/VertexArray.h" |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 10 | |
| 11 | #include "common/utilities.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 12 | #include "libANGLE/Buffer.h" |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 13 | #include "libANGLE/Context.h" |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 14 | #include "libANGLE/renderer/BufferImpl.h" |
Jamie Madill | 7aea7e0 | 2016-05-10 10:39:45 -0400 | [diff] [blame] | 15 | #include "libANGLE/renderer/GLImplFactory.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 16 | #include "libANGLE/renderer/VertexArrayImpl.h" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 17 | |
| 18 | namespace gl |
| 19 | { |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 20 | namespace |
| 21 | { |
| 22 | bool IsElementArrayBufferSubjectIndex(angle::SubjectIndex subjectIndex) |
| 23 | { |
| 24 | return (subjectIndex == MAX_VERTEX_ATTRIBS); |
| 25 | } |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 26 | |
| 27 | constexpr angle::SubjectIndex kElementArrayBufferIndex = MAX_VERTEX_ATTRIBS; |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 28 | } // anonymous namespce |
| 29 | |
Jamie Madill | bcef322 | 2018-04-13 15:19:11 -0400 | [diff] [blame] | 30 | // VertexArrayState implementation. |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 31 | VertexArrayState::VertexArrayState(VertexArray *vertexArray, |
| 32 | size_t maxAttribs, |
| 33 | size_t maxAttribBindings) |
| 34 | : mElementArrayBuffer(vertexArray, kElementArrayBufferIndex) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 35 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 36 | ASSERT(maxAttribs <= maxAttribBindings); |
| 37 | |
| 38 | for (size_t i = 0; i < maxAttribs; i++) |
| 39 | { |
| 40 | mVertexAttributes.emplace_back(static_cast<GLuint>(i)); |
Jamie Madill | ad63728 | 2018-07-31 11:22:14 -0400 | [diff] [blame] | 41 | mVertexBindings.emplace_back(static_cast<GLuint>(i)); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 42 | } |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 43 | |
| 44 | // Initially all attributes start as "client" with no buffer bound. |
| 45 | mClientMemoryAttribsMask.set(); |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Jamie Madill | 3f57268 | 2016-04-26 13:41:36 -0400 | [diff] [blame] | 48 | VertexArrayState::~VertexArrayState() |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 49 | { |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 50 | } |
| 51 | |
Jamie Madill | 51af38b | 2018-04-15 08:50:56 -0400 | [diff] [blame] | 52 | bool VertexArrayState::hasEnabledNullPointerClientArray() const |
| 53 | { |
| 54 | return (mNullPointerClientMemoryAttribsMask & mEnabledAttributesMask).any(); |
| 55 | } |
| 56 | |
Jamie Madill | ad63728 | 2018-07-31 11:22:14 -0400 | [diff] [blame] | 57 | AttributesMask VertexArrayState::getBindingToAttributesMask(GLuint bindingIndex) const |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 58 | { |
| 59 | ASSERT(bindingIndex < MAX_VERTEX_ATTRIB_BINDINGS); |
Jamie Madill | ad63728 | 2018-07-31 11:22:14 -0400 | [diff] [blame] | 60 | return mVertexBindings[bindingIndex].getBoundAttributesMask(); |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | // Set an attribute using a new binding. |
| 64 | void VertexArrayState::setAttribBinding(size_t attribIndex, GLuint newBindingIndex) |
| 65 | { |
| 66 | ASSERT(attribIndex < MAX_VERTEX_ATTRIBS && newBindingIndex < MAX_VERTEX_ATTRIB_BINDINGS); |
| 67 | |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 68 | VertexAttribute &attrib = mVertexAttributes[attribIndex]; |
| 69 | |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 70 | // Update the binding-attribute map. |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 71 | const GLuint oldBindingIndex = attrib.bindingIndex; |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 72 | ASSERT(oldBindingIndex != newBindingIndex); |
| 73 | |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 74 | VertexBinding &oldBinding = mVertexBindings[oldBindingIndex]; |
| 75 | VertexBinding &newBinding = mVertexBindings[newBindingIndex]; |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 76 | |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 77 | ASSERT(oldBinding.getBoundAttributesMask().test(attribIndex) && |
| 78 | !newBinding.getBoundAttributesMask().test(attribIndex)); |
| 79 | |
| 80 | oldBinding.resetBoundAttribute(attribIndex); |
| 81 | newBinding.setBoundAttribute(attribIndex); |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 82 | |
| 83 | // Set the attribute using the new binding. |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 84 | attrib.bindingIndex = newBindingIndex; |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 85 | attrib.updateCachedElementLimit(newBinding); |
| 86 | |
| 87 | bool isMapped = newBinding.getBuffer().get() && newBinding.getBuffer()->isMapped(); |
| 88 | mCachedMappedArrayBuffers.set(attribIndex, isMapped); |
| 89 | mCachedEnabledMappedArrayBuffers.set(attribIndex, isMapped && attrib.enabled); |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 90 | } |
| 91 | |
Jamie Madill | bcef322 | 2018-04-13 15:19:11 -0400 | [diff] [blame] | 92 | // VertexArray implementation. |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 93 | VertexArray::VertexArray(rx::GLImplFactory *factory, |
| 94 | GLuint id, |
| 95 | size_t maxAttribs, |
| 96 | size_t maxAttribBindings) |
| 97 | : mId(id), |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 98 | mState(this, maxAttribs, maxAttribBindings), |
| 99 | mVertexArray(factory->createVertexArray(mState)) |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 100 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 101 | for (size_t attribIndex = 0; attribIndex < maxAttribBindings; ++attribIndex) |
| 102 | { |
| 103 | mArrayBufferObserverBindings.emplace_back(this, attribIndex); |
| 104 | } |
Jamie Madill | 004a6f9 | 2013-07-10 15:13:38 -0400 | [diff] [blame] | 105 | } |
| 106 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 107 | void VertexArray::onDestroy(const Context *context) |
| 108 | { |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 109 | bool isBound = context->isCurrentVertexArray(this); |
Jamie Madill | bcef322 | 2018-04-13 15:19:11 -0400 | [diff] [blame] | 110 | for (VertexBinding &binding : mState.mVertexBindings) |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 111 | { |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 112 | binding.setBuffer(context, nullptr, isBound); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 113 | } |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 114 | if (isBound && mState.mElementArrayBuffer.get()) |
Jamie Madill | ca8eda4 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 115 | mState.mElementArrayBuffer->onNonTFBindingChanged(-1); |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 116 | mState.mElementArrayBuffer.bind(context, nullptr); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 117 | mVertexArray->destroy(context); |
| 118 | SafeDelete(mVertexArray); |
| 119 | delete this; |
| 120 | } |
| 121 | |
Jamie Madill | 004a6f9 | 2013-07-10 15:13:38 -0400 | [diff] [blame] | 122 | VertexArray::~VertexArray() |
| 123 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 124 | ASSERT(!mVertexArray); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 125 | } |
| 126 | |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 127 | GLuint VertexArray::id() const |
| 128 | { |
| 129 | return mId; |
| 130 | } |
| 131 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 132 | void VertexArray::setLabel(const std::string &label) |
| 133 | { |
Jamie Madill | 3f57268 | 2016-04-26 13:41:36 -0400 | [diff] [blame] | 134 | mState.mLabel = label; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | const std::string &VertexArray::getLabel() const |
| 138 | { |
Jamie Madill | 3f57268 | 2016-04-26 13:41:36 -0400 | [diff] [blame] | 139 | return mState.mLabel; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 140 | } |
| 141 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 142 | void VertexArray::detachBuffer(const Context *context, GLuint bufferName) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 143 | { |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 144 | bool isBound = context->isCurrentVertexArray(this); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 145 | for (auto &binding : mState.mVertexBindings) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 146 | { |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 147 | if (binding.getBuffer().id() == bufferName) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 148 | { |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 149 | binding.setBuffer(context, nullptr, isBound); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 153 | if (mState.mElementArrayBuffer.get() && mState.mElementArrayBuffer->id() == bufferName) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 154 | { |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 155 | if (isBound && mState.mElementArrayBuffer.get()) |
Jamie Madill | ca8eda4 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 156 | mState.mElementArrayBuffer->onNonTFBindingChanged(-1); |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 157 | mState.mElementArrayBuffer.bind(context, nullptr); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 161 | const VertexAttribute &VertexArray::getVertexAttribute(size_t attribIndex) const |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 162 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 163 | ASSERT(attribIndex < getMaxAttribs()); |
| 164 | return mState.mVertexAttributes[attribIndex]; |
| 165 | } |
| 166 | |
| 167 | const VertexBinding &VertexArray::getVertexBinding(size_t bindingIndex) const |
| 168 | { |
| 169 | ASSERT(bindingIndex < getMaxBindings()); |
| 170 | return mState.mVertexBindings[bindingIndex]; |
| 171 | } |
| 172 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 173 | size_t VertexArray::GetVertexIndexFromDirtyBit(size_t dirtyBit) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 174 | { |
| 175 | static_assert(gl::MAX_VERTEX_ATTRIBS == gl::MAX_VERTEX_ATTRIB_BINDINGS, |
| 176 | "The stride of vertex attributes should equal to that of vertex bindings."); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 177 | ASSERT(dirtyBit > DIRTY_BIT_ELEMENT_ARRAY_BUFFER); |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 178 | return (dirtyBit - DIRTY_BIT_ATTRIB_0) % gl::MAX_VERTEX_ATTRIBS; |
| 179 | } |
| 180 | |
| 181 | void VertexArray::setDirtyAttribBit(size_t attribIndex, DirtyAttribBitType dirtyAttribBit) |
| 182 | { |
| 183 | mDirtyBits.set(DIRTY_BIT_ATTRIB_0 + attribIndex); |
| 184 | mDirtyAttribBits[attribIndex].set(dirtyAttribBit); |
| 185 | } |
| 186 | |
| 187 | void VertexArray::setDirtyBindingBit(size_t bindingIndex, DirtyBindingBitType dirtyBindingBit) |
| 188 | { |
| 189 | mDirtyBits.set(DIRTY_BIT_BINDING_0 + bindingIndex); |
| 190 | mDirtyBindingBits[bindingIndex].set(dirtyBindingBit); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 191 | } |
| 192 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 193 | void VertexArray::bindVertexBufferImpl(const Context *context, |
| 194 | size_t bindingIndex, |
| 195 | Buffer *boundBuffer, |
| 196 | GLintptr offset, |
| 197 | GLsizei stride) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 198 | { |
| 199 | ASSERT(bindingIndex < getMaxBindings()); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 200 | bool isBound = context->isCurrentVertexArray(this); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 201 | |
| 202 | VertexBinding *binding = &mState.mVertexBindings[bindingIndex]; |
| 203 | |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 204 | binding->setBuffer(context, boundBuffer, isBound); |
Martin Radev | dd5f27e | 2017-06-07 10:17:09 +0300 | [diff] [blame] | 205 | binding->setOffset(offset); |
| 206 | binding->setStride(stride); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 207 | |
| 208 | updateObserverBinding(bindingIndex); |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 209 | updateCachedBufferBindingSize(binding); |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 210 | updateCachedTransformFeedbackBindingValidation(bindingIndex, boundBuffer); |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 211 | updateCachedMappedArrayBuffers(binding); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 212 | |
| 213 | // Update client memory attribute pointers. Affects all bound attributes. |
| 214 | if (boundBuffer) |
| 215 | { |
Jamie Madill | ad63728 | 2018-07-31 11:22:14 -0400 | [diff] [blame] | 216 | mState.mClientMemoryAttribsMask &= ~binding->getBoundAttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 217 | } |
| 218 | else |
| 219 | { |
Jamie Madill | ad63728 | 2018-07-31 11:22:14 -0400 | [diff] [blame] | 220 | mState.mClientMemoryAttribsMask |= binding->getBoundAttributesMask(); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 221 | } |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | void VertexArray::bindVertexBuffer(const Context *context, |
| 225 | size_t bindingIndex, |
| 226 | Buffer *boundBuffer, |
| 227 | GLintptr offset, |
| 228 | GLsizei stride) |
| 229 | { |
| 230 | bindVertexBufferImpl(context, bindingIndex, boundBuffer, offset, stride); |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 231 | setDirtyBindingBit(bindingIndex, DIRTY_BINDING_BUFFER); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 232 | } |
| 233 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 234 | void VertexArray::setVertexAttribBinding(const Context *context, |
| 235 | size_t attribIndex, |
| 236 | GLuint bindingIndex) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 237 | { |
| 238 | ASSERT(attribIndex < getMaxAttribs() && bindingIndex < getMaxBindings()); |
| 239 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 240 | if (mState.mVertexAttributes[attribIndex].bindingIndex != bindingIndex) |
| 241 | { |
| 242 | // In ES 3.0 contexts, the binding cannot change, hence the code below is unreachable. |
| 243 | ASSERT(context->getClientVersion() >= ES_3_1); |
Jiawei Shao | 6a5d98c | 2018-05-04 15:42:20 +0800 | [diff] [blame] | 244 | |
| 245 | mState.setAttribBinding(attribIndex, bindingIndex); |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 246 | |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 247 | setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_BINDING); |
Jamie Madill | dc358af | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 248 | |
| 249 | // Update client attribs mask. |
| 250 | bool hasBuffer = mState.mVertexBindings[bindingIndex].getBuffer().get() != nullptr; |
| 251 | mState.mClientMemoryAttribsMask.set(attribIndex, !hasBuffer); |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 252 | } |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | void VertexArray::setVertexBindingDivisor(size_t bindingIndex, GLuint divisor) |
| 256 | { |
| 257 | ASSERT(bindingIndex < getMaxBindings()); |
| 258 | |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 259 | VertexBinding &binding = mState.mVertexBindings[bindingIndex]; |
| 260 | |
| 261 | binding.setDivisor(divisor); |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 262 | setDirtyBindingBit(bindingIndex, DIRTY_BINDING_DIVISOR); |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 263 | |
| 264 | // Trigger updates in all bound attributes. |
| 265 | for (size_t attribIndex : binding.getBoundAttributesMask()) |
| 266 | { |
| 267 | mState.mVertexAttributes[attribIndex].updateCachedElementLimit(binding); |
| 268 | } |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 269 | } |
| 270 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 271 | void VertexArray::setVertexAttribFormatImpl(size_t attribIndex, |
| 272 | GLint size, |
| 273 | GLenum type, |
| 274 | bool normalized, |
| 275 | bool pureInteger, |
| 276 | GLuint relativeOffset) |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 277 | { |
| 278 | ASSERT(attribIndex < getMaxAttribs()); |
| 279 | |
| 280 | VertexAttribute *attrib = &mState.mVertexAttributes[attribIndex]; |
| 281 | |
| 282 | attrib->size = size; |
| 283 | attrib->type = type; |
| 284 | attrib->normalized = normalized; |
| 285 | attrib->pureInteger = pureInteger; |
| 286 | attrib->relativeOffset = relativeOffset; |
Brandon Jones | c405ae7 | 2017-12-06 14:15:03 -0800 | [diff] [blame] | 287 | mState.mVertexAttributesTypeMask.setIndex(GetVertexAttributeBaseType(*attrib), attribIndex); |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void VertexArray::setVertexAttribFormat(size_t attribIndex, |
| 291 | GLint size, |
| 292 | GLenum type, |
| 293 | bool normalized, |
| 294 | bool pureInteger, |
| 295 | GLuint relativeOffset) |
| 296 | { |
| 297 | setVertexAttribFormatImpl(attribIndex, size, type, normalized, pureInteger, relativeOffset); |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 298 | setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_FORMAT); |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 299 | |
| 300 | VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; |
| 301 | attrib.updateCachedElementLimit(mState.mVertexBindings[attrib.bindingIndex]); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 302 | } |
| 303 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 304 | void VertexArray::setVertexAttribDivisor(const Context *context, size_t attribIndex, GLuint divisor) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 305 | { |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 306 | ASSERT(attribIndex < getMaxAttribs()); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 307 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 308 | setVertexAttribBinding(context, attribIndex, static_cast<GLuint>(attribIndex)); |
| 309 | setVertexBindingDivisor(attribIndex, divisor); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 310 | } |
| 311 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 312 | void VertexArray::enableAttribute(size_t attribIndex, bool enabledState) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 313 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 314 | ASSERT(attribIndex < getMaxAttribs()); |
Shao | 80957d9 | 2017-02-20 21:25:59 +0800 | [diff] [blame] | 315 | |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 316 | VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; |
| 317 | |
Shahbaz Youssefi | 337bd69 | 2018-08-22 16:16:38 -0400 | [diff] [blame] | 318 | if (mState.mEnabledAttributesMask.test(attribIndex) == enabledState) |
| 319 | { |
| 320 | return; |
| 321 | } |
| 322 | |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 323 | attrib.enabled = enabledState; |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 324 | |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 325 | setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_ENABLED); |
Jamie Madill | aebf9dd | 2015-04-28 12:39:07 -0400 | [diff] [blame] | 326 | |
| 327 | // Update state cache |
Jamie Madill | d078c68 | 2018-01-02 11:50:24 -0500 | [diff] [blame] | 328 | mState.mEnabledAttributesMask.set(attribIndex, enabledState); |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 329 | mState.mCachedEnabledMappedArrayBuffers = |
| 330 | mState.mCachedMappedArrayBuffers & mState.mEnabledAttributesMask; |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 331 | } |
| 332 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 333 | void VertexArray::setVertexAttribPointer(const Context *context, |
| 334 | size_t attribIndex, |
| 335 | gl::Buffer *boundBuffer, |
| 336 | GLint size, |
| 337 | GLenum type, |
| 338 | bool normalized, |
| 339 | bool pureInteger, |
| 340 | GLsizei stride, |
| 341 | const void *pointer) |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 342 | { |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 343 | ASSERT(attribIndex < getMaxAttribs()); |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 344 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 345 | GLintptr offset = boundBuffer ? reinterpret_cast<GLintptr>(pointer) : 0; |
Jamie Madill | 8e34494 | 2015-07-09 14:22:07 -0400 | [diff] [blame] | 346 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 347 | setVertexAttribFormatImpl(attribIndex, size, type, normalized, pureInteger, 0); |
| 348 | setVertexAttribBinding(context, attribIndex, static_cast<GLuint>(attribIndex)); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 349 | |
| 350 | VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 351 | |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 352 | GLsizei effectiveStride = |
| 353 | stride != 0 ? stride : static_cast<GLsizei>(ComputeVertexAttributeTypeSize(attrib)); |
| 354 | attrib.pointer = pointer; |
| 355 | attrib.vertexAttribArrayStride = stride; |
| 356 | |
Shao | dde78e8 | 2017-05-22 14:13:27 +0800 | [diff] [blame] | 357 | bindVertexBufferImpl(context, attribIndex, boundBuffer, offset, effectiveStride); |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 358 | |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 359 | setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_POINTER); |
Jamie Madill | bcef322 | 2018-04-13 15:19:11 -0400 | [diff] [blame] | 360 | |
Jamie Madill | 51af38b | 2018-04-15 08:50:56 -0400 | [diff] [blame] | 361 | mState.mNullPointerClientMemoryAttribsMask.set(attribIndex, |
| 362 | boundBuffer == nullptr && pointer == nullptr); |
Brandon Jones | 5bf9829 | 2014-06-06 17:19:38 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 365 | angle::Result VertexArray::syncState(const Context *context) |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 366 | { |
| 367 | if (mDirtyBits.any()) |
| 368 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 369 | mDirtyBitsGuard = mDirtyBits; |
Frank Henigman | 0af5b86 | 2018-03-27 20:19:33 -0400 | [diff] [blame] | 370 | ANGLE_TRY( |
| 371 | mVertexArray->syncState(context, mDirtyBits, mDirtyAttribBits, mDirtyBindingBits)); |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 372 | mDirtyBits.reset(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 373 | mDirtyBitsGuard.reset(); |
Jamie Madill | e858cb1 | 2018-03-27 09:44:32 -0400 | [diff] [blame] | 374 | |
| 375 | // This is a bit of an implementation hack - but since we know the implementation |
| 376 | // details of the dirty bit class it should always have the same effect as iterating |
| 377 | // individual attribs. We could also look into schemes where iterating the dirty |
| 378 | // bit set also resets it as you pass through it. |
| 379 | memset(&mDirtyAttribBits, 0, sizeof(mDirtyAttribBits)); |
| 380 | memset(&mDirtyBindingBits, 0, sizeof(mDirtyBindingBits)); |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 381 | } |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 382 | return angle::Result::Continue(); |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 383 | } |
| 384 | |
Jamie Madill | bf5177d | 2018-08-21 12:58:20 -0400 | [diff] [blame] | 385 | void VertexArray::onBindingChanged(const Context *context, int incr) |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 386 | { |
| 387 | if (mState.mElementArrayBuffer.get()) |
Jamie Madill | ca8eda4 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 388 | mState.mElementArrayBuffer->onNonTFBindingChanged(incr); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 389 | for (auto &binding : mState.mVertexBindings) |
| 390 | { |
Jamie Madill | bf5177d | 2018-08-21 12:58:20 -0400 | [diff] [blame] | 391 | binding.onContainerBindingChanged(context, incr); |
James Darpinian | e8a93c6 | 2018-01-04 18:02:24 -0800 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 395 | VertexArray::DirtyBitType VertexArray::getDirtyBitFromIndex(bool contentsChanged, |
| 396 | angle::SubjectIndex index) const |
| 397 | { |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 398 | if (IsElementArrayBufferSubjectIndex(index)) |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 399 | { |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 400 | mIndexRangeCache.invalidate(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 401 | return contentsChanged ? DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA |
| 402 | : DIRTY_BIT_ELEMENT_ARRAY_BUFFER; |
| 403 | } |
| 404 | else |
| 405 | { |
| 406 | // Note: this currently just gets the top-level dirty bit. |
| 407 | ASSERT(index < mArrayBufferObserverBindings.size()); |
| 408 | return static_cast<DirtyBitType>( |
| 409 | (contentsChanged ? DIRTY_BIT_BUFFER_DATA_0 : DIRTY_BIT_BINDING_0) + index); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | void VertexArray::onSubjectStateChange(const gl::Context *context, |
| 414 | angle::SubjectIndex index, |
| 415 | angle::SubjectMessage message) |
| 416 | { |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 417 | switch (message) |
| 418 | { |
| 419 | case angle::SubjectMessage::CONTENTS_CHANGED: |
| 420 | setDependentDirtyBit(context, true, index); |
| 421 | break; |
| 422 | |
| 423 | case angle::SubjectMessage::STORAGE_CHANGED: |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 424 | if (!IsElementArrayBufferSubjectIndex(index)) |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 425 | { |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 426 | updateCachedBufferBindingSize(&mState.mVertexBindings[index]); |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 427 | } |
Jamie Madill | a2d1d2d | 2018-08-01 11:34:46 -0400 | [diff] [blame] | 428 | setDependentDirtyBit(context, false, index); |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 429 | break; |
| 430 | |
| 431 | case angle::SubjectMessage::BINDING_CHANGED: |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 432 | if (!IsElementArrayBufferSubjectIndex(index)) |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 433 | { |
| 434 | const Buffer *buffer = mState.mVertexBindings[index].getBuffer().get(); |
| 435 | updateCachedTransformFeedbackBindingValidation(index, buffer); |
| 436 | } |
| 437 | break; |
| 438 | |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 439 | case angle::SubjectMessage::RESOURCE_MAPPED: |
| 440 | if (!IsElementArrayBufferSubjectIndex(index)) |
| 441 | { |
| 442 | updateCachedMappedArrayBuffers(&mState.mVertexBindings[index]); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 443 | onStateChange(context, angle::SubjectMessage::RESOURCE_MAPPED); |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 444 | } |
| 445 | break; |
| 446 | |
| 447 | case angle::SubjectMessage::RESOURCE_UNMAPPED: |
| 448 | setDependentDirtyBit(context, true, index); |
| 449 | |
| 450 | if (!IsElementArrayBufferSubjectIndex(index)) |
| 451 | { |
| 452 | updateCachedMappedArrayBuffers(&mState.mVertexBindings[index]); |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 453 | onStateChange(context, angle::SubjectMessage::RESOURCE_UNMAPPED); |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 454 | } |
| 455 | break; |
| 456 | |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 457 | default: |
| 458 | UNREACHABLE(); |
| 459 | break; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | void VertexArray::setDependentDirtyBit(const gl::Context *context, |
| 464 | bool contentsChanged, |
| 465 | angle::SubjectIndex index) |
| 466 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 467 | DirtyBitType dirtyBit = getDirtyBitFromIndex(contentsChanged, index); |
| 468 | ASSERT(!mDirtyBitsGuard.valid() || mDirtyBitsGuard.value().test(dirtyBit)); |
| 469 | mDirtyBits.set(dirtyBit); |
Jamie Madill | a11819d | 2018-07-30 10:26:01 -0400 | [diff] [blame] | 470 | onStateChange(context, angle::SubjectMessage::CONTENTS_CHANGED); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | void VertexArray::updateObserverBinding(size_t bindingIndex) |
| 474 | { |
| 475 | Buffer *boundBuffer = mState.mVertexBindings[bindingIndex].getBuffer().get(); |
Jamie Madill | 472ddc8 | 2018-10-18 18:41:56 -0400 | [diff] [blame] | 476 | mArrayBufferObserverBindings[bindingIndex].bind(boundBuffer); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 477 | } |
| 478 | |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 479 | void VertexArray::updateCachedBufferBindingSize(VertexBinding *binding) |
Jamie Madill | 02c9c04 | 2018-04-17 13:43:48 -0400 | [diff] [blame] | 480 | { |
Jamie Madill | bdc610a | 2018-07-30 10:26:00 -0400 | [diff] [blame] | 481 | for (size_t boundAttribute : binding->getBoundAttributesMask()) |
| 482 | { |
| 483 | mState.mVertexAttributes[boundAttribute].updateCachedElementLimit(*binding); |
| 484 | } |
Jamie Madill | 02c9c04 | 2018-04-17 13:43:48 -0400 | [diff] [blame] | 485 | } |
| 486 | |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 487 | void VertexArray::updateCachedTransformFeedbackBindingValidation(size_t bindingIndex, |
| 488 | const Buffer *buffer) |
| 489 | { |
| 490 | const bool hasConflict = buffer && buffer->isBoundForTransformFeedbackAndOtherUse(); |
| 491 | mCachedTransformFeedbackConflictedBindingsMask.set(bindingIndex, hasConflict); |
| 492 | } |
| 493 | |
Jamie Madill | ac43aaa | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 494 | bool VertexArray::hasTransformFeedbackBindingConflict(const gl::Context *context) const |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 495 | { |
| 496 | // Fast check first. |
| 497 | if (!mCachedTransformFeedbackConflictedBindingsMask.any()) |
| 498 | { |
| 499 | return false; |
| 500 | } |
| 501 | |
Jamie Madill | ac43aaa | 2018-07-31 11:22:13 -0400 | [diff] [blame] | 502 | const AttributesMask &activeAttribues = context->getStateCache().getActiveBufferedAttribsMask(); |
| 503 | |
Jamie Madill | 7267aa6 | 2018-04-17 15:28:21 -0400 | [diff] [blame] | 504 | // Slow check. We must ensure that the conflicting attributes are enabled/active. |
| 505 | for (size_t attribIndex : activeAttribues) |
| 506 | { |
| 507 | const VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; |
| 508 | if (mCachedTransformFeedbackConflictedBindingsMask[attrib.bindingIndex]) |
| 509 | { |
| 510 | return true; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | return false; |
| 515 | } |
| 516 | |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 517 | void VertexArray::updateCachedMappedArrayBuffers(VertexBinding *binding) |
Jamie Madill | cc73f24 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 518 | { |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 519 | Buffer *buffer = binding->getBuffer().get(); |
| 520 | if (buffer && buffer->isMapped()) |
Jamie Madill | cc73f24 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 521 | { |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 522 | mState.mCachedMappedArrayBuffers |= binding->getBoundAttributesMask(); |
| 523 | } |
| 524 | else |
| 525 | { |
| 526 | mState.mCachedMappedArrayBuffers &= ~binding->getBoundAttributesMask(); |
Jamie Madill | cc73f24 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 527 | } |
| 528 | |
Jamie Madill | d69a5f1 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 529 | mState.mCachedEnabledMappedArrayBuffers = |
| 530 | mState.mCachedMappedArrayBuffers & mState.mEnabledAttributesMask; |
Jamie Madill | cc73f24 | 2018-08-01 11:34:48 -0400 | [diff] [blame] | 531 | } |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 532 | |
| 533 | angle::Result VertexArray::getIndexRangeImpl(const Context *context, |
| 534 | GLenum type, |
| 535 | GLsizei indexCount, |
| 536 | const void *indices, |
| 537 | IndexRange *indexRangeOut) const |
| 538 | { |
| 539 | Buffer *elementArrayBuffer = mState.mElementArrayBuffer.get(); |
| 540 | if (!elementArrayBuffer) |
| 541 | { |
| 542 | *indexRangeOut = ComputeIndexRange(type, indices, indexCount, |
| 543 | context->getGLState().isPrimitiveRestartEnabled()); |
| 544 | return angle::Result::Continue(); |
| 545 | } |
| 546 | |
| 547 | size_t offset = reinterpret_cast<uintptr_t>(indices); |
| 548 | ANGLE_TRY(elementArrayBuffer->getIndexRange(context, type, offset, indexCount, |
| 549 | context->getGLState().isPrimitiveRestartEnabled(), |
| 550 | indexRangeOut)); |
| 551 | |
| 552 | mIndexRangeCache.put(type, indexCount, offset, *indexRangeOut); |
| 553 | return angle::Result::Continue(); |
| 554 | } |
| 555 | |
| 556 | VertexArray::IndexRangeCache::IndexRangeCache() = default; |
| 557 | |
| 558 | void VertexArray::IndexRangeCache::put(GLenum type, |
| 559 | GLsizei indexCount, |
| 560 | size_t offset, |
| 561 | const IndexRange &indexRange) |
| 562 | { |
| 563 | ASSERT(type != GL_NONE); |
| 564 | |
| 565 | mTypeKey = type; |
| 566 | mIndexCountKey = indexCount; |
| 567 | mOffsetKey = offset; |
| 568 | mPayload = indexRange; |
| 569 | } |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 570 | } // namespace gl |