[Impeller] Remove transient usage from sampled and stored images (flutter/engine#39957)

This commit is contained in:
Kaushik Iska
2023-03-01 15:37:33 -05:00
committed by GitHub
parent a226775bdc
commit b1c105b5ec
2 changed files with 26 additions and 0 deletions

View File

@@ -132,12 +132,31 @@ static constexpr vk::ImageUsageFlags ToVKImageUsageFlags(PixelFormat format,
if (usage & static_cast<TextureUsageMask>(TextureUsage::kShaderRead)) {
vk_usage |= vk::ImageUsageFlagBits::eSampled;
// Device transient images can only be used as attachments. The caller
// specified incorrect usage flags and is attempting to read a device
// transient image in a shader. Unset the transient attachment flag. See:
// https://github.com/flutter/flutter/issues/121633
if (mode == StorageMode::kDeviceTransient) {
vk_usage &= ~vk::ImageUsageFlagBits::eTransientAttachment;
}
}
if (usage & static_cast<TextureUsageMask>(TextureUsage::kShaderWrite)) {
vk_usage |= vk::ImageUsageFlagBits::eStorage;
// Device transient images can only be used as attachments. The caller
// specified incorrect usage flags and is attempting to read a device
// transient image in a shader. Unset the transient attachment flag. See:
// https://github.com/flutter/flutter/issues/121633
if (mode == StorageMode::kDeviceTransient) {
vk_usage &= ~vk::ImageUsageFlagBits::eTransientAttachment;
}
}
// TODO (https://github.com/flutter/flutter/issues/121634):
// Add transfer usage flags to support blit passes
vk_usage |= vk::ImageUsageFlagBits::eTransferSrc |
vk::ImageUsageFlagBits::eTransferDst;
return vk_usage;
}

View File

@@ -84,12 +84,19 @@ static std::optional<vk::SurfaceFormatKHR> ChooseSurfaceFormat(
static std::optional<vk::CompositeAlphaFlagBitsKHR> ChooseAlphaCompositionMode(
vk::CompositeAlphaFlagsKHR flags) {
if (flags & vk::CompositeAlphaFlagBitsKHR::eInherit) {
return vk::CompositeAlphaFlagBitsKHR::eInherit;
}
if (flags & vk::CompositeAlphaFlagBitsKHR::ePreMultiplied) {
return vk::CompositeAlphaFlagBitsKHR::ePreMultiplied;
}
if (flags & vk::CompositeAlphaFlagBitsKHR::ePostMultiplied) {
return vk::CompositeAlphaFlagBitsKHR::ePostMultiplied;
}
if (flags & vk::CompositeAlphaFlagBitsKHR::eOpaque) {
return vk::CompositeAlphaFlagBitsKHR::eOpaque;
}
return std::nullopt;
}