Skip to content

Commit eb5b49f

Browse files
committed
[Impeller] Fix compile failures on Android
Also removes the need to not-fail on performance related failures which was done as a stop-gap for: flutter#36923
1 parent cfb5324 commit eb5b49f

File tree

7 files changed

+35
-29
lines changed

7 files changed

+35
-29
lines changed

impeller/renderer/backend/vulkan/allocator_vk.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
138138
}
139139

140140
vk::ImageViewCreateInfo view_create_info = {};
141-
view_create_info.image = img;
141+
view_create_info.image = vk::Image{img};
142142
view_create_info.viewType = vk::ImageViewType::e2D;
143143
view_create_info.format = image_create_info.format;
144144
view_create_info.subresourceRange.aspectMask =
@@ -153,6 +153,8 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
153153
return nullptr;
154154
}
155155

156+
auto image_view = static_cast<vk::ImageView::NativeType>(img_view_res.value);
157+
156158
auto texture_info = std::make_unique<TextureInfoVK>(TextureInfoVK{
157159
.backing_type = TextureBackingTypeVK::kAllocatedTexture,
158160
.allocated_texture =
@@ -161,7 +163,7 @@ std::shared_ptr<Texture> AllocatorVK::OnCreateTexture(
161163
.allocation = allocation,
162164
.allocation_info = allocation_info,
163165
.image = img,
164-
.image_view = img_view_res.value,
166+
.image_view = image_view,
165167
},
166168
});
167169
return std::make_shared<TextureVK>(desc, &context_, std::move(texture_info));

impeller/renderer/backend/vulkan/context_vk.cc

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,31 @@
2323
#include "impeller/renderer/backend/vulkan/surface_producer_vk.h"
2424
#include "impeller/renderer/backend/vulkan/swapchain_details_vk.h"
2525
#include "impeller/renderer/backend/vulkan/vk.h"
26-
#include "vulkan/vulkan.hpp"
2726

2827
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
2928

29+
namespace {
30+
31+
VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsMessengerCallback(
32+
VkDebugUtilsMessageSeverityFlagBitsEXT severity,
33+
VkDebugUtilsMessageTypeFlagsEXT type,
34+
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
35+
void* pUserData) {
36+
const auto prefix = impeller::vk::to_string(
37+
impeller::vk::DebugUtilsMessageSeverityFlagBitsEXT{severity});
38+
39+
FML_DCHECK(false) << prefix << "[" << pCallbackData->messageIdNumber << "]["
40+
<< pCallbackData->pMessageIdName
41+
<< "] : " << pCallbackData->pMessage;
42+
43+
// The return value of this callback controls whether the Vulkan call that
44+
// caused the validation message will be aborted or not We return VK_TRUE as
45+
// we DO want Vulkan calls that cause a validation message to abort
46+
return VK_TRUE;
47+
}
48+
49+
} // namespace
50+
3051
namespace impeller {
3152

3253
static std::set<std::string> kRequiredDeviceExtensions = {
@@ -335,7 +356,6 @@ ContextVK::ContextVK(
335356

336357
if (has_debug_utils) {
337358
vk::DebugUtilsMessengerCreateInfoEXT debug_messenger_info;
338-
339359
debug_messenger_info.messageSeverity =
340360
vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
341361
vk::DebugUtilsMessageSeverityFlagBitsEXT::eError;
@@ -344,23 +364,7 @@ ContextVK::ContextVK(
344364
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance |
345365
vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation;
346366
debug_messenger_info.pUserData = nullptr;
347-
debug_messenger_info.pfnUserCallback =
348-
[](VkDebugUtilsMessageSeverityFlagBitsEXT severity,
349-
VkDebugUtilsMessageTypeFlagsEXT type,
350-
const VkDebugUtilsMessengerCallbackDataEXT* data,
351-
void* user_data) -> VkBool32 {
352-
if (type == VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) {
353-
// do not terminate on performance warnings.
354-
FML_LOG(ERROR)
355-
<< vk::to_string(vk::DebugUtilsMessageSeverityFlagBitsEXT{severity})
356-
<< ": " << data->pMessage;
357-
} else {
358-
FML_DCHECK(false)
359-
<< vk::to_string(vk::DebugUtilsMessageSeverityFlagBitsEXT{severity})
360-
<< ": " << data->pMessage;
361-
}
362-
return true;
363-
};
367+
debug_messenger_info.pfnUserCallback = DebugUtilsMessengerCallback;
364368

365369
auto debug_messenger_result =
366370
instance.value->createDebugUtilsMessengerEXTUnique(

impeller/renderer/backend/vulkan/texture_vk.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ vk::ImageView TextureVK::GetImageView() const {
9090
case TextureBackingTypeVK::kUnknownType:
9191
return nullptr;
9292
case TextureBackingTypeVK::kAllocatedTexture:
93-
return texture_info_->allocated_texture.image_view;
93+
return vk::ImageView{texture_info_->allocated_texture.image_view};
9494
case TextureBackingTypeVK::kWrappedTexture:
9595
return texture_info_->wrapped_texture.swapchain_image->GetImageView();
9696
}
@@ -101,7 +101,7 @@ vk::Image TextureVK::GetImage() const {
101101
case TextureBackingTypeVK::kUnknownType:
102102
FML_CHECK(false) << "Unknown texture backing type";
103103
case TextureBackingTypeVK::kAllocatedTexture:
104-
return texture_info_->allocated_texture.image;
104+
return vk::Image{texture_info_->allocated_texture.image};
105105
case TextureBackingTypeVK::kWrappedTexture:
106106
return texture_info_->wrapped_texture.swapchain_image->GetImage();
107107
}

impeller/renderer/backend/vulkan/texture_vk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ struct AllocatedTextureInfoVK {
2828
VmaAllocator* allocator = nullptr;
2929
VmaAllocation allocation = nullptr;
3030
VmaAllocationInfo allocation_info = {};
31-
VkImage image = nullptr;
32-
VkImageView image_view = nullptr;
31+
VkImage image = VK_NULL_HANDLE;
32+
VkImageView image_view = VK_NULL_HANDLE;
3333
};
3434

3535
struct TextureInfoVK {

impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ vk::Format ToVertexDescriptorFormat(const ShaderStageIOSlot& input) {
8484
return vk::Format::eUndefined;
8585
}
8686
case ShaderType::kSignedShort: {
87-
if (input.bit_width == 8 * sizeof(short)) {
87+
if (input.bit_width == 8 * sizeof(int16_t)) {
8888
switch (input.vec_size) {
8989
case 1:
9090
return vk::Format::eR16Sint;
@@ -99,7 +99,7 @@ vk::Format ToVertexDescriptorFormat(const ShaderStageIOSlot& input) {
9999
return vk::Format::eUndefined;
100100
}
101101
case ShaderType::kUnsignedShort: {
102-
if (input.bit_width == 8 * sizeof(ushort)) {
102+
if (input.bit_width == 8 * sizeof(uint16_t)) {
103103
switch (input.vec_size) {
104104
case 1:
105105
return vk::Format::eR16Uint;

impeller/tools/impeller.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare_args() {
1717
impeller_enable_opengles = is_mac || is_linux || is_win || is_android
1818

1919
# Whether the Vulkan backend is enabled.
20-
impeller_enable_vulkan = is_linux
20+
impeller_enable_vulkan = is_linux || is_android
2121

2222
# Whether to use a prebuilt impellerc.
2323
# If this is the empty string, impellerc will be built.

shell/platform/embedder/tests/embedder_unittests_gl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ TEST_F(EmbedderTest, ExternalTextureGLRefreshedTooOften) {
40184018
TestGLSurface surface(SkISize::Make(100, 100));
40194019
auto context = surface.GetGrContext();
40204020

4021-
typedef void (*glGenTexturesProc)(uint32_t n, uint32_t * textures);
4021+
typedef void (*glGenTexturesProc)(uint32_t n, uint32_t* textures);
40224022
glGenTexturesProc glGenTextures;
40234023

40244024
glGenTextures = reinterpret_cast<glGenTexturesProc>(

0 commit comments

Comments
 (0)