Skip to content

Commit

Permalink
deploy: 5b071fd
Browse files Browse the repository at this point in the history
  • Loading branch information
slimsag committed Nov 10, 2023
1 parent e8c1dc2 commit bcbf3a6
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion engine/gpu/errors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href=https://github.com/hexops/mach class=svg-item><img alt=GitHub class=svg-icon src=https://machengine.org//img/github.svg></a>
<a href=https://discord.gg/XNG3NZgCqp class=svg-item><img alt=Discord class=svg-icon src=https://machengine.org//img/discord.svg></a>
<a href=https://github.com/sponsors/slimsag class=donate-button><img alt=Heart class=svg-icon src=https://machengine.org//img/heart.svg>
&nbsp;Donate</a></div></div></div><div class=alert><span><strong>Mach v0.2 has been released!</strong> For all the details check out <a href=https://devlog.hexops.com/2023/mach-v0.2-released/>the announcement</a></span></div><div id=content><link rel=stylesheet href=https://machengine.org/layouts/docs.51bf11142b5d77eb006102daf475645c01dfee942f7c8607ae50293a389f1b0e.css><main aria-role=main class="main-docs with-alert"><aside><ul><li><a href=https://machengine.org/engine><span>Engine overview</span></a></li><li><a href=https://machengine.org/engine/roadmap><span>Roadmap</span></a></li><li><a href=https://machengine.org/about/known-issues><span>Known issues ⮕</span></a></li><li><h3><span>Math</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/math>Overview</a></li><li><a href=https://machengine.org/engine/math/coordinate-system>Coordinate system</a></li><li><a href=https://machengine.org/engine/math/matrix-storage>Matrix storage</a></li></ul><li><h3><span>GPU</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/gpu>Overview</a></li><li><a href=https://machengine.org/engine/gpu/memory>Memory management</a></li><li><a href=https://machengine.org/engine/gpu/errors>Error handling</a></li></ul></ul></aside><div class=docs><h1 id=gpu-error-handling>GPU error handling</h1><h2 id=asynchronous-nature>Asynchronous nature</h2><p>GPUs have largely asynchronous APIs: you build up a command buffer which encodes a number of commands instructing the GPU to do something, and then you ask the GPU to execute that buffer of commands. As a result, errors must be handled asynchronously as well. <code>try</code> isn&rsquo;t going to work here.</p><h2 id=error-scopes>Error scopes</h2><p>WebGPU has a concept of <em>error scopes</em>, you can push an error scope onto the stack and pop an error scope. Commands that produce errors while the error scope was on the stack will result in <em>that</em> error scope&rsquo;s callback being invoked. Let&rsquo;s look at a concrete example:</p><h3 id=catching-a-shader-compilation-error>Catching a shader compilation error</h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-zig data-lang=zig><span style=display:flex><span><span style=color:#75715e>// Push a validation error scope, so that if compiling the shader fails we&#39;ll
&nbsp;Donate</a></div></div></div><div class=alert><span><strong>Mach v0.2 has been released!</strong> For all the details check out <a href=https://devlog.hexops.com/2023/mach-v0.2-released/>the announcement</a></span></div><div id=content><link rel=stylesheet href=https://machengine.org/layouts/docs.51bf11142b5d77eb006102daf475645c01dfee942f7c8607ae50293a389f1b0e.css><main aria-role=main class="main-docs with-alert"><aside><ul><li><a href=https://machengine.org/engine><span>Engine overview</span></a></li><li><a href=https://machengine.org/engine/roadmap><span>Roadmap</span></a></li><li><a href=https://machengine.org/about/known-issues><span>Known issues ⮕</span></a></li><li><a href=https://machengine.org/engine/modularity><span>Modularity</span></a></li><li><a href=https://machengine.org/engine/stdlib><span>Standard library</span></a></li><li><h3><span>Math</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/math>Overview</a></li><li><a href=https://machengine.org/engine/math/coordinate-system>Coordinate system</a></li><li><a href=https://machengine.org/engine/math/matrix-storage>Matrix storage</a></li></ul><li><h3><span>GPU</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/gpu>Overview</a></li><li><a href=https://machengine.org/engine/gpu/memory>Memory management</a></li><li><a href=https://machengine.org/engine/gpu/errors>Error handling</a></li></ul></ul></aside><div class=docs><h1 id=gpu-error-handling>GPU error handling</h1><h2 id=asynchronous-nature>Asynchronous nature</h2><p>GPUs have largely asynchronous APIs: you build up a command buffer which encodes a number of commands instructing the GPU to do something, and then you ask the GPU to execute that buffer of commands. As a result, errors must be handled asynchronously as well. <code>try</code> isn&rsquo;t going to work here.</p><h2 id=error-scopes>Error scopes</h2><p>WebGPU has a concept of <em>error scopes</em>, you can push an error scope onto the stack and pop an error scope. Commands that produce errors while the error scope was on the stack will result in <em>that</em> error scope&rsquo;s callback being invoked. Let&rsquo;s look at a concrete example:</p><h3 id=catching-a-shader-compilation-error>Catching a shader compilation error</h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-zig data-lang=zig><span style=display:flex><span><span style=color:#75715e>// Push a validation error scope, so that if compiling the shader fails we&#39;ll
</span></span></span><span style=display:flex><span><span style=color:#75715e>// be able to handle that error.
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>core.device().pushErrorScope(.validation);
</span></span><span style=display:flex><span>
Expand Down
2 changes: 1 addition & 1 deletion engine/gpu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<a href=https://github.com/hexops/mach class=svg-item><img alt=GitHub class=svg-icon src=https://machengine.org//img/github.svg></a>
<a href=https://discord.gg/XNG3NZgCqp class=svg-item><img alt=Discord class=svg-icon src=https://machengine.org//img/discord.svg></a>
<a href=https://github.com/sponsors/slimsag class=donate-button><img alt=Heart class=svg-icon src=https://machengine.org//img/heart.svg>
&nbsp;Donate</a></div></div></div><div class=alert><span><strong>Mach v0.2 has been released!</strong> For all the details check out <a href=https://devlog.hexops.com/2023/mach-v0.2-released/>the announcement</a></span></div><div id=content><link rel=stylesheet href=https://machengine.org/layouts/docs.51bf11142b5d77eb006102daf475645c01dfee942f7c8607ae50293a389f1b0e.css><main aria-role=main class="main-docs with-alert"><aside><ul><li><a href=https://machengine.org/engine><span>Engine overview</span></a></li><li><a href=https://machengine.org/engine/roadmap><span>Roadmap</span></a></li><li><a href=https://machengine.org/about/known-issues><span>Known issues ⮕</span></a></li><li><h3><span>Math</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/math>Overview</a></li><li><a href=https://machengine.org/engine/math/coordinate-system>Coordinate system</a></li><li><a href=https://machengine.org/engine/math/matrix-storage>Matrix storage</a></li></ul><li><h3><span>GPU</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/gpu>Overview</a></li><li><a href=https://machengine.org/engine/gpu/memory>Memory management</a></li><li><a href=https://machengine.org/engine/gpu/errors>Error handling</a></li></ul></ul></aside><div class=docs><h1 id=gpu-overview>GPU overview</h1><p>Mach uses WebGPU as its graphics API, this is an overview of that, links to learning resources and more information about how to use it.</p><h2 id=learning-resources>Learning resources</h2><h3 id=things-to-reference-as-you-go>Things to reference as you go</h3><ul><li><a href=https://webgpu.rocks/wgsl/language/types/>webgpu.rocks WGSL guide</a></li><li><a href=https://www.w3.org/TR/webgpu/>WebGPU specification</a> and <a href=https://www.w3.org/TR/WGSL/>WGSL specification</a>.</li></ul><h3 id=video-tutorials>Video tutorials</h3><p><a href="https://www.youtube.com/watch?v=UBqme9A_O3c&list=PLn3eTxaOtL2Ns3wkxdyS3CiqkJuwQdZzn">@GetIntoGameDev has an excellent series</a> of around 30 &ldquo;WebGPU for Beginners&rdquo; tutorials, they are using JavaScript but the APIs and concepts are the same. They go into an interesting raytracing-using-compute-shaders technique towards the end.</p><h3 id=code-examples>Code examples</h3><ul><li><a href=../../core#example-showcase>mach-core</a> has an example showcase with 15+ Zig examples.</li><li>JS examples: <a href=https://github.com/webgpu/webgpu-samples>https://github.com/webgpu/webgpu-samples</a></li><li>C examples: <a href=https://github.com/samdauwe/webgpu-native-examples>https://github.com/samdauwe/webgpu-native-examples</a></li></ul><h3 id=articles>Articles</h3><ul><li><a href=https://toji.dev/webgpu-best-practices/buffer-uploads.html>Buffers uploads</a> by @tojiro</li><li><a href=https://toji.github.io/webgpu-gltf-case-study/>WebGPU GLTF case study</a> by @tojiro</li><li><a href=https://toji.dev/webgpu-best-practices/compute-vertex-data>Using WebGPU Compute Shaders with Vertex Data</a> (compute skinning) - by @tojiro</li><li><a href=https://alain.xyz/blog/raw-webgpu#initialize-api>&ldquo;Raw WebGPU&rdquo;</a> has great diagrams of the basic concepts behind WebGPU - by @alain</li><li><a href=https://surma.dev/things/webgpu/>Surma.dev&rsquo;s article</a> covers WebGPU compute shaders in detail</li></ul></div><div class=toc><h3>Table of contents</h3><nav id=TableOfContents><ul><li><a href=#learning-resources>Learning resources</a><ul><li><a href=#things-to-reference-as-you-go>Things to reference as you go</a></li><li><a href=#video-tutorials>Video tutorials</a></li><li><a href=#code-examples>Code examples</a></li><li><a href=#articles>Articles</a></li></ul></li></ul></nav></div></main><div class=footer><a href=https://hexops.com/privacy>Privacy matters</a><p><a href=https://github.com/hexops/machengine.org/archive/refs/heads/gh-pages.zip>offline version of this site</a> | <a href=https://machengine.org//about#improve-this-site>Improve this site</a> | <a href=https://github.com/sponsors/slimsag>Sponsor on GitHub</a> | <a href=https://devlog.hexops.com/>Hexops' devlog</a></p></div></div></body></html>
&nbsp;Donate</a></div></div></div><div class=alert><span><strong>Mach v0.2 has been released!</strong> For all the details check out <a href=https://devlog.hexops.com/2023/mach-v0.2-released/>the announcement</a></span></div><div id=content><link rel=stylesheet href=https://machengine.org/layouts/docs.51bf11142b5d77eb006102daf475645c01dfee942f7c8607ae50293a389f1b0e.css><main aria-role=main class="main-docs with-alert"><aside><ul><li><a href=https://machengine.org/engine><span>Engine overview</span></a></li><li><a href=https://machengine.org/engine/roadmap><span>Roadmap</span></a></li><li><a href=https://machengine.org/about/known-issues><span>Known issues ⮕</span></a></li><li><a href=https://machengine.org/engine/modularity><span>Modularity</span></a></li><li><a href=https://machengine.org/engine/stdlib><span>Standard library</span></a></li><li><h3><span>Math</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/math>Overview</a></li><li><a href=https://machengine.org/engine/math/coordinate-system>Coordinate system</a></li><li><a href=https://machengine.org/engine/math/matrix-storage>Matrix storage</a></li></ul><li><h3><span>GPU</span></h3></li><ul class=sub-menu><li><a href=https://machengine.org/engine/gpu>Overview</a></li><li><a href=https://machengine.org/engine/gpu/memory>Memory management</a></li><li><a href=https://machengine.org/engine/gpu/errors>Error handling</a></li></ul></ul></aside><div class=docs><h1 id=gpu-overview>GPU overview</h1><p>Mach uses WebGPU as its graphics API, this is an overview of that, links to learning resources and more information about how to use it.</p><h2 id=learning-resources>Learning resources</h2><h3 id=things-to-reference-as-you-go>Things to reference as you go</h3><ul><li><a href=https://webgpu.rocks/wgsl/language/types/>webgpu.rocks WGSL guide</a></li><li><a href=https://www.w3.org/TR/webgpu/>WebGPU specification</a> and <a href=https://www.w3.org/TR/WGSL/>WGSL specification</a>.</li></ul><h3 id=video-tutorials>Video tutorials</h3><p><a href="https://www.youtube.com/watch?v=UBqme9A_O3c&list=PLn3eTxaOtL2Ns3wkxdyS3CiqkJuwQdZzn">@GetIntoGameDev has an excellent series</a> of around 30 &ldquo;WebGPU for Beginners&rdquo; tutorials, they are using JavaScript but the APIs and concepts are the same. They go into an interesting raytracing-using-compute-shaders technique towards the end.</p><h3 id=code-examples>Code examples</h3><ul><li><a href=../../core#example-showcase>mach-core</a> has an example showcase with 15+ Zig examples.</li><li>JS examples: <a href=https://github.com/webgpu/webgpu-samples>https://github.com/webgpu/webgpu-samples</a></li><li>C examples: <a href=https://github.com/samdauwe/webgpu-native-examples>https://github.com/samdauwe/webgpu-native-examples</a></li></ul><h3 id=articles>Articles</h3><ul><li><a href=https://toji.dev/webgpu-best-practices/buffer-uploads.html>Buffers uploads</a> by @tojiro</li><li><a href=https://toji.github.io/webgpu-gltf-case-study/>WebGPU GLTF case study</a> by @tojiro</li><li><a href=https://toji.dev/webgpu-best-practices/compute-vertex-data>Using WebGPU Compute Shaders with Vertex Data</a> (compute skinning) - by @tojiro</li><li><a href=https://alain.xyz/blog/raw-webgpu#initialize-api>&ldquo;Raw WebGPU&rdquo;</a> has great diagrams of the basic concepts behind WebGPU - by @alain</li><li><a href=https://surma.dev/things/webgpu/>Surma.dev&rsquo;s article</a> covers WebGPU compute shaders in detail</li></ul></div><div class=toc><h3>Table of contents</h3><nav id=TableOfContents><ul><li><a href=#learning-resources>Learning resources</a><ul><li><a href=#things-to-reference-as-you-go>Things to reference as you go</a></li><li><a href=#video-tutorials>Video tutorials</a></li><li><a href=#code-examples>Code examples</a></li><li><a href=#articles>Articles</a></li></ul></li></ul></nav></div></main><div class=footer><a href=https://hexops.com/privacy>Privacy matters</a><p><a href=https://github.com/hexops/machengine.org/archive/refs/heads/gh-pages.zip>offline version of this site</a> | <a href=https://machengine.org//about#improve-this-site>Improve this site</a> | <a href=https://github.com/sponsors/slimsag>Sponsor on GitHub</a> | <a href=https://devlog.hexops.com/>Hexops' devlog</a></p></div></div></body></html>
Loading

0 comments on commit bcbf3a6

Please sign in to comment.