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

[Impeller] Fix glyph atlas uploads and renders #37691

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
#include "impeller/renderer/backend/vulkan/formats_vk.h"
#include "impeller/renderer/backend/vulkan/texture_vk.h"
#include "impeller/renderer/formats.h"

namespace impeller {

Expand Down Expand Up @@ -146,6 +147,15 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
view_create_info.subresourceRange.levelCount = image_create_info.mipLevels;
view_create_info.subresourceRange.layerCount = image_create_info.arrayLayers;

// Vulkan does not have an image format that is equivalent to
// `MTLPixelFormatA8Unorm`, so we use `R8Unorm` instead. Given that the
// shaders expect that alpha channel to be set in the cases, we swizzle.
// See: https://github.com/flutter/flutter/issues/115461 for more details.
if (desc.format == PixelFormat::kA8UNormInt) {
view_create_info.components.a = vk::ComponentSwizzle::eR;
view_create_info.components.r = vk::ComponentSwizzle::eA;
}

auto img_view_res = device_.createImageView(view_create_info);
if (img_view_res.result != vk::Result::eSuccess) {
VALIDATION_LOG << "Unable to create an image view: "
Expand Down
5 changes: 1 addition & 4 deletions impeller/renderer/backend/vulkan/formats_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ constexpr vk::Format ToVKImageFormat(PixelFormat format) {
case PixelFormat::kUnknown:
return vk::Format::eUndefined;
case PixelFormat::kA8UNormInt:
return vk::Format::eA8B8G8R8UnormPack32;
return vk::Format::eR8Unorm;
case PixelFormat::kR8G8B8A8UNormInt:
return vk::Format::eR8G8B8A8Unorm;
case PixelFormat::kR8G8B8A8UNormIntSRGB:
Expand All @@ -164,9 +164,6 @@ constexpr PixelFormat ToPixelFormat(vk::Format format) {
case vk::Format::eUndefined:
return PixelFormat::kUnknown;

case vk::Format::eA8B8G8R8UnormPack32:
return PixelFormat::kA8UNormInt;

case vk::Format::eR8G8B8A8Unorm:
return PixelFormat::kR8G8B8A8UNormInt;

Expand Down