-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Optionally support SamplerAddressMode::kDecal on the OpenGLES backend #46650
Conversation
jonahwilliams
left a comment
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: reinterpret_cast
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://registry.khronos.org/OpenGL-Refpages/es3/html/glTexParameter.xhtml this value defaults to transparent black so we don't need to set anything.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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.) |
|
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" |
|
that is extremely unfortunate |
|
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… the OpenGLES backend (flutter/engine#46650)
…136215) flutter/engine@81e5bf2...0966f62 2023-10-09 [email protected] [Impeller] Optionally support SamplerAddressMode::kDecal on the OpenGLES backend (flutter/engine#46650) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#136215) flutter/engine@81e5bf2...0966f62 2023-10-09 [email protected] [Impeller] Optionally support SamplerAddressMode::kDecal on the OpenGLES backend (flutter/engine#46650) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
fix flutter/flutter#129358
Pre-launch Checklist
///).