nvpro-samples / vk_raytracing_tutorial_KHR

Ray tracing examples and tutorials using VK_KHR_ray_tracing
Apache License 2.0
1.34k stars 142 forks source link

Framebuffer becomes invalid (ray_tracing_gltf) #70

Closed CDaut closed 3 months ago

CDaut commented 3 months ago

When running the example the program SEGFAULTs in the third frame. The issue seems to be that the framebuffers ImageView handle in postRenderPassBeginInfo (L270) ) is invalid. Vulkan throws the following validation error:

 --> Validation Error: [ VUID-VkRenderPassBeginInfo-framebuffer-parameter ] Object 0: handle = 0xb991fa0000000024, name = AppBaseVk, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x3a6cbb0000000025, name = AppBase0, type = VK_OBJECT_TYPE_FRAMEBUFFER; Object 2: handle = 0xec4bec000000000b, name = swapchainImageView:0, type = VK_OBJECT_TYPE_IMAGE_VIEW; | MessageID = 0xe02fa864 | vkCmdBeginRenderPass(): pCreateInfo->pAttachments[0] VkImageView 0xec4bec000000000b[swapchainImageView:0] is invalid. The Vulkan spec states: framebuffer must be a valid VkFramebuffer handle (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkRenderPassBeginInfo-framebuffer-parameter)

What might have caused the framebuffer to become invalid? How do I fix this?

CDaut commented 3 months ago

This seems to only happen when the 0th framebuffer is requested

mklefrancois commented 3 months ago

I do not see this issue. Can you describe your environment; graphic card, driver version, operating system, ...

CDaut commented 3 months ago

Graphics card: AMD RX 7800 XT, amdgpu driver, nixos newest linux kernel

NBickford-NV commented 3 months ago

Hi @CDaut! I wonder if this is a validation layer issue. Could you send us the result of vulkaninfo --summary? That'll include the Vulkan instance (SDK) version and the driver version.

CDaut commented 3 months ago
WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/x5h6gynx5x2p395sc842jphp7333kqb7-mesa-24.0.5-drivers/lib/libvulkan_virtio.so. Skipping this driver.
WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/x5h6gynx5x2p395sc842jphp7333kqb7-mesa-24.0.5-drivers/lib/libvulkan_dzn.so. Skipping this driver.
WARNING: NVK is not a conformant Vulkan implementation, testing use only.
==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.280

Instance Extensions: count = 23
-------------------------------
VK_EXT_acquire_drm_display             : extension revision 1
VK_EXT_acquire_xlib_display            : extension revision 1
VK_EXT_debug_report                    : extension revision 10
VK_EXT_debug_utils                     : extension revision 2
VK_EXT_direct_mode_display             : extension revision 1
VK_EXT_display_surface_counter         : extension revision 1
VK_EXT_surface_maintenance1            : extension revision 1
VK_EXT_swapchain_colorspace            : extension revision 4
VK_KHR_device_group_creation           : extension revision 1
VK_KHR_display                         : extension revision 23
VK_KHR_external_fence_capabilities     : extension revision 1
VK_KHR_external_memory_capabilities    : extension revision 1
VK_KHR_external_semaphore_capabilities : extension revision 1
VK_KHR_get_display_properties2         : extension revision 1
VK_KHR_get_physical_device_properties2 : extension revision 2
VK_KHR_get_surface_capabilities2       : extension revision 1
VK_KHR_portability_enumeration         : extension revision 1
VK_KHR_surface                         : extension revision 25
VK_KHR_surface_protected_capabilities  : extension revision 1
VK_KHR_wayland_surface                 : extension revision 6
VK_KHR_xcb_surface                     : extension revision 6
VK_KHR_xlib_surface                    : extension revision 6
VK_LUNARG_direct_driver_loading        : extension revision 1

Instance Layers: count = 4
--------------------------
VK_LAYER_INTEL_nullhw       INTEL NULL HW                1.1.73   version 1
VK_LAYER_KHRONOS_validation Khronos Validation Layer     1.3.280  version 1
VK_LAYER_MESA_device_select Linux device selection layer 1.3.211  version 1
VK_LAYER_MESA_overlay       Mesa Overlay layer           1.3.211  version 1

Devices:
========
GPU0:
    apiVersion         = 1.3.274
    driverVersion      = 24.0.5
    vendorID           = 0x8086
    deviceID           = 0x3e9b
    deviceType         = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
    deviceName         = Intel(R) UHD Graphics 630 (CFL GT2)
    driverID           = DRIVER_ID_INTEL_OPEN_SOURCE_MESA
    driverName         = Intel open-source Mesa driver
    driverInfo         = Mesa 24.0.5
    conformanceVersion = 1.3.6.0
    deviceUUID         = 86809b3e-0200-0000-0002-000000000000
    driverUUID         = a3fc6a70-6ab8-4f00-fe95-e4d517b36c99
GPU1:
    apiVersion         = 1.1.274
    driverVersion      = 24.0.5
    vendorID           = 0x10de
    deviceID           = 0x1f91
    deviceType         = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
    deviceName         = TU117
    driverID           = DRIVER_ID_MESA_NVK
    driverName         = NVK
    driverInfo         = Mesa 24.0.5
    conformanceVersion = 0.0.0.0
GPU2:
    apiVersion         = 1.3.274
    driverVersion      = 24.0.5
    vendorID           = 0x1002
    deviceID           = 0x747e
    deviceType         = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
    deviceName         = AMD Radeon RX 7800 XT (RADV NAVI32)
    driverID           = DRIVER_ID_MESA_RADV
    driverName         = radv
    driverInfo         = Mesa 24.0.5
    conformanceVersion = 1.3.0.0
    deviceUUID         = 00000000-1100-0000-0000-000000000000
    driverUUID         = 414d442d-4d45-5341-2d44-525600000000
GPU3:
    apiVersion         = 1.3.274
    driverVersion      = 0.0.1
    vendorID           = 0x10005
    deviceID           = 0x0000
    deviceType         = PHYSICAL_DEVICE_TYPE_CPU
    deviceName         = llvmpipe (LLVM 17.0.6, 256 bits)
    driverID           = DRIVER_ID_MESA_LLVMPIPE
    driverName         = llvmpipe
    driverInfo         = Mesa 24.0.5 (LLVM 17.0.6)
    conformanceVersion = 1.3.1.1
    deviceUUID         = 6d657361-3234-2e30-2e35-000000000000
    driverUUID         = 6c6c766d-7069-7065-5555-494400000000
CDaut commented 3 months ago

Might the issue be related to the Version difference, i.e. the program using API 1.2 but the driver being at API 1.3? Changing the version in L123 does not fix the issue though.

CDaut commented 3 months ago

It was indeed a validation layer issue. The layer "VK_LAYER_INTEL_nullhw" seems to be broken. Patching the context_vk.cpp to not enable it fixed the issue. See this commit