You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trac3r-rust/doc/vulkano/device/index.html

83 lines
13 KiB

5 years ago
<!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 `device` mod in crate `vulkano`."><meta name="keywords" content="rust, rustlang, rust-lang, device"><title>vulkano::device - 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">&#9776;</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 device</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div><p class='location'><a href='../index.html'>vulkano</a></p><script>window.sidebarCurrent = {name: 'device', 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'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/vulkano/device/mod.rs.html#10-852' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>vulkano</a>::<wbr><a class="mod" href=''>device</a></span></h1><div class='docblock'><p>Communication channel with a physical device.</p>
<p>The <code>Device</code> is one of the most important objects of Vulkan. Creating a <code>Device</code> is required
before you can create buffers, textures, shaders, etc.</p>
<p>Basic 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">device</span>::<span class="ident">Device</span>;
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">device</span>::<span class="ident">DeviceExtensions</span>;
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">device</span>::<span class="ident">Features</span>;
<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">use</span> <span class="ident">vulkano</span>::<span class="ident">instance</span>::<span class="ident">PhysicalDevice</span>;
<span class="comment">// Creating the instance. See the documentation of the `instance` module.</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">&amp;</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">&gt;</span> <span class="ident">i</span>,
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Couldn&#39;t build instance: {:?}&quot;</span>, <span class="ident">err</span>)
};
<span class="comment">// We just choose the first physical device. In a real application you would choose depending</span>
<span class="comment">// on the capabilities of the physical device and the user&#39;s preferences.</span>
<span class="kw">let</span> <span class="ident">physical_device</span> <span class="op">=</span> <span class="ident">PhysicalDevice</span>::<span class="ident">enumerate</span>(<span class="kw-2">&amp;</span><span class="ident">instance</span>).<span class="ident">next</span>().<span class="ident">expect</span>(<span class="string">&quot;No physical device&quot;</span>);
<span class="comment">// Here is the device-creating code.</span>
<span class="kw">let</span> <span class="ident">device</span> <span class="op">=</span> {
<span class="kw">let</span> <span class="ident">queue_family</span> <span class="op">=</span> <span class="ident">physical_device</span>.<span class="ident">queue_families</span>().<span class="ident">next</span>().<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">features</span> <span class="op">=</span> <span class="ident">Features</span>::<span class="ident">none</span>();
<span class="kw">let</span> <span class="ident">ext</span> <span class="op">=</span> <span class="ident">DeviceExtensions</span>::<span class="ident">none</span>();
<span class="kw">match</span> <span class="ident">Device</span>::<span class="ident">new</span>(<span class="ident">physical_device</span>, <span class="kw-2">&amp;</span><span class="ident">features</span>, <span class="kw-2">&amp;</span><span class="ident">ext</span>, <span class="prelude-val">Some</span>((<span class="ident">queue_family</span>, <span class="number">1.0</span>))) {
<span class="prelude-val">Ok</span>(<span class="ident">d</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">d</span>,
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Couldn&#39;t build device: {:?}&quot;</span>, <span class="ident">err</span>)
}
};</pre></div>
<h1 id="features-and-extensions" class="section-header"><a href="#features-and-extensions">Features and extensions</a></h1>
<p>Two of the parameters that you pass to <code>Device::new</code> are the list of the features and the list
of extensions to enable on the newly-created device.</p>
<blockquote>
<p><strong>Note</strong>: Device extensions are the same as instance extensions, except for the device.
Features are similar to extensions, except that they are part of the core Vulkan
specifications instead of being separate documents.</p>
</blockquote>
<p>Some Vulkan capabilities, such as swapchains (that allow you to render on the screen) or
geometry shaders for example, require that you enable a certain feature or extension when you
create the device. Contrary to OpenGL, you can't use the functions provided by a feature or an
extension if you didn't explicitly enable it when creating the device.</p>
<p>Not all physical devices support all possible features and extensions. For example mobile
devices tend to not support geometry shaders, because their hardware is not capable of it. You
can query what is supported with respectively <code>PhysicalDevice::supported_features</code> and
<code>DeviceExtensions::supported_by_device</code>.</p>
<blockquote>
<p><strong>Note</strong>: The fact that you need to manually enable features at initialization also means
that you don't need to worry about a capability not being supported later on in your code.</p>
</blockquote>
<h1 id="queues" class="section-header"><a href="#queues">Queues</a></h1>
<p>Each physical device proposes one or more <em>queues</em> that are divided in <em>queue families</em>. A
queue is a thread of execution to which you can submit commands that the GPU will execute.</p>
<blockquote>
<p><strong>Note</strong>: You can think of a queue like a CPU thread. Each queue executes its commands one
after the other, and queues run concurrently. A GPU behaves similarly to the hyper-threading
technology, in the sense that queues will only run partially in parallel.</p>
</blockquote>
<p>The Vulkan API requires that you specify the list of queues that you are going to use at the
same time as when you create the device. This is done in vulkano by passing an iterator where
each element is a tuple containing a queue family and a number between 0.0 and 1.0 indicating
the priority of execution of the queue relative to the others.</p>
<p>TODO: write better doc here</p>
<p>The <code>Device::new</code> function returns the newly-created device, but also the list of queues.</p>
<h1 id="extended-example" class="section-header"><a href="#extended-example">Extended example</a></h1>
<p>TODO: write</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.Device.html" title='vulkano::device::Device struct'>Device</a></td><td class='docblock-short'><p>Represents a Vulkan context.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.DeviceExtensions.html" title='vulkano::device::DeviceExtensions struct'>DeviceExtensions</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.Features.html" title='vulkano::device::Features struct'>Features</a></td><td class='docblock-short'><p>Represents all the features that are available on a physical device or enabled on
a logical device.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Queue.html" title='vulkano::device::Queue struct'>Queue</a></td><td class='docblock-short'><p>Represents a queue where commands can be submitted.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.QueuesIter.html" title='vulkano::device::QueuesIter struct'>QueuesIter</a></td><td class='docblock-short'><p>Iterator that returns the queues produced when creating a device.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.RawDeviceExtensions.html" title='vulkano::device::RawDeviceExtensions struct'>RawDeviceExtensions</a></td><td class='docblock-short'><p>Set of extensions, not restricted to those vulkano knows about.</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.DeviceCreationError.html" title='vulkano::device::DeviceCreationError enum'>DeviceCreationError</a></td><td class='docblock-short'><p>Error that can be returned when creating a device.</p>
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table><tr class='module-item'><td><a class="trait" href="trait.DeviceOwned.html" title='vulkano::device::DeviceOwned trait'>DeviceOwned</a></td><td class='docblock-short'><p>Implemented on objects that belong to a Vulkan device.</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>&#9166;</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>