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

Conversation

@gnoliyil
Copy link
Contributor

@gnoliyil gnoliyil commented Mar 5, 2021

Change #23488
has switched all the Vulkan surfaces on Fuchsia to use
RGBA8 color type. However, Using RGBA8 format on Intel GPUs
has caused graphical artifacts on emulators
(See http://fxbug.dev/70232).

This change modifies vulkan_surface.cc to use the multi-format
vkSetBufferCollectionImageConstraintsFUCHSIA() Vulkan API,
so that it could specify multiple formats when allocating
buffer collections.

Bug: fxbug.dev/70232

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Mar 5, 2021
@gnoliyil
Copy link
Contributor Author

gnoliyil commented Mar 5, 2021

@dragostis @dreveman @arbreng Could you please take a look?

Copy link
Contributor

@dreveman dreveman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to support BGRA then please use setBufferCollectionImageConstraintsFUCHSIA instead and set multiple formats. That way we can allow the driver to decide what format is ideal and keep this type of workaround (if needed) in a more appropriate location.

Change flutter#23488
has switched all the Vulkan surfaces on Fuchsia to use
RGBA8 color type. However, Using RGBA8 format on Intel GPUs
has caused graphical artifacts on emulators
(See http://fxbug.dev/70232).

This change modifies vulkan_surface.cc to use the multi-format
vkSetBufferCollectionImageConstraintsFUCHSIA() Vulkan API,
so that it could specify multiple formats when allocating
buffer collections.

Bug: fxbug.dev/70232
@gnoliyil gnoliyil changed the title fuchsia: Use BGRA8 on non-ARM devices. fuchsia: Support multiple formats of Vulkan surface images. Mar 5, 2021
@gnoliyil
Copy link
Contributor Author

gnoliyil commented Mar 5, 2021

If we need to support BGRA then please use setBufferCollectionImageConstraintsFUCHSIA instead and set multiple formats. That way we can allow the driver to decide what format is ideal and keep this type of workaround (if needed) in a more appropriate location.

Done. PTAL.

@gnoliyil
Copy link
Contributor Author

gnoliyil commented Mar 5, 2021

This change won't build until #24829 and flutter/buildroot#441 are submitted to support the latest Vulkan headers in Flutter repository.

Comment on lines +29 to +41
//
//
//
//
// #if defined(__aarch64__)
// constexpr SkColorType kSkiaColorType = kRGBA_8888_SkColorType;
// constexpr VkFormat kVulkanFormat = VK_FORMAT_R8G8B8A8_UNORM;
// constexpr VkImageCreateFlags kVulkanImageCreateFlags = 0;
// #else
// constexpr VkImageCreateFlags kVulkanImageCreateFlags =
// VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
// #endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this before landing

.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = nullptr,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
const VkImageCreateInfo kDefaultImageCreateInfo = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not really a global constant as you're setting pnext and extent to local values. please rename to image_create_info or maybe better, fold it into the loop I'm suggesting below

.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
};

constexpr size_t kNumFormats = 2u;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace this with an array of VK_FORMATs and iterate over it to build create_infos.

Comment on lines +102 to +105
// Immutable format is technically limited to R8G8B8A8_SRGB but
// R8G8B8A8_UNORM works with existing ARM drivers so we allow that
// until we have a more reliable API for creating external Vulkan
// images using sysmem. TODO(fxb/52835)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commend doesn't make sense when using sysmem. why are you adding this back?

create_infos[0].format = VK_FORMAT_R8G8B8A8_UNORM;
format_constraints[1].sysmemFormat = static_cast<uint64_t>(fuchsia::sysmem::PixelFormatType::BGRA32);
create_infos[1].format = VK_FORMAT_B8G8R8A8_UNORM;
create_infos[1].flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add this flag? it shouldn't be needed when using sysmem

const VkImageConstraintsInfoFUCHSIA constraints_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CONSTRAINTS_INFO_FUCHSIA,
.pNext = nullptr,
.createInfoCount = kNumFormats,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: create_infos.size()

@chinmaygarde
Copy link
Member

@gnoliyil Any updates on @dreveman s last review?

@dreveman
Copy link
Contributor

We found a better way to solve this. In the driver. So this is no longer needed.

@arbreng arbreng closed this Mar 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants