-
Hi! Whenever I try to load the acceleration structure and ray tracing pipeline extensions, via fn required_extensions_for_sdl2_window(
window: &sdl2::video::Window,
) -> Result<Vec<std::ffi::CString>> {
let required_extensions = window.vulkan_instance_extensions()?;
let mut required_extensions: Vec<std::ffi::CString> = required_extensions
.into_iter()
.map(|e| std::ffi::CString::new(e).expect("Nul error."))
.collect();
required_extensions.push(std::ffi::CString::from(
ash::extensions::ext::DebugUtils::name(),
));
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
required_extensions.push(std::ffi::Cstring::from(KhrPortabilityEnumerationFn::name()));
// Enabling this extension is a requirement when using `VK_KHR_portability_subset`
required_extensions.push(std::ffi::Cstring::from(
KhrGetPhysicalDeviceProperties2Fn::name(),
));
}
Ok(required_extensions)
}
fn required_extensions_for_raytracing() -> [&'static std::ffi::CStr; 2] {
[
ash::extensions::khr::AccelerationStructure::name(),
ash::extensions::khr::RayTracingPipeline::name(),
]
}
const fn layers() -> [*const std::ffi::c_char; 1] {
unsafe {
[
std::ffi::CStr::from_bytes_with_nul_unchecked(b"VK_LAYER_KHRONOS_validation\0")
.as_ptr(),
]
}
}
fn app_info() -> vk::ApplicationInfo {
vk::ApplicationInfo::builder()
.api_version(vk::make_api_version(
0,
1,
3,
0,
))
.build()
}
fn create_instance_for_sdl2_window(
window: &sdl2::video::Window,
) -> Result<(ash::Entry, ash::Instance)> {
unsafe {
let entry = ash::Entry::load()?;
let app_info = Self::app_info();
let layer_names = Self::layers();
let required_extensions = Self::required_extensions_for_sdl2_window(window)?;
let rt_extensions = Self::required_extensions_for_raytracing();
let required_extensions: Vec<*const std::ffi::c_char> = required_extensions
.iter()
.map(|s| s.as_c_str())
.chain(rt_extensions)
.map(|s| s.as_ptr())
.collect();
let create_info = vk::InstanceCreateInfo::builder()
.application_info(&app_info)
.enabled_layer_names(&layer_names)
.enabled_extension_names(required_extensions.as_slice())
.build();
let instance = entry.create_instance(&create_info, None)?;
Ok((entry, instance))
}
} I think the problem is that I can't load the 1.3/1.2 for some reason and load 1.0 instead, but I am not sure. Is this the problem or why can't I get the ray tracing extensions then? I use the latest published fn try_create_window(
&mut self,
title: &str,
config: &crate::config::Video,
) -> Result<sdl2::video::Window> {
let res = config.resolution;
let mut window = self
.subsystem
.window(title, res.width.0.into(), res.height.0.into())
.vulkan()
.position_centered()
.allow_highdpi()
.input_grabbed()
.build()?;
if config.fullscreen {
window.set_fullscreen(sdl2::video::FullscreenType::Desktop)?;
}
// this runs the code above, which uses Entry::load and creates all the stuff.
let vulkan = VulkanRenderer::try_from(&window)?;
self.windows
.push((window.context(), Rc::new(RefCell::new(vulkan))));
Ok(window)
} Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I am sorry, I messed up. Too much work never helps. This should have been a parameter for the device create info, not instance create info. I found this out by enumerating the instance extensions and only then realised :-) Can we, I wonder, perhaps, make some use of strict types and differentiate the "instance extensions" and "device extensions" passed to the builders of those? Even if not, allowing passing |
Beta Was this translation helpful? Give feedback.
I am sorry, I messed up. Too much work never helps. This should have been a parameter for the device create info, not instance create info. I found this out by enumerating the instance extensions and only then realised :-)
Can we, I wonder, perhaps, make some use of strict types and differentiate the "instance extensions" and "device extensions" passed to the builders of those? Even if not, allowing passing
&str
would be a much better choice, in my opinion.