Struct vulkano::instance::Instance[][src]

pub struct Instance { /* fields omitted */ }

An instance of a Vulkan context. This is the main object that should be created by an application before everything else.

See the documentation of the instance module for an introduction about Vulkan instances.

Extensions and application infos

Please check the documentation of the instance module.

Layers

When creating an Instance, you have the possibility to pass a list of layers that will be activated on the newly-created instance. The list of available layers can be retrieved by calling the layers_list function.

A layer is a component that will hook and potentially modify the Vulkan function calls. For example, activating a layer could add a frames-per-second counter on the screen, or it could send information to a debugger that will debug your application.

Note: From an application’s point of view, layers “just exist”. In practice, on Windows and Linux layers can be installed by third party installers or by package managers and can also be activated by setting the value of the VK_INSTANCE_LAYERS environment variable before starting the program. See the documentation of the official Vulkan loader for these platforms.

Note: In practice, the most common use of layers right now is for debugging purposes. To do so, you are encouraged to set the VK_INSTANCE_LAYERS environment variable on Windows or Linux instead of modifying the source code of your program. For example: export VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_api_dump on Linux if you installed the Vulkan SDK will print the list of raw Vulkan function calls.

Example

// For the sake of the example, we activate all the layers that
// contain the word "foo" in their description.
let layers: Vec<_> = instance::layers_list()?
    .filter(|l| l.description().contains("foo"))
    .collect();

let layer_names = layers.iter()
    .map(|l| l.name());

let instance = Instance::new(None, &InstanceExtensions::none(), layer_names)?;

Implementations

impl Instance[src]

pub fn new<'a, L, Ext>(
    app_infos: Option<&ApplicationInfo<'_>>,
    extensions: Ext,
    layers: L
) -> Result<Arc<Instance>, InstanceCreationError> where
    L: IntoIterator<Item = &'a str>,
    Ext: Into<RawInstanceExtensions>, 
[src]

Initializes a new instance of Vulkan.

See the documentation of Instance or of the instance module for more details.

Example

use vulkano::instance::Instance;
use vulkano::instance::InstanceExtensions;

let instance = match Instance::new(None, &InstanceExtensions::none(), None) {
    Ok(i) => i,
    Err(err) => panic!("Couldn't build instance: {:?}", err)
};

Panic

  • Panics if the version numbers passed in ApplicationInfo are too large can’t be converted into a Vulkan version number.
  • Panics if the application name or engine name contain a null character.

pub fn with_loader<'a, L, Ext>(
    loader: FunctionPointers<Box<dyn Loader + Send + Sync>>,
    app_infos: Option<&ApplicationInfo<'_>>,
    extensions: Ext,
    layers: L
) -> Result<Arc<Instance>, InstanceCreationError> where
    L: IntoIterator<Item = &'a str>,
    Ext: Into<RawInstanceExtensions>, 
[src]

Same as new, but allows specifying a loader where to load Vulkan from.

pub fn pointers(&self) -> &InstancePointers[src]

Grants access to the Vulkan functions of the instance.

pub fn loaded_extensions(&self) -> InstanceExtensions[src]

Returns the list of extensions that have been loaded.

This list is equal to what was passed to Instance::new().

Example

use vulkano::instance::Instance;
use vulkano::instance::InstanceExtensions;

let extensions = InstanceExtensions::supported_by_core().unwrap();
let instance = Instance::new(None, &extensions, None).unwrap();
assert_eq!(instance.loaded_extensions(), extensions);

pub fn raw_loaded_extensions(&self) -> &RawInstanceExtensions[src]

Trait Implementations

impl Debug for Instance[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Drop for Instance[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl Hash for Instance[src]

fn hash<H: Hasher>(&self, state: &mut H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl PartialEq<Instance> for Instance[src]

fn eq(&self, other: &Self) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl VulkanObject for Instance[src]

type Object = Instance

The type of the object.

const TYPE: ObjectType[src]

The ObjectType of the internal Vulkan handle.

fn internal_object(&self) -> Instance[src]

Returns a reference to the object.

impl Eq for Instance[src]

impl RefUnwindSafe for Instance[src]

impl UnwindSafe for Instance[src]

Auto Trait Implementations

impl Send for Instance

impl Sync for Instance

impl Unpin for Instance

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> Content for T[src]

pub fn ref_from_ptr(*mut c_void, usize) -> Option<*mut T>[src]

Builds a pointer to this type from a raw pointer.

pub fn is_size_suitable(usize) -> bool[src]

Returns true if the size is suitable to store a type like this.

pub fn indiv_size() -> usize[src]

Returns the size of an individual element.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.