vulkano icon indicating copy to clipboard operation
vulkano copied to clipboard

Wrong MemoryRequirements with lavapipe

Open inferrna opened this issue 1 year ago • 5 comments

  • Version of vulkano: 0.30
  • OS: Linux
  • GPU (the selected PhysicalDevice): Lavapipe from git
  • GPU Driver: Lavapipe from git

Issue

Steps to reproduce

  1. git clone --depth 1 https://gitlab.freedesktop.org/mesa/mesa.git
  2. cd mesa
  3. meson -Dprefix=/tmp/install -Dplatforms=x11 -Degl-native-platform=x11 -Dandroid-stub=false -Ddri3=true -Dgallium-drivers=swrast -Dgallium-vdpau=false -Dvulkan-drivers=swrast -Dgles1=false -Dgles2=false -Dopengl=false -Dglx=disabled -Degl=disabled -Dgallium-lavapipe=true build/
  4. Use stuff from build/src/gallium/targets/lavapipe/
  5. run cargo test for vulkano

A lot of tests will fail with 'assertion failed: size != 0'. This size:

MemoryRequirements {
    size: 0,
    alignment: 16,
    memory_type_bits: 1,
    prefer_dedicated: false,
}

inferrna avatar Aug 05 '22 20:08 inferrna

Can you post the full assertion failed message?

Rua avatar Aug 06 '22 11:08 Rua

Failures

failures:

---- image::attachment::tests::create_regular stdout ----
thread 'image::attachment::tests::create_regular' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::attachment::tests::create_transient stdout ----
thread 'image::attachment::tests::create_transient' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::attachment::tests::d16_unorm_always_supported stdout ----
thread 'image::attachment::tests::d16_unorm_always_supported' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::storage::tests::create stdout ----
thread 'image::storage::tests::create' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::storage::tests::create_general_purpose_image_view_failed stdout ----
thread 'image::storage::tests::create_general_purpose_image_view_failed' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::storage::tests::create_general_purpose_image_view stdout ----
thread 'image::storage::tests::create_general_purpose_image_view' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- image::tests::mipmap_working_immutable_image stdout ----
thread 'image::tests::mipmap_working_immutable_image' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- pipeline::cache::tests::cache_returns_different_data stdout ----
thread 'pipeline::cache::tests::cache_returns_different_data' panicked at 'assertion failed: `(left != right)`
left: `[32, 0, 0, 0, 1, 0, 0, 0, 5, 0, 1, 0, 0, 0, 0, 0, 118, 97, 108, 45, 116, 45, 53, 52, 52, 57, 101, 54, 100, 49, 52, 0]`,
right: `[32, 0, 0, 0, 1, 0, 0, 0, 5, 0, 1, 0, 0, 0, 0, 0, 118, 97, 108, 45, 116, 45, 53, 52, 52, 57, 101, 54, 100, 49, 52, 0]`', vulkano/src/pipeline/cache.rs:395:13

---- render_pass::framebuffer::tests::attachment_dims_larger_than_specified_valid stdout ----
thread 'render_pass::framebuffer::tests::attachment_dims_larger_than_specified_valid' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::attachment_dims_smaller_than_specified stdout ----
thread 'render_pass::framebuffer::tests::attachment_dims_smaller_than_specified' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::attachment_format_mismatch stdout ----
thread 'render_pass::framebuffer::tests::attachment_format_mismatch' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::multi_attachments_auto_smaller stdout ----
thread 'render_pass::framebuffer::tests::multi_attachments_auto_smaller' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::not_enough_attachments stdout ----
thread 'render_pass::framebuffer::tests::not_enough_attachments' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::simple_create stdout ----
thread 'render_pass::framebuffer::tests::simple_create' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9

---- render_pass::framebuffer::tests::too_many_attachments stdout ----
thread 'render_pass::framebuffer::tests::too_many_attachments' panicked at 'assertion failed: size != 0', vulkano/src/memory/pool/host_visible.rs:76:9


failures:
  image::attachment::tests::create_regular
  image::attachment::tests::create_transient
  image::attachment::tests::d16_unorm_always_supported
  image::storage::tests::create
  image::storage::tests::create_general_purpose_image_view
  image::storage::tests::create_general_purpose_image_view_failed
  image::tests::mipmap_working_immutable_image
  pipeline::cache::tests::cache_returns_different_data
  render_pass::framebuffer::tests::attachment_dims_larger_than_specified_valid
  render_pass::framebuffer::tests::attachment_dims_smaller_than_specified
  render_pass::framebuffer::tests::attachment_format_mismatch
  render_pass::framebuffer::tests::multi_attachments_auto_smaller
  render_pass::framebuffer::tests::not_enough_attachments
  render_pass::framebuffer::tests::simple_create
  render_pass::framebuffer::tests::too_many_attachments

test result: FAILED. 166 passed; 15 failed; 1 ignored; 0 measured; 0 filtered out; finished in 1.28s

inferrna avatar Aug 08 '22 18:08 inferrna

Does this also happen when running examples, for example the image example? If so, could you enable the API dump layer, and post the calls to vkGetImageMemoryRequirements(2)? And are there any validation errors from the validation layer?

Rua avatar Aug 11 '22 08:08 Rua

There is another error running windowed examples. I already reported one similar https://gitlab.freedesktop.org/mesa/mesa/-/issues/7049

gdb
Thread 1 "image" received signal SIGSEGV, Segmentation fault.
lvp_BindImageMemory2 (_device=0x5555568fe650, bindInfoCount=, pBindInfos=) at ../src/gallium/frontends/lavapipe/lvp_device.c:2027
2027	                                                     mem->pmem,
(gdb) bt
#0  lvp_BindImageMemory2 (_device=0x5555568fe650, bindInfoCount=, pBindInfos=) at ../src/gallium/frontends/lavapipe/lvp_device.c:2027
#1  0x00007ffff71ab6cc in vk_common_BindImageMemory (_device=0x555556668bf0, image=, memory=, memoryOffset=0) at ../src/vulkan/runtime/vk_device.c:473
#2  0x00007ffff710a582 in wsi_create_image (chain=chain@entry=0x5555566b43f0, info=info@entry=0x5555566b4490, image=image@entry=0x5555566b4710) at ../src/vulkan/wsi/wsi_common.c:547
#3  0x00007ffff710ed1d in x11_image_init (device_h=, chain=0x5555566b43f0, pCreateInfo=0x7fffffff8280, pAllocator=, image=)
    at ../src/vulkan/wsi/wsi_common_x11.c:1648
#4  x11_surface_create_swapchain (icd_surface=, device=, wsi_device=, pCreateInfo=, pAllocator=, 
    swapchain_out=0x7fffffff8248) at ../src/vulkan/wsi/wsi_common_x11.c:2124
#5  0x00007ffff710ab27 in wsi_CreateSwapchainKHR (_device=0x5555566b49c0, pCreateInfo=0x0, pAllocator=, pSwapchain=0x7fffffff8670) at ../src/vulkan/wsi/wsi_common.c:776
#6  0x00007ffff782b2d0 in ?? () from /usr/lib/x86_64-linux-gnu/libvulkan.so.1
#7  0x00005555556c7d37 in vulkano::swapchain::swapchain::Swapchain::create (device=0x5555566b2ff0, surface=0x5555566aa0f0, create_info=0x7fffffffa5e0, old_swapchain=...)
    at /media/inferno/Ubuntu/data/dev/vulkano/vulkano/src/swapchain/swapchain.rs:584
#8  0x00005555556c6bba in vulkano::swapchain::swapchain::Swapchain::new (device=..., surface=..., create_info=...)
    at /media/inferno/Ubuntu/data/dev/vulkano/vulkano/src/swapchain/swapchain.rs:129
#9  0x00005555557be609 in image::main () at examples/src/bin/image/main.rs:123
(gdb) 

Traces running render_pass::framebuffer::tests::simple_create test: API trace with system default lvp driver (OK) API trace with newly compiled lvp driver (Failed)

(Possibly I'm wrong, trying to use lavapipe without installing mesa into system, but I don't see any reason why this shouldn't work.)

inferrna avatar Aug 12 '22 08:08 inferrna

I notice that in the good log, vkGetImageMemoryRequirements2 returns a sensible size, while in the bad log, it returns a size of 0. That seems like it's a bug in Lavapipe. There is no situation I can think of in which an image would require 0 bytes of memory. Images must always be at least 1 pixel in size, so they must take up some amount of memory.

Rua avatar Aug 12 '22 08:08 Rua