Skip to content

Commit b4d8445

Browse files
cclaoAngle LUCI CQ
authored andcommitted
Move Buffer from VertexBinding to VertexArray
In later CL we will not taking shared context lock for certain VertexArray API calls. VertexArray itself is per context, so this sounds reasonable to do. The main challenge here is a lot of VertexArray function end up accessing gl::Buffer object, which could be modified by other shared contexts. In order to safely not taking the shared context lock, we need to separate out Buffer object out of VertexArray itself so that these lockless APIs will take VertexArray that does not have access to buffer. In this CL, VertexArray is split into two classes: VertexArrayPrivate is everything in VertexArray except buffers. VertexArray is a subclass of VertexArrayPrivate and owns all the buffers. Buffer is removed from gl::VertexBinding class. In order to let back end access to buffers, VertexArrayImpl holds a weak reference to VertexArray::mVertexArrayBuffers (which is a vector of buffers). Further, VertexArrayBufferBindingMask mBufferBindingMask is moved from VertexArrayState into VertexArray class well, since it tracks which index has a non-null buffer. The bulk of change are due to the VertexARrayImpl constructor change, since it now takes vertexArrayBuffers argument. Other bulk of changes are due to VertexBinding no long has the buffer, but you need to get it directly from VertexArray or VertexArrayImpl. This CL also reverts some of the change in crrev.com/c/6758215 that mVertexBindings no longer contains kElementArrayBufferIndex. BYPASS_LARGE_CHANGE_WARNING Bug: b/433331119 Change-Id: I15f4576f7c5c8d8f4d9c9c07d38a60ce539bfeea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6774702 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
1 parent 8dca0ef commit b4d8445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+514
-390
lines changed

src/libANGLE/Context.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6148,8 +6148,9 @@ void Context::getVertexAttribivImpl(GLuint index, GLenum pname, GLint *params) c
61486148
const VertexAttribCurrentValueData &currentValues =
61496149
getState().getVertexAttribCurrentValue(index);
61506150
const VertexArray *vao = getState().getVertexArray();
6151+
size_t bindingIndex = vao->getBindingIndexFromAttribIndex(index);
61516152
QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6152-
currentValues, pname, params);
6153+
vao->getVertexArrayBuffer(bindingIndex), currentValues, pname, params);
61536154
}
61546155

61556156
void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params)
@@ -6171,8 +6172,9 @@ void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
61716172
const VertexAttribCurrentValueData &currentValues =
61726173
getState().getVertexAttribCurrentValue(index);
61736174
const VertexArray *vao = getState().getVertexArray();
6175+
size_t bindingIndex = vao->getBindingIndexFromAttribIndex(index);
61746176
QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6175-
currentValues, pname, params);
6177+
vao->getVertexArrayBuffer(bindingIndex), currentValues, pname, params);
61766178
}
61776179

61786180
void Context::getVertexAttribfvRobust(GLuint index,
@@ -6189,8 +6191,9 @@ void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
61896191
const VertexAttribCurrentValueData &currentValues =
61906192
getState().getVertexAttribCurrentValue(index);
61916193
const VertexArray *vao = getState().getVertexArray();
6194+
size_t bindingIndex = vao->getBindingIndexFromAttribIndex(index);
61926195
QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6193-
currentValues, pname, params);
6196+
vao->getVertexArrayBuffer(bindingIndex), currentValues, pname, params);
61946197
}
61956198

61966199
void Context::getVertexAttribIivRobust(GLuint index,
@@ -6207,8 +6210,9 @@ void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
62076210
const VertexAttribCurrentValueData &currentValues =
62086211
getState().getVertexAttribCurrentValue(index);
62096212
const VertexArray *vao = getState().getVertexArray();
6213+
size_t bindingIndex = vao->getBindingIndexFromAttribIndex(index);
62106214
QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
6211-
currentValues, pname, params);
6215+
vao->getVertexArrayBuffer(bindingIndex), currentValues, pname, params);
62126216
}
62136217

62146218
void Context::getVertexAttribIuivRobust(GLuint index,

src/libANGLE/State.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3672,7 +3672,7 @@ void State::getIntegeri_v(const Context *context, GLenum target, GLuint index, G
36723672
break;
36733673
case GL_VERTEX_BINDING_BUFFER:
36743674
ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings());
3675-
*data = mVertexArray->getVertexBinding(index).getBuffer().id().value;
3675+
*data = mVertexArray->getVertexArrayBufferID(index).value;
36763676
break;
36773677
case GL_VERTEX_BINDING_DIVISOR:
36783678
ASSERT(static_cast<size_t>(index) < mVertexArray->getMaxBindings());

0 commit comments

Comments
 (0)