mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Internally, when targeting x86 Android, these files fail to compile:
```
impeller/renderer/backend/vulkan/yuv_conversion_vk.cc:33:22: error: conditional expression is ambiguous; 'const impeller::vk::SamplerYcbcrConversion' can be converted to 'unsigned long long' and vice versa
return conversion_ ? conversion_.get() : VK_NULL_HANDLE;
^ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
impeller/renderer/backend/vulkan/pipeline_vk.cc:360:25: error: conditional expression is ambiguous; 'vk::Sampler' can be converted to 'unsigned long long' and vice versa
immutable_sampler ? immutable_sampler->GetSampler() : VK_NULL_HANDLE;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
```
The cause is that internally, `VULKAN_HPP_TYPESAFE_CONVERSION` is set but not for the GN build here. Copying from the [vulkan docs](https://github.com/KhronosGroup/Vulkan-Hpp/blob/main/README.md#cc-interop-for-handles):
> On 64-bit platforms Vulkan-Hpp supports implicit conversions between C++ Vulkan handles and C Vulkan handles. On 32-bit platforms all non-dispatchable handles are defined as `uint64_t`, thus preventing type-conversion checks at compile time which would catch assignments between incompatible handle types. Due to that Vulkan-Hpp does not enable implicit conversion for 32-bit platforms by default and it is recommended to use a `static_cast` for the conversion like this: `VkImage = static_cast<VkImage>(cppImage)` to prevent converting some arbitrary int to a handle or vice versa by accident. If you're developing your code on a 64-bit platform, but want compile your code for a 32-bit platform without adding the explicit casts you can define `VULKAN_HPP_TYPESAFE_CONVERSION` to 1 in your build system or before including `vulkan.hpp`. On 64-bit platforms this define is set to 1 by default and can be set to 0 to disable implicit conversions.
I'm not sure if doing the `static_cast` on the `VK_NULL_HANDLE` in this PR is right though. When targeting x86, this macro ends up being [defined as](5a5c9a6434/include/vulkan/vulkan_core.h (46)) `0LL`. But at the same time, putting the cast on the other ternary branch (e.g. `static_cast<vk::Sampler>(immutable_sampler->GetSampler())`) doesn't resolve the error.
*List which issues are fixed by this PR. You must list at least one issue.*
b/328355475