Skip to content
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

[Impeller] ensure 1x1 has mipcount of 1 #39182

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions impeller/geometry/geometry_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ TEST(GeometryTest, CanGenerateMipCounts) {
ASSERT_EQ((Size{128, 0}.MipCount()), 1u);
ASSERT_EQ((Size{128, -25}.MipCount()), 1u);
ASSERT_EQ((Size{-128, 25}.MipCount()), 1u);
ASSERT_EQ((Size{1, 1}.MipCount()), 1u);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mip counts should always at least be 1. Perhaps also check Size{0, 0}?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

TEST(GeometryTest, CanConvertTTypesExplicitly) {
Expand Down
4 changes: 3 additions & 1 deletion impeller/geometry/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ struct TSize {
if (!IsPositive()) {
return 1u;
}
return std::max(ceil(log2(width)), ceil(log2(height)));
constexpr size_t minimumMip = 1u;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

underscore_case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

size_t result = std::max(ceil(log2(width)), ceil(log2(height)));
return std::max(result, minimumMip);
}
};

Expand Down