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

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

Issue 2301523003: Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids (Closed)
Patch Set: update to ToT Created 4 years, 3 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/GrGLTextureRenderTarget.cpp ('k') | src/gpu/instanced/GLInstancedRendering.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 "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGpu.h" 10 #include "GrGLGpu.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 GrVertexAttribType type, 43 GrVertexAttribType type,
44 GrGLsizei stride, 44 GrGLsizei stride,
45 GrGLvoid* offset) { 45 GrGLvoid* offset) {
46 SkASSERT(index >= 0 && index < fAttribArrayStates.count()); 46 SkASSERT(index >= 0 && index < fAttribArrayStates.count());
47 AttribArrayState* array = &fAttribArrayStates[index]; 47 AttribArrayState* array = &fAttribArrayStates[index];
48 if (!array->fEnableIsValid || !array->fEnabled) { 48 if (!array->fEnableIsValid || !array->fEnabled) {
49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index)); 49 GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
50 array->fEnableIsValid = true; 50 array->fEnableIsValid = true;
51 array->fEnabled = true; 51 array->fEnabled = true;
52 } 52 }
53 if (array->fVertexBufferUniqueID != vertexBuffer->getUniqueID() || 53 if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
54 array->fType != type || 54 array->fType != type ||
55 array->fStride != stride || 55 array->fStride != stride ||
56 array->fOffset != offset) { 56 array->fOffset != offset) {
57 gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer); 57 gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
58 const AttribLayout& layout = gLayouts[type]; 58 const AttribLayout& layout = gLayouts[type];
59 if (!GrVertexAttribTypeIsIntType(type)) { 59 if (!GrVertexAttribTypeIsIntType(type)) {
60 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index, 60 GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
61 layout.fCount, 61 layout.fCount,
62 layout.fType, 62 layout.fType,
63 layout.fNormalize d, 63 layout.fNormalize d,
64 stride, 64 stride,
65 offset)); 65 offset));
66 } else { 66 } else {
67 SkASSERT(gpu->caps()->shaderCaps()->integerSupport()); 67 SkASSERT(gpu->caps()->shaderCaps()->integerSupport());
68 SkASSERT(!layout.fNormalized); 68 SkASSERT(!layout.fNormalized);
69 GR_GL_CALL(gpu->glInterface(), VertexAttribIPointer(index, 69 GR_GL_CALL(gpu->glInterface(), VertexAttribIPointer(index,
70 layout.fCount, 70 layout.fCount,
71 layout.fType, 71 layout.fType,
72 stride, 72 stride,
73 offset)); 73 offset));
74 } 74 }
75 array->fVertexBufferUniqueID = vertexBuffer->getUniqueID(); 75 array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
76 array->fType = type; 76 array->fType = type;
77 array->fStride = stride; 77 array->fStride = stride;
78 array->fOffset = offset; 78 array->fOffset = offset;
79 } 79 }
80 } 80 }
81 81
82 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) { 82 void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used Mask) {
83 int count = fAttribArrayStates.count(); 83 int count = fAttribArrayStates.count();
84 for (int i = 0; i < count; ++i) { 84 for (int i = 0; i < count; ++i) {
85 if (!(usedMask & 0x1)) { 85 if (!(usedMask & 0x1)) {
(...skipping 21 matching lines...) Expand all
107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) { 107 GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
108 if (0 == fID) { 108 if (0 == fID) {
109 return nullptr; 109 return nullptr;
110 } 110 }
111 gpu->bindVertexArray(fID); 111 gpu->bindVertexArray(fID);
112 return &fAttribArrays; 112 return &fAttribArrays;
113 } 113 }
114 114
115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G rBuffer* ibuff) { 115 GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu, const G rBuffer* ibuff) {
116 GrGLAttribArrayState* state = this->bind(gpu); 116 GrGLAttribArrayState* state = this->bind(gpu);
117 if (state && fIndexBufferUniqueID != ibuff->getUniqueID()) { 117 if (state && fIndexBufferUniqueID != ibuff->uniqueID()) {
118 if (ibuff->isCPUBacked()) { 118 if (ibuff->isCPUBacked()) {
119 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , 0)); 119 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , 0));
120 } else { 120 } else {
121 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(ibuff); 121 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(ibuff);
122 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER , 122 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER ,
123 glBuffer->bufferID())); 123 glBuffer->bufferID()));
124 } 124 }
125 fIndexBufferUniqueID = ibuff->getUniqueID(); 125 fIndexBufferUniqueID = ibuff->uniqueID();
126 } 126 }
127 return state; 127 return state;
128 } 128 }
129 129
130 void GrGLVertexArray::invalidateCachedState() { 130 void GrGLVertexArray::invalidateCachedState() {
131 fAttribArrays.invalidate(); 131 fAttribArrays.invalidate();
132 fIndexBufferUniqueID = SK_InvalidUniqueID; 132 fIndexBufferUniqueID = SK_InvalidUniqueID;
133 } 133 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLTextureRenderTarget.cpp ('k') | src/gpu/instanced/GLInstancedRendering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698