vulkano icon indicating copy to clipboard operation
vulkano copied to clipboard

Can't launch vulkano examples with RenderDoc

Open eyerust opened this issue 4 years ago • 4 comments

  • Version of vulkano: 0.19.0
  • OS: Gentoo Linux amd64
  • GPU (the selected PhysicalDevice): GeForce GTX 1060 6GB
  • GPU Driver: NVIDIA Accelerated Graphics Driver (Version 450.66)
  • Upload of a reasonably minimal complete main.rs file that demonstrates the issue: triangle in the examples or just the minimal example code
  • RenderDoc Version: 1.10

Minimal Example Code

use std::sync::Arc;
use vulkano::device::Features;
use vulkano::device::{Device, DeviceExtensions};
use vulkano::instance::InstanceExtensions;
use vulkano::instance::{Instance, PhysicalDevice};

fn main() {
    let instance = Instance::new(None, &InstanceExtensions::none(), None).unwrap();
    let physical = PhysicalDevice::enumerate(&instance).next().unwrap();

    let queue_family = physical.queue_families().next().unwrap();

    let (device, mut queues) = Device::new(
        physical,
        &Features::none(),
        &DeviceExtensions::none(),
        [(queue_family, 1.0)].iter().cloned(),
    )
    .unwrap();
}

Issue

I'm trying to launch the 'triangle' example with RenderDoc, but it crashes.

Here is the RenderDoc diagnostic log: renderdoc-triangle.log And the program output: thread 'main' panicked at 'called Result::unwrap() on an Err value: FeatureNotPresent', src/bin/triangle.rs:141:6

I don't understand why the error is FeatureNotPresent as it indicates that a feature was requested that is not supported, but that seems not to be the case. The error still occurs when I change physical.supported_features() to &Features::none().

The same behavior occurs when I just add the "VK_LAYER_RENDERDOC_Capture" validation layer instead of launching the app with RenderDoc.

I also tried to launch the hello_triangle example from the Vulkan Samples (https://github.com/KhronosGroup/Vulkan-Samples) to test whether my vulkan installation is the problem, but it worked without problems.

Maybe this is a bug in vulkano's device creation process?

EDIT: After more investigation I found (using vulkaninfo) that bufferDeviceAddressCaptureReplay = false. RenderDoc produces warnings about this (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT.bufferDeviceAddressCaptureReplay is false, can't support capture of VK_EXT_buffer_device_address) but ONLY when using vulkano. The VulkanSample hello_triangle doesn't produce these warnings which seems strange to me.

Another EDIT: Found out what caused the device creation failure. In the device module exists this code

            let infos = vk::DeviceCreateInfo {
                sType: vk::STRUCTURE_TYPE_DEVICE_CREATE_INFO,
                pNext: features.base_ptr() as *const _,
                flags: 0, // reserved
                queueCreateInfoCount: queues.len() as u32,
                pQueueCreateInfos: queues.as_ptr(),
                enabledLayerCount: layers_ptr.len() as u32,
                ppEnabledLayerNames: layers_ptr.as_ptr(),
                enabledExtensionCount: extensions_list.len() as u32,
                ppEnabledExtensionNames: extensions_list.as_ptr(),
                pEnabledFeatures: ptr::null(),
            };

which sets pNext instead of pEnabledFeatures. When I set pNext to ptr::null(), RenderDoc can successfully launch the app. So the issue seems to be that RenderDoc can't handle more advanced physical device features. But I still get this warning: VkPhysicalDeviceBufferDeviceAddressFeaturesEXT.bufferDeviceAddressCaptureReplay is false, can't support capture of VK_EXT_buffer_device_address

eyerust avatar Sep 21 '20 20:09 eyerust

Ok, so baldurk helped me to find the cause of the problem. Here is a code snipped with macros expanded from the FeaturesFfi constructor:

        #[inline(always)]
        pub(crate) fn new() -> Pin<Box<Self>> {
            #![allow(unused_assignments)]
            let this = FeaturesFfi {
                _pinned: PhantomPinned,
                main: vk::PhysicalDeviceFeatures2KHR {
                    sType: vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR,
                    pNext: ptr::null(),
                    features: unsafe { mem::zeroed() },
                },
                ..unsafe { mem::zeroed() }
            };
            let mut this = Box::pin(this);
            unsafe {
                let this = this.as_mut();
                let this = this.get_unchecked_mut();
                let mut base = &mut this.main as *mut _ as *mut Base;
                {
                    this.phys_dev_buf_addr.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT;
                    let next = &mut this.phys_dev_buf_addr as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
                {
                    this.variable_pointers.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES;
                    let next = &mut this.variable_pointers as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
                {
                    this.shader_atomic_i64.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES;
                    let next = &mut this.shader_atomic_i64 as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
                {
                    this.i8_storage.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
                    let next = &mut this.i8_storage as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
                {
                    this.i16_storage.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
                    let next = &mut this.i16_storage as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
                {
                    this.f16_i8.sType =
                        vk::STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
                    let next = &mut this.f16_i8 as *mut _ as *mut Base;
                    (&mut *base).pNext = next;
                    base = next;
                };
            }
            this
        }

The feature extension chain is always build. But it seems that you need to enable the device extension VK_KHR_buffer_device_address to be able to use STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT. But this device extension isn't enabled anywhere.

Thats why I get a FeatureNotPresent error only when using it with RenderDoc. Normally, VK_KHR_buffer_device_address is supported but with RenderDoc it is not!

When I modify Vulkano to enable the VK_KHR_buffer_device_address device extension, my app detects that this extension is not supported before trying to create the device.

So if I didn't misunderstand anything, this really is a bug in the Vulkano device creation process. It could be fixed if the device creation feature chain only contains the supported extensions and not all.

eyerust avatar Sep 23 '20 15:09 eyerust

But this seems like an extensive fix and I'm not confident enough to do it myself.

eyerust avatar Sep 23 '20 15:09 eyerust

I could take a look at it after work possibly.

On Sep 23, 2020, 10:32 AM, at 10:32 AM, michadaniel [email protected] wrote:

But this seems like an extensive fix and I'm not confident enough to do it myself.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/vulkano-rs/vulkano/issues/1416#issuecomment-697550037

AustinJ235 avatar Sep 24 '20 01:09 AustinJ235

i just ran into this issue as well. passing Features::none() is a workaround for now (i don't need any extension features in my program) but it's definitely a problem that vulkano is querying for unsupported extension features.

ashkitten avatar May 14 '21 22:05 ashkitten

This was fixed in #1599.

marc0246 avatar Jul 07 '23 05:07 marc0246