File tree 2 files changed +11
-4
lines changed
impeller/renderer/backend/vulkan
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 12
12
#include " impeller/renderer/backend/vulkan/device_buffer_vk.h"
13
13
#include " impeller/renderer/backend/vulkan/formats_vk.h"
14
14
#include " impeller/renderer/backend/vulkan/texture_vk.h"
15
+ #include " impeller/renderer/formats.h"
15
16
16
17
namespace impeller {
17
18
@@ -146,6 +147,15 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
146
147
view_create_info.subresourceRange .levelCount = image_create_info.mipLevels ;
147
148
view_create_info.subresourceRange .layerCount = image_create_info.arrayLayers ;
148
149
150
+ // Vulkan does not have an image format that is equivalent to
151
+ // `MTLPixelFormatA8Unorm`, so we use `R8Unorm` instead. Given that the
152
+ // shaders expect that alpha channel to be set in the cases, we swizzle.
153
+ // See: https://github.com/flutter/flutter/issues/115461 for more details.
154
+ if (desc.format == PixelFormat::kA8UNormInt ) {
155
+ view_create_info.components .a = vk::ComponentSwizzle::eR;
156
+ view_create_info.components .r = vk::ComponentSwizzle::eA;
157
+ }
158
+
149
159
auto img_view_res = device_.createImageView (view_create_info);
150
160
if (img_view_res.result != vk::Result::eSuccess) {
151
161
VALIDATION_LOG << " Unable to create an image view: "
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ constexpr vk::Format ToVKImageFormat(PixelFormat format) {
139
139
case PixelFormat::kUnknown :
140
140
return vk::Format::eUndefined;
141
141
case PixelFormat::kA8UNormInt :
142
- return vk::Format::eA8B8G8R8UnormPack32 ;
142
+ return vk::Format::eR8Unorm ;
143
143
case PixelFormat::kR8G8B8A8UNormInt :
144
144
return vk::Format::eR8G8B8A8Unorm;
145
145
case PixelFormat::kR8G8B8A8UNormIntSRGB :
@@ -164,9 +164,6 @@ constexpr PixelFormat ToPixelFormat(vk::Format format) {
164
164
case vk::Format::eUndefined:
165
165
return PixelFormat::kUnknown ;
166
166
167
- case vk::Format::eA8B8G8R8UnormPack32:
168
- return PixelFormat::kA8UNormInt ;
169
-
170
167
case vk::Format::eR8G8B8A8Unorm:
171
168
return PixelFormat::kR8G8B8A8UNormInt ;
172
169
You can’t perform that action at this time.
0 commit comments