Skip to content

Commit dd243f3

Browse files
committed
Add appendix about lower end devices
1 parent 031fa1f commit dd243f3

5 files changed

Lines changed: 694 additions & 0 deletions

File tree

appendices/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Contents
99
:titlesonly:
1010
1111
teaching-native-graphics-in-2023
12+
keep-in-mind-lower-end-devices
1213
feedback-needed
1314
building-for-the-web
1415
using-sdl
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Keep in mind lower-end devices <span class="bullet">🟢</span>
2+
==============================
3+
4+
It can be **very tempting** to discard older devices or mobile devices when developing a GPU-based application. **But please don't**.
5+
6+
The problem
7+
-----------
8+
9+
**Why is it tempting?** As a developer, **we usually work on a device that is higher end** than what the average user has (and the *average* is not even a good target)! This induces certain consequences:
10+
11+
1. We sometimes **do not even realize** that our code requires a good GPU because, well, "it works on my machine".
12+
13+
2. And some other time, we are well aware that **we assume** that the user device has this or that property. Otherwise it would require **additional care**... and again, "it works on my machine" so why bother, I'm in a hurry.
14+
15+
**Why is this an issue?** Developing for high-end devices only has **very diverse and unfortunate consequences** to keep in mind:
16+
17+
1. **Social accessibility.** Not everybody can afford your higher end device, either because of its pecuniary cost or because of incompatibilities with their lifestyle. Especially if it is **not their work tool**. Ignoring this may increase social exclusion.
18+
19+
2. **Environmental impacts.** This one is **twofold**. First, if we only develop tools for higher-end devices, we are effectively **forcing everybody to upgrade their hardware**. User computing devices (workstations, laptops, phones, tablets, etc.) are already **renewed at a rate that is far from sustainable**, so please don't participate in this. Second, writing better code (i.e., that runs on lower end devices) usually has the nice byproduct of **drawing less power** even on higher end devices.
20+
21+
3. **Economic issues.** Ignoring a significant portion of the existing user devices is usually bad for business. Some potential users/clients are completely excluded, and some other may experience **frustrating lags or failures**. If we step back, software-based obsolescence of perfectly working hardware also causes **macroeconomic issues** since we collectively destroy existing value.
22+
23+
I let you order these issues however you'd like, but at least don't overlook them.
24+
25+
```{tip}
26+
Smartphones are **by far** the most common type of user computing device. Especially in developing countries.
27+
```
28+
29+
> 🤔 Oh but I am doing research, or my app will only get out years from now, so I develop it for future devices.
30+
31+
This is arguably a **"chicken and egg" problem**: the **hardware renewal rate** is not just something you **assume**, it is also something you **trigger** (at least you participate in it) by only targeting new stuff. I guess if all you care about is the direct economic consequences to yourself, then that's fine, but if you're at least slightly concerned by one of the other points, think about it.
32+
33+
If what you write is a **research prototype** rather than an application targeting end users, **this still matters**. Don't underestimate your impact: uncertainty has a cost, so if your research was only tested on top-tier hardware, engineers who eventually **transfer your research** into end products may decide not to **risk** generalizing it to a wider range of devices. In other terms, **showing that a method works on the existing park of devices "as is" is a contribution**.
34+
35+
Suggested solutions
36+
-------------------
37+
38+
Okey so what do we do in practice?
39+
40+
### Write portable code
41+
42+
You probably already care about this if you have decided to use **WebGPU** rather than an OS or vendor-specific graphics API. What this article is about is to **push the definition of portability a little further**: it's one thing to support some systems of each OS/vendor, it's another to support as many as possible.
43+
44+
It's a question of mindset before anything else: always **consider who you might be abandoning by the roadside** when assuming something about the user device.
45+
46+
I know, writing portable code and writing code that makes better use of the hardware is **sort of contradictory** because one cannot optimize for a specific device then. The thing is, the impacts of hardware renewal is generally **more significant** than the impacts of portability overheads.
47+
48+
Of course, if you have time nothing prevents from also optimizing for the most common devices, but only after making sure you do not disregard anybody's device.
49+
50+
### Do the most out of the default limits
51+
52+
The WebGPU specification defines [default limits](https://www.w3.org/TR/webgpu/#limit-default), which are **designed to be widely available**. Said differently, if you start requiring non-default limits, you are restraining the access to your application.
53+
54+
When requesting the WebGPU device from the WebGPU adapter (see chapters [*The Adapter*](../getting-started/adapter-and-device/the-adapter.md) and [*The Device*](../getting-started/adapter-and-device/the-device.md)), **do not blindly request the maximum supported limits**. Just because the adapter tells you "I can support 16K textures" does not mean you should use more than the default limit of 8K unless you have a good reason to.
55+
56+
My advice would then be **do as much as possible to fit within the default limits**, and whenever you'd really like to ask for more, consider **providing a fallback** for people who do not support it.
57+
58+
### Provide a fallback path
59+
60+
Or maybe the higher-end path should be treated as the nice-to-have exception, rather than looking at the default as the painful exception.
61+
62+
Let me reuse this figure from chapter [*The Adapter*](../getting-started/adapter-and-device/the-adapter.md):
63+
64+
```{figure} /images/device-creation.png
65+
:align: center
66+
In an advanced use of the adapter/device duality, we can set up multiple limit presets and select one depending on the adapter.
67+
```
68+
69+
The "low quality tier" here should correspond to the **default limits and features**, so that there is at least a valid code path. The you can have as many quality tiers as you want. What matters is that if you disable a feature of your application, it is really because the device cannot support it, and not just because you did not have time to treat that case: **treat the default case first**.
70+
71+
### Test on older devices
72+
73+
It may sound obvious, but we probably do not do it enough. Yet, this is the best way to **effectively check** that our program is indeed **portable**. Maybe you have an old computer gathering dust in your basement, or maybe you can borrow one.
74+
75+
Then, importantly, **report that it works**! For instance, if you are writing an academic paper, it typically includes something like "*we tested our method on a XXXX GPU*": ideally you should let know the lowest end device you could successfully test with, to **help the reader better scope the portability of your method**.
76+
77+
And what about **developing from the lower end device**? A bit more drastic, I admit, but there is value in not upgrading your own workstation too often, so that you do **not as easily inadvertently waste resources**!
78+
79+
### Spread the word
80+
81+
As we've noticed, this is a typical instance of the "chicken and egg" problem. The more developers believe in the idea that users will renew their hardware, the more it becomes a fact, with all the unfortunate consequences mentioned earlier.
82+
83+
So, discuss this at the **cafeteria**, in **meetings**, etc. Bring it to the table as an argument to make **better software**, software that **makes better use of the existing hardware**.
84+
85+
Afterword
86+
---------
87+
88+
I am well aware that this appendix is **a bit more opinionated** than the rest of the guide. If you would like to discuss this further, I warmly invite you to join [the Discord server](https://discord.gg/2Tar4Kt564)!

next/basic-3d-rendering/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ Contents
88
:titlesonly:
99
1010
hello-triangle
11+
input-geometry/index
1112
```

0 commit comments

Comments
 (0)