mirror of
https://github.com/sotrh/learn-wgpu.git
synced 2024-11-18 03:25:33 +00:00
30 lines
26 KiB
HTML
30 lines
26 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-US">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>News | Learn Wgpu</title>
|
|
<meta name="description" content="">
|
|
<meta name="generator" content="VuePress 1.4.0">
|
|
|
|
<meta property="article:modified_time" content="2021-07-10T08:04:39.000Z"><meta property="og:site_name" content="Learn Wgpu"><meta property="og:title" content="News"><meta property="og:type" content="website"><meta property="og:url" content="/news/"><meta name="twitter:title" content="News"><meta name="twitter:url" content="/news/"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:label1" content="Written by"><meta name="twitter:data2" content="Benjamin R Hansen"><meta name="twitter:creator" content="https://twitter.com/sotrh760">
|
|
<link rel="preload" href="/learn-wgpu/assets/css/0.styles.e2608c6d.css" as="style"><link rel="preload" href="/learn-wgpu/assets/js/app.3c04ae58.js" as="script"><link rel="preload" href="/learn-wgpu/assets/js/2.da3fd46f.js" as="script"><link rel="preload" href="/learn-wgpu/assets/js/17.d3375cb5.js" as="script"><link rel="preload" href="/learn-wgpu/assets/js/9.ecb6e79c.js" as="script"><link rel="prefetch" href="/learn-wgpu/assets/js/10.de8cadfb.js"><link rel="prefetch" href="/learn-wgpu/assets/js/11.fdda3025.js"><link rel="prefetch" href="/learn-wgpu/assets/js/12.4285c323.js"><link rel="prefetch" href="/learn-wgpu/assets/js/13.2da6599a.js"><link rel="prefetch" href="/learn-wgpu/assets/js/14.3139647c.js"><link rel="prefetch" href="/learn-wgpu/assets/js/15.4800fa06.js"><link rel="prefetch" href="/learn-wgpu/assets/js/16.8cb7b62f.js"><link rel="prefetch" href="/learn-wgpu/assets/js/18.83accaf9.js"><link rel="prefetch" href="/learn-wgpu/assets/js/19.bee0cfc3.js"><link rel="prefetch" href="/learn-wgpu/assets/js/20.17c44988.js"><link rel="prefetch" href="/learn-wgpu/assets/js/21.fed3f353.js"><link rel="prefetch" href="/learn-wgpu/assets/js/22.2132e362.js"><link rel="prefetch" href="/learn-wgpu/assets/js/23.1a88f225.js"><link rel="prefetch" href="/learn-wgpu/assets/js/24.a60d2f4f.js"><link rel="prefetch" href="/learn-wgpu/assets/js/25.5c4d11d0.js"><link rel="prefetch" href="/learn-wgpu/assets/js/26.745a2634.js"><link rel="prefetch" href="/learn-wgpu/assets/js/27.04f788d9.js"><link rel="prefetch" href="/learn-wgpu/assets/js/28.a3ac06e2.js"><link rel="prefetch" href="/learn-wgpu/assets/js/29.281013fa.js"><link rel="prefetch" href="/learn-wgpu/assets/js/3.ee149516.js"><link rel="prefetch" href="/learn-wgpu/assets/js/30.dc887be9.js"><link rel="prefetch" href="/learn-wgpu/assets/js/4.302cd27d.js"><link rel="prefetch" href="/learn-wgpu/assets/js/5.5061acf7.js"><link rel="prefetch" href="/learn-wgpu/assets/js/6.13a65f6c.js"><link rel="prefetch" href="/learn-wgpu/assets/js/7.88810c81.js"><link rel="prefetch" href="/learn-wgpu/assets/js/8.a23f98ec.js">
|
|
<link rel="stylesheet" href="/learn-wgpu/assets/css/0.styles.e2608c6d.css">
|
|
</head>
|
|
<body>
|
|
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="inner"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/learn-wgpu/" class="home-link router-link-active"><!----> <span class="site-name">Learn Wgpu</span></a> <div class="links"><!----> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div></div></div></header> <div class="sidebar-mask"></div> <div class="docs-layout"><aside class="sidebar"><!----> <ul class="sidebar-links"><li><a href="/learn-wgpu/" class="sidebar-link">Introduction</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Beginner</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/learn-wgpu/beginner/tutorial1-window/" class="sidebar-link">Dependencies and the window</a></li><li><a href="/learn-wgpu/beginner/tutorial2-swapchain/" class="sidebar-link">The Swapchain</a></li><li><a href="/learn-wgpu/beginner/tutorial3-pipeline/" class="sidebar-link">The Pipeline</a></li><li><a href="/learn-wgpu/beginner/tutorial4-buffer/" class="sidebar-link">Buffers and Indices</a></li><li><a href="/learn-wgpu/beginner/tutorial5-textures/" class="sidebar-link">Textures and bind groups</a></li><li><a href="/learn-wgpu/beginner/tutorial6-uniforms/" class="sidebar-link">Uniform buffers and a 3d camera</a></li><li><a href="/learn-wgpu/beginner/tutorial7-instancing/" class="sidebar-link">Instancing</a></li><li><a href="/learn-wgpu/beginner/tutorial8-depth/" class="sidebar-link">The Depth Buffer</a></li><li><a href="/learn-wgpu/beginner/tutorial9-models/" class="sidebar-link">Model Loading</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Intermediate</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/learn-wgpu/intermediate/tutorial10-lighting/" class="sidebar-link">Working with Lights</a></li><li><a href="/learn-wgpu/intermediate/tutorial11-normals/" class="sidebar-link">Normal Mapping</a></li><li><a href="/learn-wgpu/intermediate/tutorial12-camera/" class="sidebar-link">A Better Camera</a></li><li><a href="/learn-wgpu/intermediate/tutorial13-threading/" class="sidebar-link">Multi-threading with Wgpu and Rayon</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Showcase</span> <span class="arrow right"></span></p> <!----></section></li><li><a href="/learn-wgpu/news/" class="active sidebar-link">News</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#pong-and-imgui-demos-are-fixed" class="sidebar-link">Pong and imgui demos are fixed!</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#_0-8-and-wgsl" class="sidebar-link">0.8 and WGSL</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#_0-7" class="sidebar-link">0.7</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#november-2020-cleanup-content-freeze-and-patreon" class="sidebar-link">November 2020 Cleanup, Content Freeze, and Patreon</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#_0-6" class="sidebar-link">0.6</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#added-pong-showcase" class="sidebar-link">Added Pong Showcase</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#normal-mapping" class="sidebar-link">Normal mapping</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#_0-5" class="sidebar-link">0.5!</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#reworked-lighting-tutorial" class="sidebar-link">Reworked lighting tutorial</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#added-gif-showcase" class="sidebar-link">Added GIF showcase</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#updated-texture-tutorials" class="sidebar-link">Updated texture tutorials</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#fixed-panics-do-to-not-specifying-the-correct-usage" class="sidebar-link">Fixed panics do to not specifying the correct usage</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#updating-winit-from-0-20-0-alpha5-to-0-20" class="sidebar-link">Updating Winit from 0.20.0-alpha5 to 0.20</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#changed-tutorial-examples-to-use-a-src-directory" class="sidebar-link">Changed tutorial examples to use a src directory</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#updating-to-0-4-from-0-3" class="sidebar-link">Updating to 0.4 from 0.3</a></li><li class="sidebar-sub-header"><a href="/learn-wgpu/news/#new-recent-articles" class="sidebar-link">New/Recent Articles</a></li></ul></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="news"><a href="#news" class="header-anchor">#</a> News</h1> <h2 id="pong-and-imgui-demos-are-fixed"><a href="#pong-and-imgui-demos-are-fixed" class="header-anchor">#</a> Pong and imgui demos are fixed!</h2> <p>The <code>imgui_wgpu</code> and <code>wgpu_glyph</code> crates have been updated to <code>wgpu</code> 0.8 so I was able to fixed the demos! They both still use GLSL, and I don't think I'll be changing that for now. I may switch them over to <code>naga</code> at some point.</p> <h2 id="_0-8-and-wgsl"><a href="#_0-8-and-wgsl" class="header-anchor">#</a> 0.8 and WGSL</h2> <h3 id="the-glsl-shaders-have-been-translated-to-wgsl"><a href="#the-glsl-shaders-have-been-translated-to-wgsl" class="header-anchor">#</a> The GLSL shaders have been translated to WGSL</h3> <p>Originally I wanted to wait until the WGSL spec fully stabilized, but due to some issues with the GLSL code, I've decided to switch over the code now. While GLSL is supported by WebGPU, it's currently secondary to WGSL. I'll keep an example of how to use GLSL (and maybe add HLSL and Metal as well), but I'm going to use WGSL from now on.</p> <h3 id="shaderc-has-been-removed"><a href="#shaderc-has-been-removed" class="header-anchor">#</a> Shaderc has been removed</h3> <p>I've been thinking about doing this for a while now. Because shaderc is a c library, it often has to be redownloaded during builds. This has been slowing down my ability to add new content and maintain old content. I had been considering switching to naga earlier, but some of my shaders (notably the lighting ones) weren't compiling with naga as I was using features not available for compatibility reasons (<code>inverse</code> is not available in all languages targeting spirv).</p> <p>Since I needed to make a bunch of changes to the code base to make the glsl, and because I wanted to switch the tutorial to WGSL anyways, I decided to bite the bullet and recode everything in WGSL and remove shaderc from the tutorials.</p> <h3 id="some-of-the-showcase-examples-are-broken"><a href="#some-of-the-showcase-examples-are-broken" class="header-anchor">#</a> Some of the showcase examples are broken</h3> <p>The <code>wgpu_glyph</code>, and <code>imgui-wgpu</code> crates currently depend on <code>wgpu</code> 0.7, which is causing the <code>pong</code> and <code>imgui-demo</code> to not compile. I decided to excluded them from the workspace until the underlying crates update to using <code>wgpu</code> 0.8. (Feel free to submit a issue or even PR when that happens!)</p> <h3 id="various-api-changes"><a href="#various-api-changes" class="header-anchor">#</a> Various API changes</h3> <ul><li>The <code>depth</code> field is now <code>depth_or_array_layers</code></li> <li><code>wgpu::VertexFormat::Float3</code> is now <code>wgpu::VertexFormat::Float32x3</code>. Similar things apply to <code>Float2</code> and <code>Float4</code></li> <li><code>CullMode</code> is no longer a thing, instead <code>PrimitiveState::cull_mode</code> will require an <code>Option<Face></code></li> <li>Added <code>clamp_depth</code> and <code>conservative</code> to <code>PrimitiveState</code>. Part of this means that <code>DepthStencilState</code> no longer has a <code>clamp_depth</code> field.</li> <li><code>color_blend</code> and <code>alpha_blend</code> have been moved into the new <code>blend</code> field with accepts an <code>Option<wgpu::BlendState></code></li> <li><code>adapter.get_swap_chain_preferred_format()</code> now returns an <code>Option<wgpu::TextureFormat></code></li> <li><code>wgpu::RenderPassColorAttachmentDescriptor</code> has been renamed <code>wgpu::RenderPassColorAttachement</code> and the <code>attachment</code> field has been renamed to <code>view</code></li> <li><code>wgpu::RenderPassDepthStencialAttachmentDescriptor</code> also loses the <code>Descriptor</code> part of it's name. <code>attachment</code> gets renamed to <code>view</code> as well.</li> <li><code>wgpu::TextureCopyView</code> has been renamed to <code>wgpu::ImageCopyTexture</code>. This is a typedef for <code>wgpu::ImageCopyTextureBase<T></code></li> <li><code>wgpu::TextureDataLayout</code> is now <code>wgpu::ImageDataLayout</code> and it's <code>bytes_per_row</code> and <code>rows_per_image</code> now take <code>NonZeroU32</code>.</li> <li><code>wgpu::ImageCopyBuffer</code> is now <code>wgpu::ImageCopyBuffer</code>.</li></ul> <h2 id="_0-7"><a href="#_0-7" class="header-anchor">#</a> 0.7</h2> <p>There were a lot of changes particularly to the <code>RenderPipelineDescriptor</code>. Most other things have not changed. You can check out the <a href="https://github.com/sotrh/learn-wgpu/pull/140" target="_blank" rel="noopener noreferrer">0.9 PR<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> for the full details.</p> <h2 id="november-2020-cleanup-content-freeze-and-patreon"><a href="#november-2020-cleanup-content-freeze-and-patreon" class="header-anchor">#</a> November 2020 Cleanup, Content Freeze, and Patreon</h2> <p>School is starting to ramp up, so I haven't had as much time to work on the site as I would like to. Because of that there were some issues piling up. I decided to tackle a bunch of them in one go. Here's a snapshot of what I did:</p> <ul><li>The tutorial now handles <code>SwapChainError</code> properly</li> <li>I'm now using bytemuck's derive feature on all buffer data structs.</li> <li>The <a href="../beginner/tutorial7-instancing">instancing tutorial</a> now uses vertex buffers instead of storage buffers.</li> <li><code>build.rs</code> now updates when individual shaders are changed, not whenever <code>/src</code> is changed.</li> <li>Had some help from Github user @kanerogers to clean up the <a href="../beginner/tutorial5-textures">texturing tutorial</a>.</li> <li>I made a <a href="../showcase/compute">compute pipeline showcase</a> that computes the tangent and bitangent for each vertex in a model.</li> <li>I made a <a href="../showcase/imgui-demo">imgui showcase</a>. It's very basic, but it should be a good starting point.</li></ul> <p>Now in the headline I mentioned a "Content Freeze". Wgpu is still a moving target. The migration from <code>0.4</code> to <code>0.5</code> was lot of work. The same goes for <code>0.5</code> to <code>0.6</code>. I'm expected the next migration to be just as much work. As such, I won't be added much content until the API becomes a bit more stable. That being said, I still plan on resolving any issues with the content.</p> <p>One more thing. This is actually quite awkward for me (especially since I'll be slowing down development), but I've started a <a href="https://www.patreon.com/sotrh" target="_blank" rel="noopener noreferrer">patreon<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>. My job doesn't give me a ton of hours, so things are a bit tight. You are by no means obligated to donate, but I would appreciate it.</p> <p>You can find out more about contributing to this project on the <a href="/learn-wgpu/#contribution-and-support">introduction page</a></p> <h2 id="_0-6"><a href="#_0-6" class="header-anchor">#</a> 0.6</h2> <p>This took me way too long. The changes weren't difficult, but I had to do a lot of copy pasting. The main changes are using <code>queue.write_buffer()</code> and <code>queue.write_texture()</code> everywhere. I won't get into the nitty gritty, but you can checkout the <a href="https://github.com/sotrh/learn-wgpu/pull/90" target="_blank" rel="noopener noreferrer">pull request<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> if you're interested.</p> <h2 id="added-pong-showcase"><a href="#added-pong-showcase" class="header-anchor">#</a> Added Pong Showcase</h2> <p><a href="/learn-wgpu/showcase/pong/">See it here</a></p> <h2 id="normal-mapping"><a href="#normal-mapping" class="header-anchor">#</a> Normal mapping</h2> <p>My perfectionism got in my way a bit with this one. I wasn't sure that what I was getting was "physically accurate", but it seems to look good.</p> <p><img src="/learn-wgpu/assets/img/normal_mapping_correct.2731b486.png" alt=""></p> <h2 id="_0-5"><a href="#_0-5" class="header-anchor">#</a> 0.5!</h2> <p>Too many things changed to make note of them here. Check out <a href="https://github.com/sotrh/learn-wgpu/pull/29" target="_blank" rel="noopener noreferrer">the 0.5 pull request<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> if you're curious about specifics. That being said, 2 things are worth mentioning directly: the y-axis now points up like with DirectX and Metal, and requesting an adapter and creating a device now use <code>Future</code>s. The tutorials have been updated as well as the code.</p> <h2 id="reworked-lighting-tutorial"><a href="#reworked-lighting-tutorial" class="header-anchor">#</a> Reworked lighting tutorial</h2> <p>The <a href="/learn-wgpu/intermediate/tutorial10-lighting/">lighting tutorial</a> was not up to par, so I redid it.</p> <h2 id="added-gif-showcase"><a href="#added-gif-showcase" class="header-anchor">#</a> Added GIF showcase</h2> <p><a href="/learn-wgpu/showcase/gifs/">Creating GIFs</a></p> <h2 id="updated-texture-tutorials"><a href="#updated-texture-tutorials" class="header-anchor">#</a> Updated texture tutorials</h2> <p>Up to this point, we created textures manually everytime. I've pulled out the texture creation code into a new <code>texture.rs</code> file and included it every tutorial from the <a href="/learn-wgpu/beginner/tutorial5-textures/#cleaning-things-up">textures tutorial</a> onward.</p> <h2 id="fixed-panics-do-to-not-specifying-the-correct-usage"><a href="#fixed-panics-do-to-not-specifying-the-correct-usage" class="header-anchor">#</a> Fixed panics do to not specifying the correct <code>usage</code></h2> <p>Wgpu has become more strict about what <code>BufferUsage</code>s and <code>TextureUsage</code>s are required when performing certain operations. For example int the <a href="/learn-wgpu/intermediate/windowless/">Wgpu without a window example</a>, the <code>texture_desc</code> only specified the usage to by <code>COPY_SRC</code>. This caused a crash when the <code>texture</code> was used as a render target. Adding <code>OUTPUT_ATTACHMENT</code> fixed the issue.</p> <h2 id="updating-winit-from-0-20-0-alpha5-to-0-20"><a href="#updating-winit-from-0-20-0-alpha5-to-0-20" class="header-anchor">#</a> Updating Winit from 0.20.0-alpha5 to 0.20</h2> <p>There were a lot of small changes to how the dpi stuff works. You can see all the changes <a href="https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md" target="_blank" rel="noopener noreferrer">in the changelog<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>. That means that some of the tutorials had to change.</p> <ul><li>I've removed <code>hidpi_factor</code> from <code>State</code> entirely. They removed the <code>hidpi_factor()</code> method from <code>winit::window::Window</code>, and changed <code>inner_size()</code> to return <code>PhysicalSize</code> instead of <code>LogicalSize</code>, so we don't need to store the <code>hidpi_factor</code> anymore.</li> <li><code>update_hidpi_and_resize</code> is no more. Since <code>ScaleFactorChanged</code> passes in the windows new <code>PhysicalSize</code>, we can simply use <code>resize()</code>.</li> <li><code>State::size</code> is now <code>PhysicalSize<u32></code> instead of the pre 0.20 <code>LogicalSize</code>.</li> <li><code>EventsCleared</code> is now <code>MainEventsCleared</code>.</li></ul> <p>I may have missed a change, but I made sure that all the examples compile an run, so if you have trouble with your code you can use them as a reference.</p> <h2 id="changed-tutorial-examples-to-use-a-src-directory"><a href="#changed-tutorial-examples-to-use-a-src-directory" class="header-anchor">#</a> Changed tutorial examples to use a src directory</h2> <p>I wasn't using the traditional cargo binary folder setup. I've changed it to the standardized form now.</p> <h2 id="updating-to-0-4-from-0-3"><a href="#updating-to-0-4-from-0-3" class="header-anchor">#</a> Updating to 0.4 from 0.3</h2> <p>There are a few things that have changed:</p> <ol><li>The use of <code>Instance</code> has been removed. Creating a <code>Surface</code> and requesting an <code>Adapter</code> are done as follows.</li></ol> <div class="language-rust extra-class"><pre class="language-rust"><code><span class="token keyword">let</span> surface <span class="token operator">=</span> <span class="token namespace">wgpu<span class="token punctuation">::</span></span><span class="token class-name">Surface</span><span class="token punctuation">::</span><span class="token function">create</span><span class="token punctuation">(</span>window<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
<span class="token keyword">let</span> adapter <span class="token operator">=</span> <span class="token namespace">wgpu<span class="token punctuation">::</span></span><span class="token class-name">Adapter</span><span class="token punctuation">::</span><span class="token function">request</span><span class="token punctuation">(</span><span class="token operator">&</span><span class="token namespace">wgpu<span class="token punctuation">::</span></span><span class="token class-name">RequestAdapterOptions</span> <span class="token punctuation">{</span>
|
|
<span class="token punctuation">..</span><span class="token class-name">Default</span><span class="token punctuation">::</span><span class="token function">default</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
|
|
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// needs to be unwrapped</span>
|
|
</code></pre></div><ol start="2"><li>The <code>request_device</code> method now returns a <code>(Device, Queue)</code> tuple. This means that you can borrow the <code>Queue</code> mutably while using the <code>Device</code> immutably. Because of this change, submitting <code>CommandBuffer</code>s to the queue uses the <code>submit</code> method on the <code>Queue</code> directly.</li></ol> <div class="language-rust extra-class"><pre class="language-rust"><code><span class="token keyword">self</span><span class="token punctuation">.</span>queue<span class="token punctuation">.</span><span class="token function">submit</span><span class="token punctuation">(</span><span class="token operator">&</span><span class="token punctuation">[</span>
|
|
encoder<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
|
|
<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
</code></pre></div><ol start="3"><li>The <code>create</code> method on <code>Surface</code> takes in any struct that implements the <code>HasRawWindow</code> trait, instead of a <code>RawWindowHandle</code>. This means that the <code>raw-window-handle = "0.3"</code> line in <code>Cargo.toml</code> is no longer needed.</li></ol> <p>I don't know if this is a change from 0.4, but you use <code>wgpu = "0.4"</code> line in dependencies instead of the <code>[dependencies.wgpu]</code> as wgpu will determine the best back end for you.</p> <h2 id="new-recent-articles"><a href="#new-recent-articles" class="header-anchor">#</a> New/Recent Articles</h2> <div><ul><li><a href="/beginner/tutorial1-window/">Dependencies and the window</a></li><li><a href="/beginner/tutorial2-swapchain/">The Swapchain</a></li><li><a href="/beginner/tutorial3-pipeline/">The Pipeline</a></li><li><a href="/beginner/tutorial4-buffer/">Buffers and Indices</a></li><li><a href="/beginner/tutorial5-textures/">Textures and bind groups</a></li></ul></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">7/10/2021, 8:04:39 AM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
|
|
←
|
|
<a href="/learn-wgpu/showcase/imgui-demo/" class="prev">
|
|
Basic Imgui Demo
|
|
</a></span> <!----></p></div> </main></div></div><div class="global-ui"><!----></div></div>
|
|
<script src="/learn-wgpu/assets/js/app.3c04ae58.js" defer></script><script src="/learn-wgpu/assets/js/2.da3fd46f.js" defer></script><script src="/learn-wgpu/assets/js/17.d3375cb5.js" defer></script><script src="/learn-wgpu/assets/js/9.ecb6e79c.js" defer></script>
|
|
</body>
|
|
</html>
|