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

Side by Side Diff: src/gpu/gl/GrGLVertexArray.h

Issue 23542013: Improve handling of FF vertex array state (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « no previous file | src/gpu/gl/GrGLVertexArray.cpp » ('j') | src/gpu/gl/GrGpuGL.h » ('J')
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 #ifndef GrGLVertexArray_DEFINED 8 #ifndef GrGLVertexArray_DEFINED
9 #define GrGLVertexArray_DEFINED 9 #define GrGLVertexArray_DEFINED
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount); 42 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount);
43 return kLayouts[type]; 43 return kLayouts[type];
44 } 44 }
45 45
46 /** 46 /**
47 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray 47 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray
48 * (below) but is separate because it is also used to track the state of vertex array object 0. 48 * (below) but is separate because it is also used to track the state of vertex array object 0.
49 */ 49 */
50 class GrGLAttribArrayState { 50 class GrGLAttribArrayState {
51 public: 51 public:
52 explicit GrGLAttribArrayState(int arrayCount = 0) { this->resize(arrayCount) ; } 52 explicit GrGLAttribArrayState(int arrayCount = 0) {
53 this->resize(arrayCount);
54 // glVertexPointer doesn't have a normalization param.
55 fFixedFunctionVertexArray.fNormalized = false;
56 fUnusedFixedFunctionArraysDisabled = false;
57 }
53 58
54 void resize(int newCount) { 59 void resize(int newCount) {
55 fAttribArrayStates.resize_back(newCount); 60 fAttribArrayStates.resize_back(newCount);
56 for (int i = 0; i < newCount; ++i) { 61 for (int i = 0; i < newCount; ++i) {
57 fAttribArrayStates[i].invalidate(); 62 fAttribArrayStates[i].invalidate();
58 } 63 }
59 } 64 }
60 65
61 /** 66 /**
62 * This function enables and sets vertex attrib state for the specified attr ib index. It is 67 * This function enables and sets vertex attrib state for the specified attr ib index. It is
63 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex 68 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex
64 * array object. 69 * array object.
65 */ 70 */
66 void set(const GrGpuGL*, 71 void set(const GrGpuGL*,
67 int index, 72 int index,
68 GrGLVertexBuffer*, 73 GrGLVertexBuffer*,
69 GrGLint size, 74 GrGLint size,
70 GrGLenum type, 75 GrGLenum type,
71 GrGLboolean normalized, 76 GrGLboolean normalized,
72 GrGLsizei stride, 77 GrGLsizei stride,
73 GrGLvoid* offset); 78 GrGLvoid* offset);
74 79
80 void setFixedFunctionVertexArray(const GrGpuGL*,
81 GrGLVertexBuffer*,
82 GrGLint size,
83 GrGLenum type,
84 GrGLsizei stride,
85 GrGLvoid* offset);
86
75 /** 87 /**
76 * This function disables vertex attribs not present in the mask. It is assu med that the 88 * This function disables vertex attribs not present in the mask. It is assu med that the
77 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object. 89 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object.
78 */ 90 */
79 void disableUnusedAttribArrays(const GrGpuGL*, uint64_t usedAttribArrayMask) ; 91 void disableUnusedArrays(const GrGpuGL*, uint64_t usedAttribArrayMask, bool usingFFVertexArray);
80 92
81 void invalidate() { 93 void invalidate() {
82 int count = fAttribArrayStates.count(); 94 int count = fAttribArrayStates.count();
83 for (int i = 0; i < count; ++i) { 95 for (int i = 0; i < count; ++i) {
84 fAttribArrayStates[i].invalidate(); 96 fAttribArrayStates[i].invalidate();
85 } 97 }
98 fFixedFunctionVertexArray.invalidate();
robertphillips 2013/09/09 13:53:33 Does this really need to get reset here (fUnusedFi
bsalomon 2013/09/09 14:11:44 I think so... this comes from onResetContext(). Th
99 fUnusedFixedFunctionArraysDisabled = false;
86 } 100 }
87 101
88 void notifyVertexBufferDelete(GrGLuint id) { 102 void notifyVertexBufferDelete(GrGLuint id) {
89 int count = fAttribArrayStates.count(); 103 int count = fAttribArrayStates.count();
90 for (int i = 0; i < count; ++i) { 104 for (int i = 0; i < count; ++i) {
91 if (fAttribArrayStates[i].fAttribPointerIsValid && 105 if (fAttribArrayStates[i].fAttribPointerIsValid &&
92 id == fAttribArrayStates[i].fVertexBufferID) { 106 id == fAttribArrayStates[i].fVertexBufferID) {
93 fAttribArrayStates[i].invalidate(); 107 fAttribArrayStates[i].invalidate();
94 } 108 }
95 } 109 }
110 if (fFixedFunctionVertexArray.fAttribPointerIsValid &&
111 id == fFixedFunctionVertexArray.fVertexBufferID) {
112 fFixedFunctionVertexArray.invalidate();
113 }
96 } 114 }
97 115
98 /** 116 /**
99 * The number of attrib arrays that this object is configured to track. 117 * The number of attrib arrays that this object is configured to track.
100 */ 118 */
101 int count() const { return fAttribArrayStates.count(); } 119 int count() const { return fAttribArrayStates.count(); }
102 120
103 private: 121 private:
104 /** 122 /**
105 * Tracks the state of glVertexAttribArray for an attribute index. 123 * Tracks the state of glVertexAttribArray for an attribute index.
106 */ 124 */
107 struct AttribArrayState { 125 struct AttribArrayState {
108 void invalidate() { 126 void invalidate() {
109 fEnableIsValid = false; 127 fEnableIsValid = false;
110 fAttribPointerIsValid = false; 128 fAttribPointerIsValid = false;
111 } 129 }
112 130
113 bool fEnableIsValid; 131 bool fEnableIsValid;
114 bool fAttribPointerIsValid; 132 bool fAttribPointerIsValid;
115 bool fEnabled; 133 bool fEnabled;
116 GrGLuint fVertexBufferID; 134 GrGLuint fVertexBufferID;
117 GrGLint fSize; 135 GrGLint fSize;
118 GrGLenum fType; 136 GrGLenum fType;
119 GrGLboolean fNormalized; 137 GrGLboolean fNormalized;
120 GrGLsizei fStride; 138 GrGLsizei fStride;
121 GrGLvoid* fOffset; 139 GrGLvoid* fOffset;
122 }; 140 };
123 141
124 SkSTArray<16, AttribArrayState, true> fAttribArrayStates; 142 SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
143
144 // Tracks the array specified by glVertexPointer.
145 AttribArrayState fFixedFunctionVertexArray;
146
robertphillips 2013/09/09 13:53:33 // informative comment?
bsalomon 2013/09/09 14:11:44 Done.
147 bool fUnusedFixedFunctionArraysDisabled;
125 }; 148 };
126 149
127 /** 150 /**
128 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array 151 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
129 * and is used to track the state of the vertex array to avoid redundant GL call s. 152 * and is used to track the state of the vertex array to avoid redundant GL call s.
130 */ 153 */
131 class GrGLVertexArray : public GrResource { 154 class GrGLVertexArray : public GrResource {
132 public: 155 public:
133 GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount); 156 GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount);
134 157
(...skipping 30 matching lines...) Expand all
165 private: 188 private:
166 GrGLuint fID; 189 GrGLuint fID;
167 GrGLAttribArrayState fAttribArrays; 190 GrGLAttribArrayState fAttribArrays;
168 GrGLuint fIndexBufferID; 191 GrGLuint fIndexBufferID;
169 bool fIndexBufferIDIsValid; 192 bool fIndexBufferIDIsValid;
170 193
171 typedef GrResource INHERITED; 194 typedef GrResource INHERITED;
172 }; 195 };
173 196
174 #endif 197 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLVertexArray.cpp » ('j') | src/gpu/gl/GrGpuGL.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698