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

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

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