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

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

Issue 1669853002: Improve GLSL integer support (Closed) Base URL: https://skia.googlesource.com/skia.git@uploat_dratindirect
Patch Set: rebase Created 4 years, 10 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/GrGLNoOpInterface.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 GrGLVertexBuffer; 16 class GrGLVertexBuffer;
17 class GrGLIndexBuffer; 17 class GrGLIndexBuffer;
18 class GrGLGpu; 18 class GrGLGpu;
19 19
20 struct GrGLAttribLayout {
21 GrGLint fCount;
22 GrGLenum fType;
23 GrGLboolean fNormalized;
24 };
25
26 static inline const GrGLAttribLayout& GrGLAttribTypeToLayout(GrVertexAttribType type) {
27 static const GrGLAttribLayout kLayouts[kGrVertexAttribTypeCount] = {
28 {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType
29 {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType
30 {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType
31 {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType
32 {1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType
33 {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType
34 {2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType
35 {4, GR_GL_INT, false}, // kInt_GrVertexAttribType
36 };
37 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
38 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
39 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
40 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
41 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
42 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
43 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
44 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
45 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayouts) == kGrVertexAttribTypeCount);
46 return kLayouts[type];
47 }
48
49 /** 20 /**
50 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray 21 * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray
51 * (below) but is separate because it is also used to track the state of vertex array object 0. 22 * (below) but is separate because it is also used to track the state of vertex array object 0.
52 */ 23 */
53 class GrGLAttribArrayState { 24 class GrGLAttribArrayState {
54 public: 25 public:
55 explicit GrGLAttribArrayState(int arrayCount = 0) { 26 explicit GrGLAttribArrayState(int arrayCount = 0) {
56 this->resize(arrayCount); 27 this->resize(arrayCount);
57 } 28 }
58 29
59 void resize(int newCount) { 30 void resize(int newCount) {
60 fAttribArrayStates.resize_back(newCount); 31 fAttribArrayStates.resize_back(newCount);
61 for (int i = 0; i < newCount; ++i) { 32 for (int i = 0; i < newCount; ++i) {
62 fAttribArrayStates[i].invalidate(); 33 fAttribArrayStates[i].invalidate();
63 } 34 }
64 } 35 }
65 36
66 /** 37 /**
67 * This function enables and sets vertex attrib state for the specified attr ib index. It is 38 * This function enables and sets vertex attrib state for the specified attr ib index. It is
68 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex 39 * assumed that the GrGLAttribArrayState is tracking the state of the curren tly bound vertex
69 * array object. 40 * array object.
70 */ 41 */
71 void set(GrGLGpu*, 42 void set(GrGLGpu*,
72 int attribIndex, 43 int attribIndex,
73 GrGLuint vertexBufferID, 44 GrGLuint vertexBufferID,
74 GrGLint size, 45 GrVertexAttribType type,
75 GrGLenum type,
76 GrGLboolean normalized,
77 GrGLsizei stride, 46 GrGLsizei stride,
78 GrGLvoid* offset); 47 GrGLvoid* offset);
79 48
80 /** 49 /**
81 * This function disables vertex attribs not present in the mask. It is assu med that the 50 * This function disables vertex attribs not present in the mask. It is assu med that the
82 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object. 51 * GrGLAttribArrayState is tracking the state of the currently bound vertex array object.
83 */ 52 */
84 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask); 53 void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask);
85 54
86 void invalidate() { 55 void invalidate() {
(...skipping 21 matching lines...) Expand all
108 private: 77 private:
109 /** 78 /**
110 * Tracks the state of glVertexAttribArray for an attribute index. 79 * Tracks the state of glVertexAttribArray for an attribute index.
111 */ 80 */
112 struct AttribArrayState { 81 struct AttribArrayState {
113 void invalidate() { 82 void invalidate() {
114 fEnableIsValid = false; 83 fEnableIsValid = false;
115 fAttribPointerIsValid = false; 84 fAttribPointerIsValid = false;
116 } 85 }
117 86
118 bool fEnableIsValid; 87 bool fEnableIsValid;
119 bool fAttribPointerIsValid; 88 bool fAttribPointerIsValid;
120 bool fEnabled; 89 bool fEnabled;
121 GrGLuint fVertexBufferID; 90 GrGLuint fVertexBufferID;
122 GrGLint fSize; 91 GrVertexAttribType fType;
123 GrGLenum fType; 92 GrGLsizei fStride;
124 GrGLboolean fNormalized; 93 GrGLvoid* fOffset;
125 GrGLsizei fStride;
126 GrGLvoid* fOffset;
127 }; 94 };
128 95
129 SkSTArray<16, AttribArrayState, true> fAttribArrayStates; 96 SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
130 }; 97 };
131 98
132 /** 99 /**
133 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array 100 * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
134 * and is used to track the state of the vertex array to avoid redundant GL call s. 101 * and is used to track the state of the vertex array to avoid redundant GL call s.
135 */ 102 */
136 class GrGLVertexArray { 103 class GrGLVertexArray {
(...skipping 24 matching lines...) Expand all
161 void invalidateCachedState(); 128 void invalidateCachedState();
162 129
163 private: 130 private:
164 GrGLuint fID; 131 GrGLuint fID;
165 GrGLAttribArrayState fAttribArrays; 132 GrGLAttribArrayState fAttribArrays;
166 GrGLuint fIndexBufferID; 133 GrGLuint fIndexBufferID;
167 bool fIndexBufferIDIsValid; 134 bool fIndexBufferIDIsValid;
168 }; 135 };
169 136
170 #endif 137 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLNoOpInterface.cpp ('k') | src/gpu/gl/GrGLVertexArray.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698