-
Notifications
You must be signed in to change notification settings - Fork 762
gui: limit number of bpins to avoid excessive render times #9194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| #include <QPolygon> | ||
| #include <algorithm> | ||
| #include <cmath> | ||
| #include <cstdint> | ||
| #include <exception> | ||
| #include <iterator> | ||
| #include <mutex> | ||
|
|
@@ -1552,18 +1553,14 @@ void RenderThread::setupIOPins(odb::dbBlock* block, const odb::Rect& bounds) | |
| } | ||
|
|
||
| const auto die_area = block->getDieArea(); | ||
| const auto die_width = die_area.dx(); | ||
| const auto die_height = die_area.dy(); | ||
|
|
||
| pin_draw_names_ = viewer_->options_->areIOPinNamesVisible(); | ||
| const double scale_factor | ||
| = 0.02; // 4 Percent of bounds is used to draw pin-markers | ||
| const int die_max_dim = std::min(die_area.maxDXDY(), bounds.maxDXDY()); | ||
| const double abs_min_dim = 8.0; // prevent markers from falling apart | ||
| pin_max_size_ = std::max(scale_factor * die_max_dim, abs_min_dim); | ||
| if (pin_draw_names_) { | ||
| const double scale_factor | ||
| = 0.02; // 4 Percent of bounds is used to draw pin-markers | ||
| const int die_max_dim | ||
| = std::min(std::max(die_width, die_height), bounds.maxDXDY()); | ||
| const double abs_min_dim = 8.0; // prevent markers from falling apart | ||
| pin_max_size_ = std::max(scale_factor * die_max_dim, abs_min_dim); | ||
|
|
||
| pin_font_ = viewer_->options_->ioPinMarkersFont(); | ||
| const QFontMetrics font_metrics(pin_font_); | ||
|
|
||
|
|
@@ -1690,16 +1687,33 @@ void RenderThread::drawIOPins(Painter& painter, | |
| }; | ||
| std::vector<PinText> pin_text_spec; | ||
|
|
||
| const int min_bpin_size = viewer_->options_->isDetailedVisibility() | ||
| ? viewer_->fineViewableResolution() | ||
| : viewer_->nominalViewableResolution(); | ||
| const int64_t max_lin_bpins = bounds.minDXDY() / min_bpin_size; | ||
| const int64_t max_bpins | ||
| = std::min(kMaxBPinsPerLayer, max_lin_bpins * max_lin_bpins); | ||
|
|
||
| painter.setPen(layer); | ||
| painter.setBrush(layer); | ||
|
|
||
| auto bpins = viewer_->search_.searchBPins( | ||
| block, layer, bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax()); | ||
| debugPrint(logger_, | ||
| GUI, | ||
| "draw", | ||
| 2, | ||
| "found {} bpins on layer {}, drawing limit {} ({}) bpins", | ||
| bpins.size(), | ||
| layer->getName(), | ||
| max_bpins, | ||
| max_lin_bpins); | ||
| if (bpins.size() > max_bpins) { | ||
| return; | ||
| } | ||
|
Comment on lines
+1700
to
+1713
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation is inefficient for a large number of bpins. A more efficient approach is to iterate once, collecting the bpins into a vector and stopping as soon as the number of bpins exceeds auto bpins_range = viewer_->search_.searchBPins(
block, layer, bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax());
std::vector<std::pair<odb::dbBox*, odb::dbBPin*>> bpins;
bpins.reserve(max_bpins + 1);
for (const auto& bpin : bpins_range) {
bpins.push_back(bpin);
if (bpins.size() > max_bpins) {
break;
}
}
debugPrint(logger_,
GUI,
"draw",
2,
"found {} bpins on layer {}, drawing limit {} ({}) bpins",
bpins.size() > max_bpins ? std::string(">") + std::to_string(max_bpins) : std::to_string(bpins.size()),
layer->getName(),
max_bpins,
max_lin_bpins);
if (bpins.size() > max_bpins) {
return;
}References
|
||
|
|
||
| std::vector<odb::Rect> pin_text_spec_shape_rects; | ||
| for (const auto& [box, pin] : viewer_->search_.searchBPins(block, | ||
| layer, | ||
| bounds.xMin(), | ||
| bounds.yMin(), | ||
| bounds.xMax(), | ||
| bounds.yMax())) { | ||
| for (const auto& [box, pin] : bpins) { | ||
| if (restart_) { | ||
| break; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
|
|
||
| #include <QObject> | ||
| #include <atomic> | ||
| #include <iterator> | ||
| #include <map> | ||
| #include <mutex> | ||
| #include <tuple> | ||
|
|
@@ -126,6 +127,8 @@ class Search : public QObject, public odb::dbBlockCallBackObj | |
| Iterator begin() { return begin_; } | ||
| Iterator end() { return end_; } | ||
|
|
||
| int size() const { return std::distance(begin_, end_); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The References
|
||
|
|
||
| private: | ||
| Iterator begin_; | ||
| Iterator end_; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.