Swtich device to the new extension version format
This commit is contained in:
parent
d964453d2d
commit
45936ae6bb
|
@ -16,7 +16,8 @@ use ash::device::Device;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
use ash::instance::{V1_0, InstanceV1_0};
|
pub use ash::instance::{V1_0, InstanceV1_0};
|
||||||
|
pub use ash::device::{DeviceV1_0};
|
||||||
|
|
||||||
// Simple offset_of macro akin to C++ offsetof
|
// Simple offset_of macro akin to C++ offsetof
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -32,7 +33,7 @@ macro_rules! offset_of{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(device: &Device,
|
pub fn record_submit_commandbuffer<F: FnOnce(&Device<V1_0>, vk::CommandBuffer)>(device: &Device<V1_0>,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
submit_queue: vk::Queue,
|
submit_queue: vk::Queue,
|
||||||
wait_mask: &[vk::PipelineStageFlags],
|
wait_mask: &[vk::PipelineStageFlags],
|
||||||
|
@ -188,7 +189,7 @@ fn resize_callback(width: u32, height: u32) {
|
||||||
pub struct ExampleBase {
|
pub struct ExampleBase {
|
||||||
pub entry: Entry,
|
pub entry: Entry,
|
||||||
pub instance: Instance<V1_0>,
|
pub instance: Instance<V1_0>,
|
||||||
pub device: Device,
|
pub device: Device<V1_0>,
|
||||||
pub surface_loader: Surface,
|
pub surface_loader: Surface,
|
||||||
pub swapchain_loader: Swapchain,
|
pub swapchain_loader: Swapchain,
|
||||||
pub debug_report_loader: DebugReport,
|
pub debug_report_loader: DebugReport,
|
||||||
|
@ -334,7 +335,7 @@ impl ExampleBase {
|
||||||
pp_enabled_extension_names: device_extension_names_raw.as_ptr(),
|
pp_enabled_extension_names: device_extension_names_raw.as_ptr(),
|
||||||
p_enabled_features: &features,
|
p_enabled_features: &features,
|
||||||
};
|
};
|
||||||
let device: Device = instance.create_device(pdevice, &device_create_info, None)
|
let device: Device<V1_0> = instance.create_device(pdevice, &device_create_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let present_queue = device.get_device_queue(queue_family_index as u32, 0);
|
let present_queue = device.get_device_queue(queue_family_index as u32, 0);
|
||||||
|
|
||||||
|
|
381
src/device.rs
381
src/device.rs
|
@ -4,153 +4,149 @@ use std::mem;
|
||||||
use vk;
|
use vk;
|
||||||
use ::RawPtr;
|
use ::RawPtr;
|
||||||
|
|
||||||
unsafe impl Sync for Device {}
|
use instance::{VkVersion, V1_0};
|
||||||
unsafe impl Send for Device {}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
// unsafe impl Sync for Device {}
|
||||||
pub struct Device {
|
// unsafe impl Send for Device {}
|
||||||
handle: vk::Device,
|
|
||||||
device_fn: vk::DeviceFn,
|
pub struct DeviceFpV1_0 {
|
||||||
|
pub device_fn: vk::DeviceFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Device {
|
pub trait DeviceV1_0 {
|
||||||
pub fn handle(&self) -> vk::Device {
|
fn handle(&self) -> vk::Device;
|
||||||
self.handle
|
fn fp_v1_0(&self) -> &vk::DeviceFn;
|
||||||
|
unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
|
self.fp_v1_0().destroy_device(self.handle(), allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn from_raw(handle: vk::Device, device_fn: vk::DeviceFn) -> Self {
|
unsafe fn destroy_sampler(&self,
|
||||||
Device {
|
|
||||||
handle: handle,
|
|
||||||
device_fn: device_fn,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
|
||||||
self.device_fn.destroy_device(self.handle, allocation_callbacks.as_raw_ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn destroy_sampler(&self,
|
|
||||||
sampler: vk::Sampler,
|
sampler: vk::Sampler,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_sampler(self.handle, sampler, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_sampler(self.handle(), sampler, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn free_memory(&self,
|
unsafe fn free_memory(&self,
|
||||||
memory: vk::DeviceMemory,
|
memory: vk::DeviceMemory,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.free_memory(self.handle, memory, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().free_memory(self.handle(), memory, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_fence(&self,
|
unsafe fn destroy_fence(&self,
|
||||||
fence: vk::Fence,
|
fence: vk::Fence,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_fence(self.handle, fence, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_fence(self.handle(), fence, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_image(&self,
|
unsafe fn destroy_image(&self,
|
||||||
image: vk::Image,
|
image: vk::Image,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_image(self.handle, image, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_image(self.handle(), image, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_command_pool(&self,
|
unsafe fn destroy_command_pool(&self,
|
||||||
pool: vk::CommandPool,
|
pool: vk::CommandPool,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_command_pool(self.handle, pool, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_command_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_image_view(&self,
|
unsafe fn destroy_image_view(&self,
|
||||||
image_view: vk::ImageView,
|
image_view: vk::ImageView,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_image_view(self.handle, image_view, allocation_callbacks.as_raw_ptr());
|
.destroy_image_view(self.handle(), image_view, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_render_pass(&self,
|
unsafe fn destroy_render_pass(&self,
|
||||||
renderpass: vk::RenderPass,
|
renderpass: vk::RenderPass,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_render_pass(self.handle, renderpass, allocation_callbacks.as_raw_ptr());
|
.destroy_render_pass(self.handle(), renderpass, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_framebuffer(&self,
|
unsafe fn destroy_framebuffer(&self,
|
||||||
framebuffer: vk::Framebuffer,
|
framebuffer: vk::Framebuffer,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_framebuffer(self.handle, framebuffer, allocation_callbacks.as_raw_ptr());
|
.destroy_framebuffer(self.handle(),
|
||||||
|
framebuffer,
|
||||||
|
allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_pipeline_layout(&self,
|
unsafe fn destroy_pipeline_layout(&self,
|
||||||
pipeline_layout: vk::PipelineLayout,
|
pipeline_layout: vk::PipelineLayout,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_pipeline_layout(self.handle,
|
self.fp_v1_0().destroy_pipeline_layout(self.handle(),
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
allocation_callbacks.as_raw_ptr());
|
allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_buffer(&self,
|
unsafe fn destroy_buffer(&self,
|
||||||
buffer: vk::Buffer,
|
buffer: vk::Buffer,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_buffer(self.handle, buffer, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_buffer(self.handle(), buffer, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_shader_module(&self,
|
unsafe fn destroy_shader_module(&self,
|
||||||
shader: vk::ShaderModule,
|
shader: vk::ShaderModule,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_shader_module(self.handle, shader, allocation_callbacks.as_raw_ptr());
|
.destroy_shader_module(self.handle(), shader, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_pipeline(&self,
|
unsafe fn destroy_pipeline(&self,
|
||||||
pipeline: vk::Pipeline,
|
pipeline: vk::Pipeline,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_pipeline(self.handle, pipeline, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0().destroy_pipeline(self.handle(), pipeline, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_semaphore(&self,
|
unsafe fn destroy_semaphore(&self,
|
||||||
semaphore: vk::Semaphore,
|
semaphore: vk::Semaphore,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn.destroy_semaphore(self.handle, semaphore, allocation_callbacks.as_raw_ptr());
|
self.fp_v1_0()
|
||||||
|
.destroy_semaphore(self.handle(), semaphore, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_descriptor_pool(&self,
|
unsafe fn destroy_descriptor_pool(&self,
|
||||||
pool: vk::DescriptorPool,
|
pool: vk::DescriptorPool,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_descriptor_pool(self.handle, pool, allocation_callbacks.as_raw_ptr());
|
.destroy_descriptor_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn destroy_descriptor_set_layout(&self, layout: vk::DescriptorSetLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
unsafe fn destroy_descriptor_set_layout(&self, layout: vk::DescriptorSetLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.destroy_descriptor_set_layout(self.handle, layout, allocation_callbacks.as_raw_ptr());
|
.destroy_descriptor_set_layout(self.handle(),
|
||||||
|
layout,
|
||||||
|
allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn free_descriptor_sets(&self,
|
unsafe fn free_descriptor_sets(&self,
|
||||||
pool: vk::DescriptorPool,
|
pool: vk::DescriptorPool,
|
||||||
descriptor_sets: &[vk::DescriptorSet]) {
|
descriptor_sets: &[vk::DescriptorSet]) {
|
||||||
self.device_fn.free_descriptor_sets(self.handle,
|
self.fp_v1_0().free_descriptor_sets(self.handle(),
|
||||||
pool,
|
pool,
|
||||||
descriptor_sets.len() as u32,
|
descriptor_sets.len() as u32,
|
||||||
descriptor_sets.as_ptr());
|
descriptor_sets.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn update_descriptor_sets(&self,
|
unsafe fn update_descriptor_sets(&self,
|
||||||
descriptor_writes: &[vk::WriteDescriptorSet],
|
descriptor_writes: &[vk::WriteDescriptorSet],
|
||||||
descriptor_copies: &[vk::CopyDescriptorSet]) {
|
descriptor_copies: &[vk::CopyDescriptorSet]) {
|
||||||
self.device_fn.update_descriptor_sets(self.handle,
|
self.fp_v1_0().update_descriptor_sets(self.handle(),
|
||||||
descriptor_writes.len() as u32,
|
descriptor_writes.len() as u32,
|
||||||
descriptor_writes.as_ptr(),
|
descriptor_writes.as_ptr(),
|
||||||
descriptor_copies.len() as u32,
|
descriptor_copies.len() as u32,
|
||||||
descriptor_copies.as_ptr());
|
descriptor_copies.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_sampler(&self,
|
unsafe fn create_sampler(&self,
|
||||||
create_info: &vk::SamplerCreateInfo,
|
create_info: &vk::SamplerCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Sampler> {
|
-> VkResult<vk::Sampler> {
|
||||||
let mut sampler = mem::uninitialized();
|
let mut sampler = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_sampler(self.handle,
|
.create_sampler(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut sampler);
|
&mut sampler);
|
||||||
|
@ -160,26 +156,26 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_copy_buffer(&self,
|
unsafe fn cmd_copy_buffer(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
src_buffer: vk::Buffer,
|
src_buffer: vk::Buffer,
|
||||||
dst_buffer: vk::Buffer,
|
dst_buffer: vk::Buffer,
|
||||||
regions: &[vk::BufferCopy]) {
|
regions: &[vk::BufferCopy]) {
|
||||||
|
|
||||||
self.device_fn.cmd_copy_buffer(command_buffer,
|
self.fp_v1_0().cmd_copy_buffer(command_buffer,
|
||||||
src_buffer,
|
src_buffer,
|
||||||
dst_buffer,
|
dst_buffer,
|
||||||
regions.len() as u32,
|
regions.len() as u32,
|
||||||
regions.as_ptr());
|
regions.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_copy_buffer_to_image(&self,
|
unsafe fn cmd_copy_buffer_to_image(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
src_buffer: vk::Buffer,
|
src_buffer: vk::Buffer,
|
||||||
dst_image: vk::Image,
|
dst_image: vk::Image,
|
||||||
dst_image_layout: vk::ImageLayout,
|
dst_image_layout: vk::ImageLayout,
|
||||||
regions: &[vk::BufferImageCopy]) {
|
regions: &[vk::BufferImageCopy]) {
|
||||||
self.device_fn.cmd_copy_buffer_to_image(command_buffer,
|
self.fp_v1_0().cmd_copy_buffer_to_image(command_buffer,
|
||||||
src_buffer,
|
src_buffer,
|
||||||
dst_image,
|
dst_image,
|
||||||
dst_image_layout,
|
dst_image_layout,
|
||||||
|
@ -187,14 +183,14 @@ impl Device {
|
||||||
regions.as_ptr());
|
regions.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_copy_image(&self,
|
unsafe fn cmd_copy_image(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
src_image: vk::Image,
|
src_image: vk::Image,
|
||||||
src_image_layout: vk::ImageLayout,
|
src_image_layout: vk::ImageLayout,
|
||||||
dst_image: vk::Image,
|
dst_image: vk::Image,
|
||||||
dst_image_layout: vk::ImageLayout,
|
dst_image_layout: vk::ImageLayout,
|
||||||
regions: &[vk::ImageCopy]) {
|
regions: &[vk::ImageCopy]) {
|
||||||
self.device_fn.cmd_copy_image(command_buffer,
|
self.fp_v1_0().cmd_copy_image(command_buffer,
|
||||||
src_image,
|
src_image,
|
||||||
src_image_layout,
|
src_image_layout,
|
||||||
dst_image,
|
dst_image,
|
||||||
|
@ -203,12 +199,12 @@ impl Device {
|
||||||
regions.as_ptr());
|
regions.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn allocate_descriptor_sets(&self,
|
unsafe fn allocate_descriptor_sets(&self,
|
||||||
create_info: &vk::DescriptorSetAllocateInfo)
|
create_info: &vk::DescriptorSetAllocateInfo)
|
||||||
-> VkResult<Vec<vk::DescriptorSet>> {
|
-> VkResult<Vec<vk::DescriptorSet>> {
|
||||||
let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize);
|
let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize);
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.allocate_descriptor_sets(self.handle, create_info, desc_set.as_mut_ptr());
|
.allocate_descriptor_sets(self.handle(), create_info, desc_set.as_mut_ptr());
|
||||||
|
|
||||||
desc_set.set_len(create_info.descriptor_set_count as usize);
|
desc_set.set_len(create_info.descriptor_set_count as usize);
|
||||||
match err_code {
|
match err_code {
|
||||||
|
@ -217,13 +213,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_descriptor_set_layout(&self,
|
unsafe fn create_descriptor_set_layout(&self,
|
||||||
create_info: &vk::DescriptorSetLayoutCreateInfo,
|
create_info: &vk::DescriptorSetLayoutCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::DescriptorSetLayout> {
|
-> VkResult<vk::DescriptorSetLayout> {
|
||||||
let mut layout = mem::uninitialized();
|
let mut layout = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_descriptor_set_layout(self.handle,
|
.create_descriptor_set_layout(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut layout);
|
&mut layout);
|
||||||
|
@ -233,9 +229,9 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn device_wait_idle(&self) -> VkResult<()> {
|
fn device_wait_idle(&self) -> VkResult<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let err_code = self.device_fn.device_wait_idle(self.handle);
|
let err_code = self.fp_v1_0().device_wait_idle(self.handle());
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
|
@ -243,13 +239,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_descriptor_pool(&self,
|
unsafe fn create_descriptor_pool(&self,
|
||||||
create_info: &vk::DescriptorPoolCreateInfo,
|
create_info: &vk::DescriptorPoolCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::DescriptorPool> {
|
-> VkResult<vk::DescriptorPool> {
|
||||||
let mut pool = mem::uninitialized();
|
let mut pool = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_descriptor_pool(self.handle,
|
.create_descriptor_pool(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pool);
|
&mut pool);
|
||||||
|
@ -259,11 +255,11 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn reset_command_buffer(&self,
|
unsafe fn reset_command_buffer(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
flags: vk::CommandBufferResetFlags)
|
flags: vk::CommandBufferResetFlags)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.reset_command_buffer(command_buffer, flags);
|
.reset_command_buffer(command_buffer, flags);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
|
@ -271,24 +267,24 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
|
unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.reset_fences(self.handle, fences.len() as vk::uint32_t, fences.as_ptr());
|
.reset_fences(self.handle(), fences.len() as vk::uint32_t, fences.as_ptr());
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_bind_index_buffer(&self,
|
unsafe fn cmd_bind_index_buffer(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
buffer: vk::Buffer,
|
buffer: vk::Buffer,
|
||||||
offset: vk::DeviceSize,
|
offset: vk::DeviceSize,
|
||||||
index_type: vk::IndexType) {
|
index_type: vk::IndexType) {
|
||||||
self.device_fn.cmd_bind_index_buffer(command_buffer, buffer, offset, index_type);
|
self.fp_v1_0().cmd_bind_index_buffer(command_buffer, buffer, offset, index_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_draw_indexed(&self,
|
unsafe fn cmd_draw_indexed(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
index_count: vk::uint32_t,
|
index_count: vk::uint32_t,
|
||||||
instance_count: vk::uint32_t,
|
instance_count: vk::uint32_t,
|
||||||
|
@ -296,7 +292,7 @@ impl Device {
|
||||||
vertex_offset: vk::int32_t,
|
vertex_offset: vk::int32_t,
|
||||||
first_instance: vk::uint32_t) {
|
first_instance: vk::uint32_t) {
|
||||||
|
|
||||||
self.device_fn.cmd_draw_indexed(command_buffer,
|
self.fp_v1_0().cmd_draw_indexed(command_buffer,
|
||||||
index_count,
|
index_count,
|
||||||
instance_count,
|
instance_count,
|
||||||
first_index,
|
first_index,
|
||||||
|
@ -304,14 +300,14 @@ impl Device {
|
||||||
first_instance);
|
first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_bind_descriptor_sets(&self,
|
unsafe fn cmd_bind_descriptor_sets(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
pipeline_bind_point: vk::PipelineBindPoint,
|
pipeline_bind_point: vk::PipelineBindPoint,
|
||||||
layout: vk::PipelineLayout,
|
layout: vk::PipelineLayout,
|
||||||
first_set: vk::uint32_t,
|
first_set: vk::uint32_t,
|
||||||
descriptor_sets: &[vk::DescriptorSet],
|
descriptor_sets: &[vk::DescriptorSet],
|
||||||
dynamic_offsets: &[vk::uint32_t]) {
|
dynamic_offsets: &[vk::uint32_t]) {
|
||||||
self.device_fn.cmd_bind_descriptor_sets(command_buffer,
|
self.fp_v1_0().cmd_bind_descriptor_sets(command_buffer,
|
||||||
pipeline_bind_point,
|
pipeline_bind_point,
|
||||||
layout,
|
layout,
|
||||||
first_set,
|
first_set,
|
||||||
|
@ -321,74 +317,72 @@ impl Device {
|
||||||
dynamic_offsets.as_ptr())
|
dynamic_offsets.as_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_begin_render_pass(&self,
|
unsafe fn cmd_begin_render_pass(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
create_info: &vk::RenderPassBeginInfo,
|
create_info: &vk::RenderPassBeginInfo,
|
||||||
contents: vk::SubpassContents) {
|
contents: vk::SubpassContents) {
|
||||||
self.device_fn.cmd_begin_render_pass(command_buffer, create_info, contents);
|
self.fp_v1_0().cmd_begin_render_pass(command_buffer, create_info, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_bind_pipeline(&self,
|
unsafe fn cmd_bind_pipeline(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
pipeline_bind_point: vk::PipelineBindPoint,
|
pipeline_bind_point: vk::PipelineBindPoint,
|
||||||
pipeline: vk::Pipeline) {
|
pipeline: vk::Pipeline) {
|
||||||
self.device_fn.cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline);
|
self.fp_v1_0().cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_set_scissor(&self,
|
unsafe fn cmd_set_scissor(&self, command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D]) {
|
||||||
command_buffer: vk::CommandBuffer,
|
self.fp_v1_0()
|
||||||
scissors: &[vk::Rect2D]) {
|
|
||||||
self.device_fn
|
|
||||||
.cmd_set_scissor(command_buffer,
|
.cmd_set_scissor(command_buffer,
|
||||||
0,
|
0,
|
||||||
scissors.len() as vk::uint32_t,
|
scissors.len() as vk::uint32_t,
|
||||||
scissors.as_ptr());
|
scissors.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_bind_vertex_buffers(&self,
|
unsafe fn cmd_bind_vertex_buffers(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
buffers: &[vk::Buffer],
|
buffers: &[vk::Buffer],
|
||||||
offsets: &vk::DeviceSize) {
|
offsets: &vk::DeviceSize) {
|
||||||
self.device_fn.cmd_bind_vertex_buffers(command_buffer,
|
self.fp_v1_0().cmd_bind_vertex_buffers(command_buffer,
|
||||||
0,
|
0,
|
||||||
buffers.len() as vk::uint32_t,
|
buffers.len() as vk::uint32_t,
|
||||||
buffers.as_ptr(),
|
buffers.as_ptr(),
|
||||||
offsets);
|
offsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) {
|
unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) {
|
||||||
self.device_fn.cmd_end_render_pass(command_buffer);
|
self.fp_v1_0().cmd_end_render_pass(command_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_draw(&self,
|
unsafe fn cmd_draw(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
vertex_count: vk::uint32_t,
|
vertex_count: vk::uint32_t,
|
||||||
instance_count: vk::uint32_t,
|
instance_count: vk::uint32_t,
|
||||||
first_vertex: vk::uint32_t,
|
first_vertex: vk::uint32_t,
|
||||||
first_instance: vk::uint32_t) {
|
first_instance: vk::uint32_t) {
|
||||||
self.device_fn.cmd_draw(command_buffer,
|
self.fp_v1_0().cmd_draw(command_buffer,
|
||||||
vertex_count,
|
vertex_count,
|
||||||
instance_count,
|
instance_count,
|
||||||
first_vertex,
|
first_vertex,
|
||||||
first_instance);
|
first_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_set_viewport(&self,
|
unsafe fn cmd_set_viewport(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
viewports: &[vk::Viewport]) {
|
viewports: &[vk::Viewport]) {
|
||||||
self.device_fn.cmd_set_viewport(command_buffer,
|
self.fp_v1_0().cmd_set_viewport(command_buffer,
|
||||||
0,
|
0,
|
||||||
viewports.len() as vk::uint32_t,
|
viewports.len() as vk::uint32_t,
|
||||||
viewports.as_ptr());
|
viewports.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_semaphore(&self,
|
unsafe fn create_semaphore(&self,
|
||||||
create_info: &vk::SemaphoreCreateInfo,
|
create_info: &vk::SemaphoreCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Semaphore> {
|
-> VkResult<vk::Semaphore> {
|
||||||
let mut semaphore = mem::uninitialized();
|
let mut semaphore = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_semaphore(self.handle,
|
.create_semaphore(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut semaphore);
|
&mut semaphore);
|
||||||
|
@ -398,14 +392,14 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_graphics_pipelines(&self,
|
unsafe fn create_graphics_pipelines(&self,
|
||||||
pipeline_cache: vk::PipelineCache,
|
pipeline_cache: vk::PipelineCache,
|
||||||
create_infos: &[vk::GraphicsPipelineCreateInfo],
|
create_infos: &[vk::GraphicsPipelineCreateInfo],
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<Vec<vk::Pipeline>> {
|
-> VkResult<Vec<vk::Pipeline>> {
|
||||||
let mut pipelines = Vec::with_capacity(create_infos.len());
|
let mut pipelines = Vec::with_capacity(create_infos.len());
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_graphics_pipelines(self.handle,
|
.create_graphics_pipelines(self.handle(),
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
create_infos.len() as vk::uint32_t,
|
create_infos.len() as vk::uint32_t,
|
||||||
create_infos.as_ptr(),
|
create_infos.as_ptr(),
|
||||||
|
@ -418,13 +412,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_buffer(&self,
|
unsafe fn create_buffer(&self,
|
||||||
create_info: &vk::BufferCreateInfo,
|
create_info: &vk::BufferCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Buffer> {
|
-> VkResult<vk::Buffer> {
|
||||||
let mut buffer = mem::uninitialized();
|
let mut buffer = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_buffer(self.handle,
|
.create_buffer(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut buffer);
|
&mut buffer);
|
||||||
|
@ -434,14 +428,14 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_pipeline_layout(&self,
|
fn create_pipeline_layout(&self,
|
||||||
create_info: &vk::PipelineLayoutCreateInfo,
|
create_info: &vk::PipelineLayoutCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::PipelineLayout> {
|
-> VkResult<vk::PipelineLayout> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut pipeline_layout = mem::uninitialized();
|
let mut pipeline_layout = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_pipeline_layout(self.handle,
|
.create_pipeline_layout(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pipeline_layout);
|
&mut pipeline_layout);
|
||||||
|
@ -452,7 +446,7 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn map_memory<T>(&self,
|
unsafe fn map_memory<T>(&self,
|
||||||
memory: vk::DeviceMemory,
|
memory: vk::DeviceMemory,
|
||||||
offset: vk::DeviceSize,
|
offset: vk::DeviceSize,
|
||||||
size: vk::DeviceSize,
|
size: vk::DeviceSize,
|
||||||
|
@ -460,8 +454,8 @@ impl Device {
|
||||||
-> VkResult<&mut [T]> {
|
-> VkResult<&mut [T]> {
|
||||||
|
|
||||||
let mut data: *mut () = mem::uninitialized();
|
let mut data: *mut () = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.map_memory(self.handle, memory, offset, size, flags, &mut data);
|
.map_memory(self.handle(), memory, offset, size, flags, &mut data);
|
||||||
let x: *mut T = data as *mut T;
|
let x: *mut T = data as *mut T;
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => {
|
vk::Result::Success => {
|
||||||
|
@ -471,18 +465,18 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn unmap_memory(&self, memory: vk::DeviceMemory) {
|
unsafe fn unmap_memory(&self, memory: vk::DeviceMemory) {
|
||||||
self.device_fn.unmap_memory(self.handle, memory);
|
self.fp_v1_0().unmap_memory(self.handle(), memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_framebuffer(&self,
|
fn create_framebuffer(&self,
|
||||||
create_info: &vk::FramebufferCreateInfo,
|
create_info: &vk::FramebufferCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Framebuffer> {
|
-> VkResult<vk::Framebuffer> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut framebuffer = mem::uninitialized();
|
let mut framebuffer = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_framebuffer(self.handle,
|
.create_framebuffer(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut framebuffer);
|
&mut framebuffer);
|
||||||
|
@ -493,17 +487,17 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn get_device_queue(&self,
|
unsafe fn get_device_queue(&self,
|
||||||
queue_family_index: vk::uint32_t,
|
queue_family_index: vk::uint32_t,
|
||||||
queue_index: vk::uint32_t)
|
queue_index: vk::uint32_t)
|
||||||
-> vk::Queue {
|
-> vk::Queue {
|
||||||
let mut queue = mem::uninitialized();
|
let mut queue = mem::uninitialized();
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.get_device_queue(self.handle, queue_family_index, queue_index, &mut queue);
|
.get_device_queue(self.handle(), queue_family_index, queue_index, &mut queue);
|
||||||
queue
|
queue
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_pipeline_barrier(&self,
|
unsafe fn cmd_pipeline_barrier(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
src_stage_mask: vk::PipelineStageFlags,
|
src_stage_mask: vk::PipelineStageFlags,
|
||||||
dst_stage_mask: vk::PipelineStageFlags,
|
dst_stage_mask: vk::PipelineStageFlags,
|
||||||
|
@ -511,7 +505,7 @@ impl Device {
|
||||||
memory_barriers: &[vk::MemoryBarrier],
|
memory_barriers: &[vk::MemoryBarrier],
|
||||||
buffer_memory_barriers: &[vk::BufferMemoryBarrier],
|
buffer_memory_barriers: &[vk::BufferMemoryBarrier],
|
||||||
image_memory_barriers: &[vk::ImageMemoryBarrier]) {
|
image_memory_barriers: &[vk::ImageMemoryBarrier]) {
|
||||||
self.device_fn.cmd_pipeline_barrier(command_buffer,
|
self.fp_v1_0().cmd_pipeline_barrier(command_buffer,
|
||||||
src_stage_mask,
|
src_stage_mask,
|
||||||
dst_stage_mask,
|
dst_stage_mask,
|
||||||
dependency_flags,
|
dependency_flags,
|
||||||
|
@ -523,13 +517,13 @@ impl Device {
|
||||||
image_memory_barriers.as_ptr());
|
image_memory_barriers.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_render_pass(&self,
|
unsafe fn create_render_pass(&self,
|
||||||
create_info: &vk::RenderPassCreateInfo,
|
create_info: &vk::RenderPassCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::RenderPass> {
|
-> VkResult<vk::RenderPass> {
|
||||||
let mut renderpass = mem::uninitialized();
|
let mut renderpass = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_render_pass(self.handle,
|
.create_render_pass(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut renderpass);
|
&mut renderpass);
|
||||||
|
@ -539,11 +533,11 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn begin_command_buffer(&self,
|
unsafe fn begin_command_buffer(&self,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
create_info: &vk::CommandBufferBeginInfo)
|
create_info: &vk::CommandBufferBeginInfo)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.begin_command_buffer(command_buffer, create_info);
|
.begin_command_buffer(command_buffer, create_info);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
|
@ -551,8 +545,8 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> {
|
unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.end_command_buffer(command_buffer);
|
.end_command_buffer(command_buffer);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
|
@ -560,13 +554,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn wait_for_fences(&self,
|
unsafe fn wait_for_fences(&self,
|
||||||
fences: &[vk::Fence],
|
fences: &[vk::Fence],
|
||||||
wait_all: bool,
|
wait_all: bool,
|
||||||
timeout: vk::uint64_t)
|
timeout: vk::uint64_t)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.wait_for_fences(self.handle,
|
.wait_for_fences(self.handle(),
|
||||||
fences.len() as vk::uint32_t,
|
fences.len() as vk::uint32_t,
|
||||||
fences.as_ptr(),
|
fences.as_ptr(),
|
||||||
wait_all as vk::uint32_t,
|
wait_all as vk::uint32_t,
|
||||||
|
@ -577,20 +571,20 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
|
unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
|
||||||
let err_code = self.device_fn.queue_wait_idle(queue);
|
let err_code = self.fp_v1_0().queue_wait_idle(queue);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn queue_submit(&self,
|
unsafe fn queue_submit(&self,
|
||||||
queue: vk::Queue,
|
queue: vk::Queue,
|
||||||
submits: &[vk::SubmitInfo],
|
submits: &[vk::SubmitInfo],
|
||||||
fence: vk::Fence)
|
fence: vk::Fence)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.queue_submit(queue,
|
.queue_submit(queue,
|
||||||
submits.len() as vk::uint32_t,
|
submits.len() as vk::uint32_t,
|
||||||
submits.as_ptr(),
|
submits.as_ptr(),
|
||||||
|
@ -601,13 +595,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_image_view(&self,
|
unsafe fn create_image_view(&self,
|
||||||
create_info: &vk::ImageViewCreateInfo,
|
create_info: &vk::ImageViewCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::ImageView> {
|
-> VkResult<vk::ImageView> {
|
||||||
let mut image_view = mem::uninitialized();
|
let mut image_view = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_image_view(self.handle,
|
.create_image_view(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut image_view);
|
&mut image_view);
|
||||||
|
@ -618,12 +612,12 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub unsafe fn allocate_command_buffers(&self,
|
unsafe fn allocate_command_buffers(&self,
|
||||||
create_info: &vk::CommandBufferAllocateInfo)
|
create_info: &vk::CommandBufferAllocateInfo)
|
||||||
-> VkResult<Vec<vk::CommandBuffer>> {
|
-> VkResult<Vec<vk::CommandBuffer>> {
|
||||||
let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t);
|
let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t);
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.allocate_command_buffers(self.handle, create_info, buffers.as_mut_ptr());
|
.allocate_command_buffers(self.handle(), create_info, buffers.as_mut_ptr());
|
||||||
buffers.set_len(create_info.command_buffer_count as vk::size_t);
|
buffers.set_len(create_info.command_buffer_count as vk::size_t);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(buffers),
|
vk::Result::Success => Ok(buffers),
|
||||||
|
@ -631,13 +625,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_command_pool(&self,
|
unsafe fn create_command_pool(&self,
|
||||||
create_info: &vk::CommandPoolCreateInfo,
|
create_info: &vk::CommandPoolCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::CommandPool> {
|
-> VkResult<vk::CommandPool> {
|
||||||
let mut pool = mem::uninitialized();
|
let mut pool = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_command_pool(self.handle,
|
.create_command_pool(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pool);
|
&mut pool);
|
||||||
|
@ -647,13 +641,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_image(&self,
|
unsafe fn create_image(&self,
|
||||||
create_info: &vk::ImageCreateInfo,
|
create_info: &vk::ImageCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Image> {
|
-> VkResult<vk::Image> {
|
||||||
let mut image = mem::uninitialized();
|
let mut image = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_image(self.handle,
|
.create_image(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut image);
|
&mut image);
|
||||||
|
@ -663,31 +657,31 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
|
fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut mem_req = mem::uninitialized();
|
let mut mem_req = mem::uninitialized();
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.get_image_memory_requirements(self.handle, image, &mut mem_req);
|
.get_image_memory_requirements(self.handle(), image, &mut mem_req);
|
||||||
mem_req
|
mem_req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
|
fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut mem_req = mem::uninitialized();
|
let mut mem_req = mem::uninitialized();
|
||||||
self.device_fn
|
self.fp_v1_0()
|
||||||
.get_buffer_memory_requirements(self.handle, buffer, &mut mem_req);
|
.get_buffer_memory_requirements(self.handle(), buffer, &mut mem_req);
|
||||||
mem_req
|
mem_req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn allocate_memory(&self,
|
unsafe fn allocate_memory(&self,
|
||||||
create_info: &vk::MemoryAllocateInfo,
|
create_info: &vk::MemoryAllocateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::DeviceMemory> {
|
-> VkResult<vk::DeviceMemory> {
|
||||||
let mut memory = mem::uninitialized();
|
let mut memory = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.allocate_memory(self.handle,
|
.allocate_memory(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut memory);
|
&mut memory);
|
||||||
|
@ -697,13 +691,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_shader_module(&self,
|
unsafe fn create_shader_module(&self,
|
||||||
create_info: &vk::ShaderModuleCreateInfo,
|
create_info: &vk::ShaderModuleCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::ShaderModule> {
|
-> VkResult<vk::ShaderModule> {
|
||||||
let mut shader = mem::uninitialized();
|
let mut shader = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_shader_module(self.handle,
|
.create_shader_module(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut shader);
|
&mut shader);
|
||||||
|
@ -713,13 +707,13 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_fence(&self,
|
unsafe fn create_fence(&self,
|
||||||
create_info: &vk::FenceCreateInfo,
|
create_info: &vk::FenceCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> VkResult<vk::Fence> {
|
-> VkResult<vk::Fence> {
|
||||||
let mut fence = mem::uninitialized();
|
let mut fence = mem::uninitialized();
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.create_fence(self.handle,
|
.create_fence(self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut fence);
|
&mut fence);
|
||||||
|
@ -729,29 +723,58 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn bind_buffer_memory(&self,
|
unsafe fn bind_buffer_memory(&self,
|
||||||
buffer: vk::Buffer,
|
buffer: vk::Buffer,
|
||||||
device_memory: vk::DeviceMemory,
|
device_memory: vk::DeviceMemory,
|
||||||
offset: vk::DeviceSize)
|
offset: vk::DeviceSize)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.bind_buffer_memory(self.handle, buffer, device_memory, offset);
|
.bind_buffer_memory(self.handle(), buffer, device_memory, offset);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn bind_image_memory(&self,
|
unsafe fn bind_image_memory(&self,
|
||||||
image: vk::Image,
|
image: vk::Image,
|
||||||
device_memory: vk::DeviceMemory,
|
device_memory: vk::DeviceMemory,
|
||||||
offset: vk::DeviceSize)
|
offset: vk::DeviceSize)
|
||||||
-> VkResult<()> {
|
-> VkResult<()> {
|
||||||
let err_code = self.device_fn
|
let err_code = self.fp_v1_0()
|
||||||
.bind_image_memory(self.handle, image, device_memory, offset);
|
.bind_image_memory(self.handle(), image, device_memory, offset);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::Success => Ok(()),
|
vk::Result::Success => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Device<V: VkVersion> {
|
||||||
|
handle: vk::Device,
|
||||||
|
device_fn: V::DeviceFp,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceV1_0 for Device<V1_0> {
|
||||||
|
fn handle(&self) -> vk::Device {
|
||||||
|
self.handle
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fp_v1_0(&self) -> &vk::DeviceFn {
|
||||||
|
&self.device_fn.device_fn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<V: VkVersion> Device<V> {
|
||||||
|
pub fn handle(&self) -> vk::Device {
|
||||||
|
self.handle
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn from_raw(handle: vk::Device, device_fn: V::DeviceFp) -> Self {
|
||||||
|
Device {
|
||||||
|
handle: handle,
|
||||||
|
device_fn: device_fn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct Swapchain {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Swapchain {
|
impl Swapchain {
|
||||||
pub fn new(instance: &Instance<V1_0>, device: &Device) -> Result<Swapchain, Vec<&'static str>> {
|
pub fn new(instance: &Instance<V1_0>, device: &Device<V1_0>) -> Result<Swapchain, Vec<&'static str>> {
|
||||||
let swapchain_fn = vk::SwapchainFn::load(|name| {
|
let swapchain_fn = vk::SwapchainFn::load(|name| {
|
||||||
unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }
|
unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub struct Win32Surface {
|
||||||
win32_surface_fn: vk::Win32SurfaceFn,
|
win32_surface_fn: vk::Win32SurfaceFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Win32Surface {
|
impl Win32Surface {
|
||||||
pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<Win32Surface, Vec<&'static str>> {
|
pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<Win32Surface, Vec<&'static str>> {
|
||||||
let surface_fn = vk::Win32SurfaceFn::load(|name| {
|
let surface_fn = vk::Win32SurfaceFn::load(|name| {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use prelude::*;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use vk;
|
use vk;
|
||||||
use device::Device;
|
use device::{Device, DeviceFpV1_0};
|
||||||
use ::RawPtr;
|
use ::RawPtr;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -12,36 +12,35 @@ pub enum DeviceError {
|
||||||
VkError(vk::Result),
|
VkError(vk::Result),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait VkVersion{
|
pub trait VkVersion {
|
||||||
type InstanceFp;
|
type InstanceFp;
|
||||||
type DeviceFp;
|
type DeviceFp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[warn(non_camel_case_types)]
|
#[warn(non_camel_case_types)]
|
||||||
pub struct V1_0;
|
pub struct V1_0;
|
||||||
impl VkVersion for V1_0{
|
impl VkVersion for V1_0 {
|
||||||
type InstanceFp = InstanceFpV1_0;
|
type InstanceFp = InstanceFpV1_0;
|
||||||
type DeviceFp = ();
|
type DeviceFp = DeviceFpV1_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[warn(non_camel_case_types)]
|
#[warn(non_camel_case_types)]
|
||||||
pub struct InstanceFpV1_0{
|
pub struct InstanceFpV1_0 {
|
||||||
pub instance_fn: vk::InstanceFn
|
pub instance_fn: vk::InstanceFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Instance<V: VkVersion> {
|
pub struct Instance<V: VkVersion> {
|
||||||
handle: vk::Instance,
|
handle: vk::Instance,
|
||||||
instance_fp: V::InstanceFp
|
instance_fp: V::InstanceFp,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InstanceV1_0 for Instance<V1_0>{
|
impl InstanceV1_0 for Instance<V1_0> {
|
||||||
fn handle(&self) -> vk::Instance{
|
fn handle(&self) -> vk::Instance {
|
||||||
self.handle
|
self.handle
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fp_v1_0(&self) -> &vk::InstanceFn{
|
fn fp_v1_0(&self) -> &vk::InstanceFn {
|
||||||
&self.instance_fp.instance_fn
|
&self.instance_fp.instance_fn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,21 +52,17 @@ impl<V: VkVersion> Instance<V> {
|
||||||
pub fn from_raw(handle: vk::Instance, version: V::InstanceFp) -> Self {
|
pub fn from_raw(handle: vk::Instance, version: V::InstanceFp) -> Self {
|
||||||
Instance {
|
Instance {
|
||||||
handle: handle,
|
handle: handle,
|
||||||
instance_fp: version
|
instance_fp: version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[warn(non_camel_case_types)]
|
impl Instance<V1_0> {
|
||||||
pub trait InstanceV1_0 {
|
pub unsafe fn create_device(&self,
|
||||||
fn handle(&self) -> vk::Instance;
|
|
||||||
fn fp_v1_0(&self) -> &vk::InstanceFn;
|
|
||||||
unsafe fn create_device(&self,
|
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
create_info: &vk::DeviceCreateInfo,
|
create_info: &vk::DeviceCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
-> Result<Device, DeviceError> {
|
-> Result<Device<V1_0>, DeviceError> {
|
||||||
let mut device: vk::Device = mem::uninitialized();
|
let mut device: vk::Device = mem::uninitialized();
|
||||||
let err_code = self.fp_v1_0()
|
let err_code = self.fp_v1_0()
|
||||||
.create_device(physical_device,
|
.create_device(physical_device,
|
||||||
|
@ -80,8 +75,14 @@ pub trait InstanceV1_0 {
|
||||||
let device_fn = vk::DeviceFn::load(|name| {
|
let device_fn = vk::DeviceFn::load(|name| {
|
||||||
mem::transmute(self.fp_v1_0().get_device_proc_addr(device, name.as_ptr()))
|
mem::transmute(self.fp_v1_0().get_device_proc_addr(device, name.as_ptr()))
|
||||||
}).map_err(|err| DeviceError::LoadError(err))?;
|
}).map_err(|err| DeviceError::LoadError(err))?;
|
||||||
Ok(Device::from_raw(device, device_fn))
|
Ok(Device::from_raw(device, DeviceFpV1_0 { device_fn: device_fn }))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[warn(non_camel_case_types)]
|
||||||
|
pub trait InstanceV1_0 {
|
||||||
|
fn handle(&self) -> vk::Instance;
|
||||||
|
fn fp_v1_0(&self) -> &vk::InstanceFn;
|
||||||
fn get_device_proc_addr(&self,
|
fn get_device_proc_addr(&self,
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
p_name: *const vk::c_char)
|
p_name: *const vk::c_char)
|
||||||
|
@ -176,6 +177,5 @@ pub trait InstanceV1_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//pub trait InstanceMajor1Minor1: InstanceMajor1Minor0 {}
|
// pub trait InstanceMajor1Minor1: InstanceMajor1Minor0 {}
|
||||||
//pub trait InstanceMajor1Minor2: InstanceMajor1Minor1 {}
|
// pub trait InstanceMajor1Minor2: InstanceMajor1Minor1 {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue