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

Unified Diff: src/gpu/instanced/InstancedRenderingTypes.h

Issue 2119123002: Don't batch large instanced rects with other shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Don't batch large instanced rects with other shapes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/instanced/InstancedRendering.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/instanced/InstancedRenderingTypes.h
diff --git a/src/gpu/instanced/InstancedRenderingTypes.h b/src/gpu/instanced/InstancedRenderingTypes.h
index ff9471c428488ab7d406daa2bf3ab1e54ec80814..5dca43581b339524b9bb249af7de3f8bf0f898aa 100644
--- a/src/gpu/instanced/InstancedRenderingTypes.h
+++ b/src/gpu/instanced/InstancedRenderingTypes.h
@@ -124,31 +124,14 @@ GR_STATIC_ASSERT(4 * 4 == sizeof(ParamsTexel));
*/
struct BatchInfo {
BatchInfo() : fData(0) {}
+ explicit BatchInfo(uint32_t data) : fData(data) {}
+
+ static bool CanCombine(const BatchInfo& a, const BatchInfo& b);
bool isSimpleRects() const {
return !((fShapeTypes & ~kRect_ShapeFlag) | fInnerShapeTypes);
}
- bool canJoin(BatchInfo that) const {
- if (fAntialiasMode != that.fAntialiasMode) {
- return false;
- }
- if (SkToBool(fInnerShapeTypes) != SkToBool(that.fInnerShapeTypes)) {
- // GrInstanceProcessor can't currently combine draws with and without inner shapes.
- return false;
- }
- if (fCannotDiscard != that.fCannotDiscard) {
- // For stencil draws, the use of discard can be a requirement.
- return false;
- }
- return true;
- }
-
- void join(BatchInfo that) {
- SkASSERT(this->canJoin(that));
- fData |= that.fData;
- }
-
union {
struct {
AntialiasMode fAntialiasMode;
@@ -170,6 +153,26 @@ struct BatchInfo {
GR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(BatchInfo));
GR_STATIC_ASSERT(kNumShapeTypes <= 8);
+inline bool BatchInfo::CanCombine(const BatchInfo& a, const BatchInfo& b) {
+ if (a.fAntialiasMode != b.fAntialiasMode) {
+ return false;
+ }
+ if (SkToBool(a.fInnerShapeTypes) != SkToBool(b.fInnerShapeTypes)) {
+ // GrInstanceProcessor can't currently combine draws with and without inner shapes.
+ return false;
+ }
+ if (a.fCannotDiscard != b.fCannotDiscard) {
+ // For stencil draws, the use of discard can be a requirement.
+ return false;
+ }
+ return true;
+}
+
+inline BatchInfo operator|(const BatchInfo& a, const BatchInfo& b) {
+ SkASSERT(BatchInfo::CanCombine(a, b));
+ return BatchInfo(a.fData | b.fData);
+}
+
template<typename T> struct TRange {
bool operator ==(const TRange& that) const {
return fStart == that.fStart && fCount == that.fCount;
« no previous file with comments | « src/gpu/instanced/InstancedRendering.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698