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

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

Issue 23542013: Improve handling of FF vertex array state (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rob's comments and add secondary color array disable Created 7 years, 3 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/gl/GrGpuGL.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 bf3d3b5e981240d85ca099980419374f84a308a9..605ec3327b3ad03e735c53aa339646ebeefa5536 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -49,7 +49,39 @@ void GrGLAttribArrayState::set(const GrGpuGL* gpu,
}
}
-void GrGLAttribArrayState::disableUnusedAttribArrays(const GrGpuGL* gpu, uint64_t usedMask) {
+void GrGLAttribArrayState::setFixedFunctionVertexArray(const GrGpuGL* gpu,
+ GrGLVertexBuffer* buffer,
+ GrGLint size,
+ GrGLenum type,
+ GrGLsizei stride,
+ GrGLvoid* offset) {
+ SkASSERT(gpu->glCaps().fixedFunctionSupport());
+ AttribArrayState* array = &fFixedFunctionVertexArray;
+ if (!array->fEnableIsValid || !array->fEnabled) {
+ GR_GL_CALL(gpu->glInterface(), EnableClientState(GR_GL_VERTEX_ARRAY));
+ array->fEnableIsValid = true;
+ array->fEnabled = true;
+ }
+ if (!array->fAttribPointerIsValid ||
+ array->fVertexBufferID != buffer->bufferID() ||
+ array->fSize != size ||
+ array->fStride != stride ||
+ array->fOffset != offset) {
+
+ buffer->bind();
+ GR_GL_CALL(gpu->glInterface(), VertexPointer(size,
+ type,
+ stride,
+ offset));
+ array->fAttribPointerIsValid = true;
+ array->fVertexBufferID = buffer->bufferID();
+ array->fSize = size;
+ array->fStride = stride;
+ array->fOffset = offset;
+ }
+}
+
+void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t usedMask, bool usingFFVertexArray) {
int count = fAttribArrayStates.count();
for (int i = 0; i < count; ++i) {
if (!(usedMask & 0x1)) {
@@ -58,10 +90,41 @@ void GrGLAttribArrayState::disableUnusedAttribArrays(const GrGpuGL* gpu, uint64_
fAttribArrayStates[i].fEnableIsValid = true;
fAttribArrayStates[i].fEnabled = false;
}
+ } else {
+ SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[i].fEnabled);
}
// if the count is greater than 64 then this will become 0 and we will disable arrays 64+.
usedMask >>= 1;
}
+
+ // Deal with fixed-function vertex arrays.
+ if (gpu->glCaps().fixedFunctionSupport()) {
+ if (!usingFFVertexArray) {
+ if (!fFixedFunctionVertexArray.fEnableIsValid || fFixedFunctionVertexArray.fEnabled) {
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_VERTEX_ARRAY));
+ fFixedFunctionVertexArray.fEnableIsValid = true;
+ fFixedFunctionVertexArray.fEnabled = false;
+ }
+ } else {
+ SkASSERT(fFixedFunctionVertexArray.fEnableIsValid && fFixedFunctionVertexArray.fEnabled);
+ }
+ // When we use fixed function vertex processing we always use the vertex array and none of
+ // the other arrays.
+ if (!fUnusedFixedFunctionArraysDisabled) {
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_NORMAL_ARRAY));
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_COLOR_ARRAY));
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_SECONDARY_COLOR_ARRAY));
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_INDEX_ARRAY));
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_EDGE_FLAG_ARRAY));
+ for (int i = 0; i < gpu->glCaps().maxFixedFunctionTextureCoords(); ++i) {
+ GR_GL_CALL(gpu->glInterface(), ClientActiveTexture(GR_GL_TEXTURE0 + i));
+ GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
+ }
+ fUnusedFixedFunctionArraysDisabled = true;
+ }
+ } else {
+ SkASSERT(!usingFFVertexArray);
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,9 +178,6 @@ void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
}
void GrGLVertexArray::invalidateCachedState() {
- int count = fAttribArrays.count();
- for (int i = 0; i < count; ++i) {
- fAttribArrays.invalidate();
- }
+ fAttribArrays.invalidate();
fIndexBufferIDIsValid = false;
}
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698