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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLVertexArray.h" 8 #include "GrGLVertexArray.h"
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 offset)); 42 offset));
43 array->fAttribPointerIsValid = true; 43 array->fAttribPointerIsValid = true;
44 array->fVertexBufferID = buffer->bufferID(); 44 array->fVertexBufferID = buffer->bufferID();
45 array->fSize = size; 45 array->fSize = size;
46 array->fNormalized = normalized; 46 array->fNormalized = normalized;
47 array->fStride = stride; 47 array->fStride = stride;
48 array->fOffset = offset; 48 array->fOffset = offset;
49 } 49 }
50 } 50 }
51 51
52 void GrGLAttribArrayState::disableUnusedAttribArrays(const GrGpuGL* gpu, uint64_ t usedMask) { 52 void GrGLAttribArrayState::setFixedFunctionVertexArray(const GrGpuGL* gpu,
53 GrGLVertexBuffer* buffer,
54 GrGLint size,
55 GrGLenum type,
56 GrGLsizei stride,
57 GrGLvoid* offset) {
58 SkASSERT(gpu->glCaps().fixedFunctionSupport());
59 AttribArrayState* array = &fFixedFunctionVertexArray;
60 if (!array->fEnableIsValid || !array->fEnabled) {
61 GR_GL_CALL(gpu->glInterface(), EnableClientState(GR_GL_VERTEX_ARRAY));
62 array->fEnableIsValid = true;
63 array->fEnabled = true;
64 }
65 if (!array->fAttribPointerIsValid ||
66 array->fVertexBufferID != buffer->bufferID() ||
67 array->fSize != size ||
68 array->fStride != stride ||
69 array->fOffset != offset) {
70
71 buffer->bind();
72 GR_GL_CALL(gpu->glInterface(), VertexPointer(size,
73 type,
74 stride,
75 offset));
76 array->fAttribPointerIsValid = true;
77 array->fVertexBufferID = buffer->bufferID();
78 array->fSize = size;
79 array->fStride = stride;
80 array->fOffset = offset;
81 }
82 }
83
84 void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used Mask, bool usingFFVertexArray) {
53 int count = fAttribArrayStates.count(); 85 int count = fAttribArrayStates.count();
54 for (int i = 0; i < count; ++i) { 86 for (int i = 0; i < count; ++i) {
55 if (!(usedMask & 0x1)) { 87 if (!(usedMask & 0x1)) {
56 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) { 88 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) {
57 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); 89 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i));
58 fAttribArrayStates[i].fEnableIsValid = true; 90 fAttribArrayStates[i].fEnableIsValid = true;
59 fAttribArrayStates[i].fEnabled = false; 91 fAttribArrayStates[i].fEnabled = false;
60 } 92 }
93 } else {
94 SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[ i].fEnabled);
61 } 95 }
62 // if the count is greater than 64 then this will become 0 and we will d isable arrays 64+. 96 // if the count is greater than 64 then this will become 0 and we will d isable arrays 64+.
63 usedMask >>= 1; 97 usedMask >>= 1;
64 } 98 }
99
100 // Deal with fixed-function vertex arrays.
101 if (gpu->glCaps().fixedFunctionSupport()) {
102 if (!usingFFVertexArray) {
103 if (!fFixedFunctionVertexArray.fEnableIsValid || fFixedFunctionVerte xArray.fEnabled) {
104 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_VERTEX_A RRAY));
105 fFixedFunctionVertexArray.fEnableIsValid = true;
106 fFixedFunctionVertexArray.fEnabled = false;
107 }
108 } else {
109 SkASSERT(fFixedFunctionVertexArray.fEnableIsValid && fFixedFunctionV ertexArray.fEnabled);
110 }
111 // When we use fixed function vertex processing we always use the vertex array and none of
112 // the other arrays.
113 if (!fUnusedFixedFunctionArraysDisabled) {
114 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_NORMAL_ARRAY ));
115 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_COLOR_ARRAY) );
116 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_SECONDARY_CO LOR_ARRAY));
117 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_INDEX_ARRAY) );
118 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_EDGE_FLAG_AR RAY));
119 for (int i = 0; i < gpu->glCaps().maxFixedFunctionTextureCoords(); + +i) {
120 GR_GL_CALL(gpu->glInterface(), ClientActiveTexture(GR_GL_TEXTURE 0 + i));
121 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_TEXTURE_ COORD_ARRAY));
122 }
123 fUnusedFixedFunctionArraysDisabled = true;
124 }
125 } else {
126 SkASSERT(!usingFFVertexArray);
127 }
65 } 128 }
66 129
67 //////////////////////////////////////////////////////////////////////////////// /////////////////// 130 //////////////////////////////////////////////////////////////////////////////// ///////////////////
68 131
69 GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount) 132 GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount)
70 : GrResource(gpu, false) 133 : GrResource(gpu, false)
71 , fID(id) 134 , fID(id)
72 , fAttribArrays(attribCount) 135 , fAttribArrays(attribCount)
73 , fIndexBufferIDIsValid(false) { 136 , fIndexBufferIDIsValid(false) {
74 } 137 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return state; 171 return state;
109 } 172 }
110 173
111 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { 174 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
112 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { 175 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
113 fIndexBufferID = 0; 176 fIndexBufferID = 0;
114 } 177 }
115 } 178 }
116 179
117 void GrGLVertexArray::invalidateCachedState() { 180 void GrGLVertexArray::invalidateCachedState() {
118 int count = fAttribArrays.count(); 181 fAttribArrays.invalidate();
119 for (int i = 0; i < count; ++i) {
120 fAttribArrays.invalidate();
121 }
122 fIndexBufferIDIsValid = false; 182 fIndexBufferIDIsValid = false;
123 } 183 }
OLDNEW
« 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