aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLVertexArray.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2016-04-06 18:24:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-06 18:24:34 -0700
commit044d3c185876f9960f07b88f068cf08d78311e33 (patch)
tree94deb4d2c100f848df9abf863470de1af0d3e0f2 /src/gpu/gl/GrGLVertexArray.cpp
parent6e077e140a6b603192e2395ba0adac7b670b3f03 (diff)
Revert of Track GL buffer state based on unique resource ID (patchset #6 id:100001 of https://codereview.chromium.org/1854283004/ )
Reason for revert: Chrome roll's broken, seems to be missing fTarget: https://codereview.chromium.org/1861473005 Original issue's description: > 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 > > Committed: https://skia.googlesource.com/skia/+/deacc97bc63513b5eacaf21f858727f6e8b98ce5 TBR=bsalomon@google.com,jvanverth@google.com,cdalton@nvidia.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1870553002
Diffstat (limited to 'src/gpu/gl/GrGLVertexArray.cpp')
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index d131ff2186..564a91a1b6 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -6,7 +6,6 @@
*/
#include "GrGLVertexArray.h"
-#include "GrGLBuffer.h"
#include "GrGLGpu.h"
struct AttribLayout {
@@ -39,7 +38,7 @@ GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
void GrGLAttribArrayState::set(GrGLGpu* gpu,
int index,
- const GrGLBuffer* vertexBuffer,
+ GrGLuint vertexBufferID,
GrVertexAttribType type,
GrGLsizei stride,
GrGLvoid* offset) {
@@ -50,11 +49,13 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
array->fEnableIsValid = true;
array->fEnabled = true;
}
- if (array->fVertexBufferUniqueID != vertexBuffer->getUniqueID() ||
+ if (!array->fAttribPointerIsValid ||
+ array->fVertexBufferID != vertexBufferID ||
array->fType != type ||
array->fStride != stride ||
array->fOffset != offset) {
- gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
+
+ gpu->bindVertexBuffer(vertexBufferID);
const AttribLayout& layout = gLayouts[type];
if (!GrVertexAttribTypeIsIntType(type)) {
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
@@ -72,7 +73,8 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
stride,
offset));
}
- array->fVertexBufferUniqueID = vertexBuffer->getUniqueID();
+ array->fAttribPointerIsValid = true;
+ array->fVertexBufferID = vertexBufferID;
array->fType = type;
array->fStride = stride;
array->fOffset = offset;
@@ -101,7 +103,7 @@ void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used
GrGLVertexArray::GrGLVertexArray(GrGLint id, int attribCount)
: fID(id)
, fAttribArrays(attribCount)
- , fIndexBufferUniqueID(SK_InvalidUniqueID) {
+ , fIndexBufferIDIsValid(false) {
}
GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
@@ -112,16 +114,25 @@ GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
return &fAttribArrays;
}
-GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const GrGLBuffer* ibuff) {
+GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, GrGLuint ibufferID) {
GrGLAttribArrayState* state = this->bind(gpu);
- if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) {
- GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ibuff->bufferID()));
- fIndexBufferUniqueID = ibuff->getUniqueID();
+ if (state) {
+ if (!fIndexBufferIDIsValid || ibufferID != fIndexBufferID) {
+ GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, ibufferID));
+ fIndexBufferIDIsValid = true;
+ fIndexBufferID = ibufferID;
+ }
}
return state;
}
+void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
+ if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
+ fIndexBufferID = 0;
+ }
+ }
+
void GrGLVertexArray::invalidateCachedState() {
fAttribArrays.invalidate();
- fIndexBufferUniqueID = SK_InvalidUniqueID;
+ fIndexBufferIDIsValid = false;
}