diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.c b/app/src/main/cpp/waylandcomp/src/vk_present.c index a44dfe0b7..bd6a63dd9 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.c +++ b/app/src/main/cpp/waylandcomp/src/vk_present.c @@ -1834,9 +1834,9 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t uint32_t stride, uint32_t offset, int as_blit_dst) { if (modifier == MOD_INVALID || w <= 0 || h <= 0) return NULL; if (dev_init() != 0) return NULL; - if (!vkp_dmabuf_layout_describable(g_drm_modifiers, modifier)) { - LOGE("%s: the driver has no VK_EXT_image_drm_format_modifier to lay out the %s %dx%d dma-buf", - as_blit_dst ? "layer" : "dmabuf", vkp_modifier_name(modifier), w, h); + if (as_blit_dst && !vkp_dmabuf_layout_describable(g_drm_modifiers, modifier)) { + LOGE("layer: the driver has no VK_EXT_image_drm_format_modifier to lay out the %s %dx%d dma-buf", + vkp_modifier_name(modifier), w, h); return NULL; } diff --git a/tools/tests/test_vk_linear_dmabuf.py b/tools/tests/test_vk_linear_dmabuf.py index ad39af709..d4715920e 100644 --- a/tools/tests/test_vk_linear_dmabuf.py +++ b/tools/tests/test_vk_linear_dmabuf.py @@ -124,9 +124,14 @@ class VkLinearDmabufTest(unittest.TestCase): self.assertIn("!as_blit_dst", terms) self.assertIn("g_vk.GetPhysicalDeviceImageFormatProperties2", terms) + def test_client_imports_are_not_refused_by_the_layer_guard(self): + body = function((SRC / "vk_present.c").read_text(), "vkp_image_import_dmabuf") + self.assertEqual(body.count("vkp_dmabuf_layout_describable("), 1) + self.assertIn("as_blit_dst && !vkp_dmabuf_layout_describable(", body) + def test_undescribable_layout_is_refused_before_any_image_is_made(self): body = function((SRC / "vk_present.c").read_text(), "vkp_image_import_dmabuf") - guard = body.index("if (!vkp_dmabuf_layout_describable(g_drm_modifiers, modifier))") + guard = body.index("if (as_blit_dst && !vkp_dmabuf_layout_describable(g_drm_modifiers, modifier))") self.assertLess(body.index("dev_init()"), guard) self.assertIn("return NULL;", body[guard:body.index("drm_to_vk(drm_format)")]) self.assertLess(guard, body.index("calloc(1, sizeof(*img))"))