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

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 865153005: simple fix to close batches on anything push to the GrIODB recorder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/GrInOrderDrawBuffer.h ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 return instancesToConcat; 244 return instancesToConcat;
245 } 245 }
246 246
247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder, 247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder,
248 const GrGeometryProcessor* gp, 248 const GrGeometryProcessor* gp,
249 const DrawInfo& info, 249 const DrawInfo& info,
250 const GrScissorState& scissorState, 250 const GrScissorState& scissorState,
251 const GrDeviceCoordTexture* dstCopy) { 251 const GrDeviceCoordTexture* dstCopy) {
252 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); 252 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
253
254 // This closeBatch call is required because we may introduce new draws when we setup clip
255 this->closeBatch(); 253 this->closeBatch();
256 254
257 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, dstCo py)) { 255 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, dstCo py)) {
258 return; 256 return;
259 } 257 }
260 258
261 Draw* draw; 259 Draw* draw;
262 if (info.isInstanced()) { 260 if (info.isInstanced()) {
263 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ; 261 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ;
264 if (info.instanceCount() > instancesConcated) { 262 if (info.instanceCount() > instancesConcated) {
(...skipping 30 matching lines...) Expand all
295 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch)); 293 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch));
296 } 294 }
297 this->recordTraceMarkersIfNecessary(); 295 this->recordTraceMarkersIfNecessary();
298 } 296 }
299 297
300 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder , 298 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder ,
301 const GrPathProcessor* pathProc, 299 const GrPathProcessor* pathProc,
302 const GrPath* path, 300 const GrPath* path,
303 const GrScissorState& scissorState, 301 const GrScissorState& scissorState,
304 const GrStencilSettings& stencilSettings ) { 302 const GrStencilSettings& stencilSettings ) {
303 this->closeBatch();
304
305 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, 305 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath,
306 (path, pipelineBuilder.getRenderT arget())); 306 (path, pipelineBuilder.getRenderT arget()));
307 sp->fScissor = scissorState; 307 sp->fScissor = scissorState;
308 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); 308 sp->fUseHWAA = pipelineBuilder.isHWAntialias();
309 sp->fViewMatrix = pathProc->viewMatrix(); 309 sp->fViewMatrix = pathProc->viewMatrix();
310 sp->fStencil = stencilSettings; 310 sp->fStencil = stencilSettings;
311 this->recordTraceMarkersIfNecessary(); 311 this->recordTraceMarkersIfNecessary();
312 } 312 }
313 313
314 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder, 314 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder,
(...skipping 20 matching lines...) Expand all
335 PathIndexType indexType, 335 PathIndexType indexType,
336 const float transformValues[], 336 const float transformValues[],
337 PathTransformType transformType, 337 PathTransformType transformType,
338 int count, 338 int count,
339 const GrScissorState& scissorState, 339 const GrScissorState& scissorState,
340 const GrStencilSettings& stencilSettings, 340 const GrStencilSettings& stencilSettings,
341 const GrDeviceCoordTexture* dstCopy) { 341 const GrDeviceCoordTexture* dstCopy) {
342 SkASSERT(pathRange); 342 SkASSERT(pathRange);
343 SkASSERT(indices); 343 SkASSERT(indices);
344 SkASSERT(transformValues); 344 SkASSERT(transformValues);
345
346 this->closeBatch(); 345 this->closeBatch();
347 346
348 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) { 347 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) {
349 return; 348 return;
350 } 349 }
351 350
352 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); 351 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType);
353 if (int misalign = fPathIndexBuffer.count() % indexBytes) { 352 if (int misalign = fPathIndexBuffer.count() % indexBytes) {
354 // Add padding to the index buffer so the indices are aligned properly. 353 // Add padding to the index buffer so the indices are aligned properly.
355 fPathIndexBuffer.append(indexBytes - misalign); 354 fPathIndexBuffer.append(indexBytes - misalign);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 dp->fTransformType = transformType; 388 dp->fTransformType = transformType;
390 dp->fCount = count; 389 dp->fCount = count;
391 dp->fStencilSettings = stencilSettings; 390 dp->fStencilSettings = stencilSettings;
392 391
393 this->recordTraceMarkersIfNecessary(); 392 this->recordTraceMarkersIfNecessary();
394 } 393 }
395 394
396 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, 395 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color,
397 bool canIgnoreRect, GrRenderTarget* renderTarg et) { 396 bool canIgnoreRect, GrRenderTarget* renderTarg et) {
398 SkASSERT(renderTarget); 397 SkASSERT(renderTarget);
398 this->closeBatch();
399
399 SkIRect r; 400 SkIRect r;
400 if (NULL == rect) { 401 if (NULL == rect) {
401 // We could do something smart and remove previous draws and clears to 402 // We could do something smart and remove previous draws and clears to
402 // the current render target. If we get that smart we have to make sure 403 // the current render target. If we get that smart we have to make sure
403 // those draws aren't read before this clear (render-to-texture). 404 // those draws aren't read before this clear (render-to-texture).
404 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); 405 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
405 rect = &r; 406 rect = &r;
406 } 407 }
407 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 408 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
408 GrColorIsPMAssert(color); 409 GrColorIsPMAssert(color);
409 clr->fColor = color; 410 clr->fColor = color;
410 clr->fRect = *rect; 411 clr->fRect = *rect;
411 clr->fCanIgnoreRect = canIgnoreRect; 412 clr->fCanIgnoreRect = canIgnoreRect;
412 this->recordTraceMarkersIfNecessary(); 413 this->recordTraceMarkersIfNecessary();
413 } 414 }
414 415
415 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, 416 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect,
416 bool insideClip, 417 bool insideClip,
417 GrRenderTarget* renderTarget) { 418 GrRenderTarget* renderTarget) {
418 SkASSERT(renderTarget); 419 SkASSERT(renderTarget);
420 this->closeBatch();
421
419 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget)); 422 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget));
420 clr->fRect = rect; 423 clr->fRect = rect;
421 clr->fInsideClip = insideClip; 424 clr->fInsideClip = insideClip;
422 this->recordTraceMarkersIfNecessary(); 425 this->recordTraceMarkersIfNecessary();
423 } 426 }
424 427
425 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { 428 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
426 SkASSERT(renderTarget); 429 SkASSERT(renderTarget);
430 this->closeBatch();
431
427 if (!this->caps()->discardRenderTargetSupport()) { 432 if (!this->caps()->discardRenderTargetSupport()) {
428 return; 433 return;
429 } 434 }
430 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 435 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
431 clr->fColor = GrColor_ILLEGAL; 436 clr->fColor = GrColor_ILLEGAL;
432 this->recordTraceMarkersIfNecessary(); 437 this->recordTraceMarkersIfNecessary();
433 } 438 }
434 439
435 void GrInOrderDrawBuffer::onReset() { 440 void GrInOrderDrawBuffer::onReset() {
436 fCmdBuffer.reset(); 441 fCmdBuffer.reset();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { 645 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {
641 SkASSERT(!fCmdBuffer.empty()); 646 SkASSERT(!fCmdBuffer.empty());
642 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); 647 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType));
643 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 648 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
644 if (activeTraceMarkers.count() > 0) { 649 if (activeTraceMarkers.count() > 0) {
645 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); 650 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType);
646 fGpuCmdMarkers.push_back(activeTraceMarkers); 651 fGpuCmdMarkers.push_back(activeTraceMarkers);
647 } 652 }
648 } 653 }
649 654
650 void GrInOrderDrawBuffer::closeBatch() {
651 if (fDrawBatch) {
652 fBatchTarget.resetNumberOfDraws();
653 fDrawBatch->execute(this, fPrevState);
654 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
655 fDrawBatch = NULL;
656 }
657 }
658
659 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, 655 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount,
660 size_t vertexStride, 656 size_t vertexStride,
661 int indexCount) { 657 int indexCount) {
662 this->closeBatch(); 658 this->closeBatch();
663 659
664 // We use geometryHints() to know whether to flush the draw buffer. We 660 // We use geometryHints() to know whether to flush the draw buffer. We
665 // can't flush if we are inside an unbalanced pushGeometrySource. 661 // can't flush if we are inside an unbalanced pushGeometrySource.
666 // Moreover, flushing blows away vertex and index data that was 662 // Moreover, flushing blows away vertex and index data that was
667 // previously reserved. So if the vertex or index data is pulled from 663 // previously reserved. So if the vertex or index data is pulled from
668 // reserved space and won't be released by this request then we can't 664 // reserved space and won't be released by this request then we can't
(...skipping 11 matching lines...) Expand all
680 int vcount = vertexCount; 676 int vcount = vertexCount;
681 int icount = indexCount; 677 int icount = indexCount;
682 678
683 if (!insideGeoPush && 679 if (!insideGeoPush &&
684 !unreleasedVertexSpace && 680 !unreleasedVertexSpace &&
685 !unreleasedIndexSpace && 681 !unreleasedIndexSpace &&
686 this->geometryHints(vertexStride, &vcount, &icount)) { 682 this->geometryHints(vertexStride, &vcount, &icount)) {
687 this->flush(); 683 this->flush();
688 } 684 }
689 } 685 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698