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

Side by Side Diff: src/gpu/instanced/InstancedRendering.cpp

Issue 2120163002: Enable blend optimizations with instanced draws (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_ingorecov
Patch Set: Created 4 years, 5 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/instanced/InstanceProcessor.cpp ('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 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 "InstancedRendering.h" 8 #include "InstancedRendering.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 void InstancedRendering::Batch::appendParamsTexel(SkScalar x, SkScalar y, SkScal ar z) { 322 void InstancedRendering::Batch::appendParamsTexel(SkScalar x, SkScalar y, SkScal ar z) {
323 SkASSERT(!fIsTracked); 323 SkASSERT(!fIsTracked);
324 ParamsTexel& texel = fParams.push_back(); 324 ParamsTexel& texel = fParams.push_back();
325 texel.fX = SkScalarToFloat(x); 325 texel.fX = SkScalarToFloat(x);
326 texel.fY = SkScalarToFloat(y); 326 texel.fY = SkScalarToFloat(y);
327 texel.fZ = SkScalarToFloat(z); 327 texel.fZ = SkScalarToFloat(z);
328 fInfo.fHasParams = true; 328 fInfo.fHasParams = true;
329 } 329 }
330 330
331 void InstancedRendering::Batch::computePipelineOptimizations(GrInitInvariantOutp ut* color,
332 GrInitInvariantOutpu t* coverage,
333 GrBatchToXPOverrides * overrides) const {
334 color->setKnownFourComponents(this->getSingleInstance().fColor);
335
336 if (AntialiasMode::kCoverage == fInfo.fAntialiasMode ||
337 (AntialiasMode::kNone == fInfo.fAntialiasMode &&
338 !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) {
339 coverage->setUnknownSingleComponent();
340 } else {
341 coverage->setKnownSingleComponent(255);
342 }
343 }
344
331 void InstancedRendering::Batch::initBatchTracker(const GrXPOverridesForBatch& ov errides) { 345 void InstancedRendering::Batch::initBatchTracker(const GrXPOverridesForBatch& ov errides) {
332 Draw& draw = this->getSingleDraw(); // This will assert if we have > 1 comma nd. 346 Draw& draw = this->getSingleDraw(); // This will assert if we have > 1 comma nd.
333 SkASSERT(draw.fGeometry.isEmpty()); 347 SkASSERT(draw.fGeometry.isEmpty());
334 SkASSERT(SkIsPow2(fInfo.fShapeTypes)); 348 SkASSERT(SkIsPow2(fInfo.fShapeTypes));
335 SkASSERT(!fIsTracked); 349 SkASSERT(!fIsTracked);
336 350
337 if (kRect_ShapeFlag == fInfo.fShapeTypes) { 351 if (kRect_ShapeFlag == fInfo.fShapeTypes) {
338 draw.fGeometry = InstanceProcessor::GetIndexRangeForRect(fInfo.fAntialia sMode); 352 draw.fGeometry = InstanceProcessor::GetIndexRangeForRect(fInfo.fAntialia sMode);
339 } else if (kOval_ShapeFlag == fInfo.fShapeTypes) { 353 } else if (kOval_ShapeFlag == fInfo.fShapeTypes) {
340 draw.fGeometry = InstanceProcessor::GetIndexRangeForOval(fInfo.fAntialia sMode, fBounds); 354 draw.fGeometry = InstanceProcessor::GetIndexRangeForOval(fInfo.fAntialia sMode, fBounds);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 ++fNumChangesInGeometry; 396 ++fNumChangesInGeometry;
383 } 397 }
384 fTailDraw->fNext = that->fHeadDraw; 398 fTailDraw->fNext = that->fHeadDraw;
385 fTailDraw = that->fTailDraw; 399 fTailDraw = that->fTailDraw;
386 400
387 that->fHeadDraw = that->fTailDraw = nullptr; 401 that->fHeadDraw = that->fTailDraw = nullptr;
388 402
389 return true; 403 return true;
390 } 404 }
391 405
392 void InstancedRendering::Batch::computePipelineOptimizations(GrInitInvariantOutp ut* color,
393 GrInitInvariantOutpu t* coverage,
394 GrBatchToXPOverrides * overrides) const {
395 // We need to be careful about fInfo here and consider how it might change a s batches combine.
396 // e.g. We can't make an assumption based on fInfo.isSimpleRects() because t he batch might
397 // later combine with a non-rect.
csmartdalton 2016/07/03 17:36:43 This comment was actually just about a bug, fixed
398 color->setUnknownFourComponents();
399 if (fInfo.fAntialiasMode >= AntialiasMode::kMSAA) {
400 coverage->setKnownSingleComponent(255);
401 } else if (AntialiasMode::kNone == fInfo.fAntialiasMode && !fInfo.fCannotDis card) {
402 coverage->setKnownSingleComponent(255);
403 } else {
404 coverage->setUnknownSingleComponent();
405 }
406 }
407
408 void InstancedRendering::beginFlush(GrResourceProvider* rp) { 406 void InstancedRendering::beginFlush(GrResourceProvider* rp) {
409 SkASSERT(State::kRecordingDraws == fState); 407 SkASSERT(State::kRecordingDraws == fState);
410 fState = State::kFlushing; 408 fState = State::kFlushing;
411 409
412 if (fTrackedBatches.isEmpty()) { 410 if (fTrackedBatches.isEmpty()) {
413 return; 411 return;
414 } 412 }
415 413
416 if (!fVertexBuffer) { 414 if (!fVertexBuffer) {
417 fVertexBuffer.reset(InstanceProcessor::FindOrCreateVertexBuffer(fGpu)); 415 fVertexBuffer.reset(InstanceProcessor::FindOrCreateVertexBuffer(fGpu));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 463 }
466 464
467 void InstancedRendering::resetGpuResources(ResetType resetType) { 465 void InstancedRendering::resetGpuResources(ResetType resetType) {
468 fVertexBuffer.reset(); 466 fVertexBuffer.reset();
469 fIndexBuffer.reset(); 467 fIndexBuffer.reset();
470 fParamsBuffer.reset(); 468 fParamsBuffer.reset();
471 this->onResetGpuResources(resetType); 469 this->onResetGpuResources(resetType);
472 } 470 }
473 471
474 } 472 }
OLDNEW
« no previous file with comments | « src/gpu/instanced/InstanceProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698