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

Conversation

@ColdPaleLight
Copy link
Member

fix flutter/flutter#129358

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

Nice!

There are a few places where we ifdef in the shader, such as

#ifdef IMPELLER_TARGET_OPENGLES

I think we should be able to update the ifdef to check for the extension? or something like that.

}

static GLint ToAddressMode(SamplerAddressMode mode) {
static GLint ToAddressMode(SamplerAddressMode mode,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I might just pass in a bool for whether or not decal is supported.

Copy link
Member

Choose a reason for hiding this comment

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

Just a drive by comment; Is it just me or does anyone else find "decal" mode to be a non-standard and/or overly confusing term? How about just ClampToBorderColor? Thats what the various APIs call it (GL_CLAMP_TO_BORDER_EXT, MTLSamplerAddressModeClampToBorderColor, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER).

Perhaps later, we can rename this enum value for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a cost for non-consistency with the underlying graphics API, but there is also a value in matching the framework level enumeration which uses decal as a terminology. I don't feel as strongly about decal as I do about "FilterQuality", which is entirely opaque - at least decal has some semantic meaning

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: I might just pass in a bool for whether or not decal is supported.

Done


TEST(CapabilitiesGLES, SupportsDecalSamplerAddressMode) {
auto const extensions = std::vector<unsigned char*>{
(unsigned char*)"GL_KHR_debug", //
Copy link
Member

Choose a reason for hiding this comment

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

Nit: reinterpret_cast

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

}

static GLint ToAddressMode(SamplerAddressMode mode) {
static GLint ToAddressMode(SamplerAddressMode mode,
Copy link
Member

Choose a reason for hiding this comment

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

Just a drive by comment; Is it just me or does anyone else find "decal" mode to be a non-standard and/or overly confusing term? How about just ClampToBorderColor? Thats what the various APIs call it (GL_CLAMP_TO_BORDER_EXT, MTLSamplerAddressModeClampToBorderColor, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER).

Perhaps later, we can rename this enum value for consistency.

ToAddressMode(desc.width_address_mode));
gl.TexParameteri(target.value(), GL_TEXTURE_WRAP_T,
ToAddressMode(desc.height_address_mode));
gl.TexParameteri(
Copy link
Member

Choose a reason for hiding this comment

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

How do we set the border color? TEXTURE_BORDER_COLOR_EXT

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this defaults to transparent black so we don't need to worry about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I guess. I took a look at Vulkan and setting the border color is an extension. But setting it to VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER is not. I guess this is fine. I don't think we set the color on Metal either. Just really odd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Flutter does not expose an API for setting the border color.

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. Its an extension that is core in 1.1. And we do set it to transparent black. Let's be explicit and do the same here as well please?

Copy link
Member

Choose a reason for hiding this comment

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

Its is also dealers choice on Metal at the moment. Let's be explicit and set borderColor here too. In fact, a default border color specification in formats.h would be good for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Flutter does not expose an API for setting the border color.

Yeah, just didn't want to read the spec to see if the default was transparent black. Just being explicit seemed better. There isn't any bug though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Issue filed: flutter/flutter#136153

@ColdPaleLight
Copy link
Member Author

Nice!

There are a few places where we ifdef in the shader, such as

#ifdef IMPELLER_TARGET_OPENGLES

I think we should be able to update the ifdef to check for the extension? or something like that.

I removed the macro and added a variable in the uniform block to determine if the gpu api supports clip to border. (I originally planned to use different pipelines that support decal and those that do not, but I found that this would double the number of advanced blend pipelines.)

@jonahwilliams
Copy link
Contributor

Rather than use a uniform, can we use a combination of defines - if opengles and at least one of the decal extensions not defined? Each extension should have a corresponding define already

@ColdPaleLight
Copy link
Member Author

Rather than use a uniform, can we use a combination of defines - if opengles and at least one of the decal extensions not defined? Each extension should have a corresponding define already

I guess this won't work because shaderc will do a preprocessing before compiling glsl, so the macros will be handled at that stage. Therefore, glsl generated by spirv cross no longer contains statements like "#ifdef GL_EXT_texture_border_clamp"

@jonahwilliams
Copy link
Contributor

that is extremely unfortunate

@jonahwilliams
Copy link
Contributor

Well, we can clean it up later then. There is probably another way to do it by way of tinkering with SPIRV cross.

#else
return texture(texture_sampler, texture_coords);
#endif
if (blend_info.supports_decal_sampler_address_mode > 0.0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These can still technically be ifdefs since vulkan/metal always support this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, added them back.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@ColdPaleLight ColdPaleLight added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 9, 2023
@auto-submit auto-submit bot merged commit 0966f62 into flutter:main Oct 9, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] OpenGLES: Optionally support SamplerAddressMode::kDecal

3 participants