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/command_buffer/index.html

73 lines
16 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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 `command_buffer` mod in crate `vulkano`."><meta name="keywords" content="rust, rustlang, rust-lang, command_buffer"><title>vulkano::command_buffer - 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 command_buffer</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><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: 'command_buffer', 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/command_buffer/mod.rs.html#10-174' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>vulkano</a>::<wbr><a class="mod" href=''>command_buffer</a></span></h1><div class='docblock'><p>Commands that the GPU will execute (includes draw commands).</p>
<p>With Vulkan, before the GPU can do anything you must create a <code>CommandBuffer</code>. A command buffer
is a list of commands that will executed by the GPU. Once a command buffer is created, you can
execute it. A command buffer must always be created even for the most simple tasks.</p>
<h1 id="primary-and-secondary-command-buffers" class="section-header"><a href="#primary-and-secondary-command-buffers">Primary and secondary command buffers.</a></h1>
<p>There are three types of command buffers:</p>
<ul>
<li><strong>Primary command buffers</strong>. They can contain any command. They are the only type of command
buffer that can be submitted to a queue.</li>
<li><strong>Secondary &quot;graphics&quot; command buffers</strong>. They can only contain draw and clear commands.
They can only be called from a primary command buffer when inside a render pass.</li>
<li><strong>Secondary &quot;compute&quot; command buffers</strong>. They can only contain non-render-pass-related
commands (ie. everything but drawing, clearing, etc.) and cannot enter a render pass. They
can only be called from a primary command buffer outside of a render pass.</li>
</ul>
<p>Using secondary command buffers leads to slightly lower performance on the GPU, but they have
two advantages on the CPU side:</p>
<ul>
<li>Building a command buffer is a single-threaded operation, but by using secondary command
buffers you can build multiple secondary command buffers in multiple threads simultaneously.</li>
<li>Secondary command buffers can be kept alive between frames. When you always repeat the same
operations, it might be a good idea to build a secondary command buffer once at
initialization and then reuse it afterwards.</li>
</ul>
<h1 id="the-autocommandbufferbuilder" class="section-header"><a href="#the-autocommandbufferbuilder">The <code>AutoCommandBufferBuilder</code></a></h1>
<p>The most basic (and recommended) way to create a command buffer is to create a
<a href="struct.AutoCommandBufferBuilder.html"><code>AutoCommandBufferBuilder</code></a>. Then use the
<a href="trait.CommandBufferBuilder.html"><code>CommandBufferBuilder</code> trait</a> to add commands to it.
When you are done adding commands, use
<a href="trait.CommandBufferBuild.html">the <code>CommandBufferBuild</code> trait</a> to obtain a
<code>AutoCommandBuffer</code>.</p>
<p>Once built, use <a href="trait.CommandBuffer.html">the <code>CommandBuffer</code> trait</a> to submit the command
buffer. Submitting a command buffer returns an object that implements the <code>GpuFuture</code> trait and
that represents the moment when the execution will end on the GPU.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">command_buffer</span>::<span class="ident">AutoCommandBufferBuilder</span>;
<span class="kw">use</span> <span class="ident">vulkano</span>::<span class="ident">command_buffer</span>::<span class="ident">CommandBuffer</span>;
<span class="kw">let</span> <span class="ident">cb</span> <span class="op">=</span> <span class="ident">AutoCommandBufferBuilder</span>::<span class="ident">new</span>(<span class="ident">device</span>.<span class="ident">clone</span>(), <span class="ident">queue</span>.<span class="ident">family</span>()).<span class="ident">unwrap</span>()
<span class="comment">// TODO: add an actual command to this example</span>
.<span class="ident">build</span>().<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">_future</span> <span class="op">=</span> <span class="ident">cb</span>.<span class="ident">execute</span>(<span class="ident">queue</span>.<span class="ident">clone</span>());</pre></div>
<h1 id="internal-architecture-of-vulkano" class="section-header"><a href="#internal-architecture-of-vulkano">Internal architecture of vulkano</a></h1>
<p>The <code>commands_raw</code> and <code>commands_extra</code> modules contain structs that correspond to various
commands that can be added to command buffer builders. A command can be added to a command
buffer builder by using the <code>AddCommand&lt;C&gt;</code> trait, where <code>C</code> is the command struct.</p>
<p>The <code>AutoCommandBufferBuilder</code> internally uses a <code>UnsafeCommandBufferBuilder</code> wrapped around
multiple layers. See the <code>cb</code> module for more information.</p>
<p>Command pools are automatically handled by default, but vulkano also allows you to use
alternative command pool implementations and use them. See the <code>pool</code> module for more
information.</p>
</div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr class='module-item'><td><a class="mod" href="pool/index.html" title='vulkano::command_buffer::pool mod'>pool</a></td><td class='docblock-short'><p>In the Vulkan API, command buffers must be allocated from <em>command pools</em>.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="submit/index.html" title='vulkano::command_buffer::submit mod'>submit</a></td><td class='docblock-short'><p>Low-level builders that allow submitting an operation to a queue.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="synced/index.html" title='vulkano::command_buffer::synced mod'>synced</a></td><td class='docblock-short'><p>Contains <code>SyncCommandBufferBuilder</code> and <code>SyncCommandBuffer</code>.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="sys/index.html" title='vulkano::command_buffer::sys mod'>sys</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="mod" href="validity/index.html" title='vulkano::command_buffer::validity mod'>validity</a></td><td class='docblock-short'><p>Functions that check the validity of commands.</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.AutoCommandBuffer.html" title='vulkano::command_buffer::AutoCommandBuffer struct'>AutoCommandBuffer</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.AutoCommandBufferBuilder.html" title='vulkano::command_buffer::AutoCommandBufferBuilder struct'>AutoCommandBufferBuilder</a></td><td class='docblock-short'><p>Note that command buffers allocated from the default command pool (<code>Arc&lt;StandardCommandPool&gt;</code>)
don't implement the <code>Send</code> and <code>Sync</code> traits. If you use this pool, then the
<code>AutoCommandBufferBuilder</code> will not implement <code>Send</code> and <code>Sync</code> either. Once a command buffer
is built, however, it <em>does</em> implement <code>Send</code> and <code>Sync</code>.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.CommandBufferExecFuture.html" title='vulkano::command_buffer::CommandBufferExecFuture struct'>CommandBufferExecFuture</a></td><td class='docblock-short'><p>Represents a command buffer being executed by the GPU and the moment when the execution
finishes.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.DispatchIndirectCommand.html" title='vulkano::command_buffer::DispatchIndirectCommand struct'>DispatchIndirectCommand</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.DrawIndexedIndirectCommand.html" title='vulkano::command_buffer::DrawIndexedIndirectCommand struct'>DrawIndexedIndirectCommand</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.DrawIndirectCommand.html" title='vulkano::command_buffer::DrawIndirectCommand struct'>DrawIndirectCommand</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="struct" href="struct.DynamicState.html" title='vulkano::command_buffer::DynamicState struct'>DynamicState</a></td><td class='docblock-short'><p>The dynamic state to use for a draw command.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.StateCacher.html" title='vulkano::command_buffer::StateCacher struct'>StateCacher</a></td><td class='docblock-short'><p>Keep track of the state of a command buffer builder, so that you don't need to bind objects
that were already bound.</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.AutoCommandBufferBuilderContextError.html" title='vulkano::command_buffer::AutoCommandBufferBuilderContextError enum'>AutoCommandBufferBuilderContextError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.BeginRenderPassError.html" title='vulkano::command_buffer::BeginRenderPassError enum'>BeginRenderPassError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.BlitImageError.html" title='vulkano::command_buffer::BlitImageError enum'>BlitImageError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.BuildError.html" title='vulkano::command_buffer::BuildError enum'>BuildError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.ClearColorImageError.html" title='vulkano::command_buffer::ClearColorImageError enum'>ClearColorImageError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.CommandBufferExecError.html" title='vulkano::command_buffer::CommandBufferExecError enum'>CommandBufferExecError</a></td><td class='docblock-short'><p>Error that can happen when attempting to execute a command buffer.</p>
</td></tr><tr class='module-item'><td><a class="enum" href="enum.CopyBufferError.html" title='vulkano::command_buffer::CopyBufferError enum'>CopyBufferError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.CopyBufferImageError.html" title='vulkano::command_buffer::CopyBufferImageError enum'>CopyBufferImageError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.CopyImageError.html" title='vulkano::command_buffer::CopyImageError enum'>CopyImageError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.DispatchError.html" title='vulkano::command_buffer::DispatchError enum'>DispatchError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.DrawError.html" title='vulkano::command_buffer::DrawError enum'>DrawError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.DrawIndexedError.html" title='vulkano::command_buffer::DrawIndexedError enum'>DrawIndexedError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.DrawIndexedIndirectError.html" title='vulkano::command_buffer::DrawIndexedIndirectError enum'>DrawIndexedIndirectError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.DrawIndirectError.html" title='vulkano::command_buffer::DrawIndirectError enum'>DrawIndirectError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.ExecuteCommandsError.html" title='vulkano::command_buffer::ExecuteCommandsError enum'>ExecuteCommandsError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.FillBufferError.html" title='vulkano::command_buffer::FillBufferError enum'>FillBufferError</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="enum" href="enum.StateCacherOutcome.html" title='vulkano::command_buffer::StateCacherOutcome enum'>StateCacherOutcome</a></td><td class='docblock-short'><p>Outcome of an operation.</p>
</td></tr><tr class='module-item'><td><a class="enum" href="enum.UpdateBufferError.html" title='vulkano::command_buffer::UpdateBufferError enum'>UpdateBufferError</a></td><td class='docblock-short'></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.CommandBuffer.html" title='vulkano::command_buffer::CommandBuffer trait'>CommandBuffer</a></td><td class='docblock-short'></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>