Make create_instance unsafe
This commit is contained in:
parent
d7c9c1489b
commit
a73b52012b
2 changed files with 16 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "ash"
|
||||
version = "0.18.6"
|
||||
version = "0.19.0"
|
||||
authors = ["maik klein <maikklein@googlemail.com>"]
|
||||
description = "Vulkan bindings for Rust"
|
||||
license = "MIT"
|
||||
|
|
|
@ -73,28 +73,26 @@ pub trait EntryV1_0 {
|
|||
fn fp_v1_0(&self) -> &vk::EntryFnV1_0;
|
||||
fn static_fn(&self) -> &vk::StaticFn;
|
||||
|
||||
fn create_instance(
|
||||
unsafe fn create_instance(
|
||||
&self,
|
||||
create_info: &vk::InstanceCreateInfo,
|
||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||
) -> Result<Instance<Self::Fp>, InstanceError> {
|
||||
unsafe {
|
||||
let mut instance: vk::Instance = mem::uninitialized();
|
||||
let err_code = self.fp_v1_0().create_instance(
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut instance,
|
||||
);
|
||||
if err_code != vk::Result::Success {
|
||||
return Err(InstanceError::VkError(err_code));
|
||||
}
|
||||
let instance_fp =
|
||||
<<Self as EntryV1_0>::Fp as FunctionPointers>::InstanceFp::load(
|
||||
&self.static_fn(),
|
||||
instance,
|
||||
).map_err(|err| InstanceError::LoadError(err))?;
|
||||
Ok(Instance::from_raw(instance, instance_fp))
|
||||
let mut instance: vk::Instance = mem::uninitialized();
|
||||
let err_code = self.fp_v1_0().create_instance(
|
||||
create_info,
|
||||
allocation_callbacks.as_raw_ptr(),
|
||||
&mut instance,
|
||||
);
|
||||
if err_code != vk::Result::Success {
|
||||
return Err(InstanceError::VkError(err_code));
|
||||
}
|
||||
let instance_fp =
|
||||
<<Self as EntryV1_0>::Fp as FunctionPointers>::InstanceFp::load(
|
||||
&self.static_fn(),
|
||||
instance,
|
||||
).map_err(|err| InstanceError::LoadError(err))?;
|
||||
Ok(Instance::from_raw(instance, instance_fp))
|
||||
}
|
||||
|
||||
fn enumerate_instance_layer_properties(&self) -> VkResult<Vec<vk::LayerProperties>> {
|
||||
|
|
Loading…
Add table
Reference in a new issue