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

Replace builders with lifetimes/setters directly on Vulkan structs #602

Merged
merged 3 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ash-window/examples/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fn main() -> Result<(), Box<dyn Error>> {
unsafe {
let entry = ash::Entry::linked();
let surface_extensions = ash_window::enumerate_required_extensions(&window)?;
let app_desc = vk::ApplicationInfo::builder().api_version(vk::make_api_version(0, 1, 0, 0));
let instance_desc = vk::InstanceCreateInfo::builder()
let app_desc = vk::ApplicationInfo::default().api_version(vk::make_api_version(0, 1, 0, 0));
let instance_desc = vk::InstanceCreateInfo::default()
.application_info(&app_desc)
.enabled_extension_names(surface_extensions);

Expand Down
14 changes: 7 additions & 7 deletions ash-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub unsafe fn create_surface(
match window_handle.raw_window_handle() {
#[cfg(target_os = "windows")]
RawWindowHandle::Windows(handle) => {
let surface_desc = vk::Win32SurfaceCreateInfoKHR::builder()
let surface_desc = vk::Win32SurfaceCreateInfoKHR::default()
.hinstance(handle.hinstance)
.hwnd(handle.hwnd);
let surface_fn = khr::Win32Surface::new(entry, instance);
Expand All @@ -41,7 +41,7 @@ pub unsafe fn create_surface(
target_os = "openbsd"
))]
RawWindowHandle::Wayland(handle) => {
let surface_desc = vk::WaylandSurfaceCreateInfoKHR::builder()
let surface_desc = vk::WaylandSurfaceCreateInfoKHR::default()
.display(handle.display)
.surface(handle.surface);
let surface_fn = khr::WaylandSurface::new(entry, instance);
Expand All @@ -56,7 +56,7 @@ pub unsafe fn create_surface(
target_os = "openbsd"
))]
RawWindowHandle::Xlib(handle) => {
let surface_desc = vk::XlibSurfaceCreateInfoKHR::builder()
let surface_desc = vk::XlibSurfaceCreateInfoKHR::default()
.dpy(handle.display as *mut _)
.window(handle.window);
let surface_fn = khr::XlibSurface::new(entry, instance);
Expand All @@ -71,7 +71,7 @@ pub unsafe fn create_surface(
target_os = "openbsd"
))]
RawWindowHandle::Xcb(handle) => {
let surface_desc = vk::XcbSurfaceCreateInfoKHR::builder()
let surface_desc = vk::XcbSurfaceCreateInfoKHR::default()
.connection(handle.connection)
.window(handle.window);
let surface_fn = khr::XcbSurface::new(entry, instance);
Expand All @@ -81,7 +81,7 @@ pub unsafe fn create_surface(
#[cfg(any(target_os = "android"))]
RawWindowHandle::Android(handle) => {
let surface_desc =
vk::AndroidSurfaceCreateInfoKHR::builder().window(handle.a_native_window);
vk::AndroidSurfaceCreateInfoKHR::default().window(handle.a_native_window);
let surface_fn = khr::AndroidSurface::new(entry, instance);
surface_fn.create_android_surface(&surface_desc, allocation_callbacks)
}
Expand All @@ -95,7 +95,7 @@ pub unsafe fn create_surface(
Layer::None => return Err(vk::Result::ERROR_INITIALIZATION_FAILED),
};

let surface_desc = vk::MetalSurfaceCreateInfoEXT::builder().layer(&*layer);
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
let surface_fn = ext::MetalSurface::new(entry, instance);
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
}
Expand All @@ -109,7 +109,7 @@ pub unsafe fn create_surface(
Layer::None => return Err(vk::Result::ERROR_INITIALIZATION_FAILED),
};

let surface_desc = vk::MetalSurfaceCreateInfoEXT::builder().layer(&*layer);
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
let surface_fn = ext::MetalSurface::new(entry, instance);
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
}
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/physical_device_drm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl PhysicalDeviceDrm {
) -> vk::PhysicalDeviceDrmPropertiesEXT {
let mut props_drm = vk::PhysicalDeviceDrmPropertiesEXT::default();
{
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_drm);
let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_drm);
instance.get_physical_device_properties2(pdevice, &mut props);
}
props_drm
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/acceleration_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl AccelerationStructure {
) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR {
let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default();
{
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt);
let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt);
instance.get_physical_device_properties2(pdevice, &mut props);
}
props_rt
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/ray_tracing_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl RayTracingPipeline {
) -> vk::PhysicalDeviceRayTracingPipelinePropertiesKHR {
let mut props_rt = vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default();
{
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt);
let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt);
instance.get_physical_device_properties2(pdevice, &mut props);
}
props_rt
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/nv/ray_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl RayTracing {
) -> vk::PhysicalDeviceRayTracingPropertiesNV {
let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesNV::default();
{
let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt);
let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt);
instance.get_physical_device_properties2(pdevice, &mut props);
}
props_rt
Expand Down
6 changes: 3 additions & 3 deletions ash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ mod tests {
use super::vk;
#[test]
fn test_ptr_chains() {
let mut variable_pointers = vk::PhysicalDeviceVariablePointerFeatures::builder();
let mut corner = vk::PhysicalDeviceCornerSampledImageFeaturesNV::builder();
let mut variable_pointers = vk::PhysicalDeviceVariablePointerFeatures::default();
let mut corner = vk::PhysicalDeviceCornerSampledImageFeaturesNV::default();
let chain = vec![
<*mut _>::cast(&mut variable_pointers),
<*mut _>::cast(&mut corner),
];
let mut device_create_info = vk::DeviceCreateInfo::builder()
let mut device_create_info = vk::DeviceCreateInfo::default()
.push_next(&mut corner)
.push_next(&mut variable_pointers);
let chain2: Vec<*mut vk::BaseOutStructure> = unsafe {
Expand Down
Loading