<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Chapter 19 Graphics on Go: Under the Hood</title><link>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/</link><description>Recent content in Chapter 19 Graphics on Go: Under the Hood</description><generator>Hugo</generator><language>en</language><atom:link href="https://golang.design/under-the-hood/en/part6hetero/ch19graphics/index.xml" rel="self" type="application/rss+xml"/><item><title>19.1 The Rendering Pipeline and Where Go Sits</title><link>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/pipeline/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/pipeline/</guid><description>&lt;h1 id="191-the-rendering-pipeline-and-where-go-sits"&gt;19.1 The Rendering Pipeline and Where Go Sits&lt;/h1&gt;
&lt;p&gt;Chapter 18 read the GPU as a &amp;ldquo;general-purpose parallel compute device.&amp;rdquo; But the GPU&amp;rsquo;s given name is the &lt;strong&gt;Graphics&lt;/strong&gt; Processing Unit, and its first and most native job is to render graphics. For the two decades before &amp;ldquo;using the GPU for general computation&amp;rdquo; became a slogan, the graphics card was already doing parallel arithmetic for every pixel on the screen. Graphics is therefore the &lt;strong&gt;oldest heterogeneous workload&lt;/strong&gt;: the massively parallel hardware on a GPU was built for it in the first place. This chapter returns to that origin to ask what role Go plays in graphics, and the starting point is to see clearly the &lt;strong&gt;rendering pipeline&lt;/strong&gt; that runs through everything, and where exactly Go&amp;rsquo;s code sits on it.&lt;/p&gt;</description></item><item><title>19.2 Graphics Bindings and Thread Affinity</title><link>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/bindings/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/bindings/</guid><description>&lt;h1 id="192-graphics-bindings-and-thread-affinity"&gt;19.2 Graphics Bindings and Thread Affinity&lt;/h1&gt;
&lt;p&gt;&lt;a href=".././pipeline"&gt;19.1&lt;/a&gt; said that Go sits at the application stage of the pipeline and is responsible for issuing draw calls. But before the first draw call can actually go out, there is a threshold in front of every Go graphics program. It does not come from graphics itself, but from a fundamental conflict between Go&amp;rsquo;s concurrency model and a property of graphics APIs: &lt;strong&gt;a graphics context is bound to a thread, while a goroutine migrates across threads&lt;/strong&gt;. This threshold is the subject of this section, and the key that &lt;a href="../../ch18gpu/sched"&gt;18.2.5&lt;/a&gt; handed us, &lt;code&gt;LockOSThread&lt;/code&gt;, turns here from an optional trick into a necessity.&lt;/p&gt;</description></item><item><title>19.3 Software Rendering and Parallelism</title><link>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/software/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/software/</guid><description>&lt;h1 id="193-software-rendering-and-parallelism"&gt;19.3 Software Rendering and Parallelism&lt;/h1&gt;
&lt;p&gt;Rendering in the previous two sections always crossed a boundary: hand the work and commands to the local GPU, pay the whole set of tolls from Chapter 18, and still attend to the thread discipline of the graphics context (&lt;a href=".././bindings"&gt;19.2&lt;/a&gt;). This section takes another road, &lt;strong&gt;software rendering&lt;/strong&gt;: compute every pixel entirely on the CPU, touching no GPU, no driver, no FFI boundary of any kind. This road was once dismissed as &amp;ldquo;the slow and useless fallback,&amp;rdquo; yet it is precisely the best stage on which to put Go&amp;rsquo;s concurrency, and Go 1.27&amp;rsquo;s &lt;code&gt;simd&lt;/code&gt;, to work in graphics.&lt;/p&gt;</description></item><item><title>19.4 Rendering in the Browser</title><link>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/wasm/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part6hetero/ch19graphics/wasm/</guid><description>&lt;h1 id="194-rendering-in-the-browser"&gt;19.4 Rendering in the Browser&lt;/h1&gt;
&lt;p&gt;Rendering in the previous three sections either pushed the work across the FFI boundary to the local GPU (19.1, 19.2) or kept it on the CPU as software rendering (&lt;a href=".././software"&gt;19.3&lt;/a&gt;). This section changes the scene to a special runtime environment: the &lt;strong&gt;browser&lt;/strong&gt;. Go can be compiled to WebAssembly (WASM) and run in the browser, and once inside the browser, rendering meets a brand-new boundary. What is interesting is that the shape of this boundary, its cost, and the way to deal with it correspond almost one to one with the heterogeneous computing of the previous two chapters, only lifted up one level. Understanding this section reveals that &amp;ldquo;the FFI boundary&amp;rdquo; is a motif far broader than cgo.&lt;/p&gt;</description></item></channel></rss>