Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec violation in vkBindImageMemory() validation with VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT #7831

Open
cgutman opened this issue Apr 11, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working

Comments

@cgutman
Copy link

cgutman commented Apr 11, 2024

Environment:

  • OS: Fedora 40
  • GPU and driver version: Intel(R) Graphics (ADL GT2) (Mesa 24.0.4)
  • SDK or header version if building from repo: v1.3.275
  • Options enabled (synchronization, best practices, etc.): N/A

Describe the Issue

The new validation introduced in #7199 regressed the UB fix made in ce2c6ef and reintroduced the crashes in reported in #5649 and #5687 (though now it's now crashing during vkBindImageMemory() rather than vkCreateImage() ). AFAICT, this regression was first released in v1.3.275 and persists today in v1.3.280.

This happens because Mesa assumes that the pNext chain passed to vkGetPhysicalDeviceImageFormatProperties2() always includes includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, which is a specification requirement per VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249. The relevant Mesa code is here: https://gitlab.freedesktop.org/mesa/mesa/-/blob/24.0/src/intel/vulkan/anv_formats.c?ref_type=heads#L1239-1243

Expected behavior

Per VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249:

tiling must be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT if and only if the pNext chain includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT

Valid Usage ID

Violation of VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249 (unreported since the violation is in the validation layer itself)

Additional context

GDB output
hread 18 "QThread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffbaa006c0 (LWP 16233)]
anv_get_image_format_properties (physical_device=physical_device@entry=0x7fff78e44740, info=info@entry=0x7fffba9fe040, pImageFormatProperties=pImageFormatProperties@entry=0x7fffba9fe080, pYcbcrImageFormatProperties=0x0, 
    from_wsi=false) at ../src/intel/vulkan/anv_formats.c:1243
Downloading source file /usr/src/debug/mesa-24.0.4-1.fc40.x86_64/redhat-linux-build/../src/intel/vulkan/anv_formats.c
1243          isl_mod_info = isl_drm_modifier_get_info(vk_mod_info->drmFormatModifier);
(gdb) info locals
vk_mod_info = 0x0
format_feature_flags = <optimized out>
maxExtent = <optimized out>
maxMipLevels = <optimized out>
maxArraySize = <optimized out>
sampleCounts = <optimized out>
devinfo = 0x7fff78e45968
format = 0x7fffaf612160 <main_formats+288>
isl_mod_info = 0x0
format_list_info = <optimized out>
maxResourceSize = <optimized out>               
(gdb) bt
#0  anv_get_image_format_properties
    (physical_device=physical_device@entry=0x7fff78e44740, info=info@entry=0x7fffba9fe040, pImageFormatProperties=pImageFormatProperties@entry=0x7fffba9fe080, pYcbcrImageFormatProperties=0x0, from_wsi=false)
    at ../src/intel/vulkan/anv_formats.c:1243
#1  0x00007fffaee98508 in anv_GetPhysicalDeviceImageFormatProperties2 (physicalDevice=0x7fff78e44740, base_info=0x7fffba9fe040, base_props=0x7fffba9fe070) at ../src/intel/vulkan/anv_formats.c:1644
#2  0x00007fff8e2d7800 in DispatchGetPhysicalDeviceImageFormatProperties2KHR () at /usr/src/debug/vulkan-validation-layers-1.3.275.0-1.fc40.x86_64/layers/vulkan/generated/layer_chassis_dispatch.cpp:3579
#3  CoreChecks::HasExternalMemoryImportSupport () at /usr/src/debug/vulkan-validation-layers-1.3.275.0-1.fc40.x86_64/layers/core_checks/cc_device_memory.cpp:228
#4  0x00007fff8e30f096 in CoreChecks::ValidateBindImageMemory () at /usr/src/debug/vulkan-validation-layers-1.3.275.0-1.fc40.x86_64/layers/core_checks/cc_device_memory.cpp:1540
#5  0x00007fff8e3115ac in CoreChecks::PreCallValidateBindImageMemory () at /usr/src/debug/vulkan-validation-layers-1.3.275.0-1.fc40.x86_64/layers/core_checks/cc_device_memory.cpp:1747
#6  0x00007fff8e86ddb3 in vulkan_layer_chassis::BindImageMemory () at /usr/src/debug/vulkan-validation-layers-1.3.275.0-1.fc40.x86_64/layers/vulkan/generated/chassis.cpp:1578
#7  0x00007ffff773c9c5 in vk_tex_create (gpu=0x7fff794e3e90, params=0x7fffba9feac0) at ../src/vulkan/gpu_tex.c:520
#8  0x00000000004b9bb5 in pl_map_avframe_drm (gpu=0x7fff794e3e90, out=0x7fffba9feef0, frame=0x7fff79949a80) at /usr/include/libplacebo/utils/libav_internal.h:999
#9  0x00000000004b9d03 in pl_map_avframe_derived (gpu=0x7fff794e3e90, out=0x7fffba9feef0, frame=0x7fff796d2f00) at /usr/include/libplacebo/utils/libav_internal.h:1037
#10 0x00000000004ba62b in pl_map_avframe_ex (gpu=0x7fff794e3e90, out=0x7fffba9feef0, params=0x7fffba9feeb0) at /usr/include/libplacebo/utils/libav_internal.h:1219
@spencer-lunarg spencer-lunarg self-assigned this Apr 11, 2024
@spencer-lunarg spencer-lunarg added the Bug Something isn't working label Apr 11, 2024
@spencer-lunarg
Copy link
Contributor

Thanks for digging up all this information, will take a look today/tomorrow

I realize we really should have added a VVL regression test when acting the DRM change before, but back then I didn't have enough knowledge of DRM Format Modifier or a Mesa build to test with

@spencer-lunarg
Copy link
Contributor

@cgutman sorry for the delay

spent some time on this and I think the issue might be that Mesa and Spec don't match up, the spec VU is

tiling must be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT if and only if the pNext chain includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT

but not that if tiling is DRM_FORMAT_MODIFIER, a pNext struct must be there

@spencer-lunarg
Copy link
Contributor

also it seems the fix was already patched in https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/7318/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants