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