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

Side by Side Diff: src/gpu/instanced/GLInstancedRendering.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/GrGLVertexArray.cpp ('k') | src/gpu/text/GrStencilAndCoverTextContext.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 2016 Google Inc. 2 * Copyright 2016 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 "GLInstancedRendering.h" 8 #include "GLInstancedRendering.h"
9 9
10 #include "GrResourceProvider.h" 10 #include "GrResourceProvider.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 emulatedBaseInstance += cmdInfo.fInstanceCount; 257 emulatedBaseInstance += cmdInfo.fInstanceCount;
258 } 258 }
259 } 259 }
260 } 260 }
261 261
262 void GLInstancedRendering::flushInstanceAttribs(int baseInstance) { 262 void GLInstancedRendering::flushInstanceAttribs(int baseInstance) {
263 SkASSERT(fVertexArrayID); 263 SkASSERT(fVertexArrayID);
264 this->glGpu()->bindVertexArray(fVertexArrayID); 264 this->glGpu()->bindVertexArray(fVertexArrayID);
265 265
266 SkASSERT(fInstanceBuffer); 266 SkASSERT(fInstanceBuffer);
267 if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->getUniqueID() || 267 if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() ||
268 fInstanceAttribsBaseInstance != baseInstance) { 268 fInstanceAttribsBaseInstance != baseInstance) {
269 Instance* offsetInBuffer = (Instance*) nullptr + baseInstance; 269 Instance* offsetInBuffer = (Instance*) nullptr + baseInstance;
270 270
271 this->glGpu()->bindBuffer(kVertex_GrBufferType, fInstanceBuffer.get()); 271 this->glGpu()->bindBuffer(kVertex_GrBufferType, fInstanceBuffer.get());
272 272
273 // Info attrib. 273 // Info attrib.
274 GL_CALL(EnableVertexAttribArray((int)Attrib::kInstanceInfo)); 274 GL_CALL(EnableVertexAttribArray((int)Attrib::kInstanceInfo));
275 GL_CALL(VertexAttribIPointer((int)Attrib::kInstanceInfo, 1, GR_GL_UNSIGN ED_INT, 275 GL_CALL(VertexAttribIPointer((int)Attrib::kInstanceInfo, 1, GR_GL_UNSIGN ED_INT,
276 sizeof(Instance), &offsetInBuffer->fInfo)); 276 sizeof(Instance), &offsetInBuffer->fInfo));
277 GL_CALL(VertexAttribDivisor((int)Attrib::kInstanceInfo, 1)); 277 GL_CALL(VertexAttribDivisor((int)Attrib::kInstanceInfo, 1));
(...skipping 13 matching lines...) Expand all
291 GL_CALL(VertexAttribPointer((int)Attrib::kColor, 4, GR_GL_UNSIGNED_BYTE, GR_GL_TRUE, 291 GL_CALL(VertexAttribPointer((int)Attrib::kColor, 4, GR_GL_UNSIGNED_BYTE, GR_GL_TRUE,
292 sizeof(Instance), &offsetInBuffer->fColor)); 292 sizeof(Instance), &offsetInBuffer->fColor));
293 GL_CALL(VertexAttribDivisor((int)Attrib::kColor, 1)); 293 GL_CALL(VertexAttribDivisor((int)Attrib::kColor, 1));
294 294
295 // Local rect attrib. 295 // Local rect attrib.
296 GL_CALL(EnableVertexAttribArray((int)Attrib::kLocalRect)); 296 GL_CALL(EnableVertexAttribArray((int)Attrib::kLocalRect));
297 GL_CALL(VertexAttribPointer((int)Attrib::kLocalRect, 4, GR_GL_FLOAT, GR_ GL_FALSE, 297 GL_CALL(VertexAttribPointer((int)Attrib::kLocalRect, 4, GR_GL_FLOAT, GR_ GL_FALSE,
298 sizeof(Instance), &offsetInBuffer->fLocalRec t)); 298 sizeof(Instance), &offsetInBuffer->fLocalRec t));
299 GL_CALL(VertexAttribDivisor((int)Attrib::kLocalRect, 1)); 299 GL_CALL(VertexAttribDivisor((int)Attrib::kLocalRect, 1));
300 300
301 fInstanceAttribsBufferUniqueId = fInstanceBuffer->getUniqueID(); 301 fInstanceAttribsBufferUniqueId = fInstanceBuffer->uniqueID();
302 fInstanceAttribsBaseInstance = baseInstance; 302 fInstanceAttribsBaseInstance = baseInstance;
303 } 303 }
304 } 304 }
305 305
306 void GLInstancedRendering::onEndFlush() { 306 void GLInstancedRendering::onEndFlush() {
307 fInstanceBuffer.reset(); 307 fInstanceBuffer.reset();
308 fDrawIndirectBuffer.reset(); 308 fDrawIndirectBuffer.reset();
309 fGLDrawCmdsInfo.reset(0); 309 fGLDrawCmdsInfo.reset(0);
310 } 310 }
311 311
312 void GLInstancedRendering::onResetGpuResources(ResetType resetType) { 312 void GLInstancedRendering::onResetGpuResources(ResetType resetType) {
313 if (fVertexArrayID && ResetType::kDestroy == resetType) { 313 if (fVertexArrayID && ResetType::kDestroy == resetType) {
314 GL_CALL(DeleteVertexArrays(1, &fVertexArrayID)); 314 GL_CALL(DeleteVertexArrays(1, &fVertexArrayID));
315 this->glGpu()->notifyVertexArrayDelete(fVertexArrayID); 315 this->glGpu()->notifyVertexArrayDelete(fVertexArrayID);
316 } 316 }
317 fVertexArrayID = 0; 317 fVertexArrayID = 0;
318 fInstanceBuffer.reset(); 318 fInstanceBuffer.reset();
319 fDrawIndirectBuffer.reset(); 319 fDrawIndirectBuffer.reset();
320 fInstanceAttribsBufferUniqueId = SK_InvalidUniqueID; 320 fInstanceAttribsBufferUniqueId = SK_InvalidUniqueID;
321 } 321 }
322 322
323 } 323 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.cpp ('k') | src/gpu/text/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698