Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1288)

Unified Diff: src/gpu/gl/GrGLVertexArray.cpp

Issue 1854283004: Track GL buffer state based on unique resource ID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix for GR_GL_USE_BUFFER_DATA_NULL_HINT=0 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/vk/GrVkGpu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLVertexArray.cpp
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index 564a91a1b64451b340a3d24c5c22368cadf227b2..d131ff21862421d7a749128b46076166fb8a7293 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;
}
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/vk/GrVkGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698