Skip to content

Commit 716a80e

Browse files
committed
[Impeller] Add regression test for Vulkan block-compressed texture support
The mock device now advertises the core textureCompressionETC2, textureCompressionASTC_LDR, and textureCompressionBC features, and a new CapabilitiesVKTest asserts CapabilitiesVK::SupportsTextureCompression reports all three families. Without the enable added in the previous commit, GetEnabledDeviceFeatures never requests them, the read-back in SetPhysicalDevice stays false, and this test fails -- guarding against a regression of the plumbing. Issue: flutter#189107
1 parent ffe5947 commit 716a80e

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎engine/src/flutter/impeller/renderer/backend/vulkan/context_vk_unittests.cc‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,24 @@ TEST(CapabilitiesVKTest, ContextInitializesWithNoStencilFormat) {
208208
PixelFormat::kD32FloatS8UInt);
209209
}
210210

211+
// Regression test for https://github.com/flutter/flutter/issues/189107.
212+
// The core Vulkan 1.0 block-compression features (ETC2, ASTC LDR, BC) must be
213+
// explicitly requested in GetEnabledDeviceFeatures so the read-back in
214+
// SetPhysicalDevice reports real support. The mock device advertises all three
215+
// as supported, so a device that enables them correctly must report them here.
216+
TEST(CapabilitiesVKTest, ReportsBlockCompressedTextureSupport) {
217+
const std::shared_ptr<ContextVK> context = MockVulkanContextBuilder().Build();
218+
ASSERT_NE(context, nullptr);
219+
const CapabilitiesVK* capabilities_vk =
220+
reinterpret_cast<const CapabilitiesVK*>(context->GetCapabilities().get());
221+
EXPECT_TRUE(capabilities_vk->SupportsTextureCompression(
222+
CompressedTextureFamily::kETC2));
223+
EXPECT_TRUE(capabilities_vk->SupportsTextureCompression(
224+
CompressedTextureFamily::kASTC));
225+
EXPECT_TRUE(capabilities_vk->SupportsTextureCompression(
226+
CompressedTextureFamily::kBC));
227+
}
228+
211229
// Impeller's 2D renderer relies on hardware support for a combined
212230
// depth-stencil format (widely supported). So fail initialization if a suitable
213231
// one couldn't be found. That way we have an opportunity to fallback to

‎engine/src/flutter/impeller/renderer/backend/vulkan/test/mock_vulkan.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,15 @@ void vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
323323

324324
void vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
325325
VkPhysicalDeviceFeatures2* pFeatures) {
326+
// Advertise the core block-compressed texture features so tests can exercise
327+
// the GetEnabledDeviceFeatures -> SetPhysicalDevice plumbing that gates
328+
// CapabilitiesVK::SupportsTextureCompression. Without this the mock reports
329+
// these core Vulkan 1.0 features as VK_FALSE and the capability is always
330+
// false regardless of the enable path.
331+
pFeatures->features.textureCompressionETC2 = VK_TRUE;
332+
pFeatures->features.textureCompressionASTC_LDR = VK_TRUE;
333+
pFeatures->features.textureCompressionBC = VK_TRUE;
334+
326335
// Advertise the features the mock supports by walking the pNext chain.
327336
auto* next = reinterpret_cast<VkBaseOutStructure*>(pFeatures->pNext);
328337
while (next != nullptr) {

0 commit comments

Comments
 (0)