skia2/tests/GrQuadListTest.cpp

283 lines
11 KiB
C++
Raw Normal View History

Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
#include "src/gpu/geometry/GrQuad.h"
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
#define ASSERT(cond) REPORTER_ASSERT(r, cond)
#define ASSERTF(cond, ...) REPORTER_ASSERT(r, cond, __VA_ARGS__)
#define TEST(name) DEF_TEST(GrQuadList##name, r)
struct TestData {
int fItem1;
float fItem2;
};
// Simple factories to make placeholder quads used in the tests. The 2D quads
// will have the kRect quad type.
static GrQuad make_2d_quad() {
return GrQuad(SkRect::MakeLTRB(1.f, 2.f, 3.f, 4.f));
}
static bool is_2d_quad(const GrPerspQuad& quad) {
return quad.x(0) == 1.f && quad.x(1) == 1.f && quad.x(2) == 3.f && quad.x(3) == 3.f &&
quad.y(0) == 2.f && quad.y(1) == 4.f && quad.y(2) == 2.f && quad.y(3) == 4.f &&
quad.w(0) == 1.f && quad.w(1) == 1.f && quad.w(2) == 1.f && quad.w(3) == 1.f;
}
static GrPerspQuad make_2d_persp_quad() {
return GrPerspQuad(SkRect::MakeLTRB(5.f, 6.f, 7.f, 8.f));
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
}
static bool is_2d_persp_quad(const GrPerspQuad& quad) {
return quad.x(0) == 5.f && quad.x(1) == 5.f && quad.x(2) == 7.f && quad.x(3) == 7.f &&
quad.y(0) == 6.f && quad.y(1) == 8.f && quad.y(2) == 6.f && quad.y(3) == 8.f &&
quad.w(0) == 1.f && quad.w(1) == 1.f && quad.w(2) == 1.f && quad.w(3) == 1.f;
}
static GrPerspQuad make_3d_persp_quad() {
// This perspective matrix leaves x and y unmodified, and sets w to the persp2 value
SkMatrix p = SkMatrix::I();
p[SkMatrix::kMPersp2] = 13.f;
SkASSERT(p.hasPerspective()); // Sanity check
return GrPerspQuad::MakeFromRect(SkRect::MakeLTRB(9.f, 10.f, 11.f, 12.f), p);
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
}
static bool is_3d_persp_quad(const GrPerspQuad& quad) {
return quad.x(0) == 9.f && quad.x(1) == 9.f && quad.x(2) == 11.f && quad.x(3) == 11.f &&
quad.y(0) == 10.f && quad.y(1) == 12.f && quad.y(2) == 10.f && quad.y(3) == 12.f &&
quad.w(0) == 13.f && quad.w(1) == 13.f && quad.w(2) == 13.f && quad.w(3) == 13.f;
}
TEST(Add2D) {
GrQuadList list2D;
// Add a plain quad, a 2D persp quad, and then a 3D persp quad, then read back and make sure
// the coordinates make sense (including that the type was lifted to perspective).
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list2D.push_back(make_2d_quad());
list2D.push_back(make_2d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
// Check 2D state of the list
ASSERTF(list2D.count() == 2, "Unexpected count: %d", list2D.count());
ASSERTF(list2D.quadType() == GrQuadType::kRect, "Unexpected quad type: %d",
(uint32_t) list2D.quadType());
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0");
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1");
// Force the 2D quads to be updated to store ws by adding a perspective quad
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list2D.push_back(make_3d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
ASSERTF(list2D.quadType() == GrQuadType::kPerspective,
"Expected 2D list to be upgraded to perspective");
// Re-check full state of list after type upgrade
ASSERTF(list2D.count() == 3, "Unexpected count: %d", list2D.count());
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0 after upgrade");
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1 after upgrade");
ASSERTF(is_3d_persp_quad(list2D[2]), "Incorrect quad at i=2");
}
TEST(Add3D) {
// Now make a list that starts with a 3D persp quad, then has conventional quads added to it
// and make sure its state is correct
GrQuadList list3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list3D.push_back(make_3d_persp_quad());
list3D.push_back(make_2d_persp_quad());
list3D.push_back(make_2d_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
ASSERTF(list3D.count() == 3, "Unexpected count: %d", list3D.count());
ASSERTF(is_3d_persp_quad(list3D[0]), "Incorrect quad at i=0");
ASSERTF(is_2d_persp_quad(list3D[1]), "Incorrect quad at i=1");
ASSERTF(is_2d_quad(list3D[2]), "Incorrect quad at i=2");
}
TEST(AddWithMetadata2D) {
// As above, but also make sure that the metadata is saved and read properly
GrTQuadList<TestData> list2D;
// Add a plain quad, a 2D persp quad, and then a 3D persp quad, then read back and make sure
// the coordinates make sense (including that the type was lifted to perspective).
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list2D.push_back(make_2d_quad(), {1, 1.f});
list2D.push_back(make_2d_persp_quad(), {2, 2.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
// Check 2D state of the list
ASSERTF(list2D.count() == 2, "Unexpected count: %d", list2D.count());
ASSERTF(list2D.quadType() == GrQuadType::kRect, "Unexpected quad type: %d",
(uint32_t) list2D.quadType());
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0");
ASSERTF(list2D.metadata(0).fItem1 == 1 && list2D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1");
ASSERTF(list2D.metadata(1).fItem1 == 2 && list2D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
// Force the 2D quads to be updated to store ws by adding a perspective quad
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list2D.push_back(make_3d_persp_quad(), {3, 3.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
ASSERTF(list2D.quadType() == GrQuadType::kPerspective,
"Expected 2D list to be upgraded to perspective");
// Re-check full state of list after type upgrade
ASSERTF(list2D.count() == 3, "Unexpected count: %d", list2D.count());
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0 after upgrade");
ASSERTF(list2D.metadata(0).fItem1 == 1 && list2D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1 after upgrade");
ASSERTF(list2D.metadata(1).fItem1 == 2 && list2D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
ASSERTF(is_3d_persp_quad(list2D[2]), "Incorrect quad at i=2");
ASSERTF(list2D.metadata(2).fItem1 == 3 && list2D.metadata(2).fItem2 == 3.f,
"Incorrect metadata at i=2");
}
TEST(AddWithMetadata3D) {
// Now make a list that starts with a 3D persp quad, then has conventional quads added to it
// and make sure its state is correct
GrTQuadList<TestData> list3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list3D.push_back(make_3d_persp_quad(), {3, 3.f});
list3D.push_back(make_2d_persp_quad(), {2, 2.f});
list3D.push_back(make_2d_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
ASSERTF(list3D.count() == 3, "Unexpected count: %d", list3D.count());
ASSERTF(is_3d_persp_quad(list3D[0]), "Incorrect quad at i=0");
ASSERTF(list3D.metadata(0).fItem1 == 3 && list3D.metadata(0).fItem2 == 3.f,
"Incorrect metadata at i=0");
ASSERTF(is_2d_persp_quad(list3D[1]), "Incorrect quad at i=1");
ASSERTF(list3D.metadata(1).fItem1 == 2 && list3D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
ASSERTF(is_2d_quad(list3D[2]), "Incorrect quad at i=2");
ASSERTF(list3D.metadata(2).fItem1 == 1 && list3D.metadata(2).fItem2 == 1.f,
"Incorrect metadata at i=2");
}
TEST(Concat2DWith2D) {
GrQuadList a2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a2D.push_back(make_2d_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrQuadList b2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b2D.push_back(make_2d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a2D.concat(b2D);
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
ASSERTF(is_2d_persp_quad(a2D[1]), "Incorrect quad at i=1");
}
TEST(Concat2DWith3D) {
GrQuadList a2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a2D.push_back(make_2d_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrQuadList b3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b3D.push_back(make_3d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a2D.concat(b3D);
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
ASSERTF(is_3d_persp_quad(a2D[1]), "Incorrect quad at i=1");
}
TEST(Concat3DWith2D) {
GrQuadList a3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a3D.push_back(make_3d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrQuadList b2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b2D.push_back(make_2d_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a3D.concat(b2D);
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
ASSERTF(is_2d_quad(a3D[1]), "Incorrect quad at i=1");
}
TEST(Concat3DWith3D) {
GrQuadList a3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a3D.push_back(make_3d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrQuadList b3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b3D.push_back(make_3d_persp_quad());
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a3D.concat(b3D);
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
ASSERTF(is_3d_persp_quad(a3D[1]), "Incorrect quad at i=1");
}
TEST(Concat2DWith2DMetadata) {
GrTQuadList<TestData> a2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a2D.push_back(make_2d_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrTQuadList<TestData> b2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b2D.push_back(make_2d_persp_quad(), {2, 2.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a2D.concat(b2D);
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
ASSERTF(a2D.metadata(0).fItem1 == 1 && a2D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_2d_persp_quad(a2D[1]), "Incorrect quad at i=1");
ASSERTF(a2D.metadata(1).fItem1 == 2 && a2D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
}
TEST(Concat2DWith3DMetadata) {
GrTQuadList<TestData> a2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a2D.push_back(make_2d_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrTQuadList<TestData> b3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b3D.push_back(make_3d_persp_quad(), {2, 2.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a2D.concat(b3D);
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
ASSERTF(a2D.metadata(0).fItem1 == 1 && a2D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_3d_persp_quad(a2D[1]), "Incorrect quad at i=1");
ASSERTF(a2D.metadata(1).fItem1 == 2 && a2D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
}
TEST(Concat3DWith2DMetadata) {
GrTQuadList<TestData> a3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a3D.push_back(make_3d_persp_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrTQuadList<TestData> b2D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b2D.push_back(make_2d_quad(), {2, 2.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a3D.concat(b2D);
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
ASSERTF(a3D.metadata(0).fItem1 == 1 && a3D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_2d_quad(a3D[1]), "Incorrect quad at i=1");
ASSERTF(a3D.metadata(1).fItem1 == 2 && a3D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
}
TEST(Concat3DWith3DMetadata) {
GrTQuadList<TestData> a3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
a3D.push_back(make_3d_persp_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
GrTQuadList<TestData> b3D;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
b3D.push_back(make_3d_persp_quad(), {2, 2.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
a3D.concat(b3D);
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
ASSERTF(a3D.metadata(0).fItem1 == 1 && a3D.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0");
ASSERTF(is_3d_persp_quad(a3D[1]), "Incorrect quad at i=1");
ASSERTF(a3D.metadata(1).fItem1 == 2 && a3D.metadata(1).fItem2 == 2.f,
"Incorrect metadata at i=1");
}
TEST(WriteMetadata) {
GrTQuadList<TestData> list;
Reland "Track quad type on GrQuad directly" This reverts commit 0dee19bacc00f327dca20cc7e4c0a97bc8082c0e. Reason for revert: properly remember src quad type Original change's description: > Revert "Track quad type on GrQuad directly" > > This reverts commit 85766c4cd367596268588f53631a1c43376c929d. > > Reason for revert: red - so much red > > Original change's description: > > Track quad type on GrQuad directly > > > > This makes subsequent higher-level drawing APIs more compact, and > > shouldn't come with a performance hit. Everywhere we used to need > > a GrPerspQuad, we'd also take the GrQuadType as a second argument. > > The quad list types already deconstruct the quad so there's no > > extra overhead in the op's memory usage. > > > > It also improves usability and decreases the likelihood that an > > incorrect quad type is ever associated with the quad. > > > > Bug: skia: > > Change-Id: Iba908fb133ad664744a5788a7088d90de0d3a1c2 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214820 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com > > Change-Id: Ied594673116fb901287b334fea41da3c71494fb1 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215607 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: Id5fb51218f2ace37086112caa2e43461d2f2b46b Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215640 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-05-23 17:59:45 +00:00
list.push_back(make_2d_quad(), {1, 1.f});
Reland "Use specialized quad lists in rectangle ops" This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8 It is updated in patchset 2 to clean up pointers passed into memcpy, and to optimize the bounds calculation in GrPerspQuad. This should fix a performance regression caused by the move away from caching 1/w. The Sk4f::invert() does not always preserve 1/1 == 1, which led to bounds slightly outside of clips and thus forced Skia to keep the scissor test enabled. The fix also restores the optimization of skipping the 1/w division when the quad is known to be 2D. Original change's description: > Use specialized quad lists in rectangle ops > > Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp > > The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2 > SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total > of 124 bytes per quad that was stored in the op. > > The first pass at the rectangle consolidation switched to storing device and > local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag > (1 int) for a total of 148 bytes per quad. After landing, several memory > regressions appeared in Chrome and our perf monitor. > > Several intertwined approaches are taken here. First, GrPerspQuad no longer > caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized > list type is defined that allows storing the x, y, and extra metadata together > for quads, but keeps the w components separate. When the quad type isn't > perspective, w is not stored at all since it is implicitly 1 and can be > reconstituted at tessellation time. This brings the total per quad to either > 84 or 116 bytes, depending on if the op list needs perspective information. > > Bug: chromium:915025 > Bug: chromium:917242 > Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6 > Reviewed-on: https://skia-review.googlesource.com/c/180644 > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> Bug: chromium:915025, chromium:917242 Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55 Reviewed-on: https://skia-review.googlesource.com/c/182203 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
ASSERTF(list.metadata(0).fItem1 == 1 && list.metadata(0).fItem2 == 1.f,
"Incorrect metadata at i=0"); // Sanity check
// Rewrite metadata within the list and read back
list.metadata(0).fItem1 = 2;
list.metadata(0).fItem2 = 2.f;
ASSERTF(list.metadata(0).fItem1 == 2 && list.metadata(0).fItem2 == 2.f,
"Incorrect metadata at i=0 after edit");
}