|
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `instance` mod in crate `vulkano`."><meta name="keywords" content="rust, rustlang, rust-lang, instance"><title>vulkano::instance - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../vulkano/index.html'><div class='logo-container'><img src='https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png' alt='logo'></div></a><p class='location'>Module instance</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>vulkano</a></p><script>window.sidebarCurrent = {name: 'instance', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/vulkano/instance/mod.rs.html#10-137' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>vulkano</a>::<wbr><a class="mod" href=''>instance</a></span></h1><div class='docblock'><p>API entry point.</p>
|
|
|
<p>The first thing to do before you start using Vulkan is to create an <code>Instance</code> object.</p>
|
|
|
<p>For example:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">Instance</span>;
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">InstanceExtensions</span>;
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">instance</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">Instance</span>::<span class="ident">new</span>(<span class="prelude-val">None</span>, <span class="kw-2">&</span><span class="ident">InstanceExtensions</span>::<span class="ident">none</span>(), <span class="prelude-val">None</span>) {
|
|
|
<span class="prelude-val">Ok</span>(<span class="ident">i</span>) <span class="op">=</span><span class="op">></span> <span class="ident">i</span>,
|
|
|
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"Couldn't build instance: {:?}"</span>, <span class="ident">err</span>)
|
|
|
};</pre></div>
|
|
|
<p>Creating an instance initializes everything and allows you to enumerate physical devices,
|
|
|
ie. all the Vulkan implementations that are available on the system.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">PhysicalDevice</span>;
|
|
|
|
|
|
<span class="kw">for</span> <span class="ident">physical_device</span> <span class="kw">in</span> <span class="ident">PhysicalDevice</span>::<span class="ident">enumerate</span>(<span class="kw-2">&</span><span class="ident">instance</span>) {
|
|
|
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Available device: {}"</span>, <span class="ident">physical_device</span>.<span class="ident">name</span>());
|
|
|
}</pre></div>
|
|
|
<h1 id="extensions" class="section-header"><a href="#extensions">Extensions</a></h1>
|
|
|
<p>Notice the second parameter of <code>Instance::new()</code>. It is an <code>InstanceExtensions</code> struct that
|
|
|
contains a list of extensions that must be enabled on the newly-created instance. Trying to
|
|
|
enable an extension that is not supported by the system will result in an error.</p>
|
|
|
<p>Contrary to OpenGL, it is not possible to use the features of an extension if it was not
|
|
|
explicitly enabled.</p>
|
|
|
<p>Extensions are especially important to take into account if you want to render images on the
|
|
|
screen, as the only way to do so is to use the <code>VK_KHR_surface</code> extension. More information
|
|
|
about this in the <code>swapchain</code> module.</p>
|
|
|
<p>For example, here is how we create an instance with the <code>VK_KHR_surface</code> and
|
|
|
<code>VK_KHR_android_surface</code> extensions enabled, which will allow us to render images to an
|
|
|
Android screen. You can compile and run this code on any system, but it is highly unlikely to
|
|
|
succeed on anything else than an Android-running device.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">Instance</span>;
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">InstanceExtensions</span>;
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">extensions</span> <span class="op">=</span> <span class="ident">InstanceExtensions</span> {
|
|
|
<span class="ident">khr_surface</span>: <span class="bool-val">true</span>,
|
|
|
<span class="ident">khr_android_surface</span>: <span class="bool-val">true</span>,
|
|
|
.. <span class="ident">InstanceExtensions</span>::<span class="ident">none</span>()
|
|
|
};
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">instance</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">Instance</span>::<span class="ident">new</span>(<span class="prelude-val">None</span>, <span class="kw-2">&</span><span class="ident">extensions</span>, <span class="prelude-val">None</span>) {
|
|
|
<span class="prelude-val">Ok</span>(<span class="ident">i</span>) <span class="op">=</span><span class="op">></span> <span class="ident">i</span>,
|
|
|
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">></span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">"Couldn't build instance: {:?}"</span>, <span class="ident">err</span>)
|
|
|
};</pre></div>
|
|
|
<h1 id="application-info" class="section-header"><a href="#application-info">Application info</a></h1>
|
|
|
<p>When you create an instance, you have the possibility to pass an <code>ApplicationInfo</code> struct as
|
|
|
the first parameter. This struct contains various information about your application, most
|
|
|
notably its name and engine.</p>
|
|
|
<p>Passing such a structure allows for example the driver to let the user configure the driver's
|
|
|
behavior for your application alone through a control panel.</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::{<span class="ident">Instance</span>, <span class="ident">InstanceExtensions</span>};
|
|
|
|
|
|
<span class="comment">// Builds an `ApplicationInfo` by looking at the content of the `Cargo.toml` file at</span>
|
|
|
<span class="comment">// compile-time.</span>
|
|
|
<span class="kw">let</span> <span class="ident">app_infos</span> <span class="op">=</span> <span class="macro">app_info_from_cargo_toml</span><span class="macro">!</span>();
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">_instance</span> <span class="op">=</span> <span class="ident">Instance</span>::<span class="ident">new</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="ident">app_infos</span>), <span class="kw-2">&</span><span class="ident">InstanceExtensions</span>::<span class="ident">none</span>(), <span class="prelude-val">None</span>).<span class="ident">unwrap</span>();</pre></div>
|
|
|
<h1 id="enumerating-physical-devices-and-creating-a-device" class="section-header"><a href="#enumerating-physical-devices-and-creating-a-device">Enumerating physical devices and creating a device</a></h1>
|
|
|
<p>After you have created an instance, the next step is usually to enumerate the physical devices
|
|
|
that are available on the system with <code>PhysicalDevice::enumerate()</code> (see above).</p>
|
|
|
<p>When choosing which physical device to use, keep in mind that physical devices may or may not
|
|
|
be able to draw to a certain surface (ie. to a window or a monitor), or may even not be able
|
|
|
to draw at all. See the <code>swapchain</code> module for more information about surfaces.</p>
|
|
|
<p>Once you have chosen a physical device, you can create a <code>Device</code> object from it. See the
|
|
|
<code>device</code> module for more info.</p>
|
|
|
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
|
|
|
<table><tr><td><code>pub use self::loader::<a class="enum" href="../../vulkano/instance/loader/enum.LoadingError.html" title="enum vulkano::instance::loader::LoadingError">LoadingError</a>;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="mod" href="debug/index.html" title='vulkano::instance::debug mod'>debug</a></td><td class='docblock-short'><p>Debug callback called by intermediate layers or by the driver.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="mod" href="loader/index.html" title='vulkano::instance::loader mod'>loader</a></td><td class='docblock-short'><p>Vulkan implementation loading system.</p>
|
|
|
</td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="struct" href="struct.ApplicationInfo.html" title='vulkano::instance::ApplicationInfo struct'>ApplicationInfo</a></td><td class='docblock-short'><p>Information that can be given to the Vulkan driver so that it can identify your application.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Instance.html" title='vulkano::instance::Instance struct'>Instance</a></td><td class='docblock-short'><p>An instance of a Vulkan context. This is the main object that should be created by an
|
|
|
application before everything else.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.InstanceExtensions.html" title='vulkano::instance::InstanceExtensions struct'>InstanceExtensions</a></td><td class='docblock-short'><p>List of extensions that are enabled or available.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.LayerProperties.html" title='vulkano::instance::LayerProperties struct'>LayerProperties</a></td><td class='docblock-short'><p>Properties of a layer.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.LayersIterator.html" title='vulkano::instance::LayersIterator struct'>LayersIterator</a></td><td class='docblock-short'><p>Iterator that produces the list of layers that are available.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Limits.html" title='vulkano::instance::Limits struct'>Limits</a></td><td class='docblock-short'><p>Limits of a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.MemoryHeap.html" title='vulkano::instance::MemoryHeap struct'>MemoryHeap</a></td><td class='docblock-short'><p>Represents a memory heap in a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.MemoryHeapsIter.html" title='vulkano::instance::MemoryHeapsIter struct'>MemoryHeapsIter</a></td><td class='docblock-short'><p>Iterator for all the memory heaps available on a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.MemoryType.html" title='vulkano::instance::MemoryType struct'>MemoryType</a></td><td class='docblock-short'><p>Represents a memory type in a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.MemoryTypesIter.html" title='vulkano::instance::MemoryTypesIter struct'>MemoryTypesIter</a></td><td class='docblock-short'><p>Iterator for all the memory types available on a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.PhysicalDevice.html" title='vulkano::instance::PhysicalDevice struct'>PhysicalDevice</a></td><td class='docblock-short'><p>Represents one of the available devices on this machine.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.PhysicalDevicesIter.html" title='vulkano::instance::PhysicalDevicesIter struct'>PhysicalDevicesIter</a></td><td class='docblock-short'><p>Iterator for all the physical devices available on hardware.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.QueueFamiliesIter.html" title='vulkano::instance::QueueFamiliesIter struct'>QueueFamiliesIter</a></td><td class='docblock-short'><p>Iterator for all the queue families available on a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.QueueFamily.html" title='vulkano::instance::QueueFamily struct'>QueueFamily</a></td><td class='docblock-short'><p>Represents a queue family in a physical device.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.RawInstanceExtensions.html" title='vulkano::instance::RawInstanceExtensions struct'>RawInstanceExtensions</a></td><td class='docblock-short'><p>Set of extensions, not restricted to those vulkano knows about.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Version.html" title='vulkano::instance::Version struct'>Version</a></td><td class='docblock-short'><p>Represents an API version of Vulkan.</p>
|
|
|
</td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="enum" href="enum.InstanceCreationError.html" title='vulkano::instance::InstanceCreationError enum'>InstanceCreationError</a></td><td class='docblock-short'><p>Error that can happen when creating an instance.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="enum" href="enum.LayersListError.html" title='vulkano::instance::LayersListError enum'>LayersListError</a></td><td class='docblock-short'><p>Error that can happen when loading the list of layers.</p>
|
|
|
</td></tr><tr class='module-item'><td><a class="enum" href="enum.PhysicalDeviceType.html" title='vulkano::instance::PhysicalDeviceType enum'>PhysicalDeviceType</a></td><td class='docblock-short'><p>Type of a physical device.</p>
|
|
|
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="fn" href="fn.layers_list.html" title='vulkano::instance::layers_list fn'>layers_list</a></td><td class='docblock-short'><p>Queries the list of layers that are available when creating an instance.</p>
|
|
|
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "vulkano";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |