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

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

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/GrGLVertexArray.h ('k') | src/gpu/gl/SkNullGLContext.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 #include "GrGLVertexArray.h" 8 #include "GrGLVertexArray.h"
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 10
11 struct AttribLayout {
12 GrGLint fCount;
13 GrGLenum fType;
14 GrGLboolean fNormalized; // Only used by floating point types.
15 };
11 16
17 static const AttribLayout gLayouts[kGrVertexAttribTypeCount] = {
18 {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType
19 {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType
20 {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType
21 {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType
22 {1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType
23 {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType
24 {2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType
25 {1, GR_GL_INT, false}, // kInt_GrVertexAttribType
26 {1, GR_GL_UNSIGNED_INT, false}, // kUint_GrVertexAttribType
27 };
28
29 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
30 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
31 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
32 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
33 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
34 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
35 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
36 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
37 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
12 38
13 void GrGLAttribArrayState::set(GrGLGpu* gpu, 39 void GrGLAttribArrayState::set(GrGLGpu* gpu,
14 int index, 40 int index,
15 GrGLuint vertexBufferID, 41 GrGLuint vertexBufferID,
16 GrGLint size, 42 GrVertexAttribType type,
17 GrGLenum type,
18 GrGLboolean normalized,
19 GrGLsizei stride, 43 GrGLsizei stride,
20 GrGLvoid* offset) { 44 GrGLvoid* offset) {
21 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); 45 SkASSERT(index >= 0 && index < fAttribArrayStates.count());
22 AttribArrayState* array = &fAttribArrayStates[index]; 46 AttribArrayState* array = &fAttribArrayStates[index];
23 if (!array->fEnableIsValid || !array->fEnabled) { 47 if (!array->fEnableIsValid || !array->fEnabled) {
24 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); 48 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
25 array->fEnableIsValid = true; 49 array->fEnableIsValid = true;
26 array->fEnabled = true; 50 array->fEnabled = true;
27 } 51 }
28 if (!array->fAttribPointerIsValid || 52 if (!array->fAttribPointerIsValid ||
29 array->fVertexBufferID != vertexBufferID || 53 array->fVertexBufferID != vertexBufferID ||
30 array->fSize != size || 54 array->fType != type ||
31 array->fNormalized != normalized ||
32 array->fStride != stride || 55 array->fStride != stride ||
33 array->fOffset != offset) { 56 array->fOffset != offset) {
34 57
35 gpu->bindVertexBuffer(vertexBufferID); 58 gpu->bindVertexBuffer(vertexBufferID);
36 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index, 59 const AttribLayout& layout = gLayouts[type];
37 size, 60 if (!GrVertexAttribTypeIsIntType(type)) {
38 type, 61 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
39 normalized, 62 layout.fCount,
40 stride, 63 layout.fType,
41 offset)); 64 layout.fNormalize d,
65 stride,
66 offset));
67 } else {
68 SkASSERT(gpu->caps()->shaderCaps()->integerSupport());
69 SkASSERT(!layout.fNormalized);
70 GR_GL_CALL(gpu->glInterface(), VertexAttribIPointer(index,
71 layout.fCount,
72 layout.fType,
73 stride,
74 offset));
75 }
42 array->fAttribPointerIsValid = true; 76 array->fAttribPointerIsValid = true;
43 array->fVertexBufferID = vertexBufferID; 77 array->fVertexBufferID = vertexBufferID;
44 array->fSize = size; 78 array->fType = type;
45 array->fNormalized = normalized;
46 array->fStride = stride; 79 array->fStride = stride;
47 array->fOffset = offset; 80 array->fOffset = offset;
48 } 81 }
49 } 82 }
50 83
51 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) { 84 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) {
52 int count = fAttribArrayStates.count(); 85 int count = fAttribArrayStates.count();
53 for (int i = 0; i < count; ++i) { 86 for (int i = 0; i < count; ++i) {
54 if (!(usedMask & 0x1)) { 87 if (!(usedMask & 0x1)) {
55 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) { 88 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { 129 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
97 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { 130 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
98 fIndexBufferID = 0; 131 fIndexBufferID = 0;
99 } 132 }
100 } 133 }
101 134
102 void GrGLVertexArray::invalidateCachedState() { 135 void GrGLVertexArray::invalidateCachedState() {
103 fAttribArrays.invalidate(); 136 fAttribArrays.invalidate();
104 fIndexBufferIDIsValid = false; 137 fIndexBufferIDIsValid = false;
105 } 138 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/SkNullGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698