aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLVertexArray.cpp
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-04-06 14:26:33 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-06 14:26:34 -0700
commitdeacc97bc63513b5eacaf21f858727f6e8b98ce5 (patch)
tree4c4c0f5e995f752b076c39fdf6c4eafc3057fdf4 /src/gpu/gl/GrGLVertexArray.cpp
parent48156ed412410c9d27b560e8596e3f34d175a277 (diff)
Track GL buffer state based on unique resource ID
Reworks GrGLGpu to track GL buffer state based on the unique GrGpuResource ID. This eliminates the need to notify the gpu object whenever a buffer is deleted. This change also allows us to remove the type specifier from GrBuffer. At this point a buffer is just a chunk of memory, and the type given at creation time is just a suggestion to the GL backend about which target to bind to for updates. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1854283004 Review URL: https://codereview.chromium.org/1854283004
Diffstat (limited to 'src/gpu/gl/GrGLVertexArray.cpp')
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index 564a91a1b6..d131ff2186 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -6,6 +6,7 @@
*/
#include "GrGLVertexArray.h"
+#include "GrGLBuffer.h"
#include "GrGLGpu.h"
struct AttribLayout {
@@ -38,7 +39,7 @@ GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
void GrGLAttribArrayState::set(GrGLGpu* gpu,
int index,
- GrGLuint vertexBufferID,
+ const GrGLBuffer* vertexBuffer,
GrVertexAttribType type,
GrGLsizei stride,
GrGLvoid* offset) {
@@ -49,13 +50,11 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
array->fEnableIsValid = true;
array->fEnabled = true;
}
- if (!array->fAttribPointerIsValid ||
- array->fVertexBufferID != vertexBufferID ||
+ if (array->fVertexBufferUniqueID != vertexBuffer->getUniqueID() ||
array->fType != type ||
array->fStride != stride ||
array->fOffset != offset) {
-
- gpu->bindVertexBuffer(vertexBufferID);
+ gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
const AttribLayout& layout = gLayouts[type];
if (!GrVertexAttribTypeIsIntType(type)) {
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
@@ -73,8 +72,7 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
stride,
offset));
}
- array->fAttribPointerIsValid = true;
- array->fVertexBufferID = vertexBufferID;
+ array->fVertexBufferUniqueID = vertexBuffer->getUniqueID();
array->fType = type;
array->fStride = stride;
array->fOffset = offset;
@@ -103,7 +101,7 @@ void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used
GrGLVertexArray::GrGLVertexArray(GrGLint id, int attribCount)
: fID(id)
, fAttribArrays(attribCount)
- , fIndexBufferIDIsValid(false) {
+ , fIndexBufferUniqueID(SK_InvalidUniqueID) {
}
GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
@@ -114,25 +112,16 @@ GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
return &fAttribArrays;
}
-GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuint ibufferID) {
+GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const GrGLBuffer* ibuff) {
GrGLAttribArrayState* state = this->bind(gpu);
- if (state) {
- if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) {
- GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ibufferID));
- fIndexBufferIDIsValid = true;
- fIndexBufferID = ibufferID;
- }
+ if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) {
+ GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ibuff->bufferID()));
+ fIndexBufferUniqueID = ibuff->getUniqueID();
}
return state;
}
-void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
- if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
- fIndexBufferID = 0;
- }
- }
-
void GrGLVertexArray::invalidateCachedState() {
fAttribArrays.invalidate();
- fIndexBufferIDIsValid = false;
+ fIndexBufferUniqueID = SK_InvalidUniqueID;
}