Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented May 18, 2022

Enables MSAA behind a flag, similar to Android. This turned out to be easier than I thought - Skia already knows how to create the resolve texture.

Manually/visually verified drawVertices does AA with this set to 4.

iOS part of flutter/flutter#100392

@jonahwilliams FYI

@dnfield dnfield marked this pull request as ready for review May 18, 2022 21:13
@dnfield dnfield requested review from chinmaygarde and cyanglaz May 18, 2022 21:13
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Minor but LGTM otherwise.

auto surface = CreateSurfaceFromMetalTexture(context_.get(), drawable.get().texture,
kTopLeft_GrSurfaceOrigin, // origin
1, // sample count
msaa_samples_, // sample count
Copy link
Member

Choose a reason for hiding this comment

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

Some validation of sample counts would be good here. Docs say it could be 1, 2, 4 or 8. Though we should stick to 1 and 4 for max compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Settings object validates that this is 0, 1, 2, 4, 8, or 16. I can add tighter validation here, but should it just bea DCHECK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added another validation FML_CHECK in GPUSurfaceMetalSkia's ctor


protected:
IOSContext();
explicit IOSContext(int msaa_samples);
Copy link
Member

Choose a reason for hiding this comment

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

Make this an enum perhaps? Saying IOSContext(1) for the ctor reads odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made an enum. Left it as an int in GPUSurfaceMetalSkia.


virtual std::shared_ptr<impeller::Context> GetImpellerContext() const;

int get_msaa_samples() const { return msaa_samples_; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be int GetMSAASamples()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (but as GetMsaaSamples. I think our style guide does want this to be get_msaa_samples but that style isn't used elsewhere in this file.

/// engine/platform.
/// @param[in] msaa_samples
/// The number of MSAA samples to use. Only supplied to
/// Skia, must be either 0, 1, 2, 4, or 8.
Copy link
Contributor

@cyanglaz cyanglaz May 18, 2022

Choose a reason for hiding this comment

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

What happens when an invalid value is passed. Do we default to certain value, or a crash, or undefined behavior.

Should we prevent it on our side or the Skia API has something to prevent it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parsing for that is handled in the Settings parse for command line, but I guess Ic an add more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added validation in GPUSurfaceMetalSkia's ctor.

@dnfield dnfield added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 18, 2022
Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM

// Skia allows 0 and clamps it to 1.
FML_CHECK(msaa_samples_ == 0 || msaa_samples_ == 1 || msaa_samples_ == 2 || msaa_samples_ == 4 ||
msaa_samples_ == 8)
<< "Invalid MSAA sample count value: " << msaa_samples_;
Copy link
Contributor

Choose a reason for hiding this comment

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

very optional nits:
maybe add a link or some message about what should be the correct value. I guess people use this parameter should be able to easily figure out when they see the error message though. Your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally this should be either 1 (disabled) or 4 (enabled), but the idea is to leave it a little more flexibleright now for experiments/benchmarking.

If we decide to ship this independently of impeller, it'll probably just be set to 4 no matter what.

@fluttergithubbot fluttergithubbot merged commit 8f5e8e7 into flutter:main May 19, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 19, 2022
dnfield added a commit that referenced this pull request May 19, 2022
dnfield added a commit that referenced this pull request May 19, 2022
dnfield added a commit to dnfield/engine that referenced this pull request May 20, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-ios waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants