cargo fmt
This commit is contained in:
parent
b622fd7993
commit
eb70d0e899
|
@ -85,10 +85,8 @@ pub trait EntryV1_0 {
|
||||||
return Err(InstanceError::VkError(err_code));
|
return Err(InstanceError::VkError(err_code));
|
||||||
}
|
}
|
||||||
let instance_fp =
|
let instance_fp =
|
||||||
<Self::Fp as FunctionPointers>::InstanceFp::load(
|
<Self::Fp as FunctionPointers>::InstanceFp::load(&self.static_fn(), instance)
|
||||||
&self.static_fn(),
|
.map_err(InstanceError::LoadError)?;
|
||||||
instance,
|
|
||||||
).map_err(InstanceError::LoadError)?;
|
|
||||||
Ok(Instance::from_raw(instance, instance_fp))
|
Ok(Instance::from_raw(instance, instance_fp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +159,8 @@ impl<V: FunctionPointers> Entry<V> {
|
||||||
.unwrap_or(ptr::null_mut())
|
.unwrap_or(ptr::null_mut())
|
||||||
}).map_err(LoadingError::StaticLoadError)?;
|
}).map_err(LoadingError::StaticLoadError)?;
|
||||||
|
|
||||||
let entry_fn = unsafe {
|
let entry_fn =
|
||||||
V::EntryFp::load(&static_fn)
|
unsafe { V::EntryFp::load(&static_fn) }.map_err(LoadingError::EntryLoadError)?;
|
||||||
}.map_err(LoadingError::EntryLoadError)?;
|
|
||||||
|
|
||||||
Ok(Entry {
|
Ok(Entry {
|
||||||
static_fn,
|
static_fn,
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl AndroidSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<AndroidSurface, Vec<&'static str>> {
|
) -> Result<AndroidSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::AndroidSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::AndroidSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(AndroidSurface {
|
Ok(AndroidSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -3,7 +3,7 @@ use prelude::*;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use vk;
|
use vk;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use version::{InstanceV1_0, DeviceV1_0};
|
use version::{DeviceV1_0, InstanceV1_0};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DebugMarker {
|
pub struct DebugMarker {
|
||||||
|
@ -13,13 +13,10 @@ pub struct DebugMarker {
|
||||||
impl DebugMarker {
|
impl DebugMarker {
|
||||||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(
|
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(
|
||||||
instance: &I,
|
instance: &I,
|
||||||
device: &D
|
device: &D,
|
||||||
) -> Result<DebugMarker, Vec<&'static str>> {
|
) -> Result<DebugMarker, Vec<&'static str>> {
|
||||||
let debug_marker_fn = vk::DebugMarkerFn::load(|name| unsafe {
|
let debug_marker_fn = vk::DebugMarkerFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
device.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(DebugMarker {
|
Ok(DebugMarker {
|
||||||
debug_marker_fn: debug_marker_fn,
|
debug_marker_fn: debug_marker_fn,
|
||||||
|
@ -33,46 +30,36 @@ impl DebugMarker {
|
||||||
pub unsafe fn debug_marker_set_object_name_ext(
|
pub unsafe fn debug_marker_set_object_name_ext(
|
||||||
&self,
|
&self,
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
name_info: &vk::DebugMarkerObjectNameInfoEXT
|
name_info: &vk::DebugMarkerObjectNameInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.debug_marker_fn.debug_marker_set_object_name_ext(
|
let err_code = self.debug_marker_fn
|
||||||
device,
|
.debug_marker_set_object_name_ext(device, name_info);
|
||||||
name_info
|
|
||||||
);
|
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code)
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_debug_marker_begin_ext(
|
pub unsafe fn cmd_debug_marker_begin_ext(
|
||||||
&self,
|
&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
marker_info: &vk::DebugMarkerMarkerInfoEXT
|
marker_info: &vk::DebugMarkerMarkerInfoEXT,
|
||||||
) {
|
) {
|
||||||
self.debug_marker_fn.cmd_debug_marker_begin_ext(
|
self.debug_marker_fn
|
||||||
command_buffer,
|
.cmd_debug_marker_begin_ext(command_buffer, marker_info);
|
||||||
marker_info
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_debug_marker_end_ext(
|
pub unsafe fn cmd_debug_marker_end_ext(&self, command_buffer: vk::CommandBuffer) {
|
||||||
&self,
|
self.debug_marker_fn
|
||||||
command_buffer: vk::CommandBuffer,
|
.cmd_debug_marker_end_ext(command_buffer);
|
||||||
) {
|
|
||||||
self.debug_marker_fn.cmd_debug_marker_end_ext(
|
|
||||||
command_buffer,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_debug_marker_insert_ext(
|
pub unsafe fn cmd_debug_marker_insert_ext(
|
||||||
&self,
|
&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
marker_info: &vk::DebugMarkerMarkerInfoEXT
|
marker_info: &vk::DebugMarkerMarkerInfoEXT,
|
||||||
) {
|
) {
|
||||||
self.debug_marker_fn.cmd_debug_marker_insert_ext(
|
self.debug_marker_fn
|
||||||
command_buffer,
|
.cmd_debug_marker_insert_ext(command_buffer, marker_info);
|
||||||
marker_info
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl DebugReport {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<DebugReport, Vec<&'static str>> {
|
) -> Result<DebugReport, Vec<&'static str>> {
|
||||||
let debug_report_fn = vk::DebugReportFn::load(|name| unsafe {
|
let debug_report_fn = vk::DebugReportFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(DebugReport {
|
Ok(DebugReport {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::mem;
|
||||||
use vk;
|
use vk;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use RawPtr;
|
use RawPtr;
|
||||||
use version::{InstanceV1_0, DeviceV1_0};
|
use version::{DeviceV1_0, InstanceV1_0};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DisplaySwapchain {
|
pub struct DisplaySwapchain {
|
||||||
|
@ -18,10 +18,7 @@ impl DisplaySwapchain {
|
||||||
device: &D,
|
device: &D,
|
||||||
) -> Result<DisplaySwapchain, Vec<&'static str>> {
|
) -> Result<DisplaySwapchain, Vec<&'static str>> {
|
||||||
let swapchain_fn = vk::DisplaySwapchainFn::load(|name| unsafe {
|
let swapchain_fn = vk::DisplaySwapchainFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
device.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(DisplaySwapchain {
|
Ok(DisplaySwapchain {
|
||||||
handle: device.handle(),
|
handle: device.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl IOSSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<IOSSurface, Vec<&'static str>> {
|
) -> Result<IOSSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::IOSSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::IOSSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(IOSSurface {
|
Ok(IOSSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl MacOSSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<MacOSSurface, Vec<&'static str>> {
|
) -> Result<MacOSSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::MacOSSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::MacOSSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(MacOSSurface {
|
Ok(MacOSSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl MirSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<MirSurface, Vec<&'static str>> {
|
) -> Result<MirSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::MirSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::MirSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(MirSurface {
|
Ok(MirSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -19,10 +19,7 @@ impl Surface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<Surface, Vec<&'static str>> {
|
) -> Result<Surface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::SurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::SurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(Surface {
|
Ok(Surface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::mem;
|
||||||
use vk;
|
use vk;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use RawPtr;
|
use RawPtr;
|
||||||
use version::{InstanceV1_0, DeviceV1_0};
|
use version::{DeviceV1_0, InstanceV1_0};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Swapchain {
|
pub struct Swapchain {
|
||||||
|
@ -19,10 +19,7 @@ impl Swapchain {
|
||||||
device: &D,
|
device: &D,
|
||||||
) -> Result<Swapchain, Vec<&'static str>> {
|
) -> Result<Swapchain, Vec<&'static str>> {
|
||||||
let swapchain_fn = vk::SwapchainFn::load(|name| unsafe {
|
let swapchain_fn = vk::SwapchainFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
device.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(Swapchain {
|
Ok(Swapchain {
|
||||||
handle: device.handle(),
|
handle: device.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl WaylandSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<WaylandSurface, Vec<&'static str>> {
|
) -> Result<WaylandSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::WaylandSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::WaylandSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(WaylandSurface {
|
Ok(WaylandSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl Win32Surface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<Win32Surface, Vec<&'static str>> {
|
) -> Result<Win32Surface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::Win32SurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::Win32SurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(Win32Surface {
|
Ok(Win32Surface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl XcbSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<XcbSurface, Vec<&'static str>> {
|
) -> Result<XcbSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::XcbSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::XcbSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(XcbSurface {
|
Ok(XcbSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl XlibSurface {
|
||||||
instance: &I,
|
instance: &I,
|
||||||
) -> Result<XlibSurface, Vec<&'static str>> {
|
) -> Result<XlibSurface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::XlibSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::XlibSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
instance.handle(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(XlibSurface {
|
Ok(XlibSurface {
|
||||||
handle: instance.handle(),
|
handle: instance.handle(),
|
||||||
|
|
|
@ -85,11 +85,10 @@ pub trait InstanceV1_0 {
|
||||||
if err_code != vk::Result::Success {
|
if err_code != vk::Result::Success {
|
||||||
return Err(DeviceError::VkError(err_code));
|
return Err(DeviceError::VkError(err_code));
|
||||||
}
|
}
|
||||||
let device_fn =
|
let device_fn = <<Self as InstanceV1_0>::Fp as FunctionPointers>::DeviceFp::load(
|
||||||
<<Self as InstanceV1_0>::Fp as FunctionPointers>::DeviceFp::load(
|
self.fp_v1_0(),
|
||||||
self.fp_v1_0(),
|
device,
|
||||||
device,
|
).map_err(|err| DeviceError::LoadError(err))?;
|
||||||
).map_err(|err| DeviceError::LoadError(err))?;
|
|
||||||
Ok(Device::from_raw(device, device_fn))
|
Ok(Device::from_raw(device, device_fn))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +101,8 @@ pub trait InstanceV1_0 {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.fp_v1_0().destroy_instance(
|
self.fp_v1_0()
|
||||||
self.handle(),
|
.destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
|
||||||
allocation_callbacks.as_raw_ptr(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_format_properties(
|
fn get_physical_device_format_properties(
|
||||||
|
@ -158,10 +155,8 @@ pub trait InstanceV1_0 {
|
||||||
) -> vk::PhysicalDeviceMemoryProperties {
|
) -> vk::PhysicalDeviceMemoryProperties {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut memory_prop = mem::uninitialized();
|
let mut memory_prop = mem::uninitialized();
|
||||||
self.fp_v1_0().get_physical_device_memory_properties(
|
self.fp_v1_0()
|
||||||
physical_device,
|
.get_physical_device_memory_properties(physical_device, &mut memory_prop);
|
||||||
&mut memory_prop,
|
|
||||||
);
|
|
||||||
memory_prop
|
memory_prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,10 +167,8 @@ pub trait InstanceV1_0 {
|
||||||
) -> vk::PhysicalDeviceProperties {
|
) -> vk::PhysicalDeviceProperties {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut prop = mem::uninitialized();
|
let mut prop = mem::uninitialized();
|
||||||
self.fp_v1_0().get_physical_device_properties(
|
self.fp_v1_0()
|
||||||
physical_device,
|
.get_physical_device_properties(physical_device, &mut prop);
|
||||||
&mut prop,
|
|
||||||
);
|
|
||||||
prop
|
prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,10 +201,8 @@ pub trait InstanceV1_0 {
|
||||||
) -> vk::PhysicalDeviceFeatures {
|
) -> vk::PhysicalDeviceFeatures {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut prop = mem::uninitialized();
|
let mut prop = mem::uninitialized();
|
||||||
self.fp_v1_0().get_physical_device_features(
|
self.fp_v1_0()
|
||||||
physical_device,
|
.get_physical_device_features(physical_device, &mut prop);
|
||||||
&mut prop,
|
|
||||||
);
|
|
||||||
prop
|
prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,11 +210,8 @@ pub trait InstanceV1_0 {
|
||||||
fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut num = mem::uninitialized();
|
let mut num = mem::uninitialized();
|
||||||
self.fp_v1_0().enumerate_physical_devices(
|
self.fp_v1_0()
|
||||||
self.handle(),
|
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
|
||||||
&mut num,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
||||||
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
extern crate libc;
|
|
||||||
extern crate shared_library;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
pub use instance::{Instance, DeviceError};
|
extern crate libc;
|
||||||
|
extern crate shared_library;
|
||||||
|
pub use instance::{DeviceError, Instance};
|
||||||
pub use device::Device;
|
pub use device::Device;
|
||||||
pub use entry::{Entry, InstanceError, LoadingError};
|
pub use entry::{Entry, InstanceError, LoadingError};
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,7 @@ impl EntryLoader for EntryFpV1_0 {
|
||||||
}
|
}
|
||||||
unsafe fn load(static_fn: &vk::StaticFn) -> Result<Self, Vec<&'static str>> {
|
unsafe fn load(static_fn: &vk::StaticFn) -> Result<Self, Vec<&'static str>> {
|
||||||
let entry_fn = vk::EntryFnV1_0::load(|name| {
|
let entry_fn = vk::EntryFnV1_0::load(|name| {
|
||||||
mem::transmute(static_fn.get_instance_proc_addr(
|
mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr()))
|
||||||
vk::Instance::null(),
|
|
||||||
name.as_ptr(),
|
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
Ok(EntryFpV1_0 { entry_fn: entry_fn })
|
Ok(EntryFpV1_0 { entry_fn: entry_fn })
|
||||||
}
|
}
|
||||||
|
@ -73,7 +70,9 @@ impl DeviceLoader for DeviceFpV1_0 {
|
||||||
let device_fn = vk::DeviceFnV1_0::load(|name| {
|
let device_fn = vk::DeviceFnV1_0::load(|name| {
|
||||||
mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr()))
|
mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr()))
|
||||||
})?;
|
})?;
|
||||||
Ok(DeviceFpV1_0 { device_fn: device_fn })
|
Ok(DeviceFpV1_0 {
|
||||||
|
device_fn: device_fn,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +87,9 @@ impl InstanceLoader for InstanceFpV1_0 {
|
||||||
let instance_fn = vk::InstanceFnV1_0::load(|name| {
|
let instance_fn = vk::InstanceFnV1_0::load(|name| {
|
||||||
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
|
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
|
||||||
})?;
|
})?;
|
||||||
Ok(InstanceFpV1_0 { instance_fn: instance_fn })
|
Ok(InstanceFpV1_0 {
|
||||||
|
instance_fn: instance_fn,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2534
ash/src/vk.rs
2534
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@ pub struct Vector3 {
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
pub z: f32,
|
pub z: f32,
|
||||||
pub _pad: f32
|
pub _pad: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -70,8 +70,8 @@ fn main() {
|
||||||
dst_subpass: Default::default(),
|
dst_subpass: Default::default(),
|
||||||
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
src_access_mask: Default::default(),
|
src_access_mask: Default::default(),
|
||||||
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT
|
||||||
vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
| vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
};
|
};
|
||||||
let subpass = vk::SubpassDescription {
|
let subpass = vk::SubpassDescription {
|
||||||
|
@ -198,9 +198,8 @@ fn main() {
|
||||||
let vertex_input_buffer = base.device
|
let vertex_input_buffer = base.device
|
||||||
.create_buffer(&vertex_input_buffer_info, None)
|
.create_buffer(&vertex_input_buffer_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let vertex_input_buffer_memory_req = base.device.get_buffer_memory_requirements(
|
let vertex_input_buffer_memory_req = base.device
|
||||||
vertex_input_buffer,
|
.get_buffer_memory_requirements(vertex_input_buffer);
|
||||||
);
|
|
||||||
let vertex_input_buffer_memory_index =
|
let vertex_input_buffer_memory_index =
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&vertex_input_buffer_memory_req,
|
&vertex_input_buffer_memory_req,
|
||||||
|
@ -240,7 +239,7 @@ fn main() {
|
||||||
x: 1.0,
|
x: 1.0,
|
||||||
y: 1.0,
|
y: 1.0,
|
||||||
z: 1.0,
|
z: 1.0,
|
||||||
_pad: 0.0
|
_pad: 0.0,
|
||||||
};
|
};
|
||||||
let uniform_color_buffer_info = vk::BufferCreateInfo {
|
let uniform_color_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BufferCreateInfo,
|
s_type: vk::StructureType::BufferCreateInfo,
|
||||||
|
@ -255,9 +254,8 @@ fn main() {
|
||||||
let uniform_color_buffer = base.device
|
let uniform_color_buffer = base.device
|
||||||
.create_buffer(&uniform_color_buffer_info, None)
|
.create_buffer(&uniform_color_buffer_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let uniform_color_buffer_memory_req = base.device.get_buffer_memory_requirements(
|
let uniform_color_buffer_memory_req = base.device
|
||||||
uniform_color_buffer,
|
.get_buffer_memory_requirements(uniform_color_buffer);
|
||||||
);
|
|
||||||
let uniform_color_buffer_memory_index =
|
let uniform_color_buffer_memory_index =
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&uniform_color_buffer_memory_req,
|
&uniform_color_buffer_memory_req,
|
||||||
|
@ -388,89 +386,97 @@ fn main() {
|
||||||
.bind_image_memory(texture_image, texture_memory, 0)
|
.bind_image_memory(texture_image, texture_memory, 0)
|
||||||
.expect("Unable to bind depth image memory");
|
.expect("Unable to bind depth image memory");
|
||||||
|
|
||||||
|
record_submit_commandbuffer(
|
||||||
|
&base.device,
|
||||||
record_submit_commandbuffer(&base.device,
|
base.setup_command_buffer,
|
||||||
base.setup_command_buffer,
|
base.present_queue,
|
||||||
base.present_queue,
|
&[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT],
|
||||||
&[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT],
|
&[],
|
||||||
&[],
|
&[],
|
||||||
&[],
|
|device, texture_command_buffer| {
|
||||||
|device, texture_command_buffer| {
|
let texture_barrier = vk::ImageMemoryBarrier {
|
||||||
let texture_barrier = vk::ImageMemoryBarrier {
|
s_type: vk::StructureType::ImageMemoryBarrier,
|
||||||
s_type: vk::StructureType::ImageMemoryBarrier,
|
p_next: ptr::null(),
|
||||||
p_next: ptr::null(),
|
src_access_mask: Default::default(),
|
||||||
src_access_mask: Default::default(),
|
dst_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
||||||
dst_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
old_layout: vk::ImageLayout::Undefined,
|
||||||
old_layout: vk::ImageLayout::Undefined,
|
new_layout: vk::ImageLayout::TransferDstOptimal,
|
||||||
new_layout: vk::ImageLayout::TransferDstOptimal,
|
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
||||||
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
||||||
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
image: texture_image,
|
||||||
image: texture_image,
|
subresource_range: vk::ImageSubresourceRange {
|
||||||
subresource_range: vk::ImageSubresourceRange {
|
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
base_mip_level: 0,
|
||||||
base_mip_level: 0,
|
level_count: 1,
|
||||||
level_count: 1,
|
base_array_layer: 0,
|
||||||
base_array_layer: 0,
|
layer_count: 1,
|
||||||
layer_count: 1,
|
},
|
||||||
},
|
};
|
||||||
};
|
device.cmd_pipeline_barrier(
|
||||||
device.cmd_pipeline_barrier(texture_command_buffer,
|
texture_command_buffer,
|
||||||
vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
vk::DependencyFlags::empty(),
|
vk::DependencyFlags::empty(),
|
||||||
&[],
|
&[],
|
||||||
&[],
|
&[],
|
||||||
&[texture_barrier]);
|
&[texture_barrier],
|
||||||
let buffer_copy_regions = [vk::BufferImageCopy {
|
);
|
||||||
image_subresource: vk::ImageSubresourceLayers {
|
let buffer_copy_regions = [
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
vk::BufferImageCopy {
|
||||||
mip_level: 0,
|
image_subresource: vk::ImageSubresourceLayers {
|
||||||
base_array_layer: 0,
|
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
||||||
layer_count: 1,
|
mip_level: 0,
|
||||||
},
|
base_array_layer: 0,
|
||||||
image_extent: vk::Extent3D {
|
layer_count: 1,
|
||||||
width: image_dimensions.0,
|
},
|
||||||
height: image_dimensions.1,
|
image_extent: vk::Extent3D {
|
||||||
depth: 1,
|
width: image_dimensions.0,
|
||||||
},
|
height: image_dimensions.1,
|
||||||
buffer_offset: 0,
|
depth: 1,
|
||||||
// FIX ME
|
},
|
||||||
buffer_image_height: 0,
|
buffer_offset: 0,
|
||||||
buffer_row_length: 0,
|
// FIX ME
|
||||||
image_offset: vk::Offset3D { x: 0, y: 0, z: 0 },
|
buffer_image_height: 0,
|
||||||
}];
|
buffer_row_length: 0,
|
||||||
device.cmd_copy_buffer_to_image(texture_command_buffer,
|
image_offset: vk::Offset3D { x: 0, y: 0, z: 0 },
|
||||||
image_buffer,
|
},
|
||||||
texture_image,
|
];
|
||||||
vk::ImageLayout::TransferDstOptimal,
|
device.cmd_copy_buffer_to_image(
|
||||||
&buffer_copy_regions);
|
texture_command_buffer,
|
||||||
let texture_barrier_end = vk::ImageMemoryBarrier {
|
image_buffer,
|
||||||
s_type: vk::StructureType::ImageMemoryBarrier,
|
texture_image,
|
||||||
p_next: ptr::null(),
|
vk::ImageLayout::TransferDstOptimal,
|
||||||
src_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
&buffer_copy_regions,
|
||||||
dst_access_mask: vk::ACCESS_SHADER_READ_BIT,
|
);
|
||||||
old_layout: vk::ImageLayout::TransferDstOptimal,
|
let texture_barrier_end = vk::ImageMemoryBarrier {
|
||||||
new_layout: vk::ImageLayout::ShaderReadOnlyOptimal,
|
s_type: vk::StructureType::ImageMemoryBarrier,
|
||||||
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
p_next: ptr::null(),
|
||||||
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
src_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
||||||
image: texture_image,
|
dst_access_mask: vk::ACCESS_SHADER_READ_BIT,
|
||||||
subresource_range: vk::ImageSubresourceRange {
|
old_layout: vk::ImageLayout::TransferDstOptimal,
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
new_layout: vk::ImageLayout::ShaderReadOnlyOptimal,
|
||||||
base_mip_level: 0,
|
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
||||||
level_count: 1,
|
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
||||||
base_array_layer: 0,
|
image: texture_image,
|
||||||
layer_count: 1,
|
subresource_range: vk::ImageSubresourceRange {
|
||||||
},
|
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
||||||
};
|
base_mip_level: 0,
|
||||||
device.cmd_pipeline_barrier(texture_command_buffer,
|
level_count: 1,
|
||||||
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
base_array_layer: 0,
|
||||||
vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
layer_count: 1,
|
||||||
vk::DependencyFlags::empty(),
|
},
|
||||||
&[],
|
};
|
||||||
&[],
|
device.cmd_pipeline_barrier(
|
||||||
&[texture_barrier_end]);
|
texture_command_buffer,
|
||||||
});
|
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
|
vk::DependencyFlags::empty(),
|
||||||
|
&[],
|
||||||
|
&[],
|
||||||
|
&[texture_barrier_end],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let sampler_info = vk::SamplerCreateInfo {
|
let sampler_info = vk::SamplerCreateInfo {
|
||||||
s_type: vk::StructureType::SamplerCreateInfo,
|
s_type: vk::StructureType::SamplerCreateInfo,
|
||||||
|
@ -564,7 +570,6 @@ fn main() {
|
||||||
p_bindings: desc_layout_bindings.as_ptr(),
|
p_bindings: desc_layout_bindings.as_ptr(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let desc_set_layouts = [
|
let desc_set_layouts = [
|
||||||
base.device
|
base.device
|
||||||
.create_descriptor_set_layout(&descriptor_info, None)
|
.create_descriptor_set_layout(&descriptor_info, None)
|
||||||
|
@ -856,13 +861,14 @@ fn main() {
|
||||||
|
|
||||||
let graphic_pipeline = graphics_pipelines[0];
|
let graphic_pipeline = graphics_pipelines[0];
|
||||||
|
|
||||||
|
|
||||||
base.render_loop(|| {
|
base.render_loop(|| {
|
||||||
let present_index = base.swapchain_loader
|
let present_index = base.swapchain_loader
|
||||||
.acquire_next_image_khr(base.swapchain,
|
.acquire_next_image_khr(
|
||||||
std::u64::MAX,
|
base.swapchain,
|
||||||
base.present_complete_semaphore,
|
std::u64::MAX,
|
||||||
vk::Fence::null())
|
base.present_complete_semaphore,
|
||||||
|
vk::Fence::null(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let clear_values = [
|
let clear_values = [
|
||||||
vk::ClearValue {
|
vk::ClearValue {
|
||||||
|
@ -948,14 +954,10 @@ fn main() {
|
||||||
base.device.destroy_pipeline(pipeline, None);
|
base.device.destroy_pipeline(pipeline, None);
|
||||||
}
|
}
|
||||||
base.device.destroy_pipeline_layout(pipeline_layout, None);
|
base.device.destroy_pipeline_layout(pipeline_layout, None);
|
||||||
base.device.destroy_shader_module(
|
base.device
|
||||||
vertex_shader_module,
|
.destroy_shader_module(vertex_shader_module, None);
|
||||||
None,
|
base.device
|
||||||
);
|
.destroy_shader_module(fragment_shader_module, None);
|
||||||
base.device.destroy_shader_module(
|
|
||||||
fragment_shader_module,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
base.device.free_memory(image_buffer_memory, None);
|
base.device.free_memory(image_buffer_memory, None);
|
||||||
base.device.destroy_buffer(image_buffer, None);
|
base.device.destroy_buffer(image_buffer, None);
|
||||||
base.device.free_memory(texture_memory, None);
|
base.device.free_memory(texture_memory, None);
|
||||||
|
@ -968,10 +970,8 @@ fn main() {
|
||||||
base.device.free_memory(vertex_input_buffer_memory, None);
|
base.device.free_memory(vertex_input_buffer_memory, None);
|
||||||
base.device.destroy_buffer(vertex_input_buffer, None);
|
base.device.destroy_buffer(vertex_input_buffer, None);
|
||||||
for &descriptor_set_layout in desc_set_layouts.iter() {
|
for &descriptor_set_layout in desc_set_layouts.iter() {
|
||||||
base.device.destroy_descriptor_set_layout(
|
base.device
|
||||||
descriptor_set_layout,
|
.destroy_descriptor_set_layout(descriptor_set_layout, None);
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
base.device.destroy_descriptor_pool(descriptor_pool, None);
|
base.device.destroy_descriptor_pool(descriptor_pool, None);
|
||||||
base.device.destroy_sampler(sampler, None);
|
base.device.destroy_sampler(sampler, None);
|
||||||
|
|
Loading…
Reference in a new issue