[Impeller] Fix Vulkan compile failures on Android (flutter/engine#37171)

This commit is contained in:
Kaushik Iska
2022-10-31 12:28:05 -04:00
committed by GitHub
parent 6013743aae
commit 09e5bccbb1
7 changed files with 35 additions and 29 deletions

View File

@@ -138,7 +138,7 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
}
vk::ImageViewCreateInfo view_create_info = {};
view_create_info.image = img;
view_create_info.image = vk::Image{img};
view_create_info.viewType = vk::ImageViewType::e2D;
view_create_info.format = image_create_info.format;
view_create_info.subresourceRange.aspectMask =
@@ -153,6 +153,8 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
return nullptr;
}
auto image_view = static_cast<vk::ImageView::NativeType>(img_view_res.value);
auto texture_info = std::make_unique<TextureInfoVK>(TextureInfoVK{
.backing_type = TextureBackingTypeVK::kAllocatedTexture,
.allocated_texture =
@@ -161,7 +163,7 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
.allocation = allocation,
.allocation_info = allocation_info,
.image = img,
.image_view = img_view_res.value,
.image_view = image_view,
},
});
return std::make_shared<TextureVK>(desc, &context_, std::move(texture_info));

View File

@@ -23,10 +23,31 @@
#include "impeller/renderer/backend/vulkan/surface_producer_vk.h"
#include "impeller/renderer/backend/vulkan/swapchain_details_vk.h"
#include "impeller/renderer/backend/vulkan/vk.h"
#include "vulkan/vulkan.hpp"
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
namespace {
VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsMessengerCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT severity,
VkDebugUtilsMessageTypeFlagsEXT type,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) {
const auto prefix = impeller::vk::to_string(
impeller::vk::DebugUtilsMessageSeverityFlagBitsEXT{severity});
FML_DCHECK(false) << prefix << "[" << pCallbackData->messageIdNumber << "]["
<< pCallbackData->pMessageIdName
<< "] : " << pCallbackData->pMessage;
// The return value of this callback controls whether the Vulkan call that
// caused the validation message will be aborted or not We return VK_TRUE as
// we DO want Vulkan calls that cause a validation message to abort
return VK_TRUE;
}
} // namespace
namespace impeller {
static std::set<std::string> kRequiredDeviceExtensions = {
@@ -335,7 +356,6 @@ ContextVK::ContextVK(
if (has_debug_utils) {
vk::DebugUtilsMessengerCreateInfoEXT debug_messenger_info;
debug_messenger_info.messageSeverity =
vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eError;
@@ -344,23 +364,7 @@ ContextVK::ContextVK(
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance |
vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation;
debug_messenger_info.pUserData = nullptr;
debug_messenger_info.pfnUserCallback =
[](VkDebugUtilsMessageSeverityFlagBitsEXT severity,
VkDebugUtilsMessageTypeFlagsEXT type,
const VkDebugUtilsMessengerCallbackDataEXT* data,
void* user_data) -> VkBool32 {
if (type == VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) {
// do not terminate on performance warnings.
FML_LOG(ERROR)
<< vk::to_string(vk::DebugUtilsMessageSeverityFlagBitsEXT{severity})
<< ": " << data->pMessage;
} else {
FML_DCHECK(false)
<< vk::to_string(vk::DebugUtilsMessageSeverityFlagBitsEXT{severity})
<< ": " << data->pMessage;
}
return true;
};
debug_messenger_info.pfnUserCallback = DebugUtilsMessengerCallback;
auto debug_messenger_result =
instance.value->createDebugUtilsMessengerEXTUnique(

View File

@@ -90,7 +90,7 @@ vk::ImageView TextureVK::GetImageView() const {
case TextureBackingTypeVK::kUnknownType:
return nullptr;
case TextureBackingTypeVK::kAllocatedTexture:
return texture_info_->allocated_texture.image_view;
return vk::ImageView{texture_info_->allocated_texture.image_view};
case TextureBackingTypeVK::kWrappedTexture:
return texture_info_->wrapped_texture.swapchain_image->GetImageView();
}
@@ -101,7 +101,7 @@ vk::Image TextureVK::GetImage() const {
case TextureBackingTypeVK::kUnknownType:
FML_CHECK(false) << "Unknown texture backing type";
case TextureBackingTypeVK::kAllocatedTexture:
return texture_info_->allocated_texture.image;
return vk::Image{texture_info_->allocated_texture.image};
case TextureBackingTypeVK::kWrappedTexture:
return texture_info_->wrapped_texture.swapchain_image->GetImage();
}

View File

@@ -28,8 +28,8 @@ struct AllocatedTextureInfoVK {
VmaAllocator* allocator = nullptr;
VmaAllocation allocation = nullptr;
VmaAllocationInfo allocation_info = {};
VkImage image = nullptr;
VkImageView image_view = nullptr;
VkImage image = VK_NULL_HANDLE;
VkImageView image_view = VK_NULL_HANDLE;
};
struct TextureInfoVK {

View File

@@ -84,7 +84,7 @@ vk::Format ToVertexDescriptorFormat(const ShaderStageIOSlot& input) {
return vk::Format::eUndefined;
}
case ShaderType::kSignedShort: {
if (input.bit_width == 8 * sizeof(short)) {
if (input.bit_width == 8 * sizeof(int16_t)) {
switch (input.vec_size) {
case 1:
return vk::Format::eR16Sint;
@@ -99,7 +99,7 @@ vk::Format ToVertexDescriptorFormat(const ShaderStageIOSlot& input) {
return vk::Format::eUndefined;
}
case ShaderType::kUnsignedShort: {
if (input.bit_width == 8 * sizeof(ushort)) {
if (input.bit_width == 8 * sizeof(uint16_t)) {
switch (input.vec_size) {
case 1:
return vk::Format::eR16Uint;

View File

@@ -17,7 +17,7 @@ declare_args() {
impeller_enable_opengles = is_mac || is_linux || is_win || is_android
# Whether the Vulkan backend is enabled.
impeller_enable_vulkan = is_linux
impeller_enable_vulkan = is_linux || is_android
# Whether to use a prebuilt impellerc.
# If this is the empty string, impellerc will be built.

View File

@@ -4018,7 +4018,7 @@ TEST_F(EmbedderTest, ExternalTextureGLRefreshedTooOften) {
TestGLSurface surface(SkISize::Make(100, 100));
auto context = surface.GetGrContext();
typedef void (*glGenTexturesProc)(uint32_t n, uint32_t * textures);
typedef void (*glGenTexturesProc)(uint32_t n, uint32_t* textures);
glGenTexturesProc glGenTextures;
glGenTextures = reinterpret_cast<glGenTexturesProc>(