anv: Unable to import I915_FORMAT_MOD_Y_TILED surfaces produced by iHD vaapi driver
Related to #5937 (closed).
System information
System: Host: fido7 Kernel: 5.16.2-051602-generic x86_64 bits: 64 compiler: gcc v: 11.2.0 Desktop: GNOME 40.5
tk: GTK 3.24.30 wm: gnome-shell dm: GDM3 Distro: Ubuntu 21.10 (Impish Indri)
CPU: Info: 12-Core model: 12th Gen Intel Core i9-12900K bits: 64 type: MT MCP arch: Alder Lake rev: 2 cache: L1: 1.4 MiB
L2: 30 MiB L3: 60 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 152985
Speed: 600 MHz min/max: 800/6500 MHz Core speeds (MHz): 1: 600 2: 801 3: 929 4: 805 5: 663 6: 600 7: 600 8: 600
9: 800 10: 1309 11: 801 12: 800 13: 600 14: 800 15: 800 16: 801 17: 801 18: 601 19: 853 20: 700 21: 695 22: 700
23: 810 24: 600
Graphics: Device-1: Intel AlderLake-S GT1 vendor: ASRock driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:4680
Device-2: NVIDIA GA102 [GeForce RTX 3090] driver: nvidia v: 495.46 bus-ID: 01:00.0 chip-ID: 10de:2204
Display: server: X.Org 1.20.13 compositor: gnome-shell driver: loaded: modesetting,nvidia
unloaded: fbdev,nouveau,vesa resolution: 3840x2160~60Hz s-dpi: 96
OpenGL: renderer: Mesa Intel Graphics (ADL-S GT1) v: 4.6 Mesa 21.3.5 - kisak-mesa PPA direct render: Yes
iHD Driver: Latest master
Describe the issue
After updating the media driver as discussed in #5937 (closed), to stop using compressed surfaces, I still cannot import exported vaapi surfaces in Vulkan with ANV.
Exported vaapi surfaces are identified with drm modifier I915_FORMAT_MOD_Y_TILED
. This format has no aux planes, but the import of the surfaces fails due to not conforming to the requirement of being 64k aligned. Where does this requirement come from? It comes from here: https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/intel/isl/isl.c#L1931
So the surface is being treated as having an aux plane even though it does not. It seems that surfaces are assumed to be aux capable unless a disable bit is set, and it is not being set.
I did a quick and dirty patch to say that if an imported surface doesn't have an aux plane, set the disable bit, and it fixed the import. I don't know if that's the correct fix.
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 0d1cd59dfdc..0a8b5bfe588 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1261,6 +1261,7 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
const VkImageCreateInfo *pCreateInfo = create_info->vk_info;
const struct VkImageDrmFormatModifierExplicitCreateInfoEXT *mod_explicit_info = NULL;
const struct isl_drm_modifier_info *isl_mod_info = NULL;
+ isl_surf_usage_flags_t isl_extra_usage_flags = create_info->isl_extra_usage_flags;
VkResult r;
vk_image_init(&device->vk, &image->vk, pCreateInfo);
@@ -1288,6 +1289,10 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
assert(isl_mod_info);
assert(image->vk.drm_format_mod == DRM_FORMAT_MOD_INVALID);
image->vk.drm_format_mod = isl_mod_info->modifier;
+
+ if (!isl_mod_info->aux_usage) {
+ isl_extra_usage_flags |= ISL_SURF_USAGE_DISABLE_AUX_BIT;
+ }
}
for (int i = 0; i < ANV_IMAGE_MEMORY_BINDING_END; ++i) {
@@ -1324,7 +1329,7 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
if (mod_explicit_info) {
r = add_all_surfaces_explicit_layout(device, image, fmt_list,
mod_explicit_info, isl_tiling_flags,
- create_info->isl_extra_usage_flags);
+ isl_extra_usage_flags);
} else {
r = add_all_surfaces_implicit_layout(device, image, fmt_list, 0,
isl_tiling_flags,
Regression
No evidence this ever worked.