Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
6 changes: 4 additions & 2 deletions impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand All @@ -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));
Expand Down
42 changes: 23 additions & 19 deletions impeller/renderer/backend/vulkan/context_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/vulkan/texture_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/vulkan/texture_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions impeller/renderer/backend/vulkan/vertex_descriptor_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion impeller/tools/impeller.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/embedder/tests/embedder_unittests_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down