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

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

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/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 };
16 11
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);
38 12
39 void GrGLAttribArrayState::set(GrGLGpu* gpu, 13 void GrGLAttribArrayState::set(GrGLGpu* gpu,
40 int index, 14 int index,
41 GrGLuint vertexBufferID, 15 GrGLuint vertexBufferID,
42 GrVertexAttribType type, 16 GrGLint size,
17 GrGLenum type,
18 GrGLboolean normalized,
43 GrGLsizei stride, 19 GrGLsizei stride,
44 GrGLvoid* offset) { 20 GrGLvoid* offset) {
45 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); 21 SkASSERT(index >= 0 && index < fAttribArrayStates.count());
46 AttribArrayState* array = &fAttribArrayStates[index]; 22 AttribArrayState* array = &fAttribArrayStates[index];
47 if (!array->fEnableIsValid || !array->fEnabled) { 23 if (!array->fEnableIsValid || !array->fEnabled) {
48 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); 24 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
49 array->fEnableIsValid = true; 25 array->fEnableIsValid = true;
50 array->fEnabled = true; 26 array->fEnabled = true;
51 } 27 }
52 if (!array->fAttribPointerIsValid || 28 if (!array->fAttribPointerIsValid ||
53 array->fVertexBufferID != vertexBufferID || 29 array->fVertexBufferID != vertexBufferID ||
54 array->fType != type || 30 array->fSize != size ||
31 array->fNormalized != normalized ||
55 array->fStride != stride || 32 array->fStride != stride ||
56 array->fOffset != offset) { 33 array->fOffset != offset) {
57 34
58 gpu->bindVertexBuffer(vertexBufferID); 35 gpu->bindVertexBuffer(vertexBufferID);
59 const AttribLayout& layout = gLayouts[type]; 36 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
60 if (!GrVertexAttribTypeIsIntType(type)) { 37 size,
61 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index, 38 type,
62 layout.fCount, 39 normalized,
63 layout.fType, 40 stride,
64 layout.fNormalize d, 41 offset));
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 }
76 array->fAttribPointerIsValid = true; 42 array->fAttribPointerIsValid = true;
77 array->fVertexBufferID = vertexBufferID; 43 array->fVertexBufferID = vertexBufferID;
78 array->fType = type; 44 array->fSize = size;
45 array->fNormalized = normalized;
46 array->fStride = stride;
79 array->fOffset = offset; 47 array->fOffset = offset;
80 } 48 }
81 } 49 }
82 50
83 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) { 51 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) {
84 int count = fAttribArrayStates.count(); 52 int count = fAttribArrayStates.count();
85 for (int i = 0; i < count; ++i) { 53 for (int i = 0; i < count; ++i) {
86 if (!(usedMask & 0x1)) { 54 if (!(usedMask & 0x1)) {
87 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) { 55 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f Enabled) {
88 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); 56 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { 96 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) {
129 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { 97 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) {
130 fIndexBufferID = 0; 98 fIndexBufferID = 0;
131 } 99 }
132 } 100 }
133 101
134 void GrGLVertexArray::invalidateCachedState() { 102 void GrGLVertexArray::invalidateCachedState() {
135 fAttribArrays.invalidate(); 103 fAttribArrays.invalidate();
136 fIndexBufferIDIsValid = false; 104 fIndexBufferIDIsValid = false;
137 } 105 }
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