Skip to main content

VulkanDevice

Struct VulkanDevice 

Source
pub struct VulkanDevice {
Show 15 fields pub device: Device, pub physical_device: PhysicalDevice, pub queue: Mutex<Queue>, pub queue_family_index: u32, pub memory_properties: PhysicalDeviceMemoryProperties, pub non_coherent_atom_size: u64, pub bindless_heap: Option<VulkanBindlessHeap>, pub swapchain_loader: Option<Device>, pub command_recorder_cache: Mutex<Vec<(CommandPool, CommandBuffer)>>, pub fence_cache: Mutex<Vec<Fence>>, pub internal_frame_semaphore: Semaphore, pub internal_frame_counter: AtomicU64, pub pending_async_recorders: Mutex<Vec<(u64, Vec<VulkanCommandRecorder>)>>, pub allocator: Mutex<VulkanSuballocator>, pub pipeline_cache: PipelineCache,
}

Fields§

§device: Device§physical_device: PhysicalDevice§queue: Mutex<Queue>§queue_family_index: u32§memory_properties: PhysicalDeviceMemoryProperties§non_coherent_atom_size: u64§bindless_heap: Option<VulkanBindlessHeap>§swapchain_loader: Option<Device>§command_recorder_cache: Mutex<Vec<(CommandPool, CommandBuffer)>>§fence_cache: Mutex<Vec<Fence>>§internal_frame_semaphore: Semaphore§internal_frame_counter: AtomicU64§pending_async_recorders: Mutex<Vec<(u64, Vec<VulkanCommandRecorder>)>>§allocator: Mutex<VulkanSuballocator>§pipeline_cache: PipelineCache

Implementations§

Source§

impl VulkanDevice

Source

pub fn create_buffer( &self, desc: &BufferDesc<'_>, ) -> Result<VulkanBuffer, HalError>

Source

pub fn write_buffer( &self, buffer: &VulkanBuffer, offset: u64, data: &[u8], ) -> Result<(), HalError>

Source

pub fn read_buffer( &self, buffer: &VulkanBuffer, offset: u64, data: &mut [u8], ) -> Result<(), HalError>

Source

pub fn destroy_buffer(&self, buffer: VulkanBuffer)

Source

pub fn register_bindless_buffer( &self, buffer: &VulkanBuffer, ) -> Result<u32, HalError>

Source

pub fn unregister_bindless_buffer(&self, slot: u32)

Source

pub fn write_buffer_descriptors_batch( &self, writes: &[(u32, &VulkanBuffer)], ) -> Result<(), HalError>

Source§

impl VulkanDevice

Source

pub fn create_command_recorder(&self) -> Result<VulkanCommandRecorder, HalError>

Source

pub fn recycle_command_recorder(&self, recorder: VulkanCommandRecorder)

Source

pub fn bind_buffers_to_compute_pipeline( &self, pipeline: &VulkanComputePipeline, buffers: &[&VulkanBuffer], )

Source

pub fn dispatch( &self, recorder: &VulkanCommandRecorder, pipeline: &VulkanComputePipeline, x: u32, y: u32, z: u32, )

Source

pub fn dispatch_bindless( &self, recorder: &VulkanCommandRecorder, pipeline: Pipeline, push_constants: &[u8], x: u32, y: u32, z: u32, ) -> Result<(), HalError>

Source

pub fn cmd_clear_and_render( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_clear_and_render_with_depth( &self, recorder: &VulkanCommandRecorder, color_texture: &VulkanTexture, depth_texture: &VulkanTexture, clear_color: [f32; 4], clear_depth: f32, ) -> Result<(), HalError>

Source

pub fn cmd_draw( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, pipeline: Pipeline, vertex_count: u32, push_constants: &[u8], clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_draw_instanced( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, pipeline: Pipeline, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32, push_constants: &[u8], clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_draw_triangle( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, pipeline: Pipeline, clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_draw_with_depth( &self, recorder: &VulkanCommandRecorder, color_texture: &VulkanTexture, depth_texture: &VulkanTexture, pipeline: Pipeline, vertex_count: u32, push_constants: &[u8], clear_color: [f32; 4], clear_depth: f32, ) -> Result<(), HalError>

Source

pub fn cmd_draw_mrt( &self, recorder: &VulkanCommandRecorder, color_textures: &[&VulkanTexture], depth_texture: Option<&VulkanTexture>, pipeline: Pipeline, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32, push_constants: &[u8], clear_color: [f32; 4], clear_depth: Option<f32>, ) -> Result<(), HalError>

Source

pub fn cmd_draw_indexed( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, pipeline: Pipeline, index_buffer: &VulkanBuffer, index_count: u32, instance_count: u32, first_index: u32, vertex_offset: i32, first_instance: u32, index_type: IndexType, push_constants: &[u8], clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_draw_indexed_with_depth( &self, recorder: &VulkanCommandRecorder, color_texture: &VulkanTexture, depth_texture: &VulkanTexture, pipeline: Pipeline, index_buffer: &VulkanBuffer, index_count: u32, instance_count: u32, first_index: u32, vertex_offset: i32, first_instance: u32, index_type: IndexType, push_constants: &[u8], clear_color: [f32; 4], clear_depth: f32, ) -> Result<(), HalError>

Source

pub fn cmd_draw_indirect( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, pipeline: Pipeline, indirect_buffer: &VulkanBuffer, offset: u64, draw_count: u32, stride: u32, push_constants: &[u8], clear_color: [f32; 4], ) -> Result<(), HalError>

Source

pub fn cmd_draw_indirect_with_depth( &self, recorder: &VulkanCommandRecorder, color_texture: &VulkanTexture, depth_texture: &VulkanTexture, pipeline: Pipeline, indirect_buffer: &VulkanBuffer, offset: u64, draw_count: u32, stride: u32, push_constants: &[u8], clear_color: [f32; 4], clear_depth: f32, ) -> Result<(), HalError>

Source

pub fn cmd_draw_with_ops( &self, recorder: &VulkanCommandRecorder, color_texture: &VulkanTexture, depth: Option<(&VulkanTexture, DepthLoadOp)>, pipeline: Pipeline, draw_cmd: DrawCommand<'_>, push_constants: &[u8], color_load_op: ColorLoadOp, ) -> Result<(), HalError>

Source

pub fn cmd_dispatch_indirect( &self, recorder: &VulkanCommandRecorder, pipeline: Pipeline, indirect_buffer: &VulkanBuffer, offset: u64, push_constants: &[u8], ) -> Result<(), HalError>

Source

pub fn cmd_copy_buffer_to_buffer( &self, recorder: &VulkanCommandRecorder, src: &VulkanBuffer, dst: &VulkanBuffer, size: u64, src_offset: u64, dst_offset: u64, )

Source

pub fn cmd_copy_buffer_to_image( &self, recorder: &VulkanCommandRecorder, buffer: &VulkanBuffer, texture: &VulkanTexture, )

Source

pub fn write_texture( &self, texture: &VulkanTexture, data: &[u8], ) -> Result<(), HalError>

Source

pub fn cmd_copy_image_to_buffer( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, buffer: &VulkanBuffer, )

Source

pub fn submit_and_wait( &self, recorder: VulkanCommandRecorder, ) -> Result<(), HalError>

Source

pub fn submit_batches_and_wait( &self, recorders: Vec<VulkanCommandRecorder>, ) -> Result<(), HalError>

Source

pub fn submit_batches_async( &self, recorders: Vec<VulkanCommandRecorder>, wait_semaphores: &[(&VulkanTimelineSemaphore, u64)], signal_semaphores: &[(&VulkanTimelineSemaphore, u64)], ) -> Result<(), HalError>

Source

pub fn cmd_memory_barrier(&self, recorder: &VulkanCommandRecorder)

Source

pub fn cmd_buffer_barrier( &self, recorder: &VulkanCommandRecorder, buffer: &VulkanBuffer, )

Source§

impl VulkanDevice

Source

pub fn wait_idle(&self) -> Result<(), HalError>

Source§

impl VulkanDevice

Source

pub fn create_shader_from_spirv( &self, spirv_words: &[u32], ) -> Result<VulkanShader, HalError>

Source

pub fn create_compute_pipeline( &self, shader: &VulkanShader, buffer_count: u32, ) -> Result<VulkanComputePipeline, HalError>

Source

pub fn create_bindless_compute_pipeline( &self, shader: &VulkanShader, ) -> Result<Pipeline, HalError>

Source

pub fn destroy_raw_pipeline(&self, pipeline: Pipeline)

Source

pub fn create_graphics_pipeline( &self, shader: &VulkanShader, vs_entry: &str, fs_entry: &str, color_format: TextureFormat, ) -> Result<Pipeline, HalError>

Source

pub fn create_graphics_pipeline_with_depth( &self, shader: &VulkanShader, vs_entry: &str, fs_entry: &str, color_format: TextureFormat, depth_format: Option<TextureFormat>, depth_test: bool, depth_write: bool, ) -> Result<Pipeline, HalError>

Source

pub fn create_graphics_pipeline_with_depth_and_samples( &self, shader: &VulkanShader, vs_entry: &str, fs_entry: &str, color_format: TextureFormat, depth_format: Option<TextureFormat>, depth_test: bool, depth_write: bool, sample_count: u32, ) -> Result<Pipeline, HalError>

Source

pub fn create_graphics_pipeline_with_desc( &self, shader: &VulkanShader, desc: &GraphicsPipelineDesc<'_>, ) -> Result<Pipeline, HalError>

Source

pub fn destroy_shader(&self, shader: VulkanShader)

Source

pub fn destroy_compute_pipeline(&self, pipeline: VulkanComputePipeline)

Source§

impl VulkanDevice

Source

pub fn create_swapchain( &self, surface: SurfaceKHR, surface_loader: &Instance, width: u32, height: u32, old_swapchain: SwapchainKHR, preferred_format: Option<Format>, preferred_present_mode: Option<PresentModeKHR>, ) -> Result<VulkanSwapchain, HalError>

Source

pub fn destroy_swapchain(&self, swapchain: VulkanSwapchain)

Source

pub fn acquire_next_image( &self, swapchain: &VulkanSwapchain, semaphore: Semaphore, timeout_nanos: u64, ) -> Result<(u32, bool), HalError>

Source

pub fn queue_present( &self, swapchain: &VulkanSwapchain, image_index: u32, wait_semaphores: &[Semaphore], ) -> Result<bool, HalError>

Source

pub fn queue_present_raw( &self, swapchain: SwapchainKHR, image_index: u32, wait_semaphores: &[Semaphore], ) -> Result<bool, HalError>

Source

pub fn cmd_transition_to_present( &self, recorder: &VulkanCommandRecorder, texture: &VulkanTexture, )

Source

pub fn submit_for_surface( &self, recorder: VulkanCommandRecorder, wait_semaphore: Semaphore, signal_semaphore: Semaphore, fence: Option<Fence>, ) -> Result<(), HalError>

Source§

impl VulkanDevice

Source§

impl VulkanDevice

Trait Implementations§

Source§

impl Drop for VulkanDevice

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl HalDevice for VulkanDevice

Available on crate feature vulkan only.
Source§

type Buffer = VulkanBuffer

Source§

type Texture = VulkanTexture

Source§

type Sampler = VulkanSampler

Source§

type CommandRecorder = VulkanCommandRecorder

Source§

fn create_buffer(&self, desc: &BufferDesc<'_>) -> Result<Self::Buffer, HalError>

Source§

fn destroy_buffer(&self, buffer: Self::Buffer)

Source§

fn write_buffer( &self, buffer: &Self::Buffer, offset: u64, bytes: &[u8], ) -> Result<(), HalError>

Source§

fn read_buffer( &self, buffer: &Self::Buffer, offset: u64, dest: &mut [u8], ) -> Result<(), HalError>

Source§

fn create_texture( &self, desc: &TextureDesc<'_>, ) -> Result<Self::Texture, HalError>

Source§

fn destroy_texture(&self, texture: Self::Texture)

Source§

fn create_sampler( &self, desc: &SamplerDesc<'_>, ) -> Result<Self::Sampler, HalError>

Source§

fn destroy_sampler(&self, sampler: Self::Sampler)

Source§

fn create_command_recorder(&self) -> Result<Self::CommandRecorder, HalError>

Source§

fn register_bindless_buffer( &self, buffer: &Self::Buffer, ) -> Result<u32, HalError>

Source§

fn unregister_bindless_buffer(&self, slot: u32)

Source§

fn register_bindless_texture( &self, texture: &Self::Texture, ) -> Result<u32, HalError>

Source§

fn unregister_bindless_texture(&self, slot: u32)

Source§

fn register_bindless_storage_image( &self, texture: &Self::Texture, ) -> Result<u32, HalError>

Source§

fn unregister_bindless_storage_image(&self, slot: u32)

Source§

fn register_bindless_sampler( &self, sampler: &Self::Sampler, ) -> Result<u32, HalError>

Source§

fn unregister_bindless_sampler(&self, slot: u32)

Source§

impl Send for VulkanDevice

Source§

impl Sync for VulkanDevice

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.