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
15 changes: 15 additions & 0 deletions impeller/renderer/backend/vulkan/driver_info_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@

#include <iomanip>
#include <sstream>
#include <string_view>

#include "flutter/fml/build_config.h"

namespace impeller {

/// Non functional Vulkan driver, see:
/// https://github.com/flutter/flutter/issues/154103
///
/// Reports "VK_INCOMPLETE" when compiling certain entity shader with
Copy link
Member

Choose a reason for hiding this comment

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

Do we know which shader this is? I'll try to follow up.

We can catch up afterwards about this. Not blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Porterduff and conical gradient ssbo

/// vkCreateGraphicsPipelines, which is not a valid return status.
constexpr std::string_view kAdreno630 = "Adreno (TM) 630";

constexpr VendorVK IdentifyVendor(uint32_t vendor) {
// Check if the vendor has a PCI ID:
// https://pcisig.com/membership/member-companies
Expand Down Expand Up @@ -188,4 +196,11 @@ bool DriverInfoVK::IsEmulator() const {
return false;
}

bool DriverInfoVK::IsKnownBadDriver() const {
if (vendor_ == VendorVK::kQualcomm && driver_name_ == kAdreno630) {
return true;
}
return false;
}

} // namespace impeller
11 changes: 11 additions & 0 deletions impeller/renderer/backend/vulkan/driver_info_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ class DriverInfoVK {
///
bool IsEmulator() const;

//----------------------------------------------------------------------------
/// @brief Determines if the driver has been tested and determined to be
/// non-functional.
///
/// If true, context setup should fail such that the device falls
/// back to OpenGLES.
///
/// @return True if non-functional device, False otherwiise.
///
bool IsKnownBadDriver() const;

private:
bool is_valid_ = false;
Version api_version_;
Expand Down
21 changes: 20 additions & 1 deletion impeller/renderer/backend/vulkan/driver_info_vk_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#include "impeller/playground/playground_test.h"
#include "impeller/renderer/backend/vulkan/context_vk.h"
#include "impeller/renderer/backend/vulkan/driver_info_vk.h"
#include "impeller/renderer/backend/vulkan/surface_context_vk.h"
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h"

namespace impeller::testing {

Expand All @@ -21,6 +23,7 @@ TEST_P(DriverInfoVKTest, CanQueryDriverInfo) {
ASSERT_NE(driver_info->GetVendor(), VendorVK::kUnknown);
ASSERT_NE(driver_info->GetDeviceType(), DeviceTypeVK::kUnknown);
ASSERT_NE(driver_info->GetDriverName(), "");
EXPECT_FALSE(driver_info->IsKnownBadDriver());
}

TEST_P(DriverInfoVKTest, CanDumpToLog) {
Expand All @@ -30,7 +33,23 @@ TEST_P(DriverInfoVKTest, CanDumpToLog) {
ASSERT_NE(driver_info, nullptr);
fml::testing::LogCapture log;
driver_info->DumpToLog();
ASSERT_TRUE(log.str().find("Driver Information") != std::string::npos);
EXPECT_TRUE(log.str().find("Driver Information") != std::string::npos);
}

TEST(DriverInfoVKTest, DisabledDevices) {
std::string name = "Adreno (TM) 630";
auto const context = MockVulkanContextBuilder()
.SetPhysicalPropertiesCallback(
[&name](VkPhysicalDevice device,
VkPhysicalDeviceProperties* prop) {
prop->vendorID = 0x168C; // Qualcomm
name.copy(prop->deviceName, name.size());
prop->deviceType =
VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
})
.Build();

EXPECT_TRUE(context->GetDriverInfo()->IsKnownBadDriver());
}

} // namespace impeller::testing
8 changes: 8 additions & 0 deletions impeller/renderer/backend/vulkan/test/mock_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,20 @@ void vkGetPhysicalDeviceFormatProperties(
g_format_properties_callback(physicalDevice, format, pFormatProperties);
}

static thread_local std::function<void(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties* pProperties)>
g_physical_device_properties_callback;

void vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties* pProperties) {
pProperties->limits.framebufferColorSampleCounts =
static_cast<VkSampleCountFlags>(VK_SAMPLE_COUNT_1_BIT |
VK_SAMPLE_COUNT_4_BIT);
pProperties->limits.maxImageDimension2D = 4096;
pProperties->limits.timestampPeriod = 1;
if (g_physical_device_properties_callback) {
g_physical_device_properties_callback(physicalDevice, pProperties);
}
}

void vkGetPhysicalDeviceQueueFamilyProperties(
Expand Down Expand Up @@ -919,6 +926,7 @@ std::shared_ptr<ContextVK> MockVulkanContextBuilder::Build() {
g_instance_extensions = instance_extensions_;
g_instance_layers = instance_layers_;
g_format_properties_callback = format_properties_callback_;
g_physical_device_properties_callback = physical_properties_callback_;
std::shared_ptr<ContextVK> result = ContextVK::Create(std::move(settings));
return result;
}
Expand Down
11 changes: 11 additions & 0 deletions impeller/renderer/backend/vulkan/test/mock_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ class MockVulkanContextBuilder {
return *this;
}

MockVulkanContextBuilder& SetPhysicalPropertiesCallback(
std::function<void(VkPhysicalDevice device,
VkPhysicalDeviceProperties* physicalProperties)>
physical_properties_callback) {
physical_properties_callback_ = std::move(physical_properties_callback);
return *this;
}

private:
std::function<void(ContextVK::Settings&)> settings_callback_;
std::vector<std::string> instance_extensions_;
Expand All @@ -108,6 +116,9 @@ class MockVulkanContextBuilder {
VkFormat format,
VkFormatProperties* pFormatProperties)>
format_properties_callback_;
std::function<void(VkPhysicalDevice device,
VkPhysicalDeviceProperties* physicalProperties)>
physical_properties_callback_;
};

/// @brief Override the image size returned by all swapchain images.
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/android/android_context_vk_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "flutter/shell/platform/android/android_context_vk_impeller.h"

#include "flutter/fml/logging.h"
#include "flutter/fml/paths.h"
#include "flutter/impeller/entity/vk/entity_shaders_vk.h"
#include "flutter/impeller/entity/vk/framebuffer_blend_shaders_vk.h"
Expand Down Expand Up @@ -67,6 +68,11 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
FML_LOG(IMPORTANT) << "Using the Impeller rendering backend (Vulkan).";
}
}
if (context->GetDriverInfo()->IsKnownBadDriver()) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps an INFO log saying this happened? Or will this cause issues with tests further down the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would that log be actionable?

Copy link
Member

Choose a reason for hiding this comment

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

To the end user, it won't. But perhaps useful to know for us when we expect Vulkan but get OpenGL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Do you need a null check on context here?

FML_LOG(INFO)
<< "Known bad Vulkan driver encountered, falling back to OpenGLES.";
return nullptr;
}

return context;
}
Expand Down