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