pub struct VulkanContext {
pub pipeline_cache: Arc<VulkanPipelineCache>,
pub desc_pool: Arc<DescriptorPool>,
pub surface: Arc<VulkanSurface>,
pub device: Arc<VulkanDevice>,
pub cpu_renderer_threads: usize,
/* private fields */
}Expand description
The Vulkan context has device, surface, swapchain, and command pools
§Important
The VulkanContext would not going to own the surface. For example, if you are using GLFW, the surface is the GLFW window.
If your surface is dropped earlier than then context, the context could not be dropped safely.
You must make sure the context is dropped before the surface is dropped.
Fields§
§pipeline_cache: Arc<VulkanPipelineCache>The pipeline cache here for a global usage
desc_pool: Arc<DescriptorPool>The descriptor pool here is normally for a global usage
surface: Arc<VulkanSurface>The surface in use
device: Arc<VulkanDevice>The device in use
cpu_renderer_threads: usizeHow many scenes could be rendered concurrently?
Implementations§
Source§impl VulkanContext
impl VulkanContext
Sourcepub fn new(
create_info: VulkanContextCreateInfo<'_, '_>,
) -> Result<Self, VulkanError>
pub fn new( create_info: VulkanContextCreateInfo<'_, '_>, ) -> Result<Self, VulkanError>
Create a new VulkanContext
Sourcepub fn get_swapchain(&self) -> Arc<RwLock<VulkanSwapchain>>
pub fn get_swapchain(&self) -> Arc<RwLock<VulkanSwapchain>>
Get the swapchain
Sourcepub fn get_swapchain_extent(&self) -> VkExtent2D
pub fn get_swapchain_extent(&self) -> VkExtent2D
Get the current swapchain extent(the framebuffer size)
Sourcepub fn get_surface_size_(
vkcore: &VkCore,
device: &VulkanDevice,
surface: &VulkanSurface,
) -> Result<VkExtent2D, VulkanError>
pub fn get_surface_size_( vkcore: &VkCore, device: &VulkanDevice, surface: &VulkanSurface, ) -> Result<VkExtent2D, VulkanError>
Get the surface size, a.k.a. the frame buffer size
Sourcepub fn get_surface_size(&self) -> Result<VkExtent2D, VulkanError>
pub fn get_surface_size(&self) -> Result<VkExtent2D, VulkanError>
Get the surface size, a.k.a. the frame buffer size
Sourcepub fn get_supported_number_of_cpu_renderer_threads(&self) -> usize
pub fn get_supported_number_of_cpu_renderer_threads(&self) -> usize
Get the number of CPU renderer threads that supports
Sourcepub fn create_pipeline_builder(
&self,
mesh: Arc<GenericMeshWithMaterial>,
shaders: Arc<DrawShaders>,
desc_props: Arc<DescriptorProps>,
) -> Result<PipelineBuilder, VulkanError>
pub fn create_pipeline_builder( &self, mesh: Arc<GenericMeshWithMaterial>, shaders: Arc<DrawShaders>, desc_props: Arc<DescriptorProps>, ) -> Result<PipelineBuilder, VulkanError>
Create a pipeline builder
Sourcepub fn recreate_swapchain(
&self,
width: u32,
height: u32,
present_interval: PresentInterval,
is_vr: bool,
) -> Result<(), VulkanError>
pub fn recreate_swapchain( &self, width: u32, height: u32, present_interval: PresentInterval, is_vr: bool, ) -> Result<(), VulkanError>
Recreate the swapchain when users toggle the switch of vsync or the framebuffer size changes
Sourcepub fn on_resize(&self) -> Result<bool, VulkanError>
pub fn on_resize(&self) -> Result<bool, VulkanError>
When the windows was resized, call this method to recreate the swapchain to fit the new size
Sourcepub fn begin_scene<'a>(
&'a self,
pool_index: usize,
rt_props: Option<Arc<RenderTargetProps>>,
) -> Result<VulkanContextScene<'a>, VulkanError>
pub fn begin_scene<'a>( &'a self, pool_index: usize, rt_props: Option<Arc<RenderTargetProps>>, ) -> Result<VulkanContextScene<'a>, VulkanError>
Acquire a command buffer and a queue, start recording the commands
- You could call this function in different threads, in order to achieve concurrent frame rendering
Trait Implementations§
Source§impl Debug for VulkanContext
impl Debug for VulkanContext
Source§impl Drop for VulkanContext
impl Drop for VulkanContext
impl Send for VulkanContext
impl Sync for VulkanContext
Auto Trait Implementations§
impl Freeze for VulkanContext
impl RefUnwindSafe for VulkanContext
impl Unpin for VulkanContext
impl UnwindSafe for VulkanContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.