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

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

Issue 1870553002: Revert of Track GL buffer state based on unique resource ID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | src/gpu/gl/GrGLVertexArray.cpp » ('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 #ifndef GrGLVertexArray_DEFINED 8 #ifndef GrGLVertexArray_DEFINED
9 #define GrGLVertexArray_DEFINED 9 #define GrGLVertexArray_DEFINED
10 10
11 #include "GrTypesPriv.h" 11 #include "GrTypesPriv.h"
12 #include "gl/GrGLDefines.h" 12 #include "gl/GrGLDefines.h"
13 #include "gl/GrGLTypes.h" 13 #include "gl/GrGLTypes.h"
14 #include "SkTArray.h" 14 #include "SkTArray.h"
15 15
16 class GrGLBuffer;
17 class GrGLGpu; 16 class GrGLGpu;
18 17
19 /** 18 /**
20 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray 19 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray
21 * (below) but is separate because it is also used to track the state of vertex array object 0. 20 * (below) but is separate because it is also used to track the state of vertex array object 0.
22 */ 21 */
23 class GrGLAttribArrayState { 22 class GrGLAttribArrayState {
24 public: 23 public:
25 explicit GrGLAttribArrayState(int arrayCount = 0) { 24 explicit GrGLAttribArrayState(int arrayCount = 0) {
26 this->resize(arrayCount); 25 this->resize(arrayCount);
27 } 26 }
28 27
29 void resize(int newCount) { 28 void resize(int newCount) {
30 fAttribArrayStates.resize_back(newCount); 29 fAttribArrayStates.resize_back(newCount);
31 for (int i = 0; i < newCount; ++i) { 30 for (int i = 0; i < newCount; ++i) {
32 fAttribArrayStates[i].invalidate(); 31 fAttribArrayStates[i].invalidate();
33 } 32 }
34 } 33 }
35 34
36 /** 35 /**
37 * This function enables and sets vertex attrib state for the specified attr ib index. It is 36 * This function enables and sets vertex attrib state for the specified attr ib index. It is
38 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex 37 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex
39 * array object. 38 * array object.
40 */ 39 */
41 void set(GrGLGpu*, 40 void set(GrGLGpu*,
42 int attribIndex, 41 int attribIndex,
43 const GrGLBuffer* vertexBuffer, 42 GrGLuint vertexBufferID,
44 GrVertexAttribType type, 43 GrVertexAttribType type,
45 GrGLsizei stride, 44 GrGLsizei stride,
46 GrGLvoid* offset); 45 GrGLvoid* offset);
47 46
48 /** 47 /**
49 * This function disables vertex attribs not present in the mask. It is assu med that the 48 * This function disables vertex attribs not present in the mask. It is assu med that the
50 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object. 49 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object.
51 */ 50 */
52 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask); 51 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask);
53 52
54 void invalidate() { 53 void invalidate() {
55 int count = fAttribArrayStates.count(); 54 int count = fAttribArrayStates.count();
56 for (int i = 0; i < count; ++i) { 55 for (int i = 0; i < count; ++i) {
57 fAttribArrayStates[i].invalidate(); 56 fAttribArrayStates[i].invalidate();
58 } 57 }
59 } 58 }
60 59
60 void notifyVertexBufferDelete(GrGLuint id) {
61 int count = fAttribArrayStates.count();
62 for (int i = 0; i < count; ++i) {
63 if (fAttribArrayStates[i].fAttribPointerIsValid &&
64 id == fAttribArrayStates[i].fVertexBufferID) {
65 fAttribArrayStates[i].invalidate();
66 }
67 }
68 }
69
61 /** 70 /**
62 * The number of attrib arrays that this object is configured to track. 71 * The number of attrib arrays that this object is configured to track.
63 */ 72 */
64 int count() const { return fAttribArrayStates.count(); } 73 int count() const { return fAttribArrayStates.count(); }
65 74
66 private: 75 private:
67 /** 76 /**
68 * Tracks the state of glVertexAttribArray for an attribute index. 77 * Tracks the state of glVertexAttribArray for an attribute index.
69 */ 78 */
70 struct AttribArrayState { 79 struct AttribArrayState {
71 void invalidate() { 80 void invalidate() {
72 fEnableIsValid = false; 81 fEnableIsValid = false;
73 fVertexBufferUniqueID = SK_InvalidUniqueID; 82 fAttribPointerIsValid = false;
74 } 83 }
75 84
76 bool fEnableIsValid; 85 bool fEnableIsValid;
86 bool fAttribPointerIsValid;
77 bool fEnabled; 87 bool fEnabled;
78 uint32_t fVertexBufferUniqueID; 88 GrGLuint fVertexBufferID;
79 GrVertexAttribType fType; 89 GrVertexAttribType fType;
80 GrGLsizei fStride; 90 GrGLsizei fStride;
81 GrGLvoid* fOffset; 91 GrGLvoid* fOffset;
82 }; 92 };
83 93
84 SkSTArray<16, AttribArrayState, true> fAttribArrayStates; 94 SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
85 }; 95 };
86 96
87 /** 97 /**
88 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array 98 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
89 * and is used to track the state of the vertex array to avoid redundant GL call s. 99 * and is used to track the state of the vertex array to avoid redundant GL call s.
90 */ 100 */
91 class GrGLVertexArray { 101 class GrGLVertexArray {
92 public: 102 public:
93 GrGLVertexArray(GrGLint id, int attribCount); 103 GrGLVertexArray(GrGLint id, int attribCount);
94 104
95 /** 105 /**
96 * Binds this vertex array. If the ID has been deleted or abandoned then nul lptr is returned. 106 * Binds this vertex array. If the ID has been deleted or abandoned then nul lptr is returned.
97 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's attrib bindings is 107 * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's attrib bindings is
98 * returned. 108 * returned.
99 */ 109 */
100 GrGLAttribArrayState* bind(GrGLGpu*); 110 GrGLAttribArrayState* bind(GrGLGpu*);
101 111
102 /** 112 /**
103 * This is a version of the above function that also binds an index buffer t o the vertex 113 * This is a version of the above function that also binds an index buffer t o the vertex
104 * array object. 114 * array object.
105 */ 115 */
106 GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, const GrGLBuffer* in dexBuffer); 116 GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, GrGLuint indexBuffer ID);
117
118 void notifyIndexBufferDelete(GrGLuint bufferID);
119
120 void notifyVertexBufferDelete(GrGLuint id) {
121 fAttribArrays.notifyVertexBufferDelete(id);
122 }
107 123
108 GrGLuint arrayID() const { return fID; } 124 GrGLuint arrayID() const { return fID; }
109 125
110 void invalidateCachedState(); 126 void invalidateCachedState();
111 127
112 private: 128 private:
113 GrGLuint fID; 129 GrGLuint fID;
114 GrGLAttribArrayState fAttribArrays; 130 GrGLAttribArrayState fAttribArrays;
115 uint32_t fIndexBufferUniqueID; 131 GrGLuint fIndexBufferID;
132 bool fIndexBufferIDIsValid;
116 }; 133 };
117 134
118 #endif 135 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | src/gpu/gl/GrGLVertexArray.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698