learn-wgpu icon indicating copy to clipboard operation
learn-wgpu copied to clipboard

Clarify `power_preference` in Surface chapter

Open doup opened this issue 2 years ago • 3 comments

In the Surface chapter, when explaining power_preference, the last sentence is not clear:

  • power_preference has two variants: LowPower, and HighPerformance. LowPower will pick an adapter that favors battery life, such as an integrated GPU. HighPerformance will pick an adapter for more power-hungry yet more performant GPU's such as a dedicated graphics card. WGPU will favor LowPower if there is no adapter for the HighPerformance option. (link to sentence)

If "there is no adapter" for HighPerformance, that's because there is only LowPower (or none?); hence there is nothing to favor?

Unless I'm misundertanding this, I suppose that it should say something like?

WGPU will favor LowPower when both a LowPower and HighPerformance options are available.

doup avatar Feb 07 '23 19:02 doup

The sentence seems correct to me, but the fact that by default wgpu sets the PowerPreference to Lower is missing. wgpu PowerPreference struct definition.

In fact the sentence makes more sense when you pass HighPerformance as the power preference value, which however in the example does not seem to be. wgpu PowerPreference choice source.

I never liked the choice of the term 'Preference', because I associate it with 'Configuration Option', in reality it must be understood as 'Preferred'. In fact, if by chance a LowPower gpu does not exist, a HighPerformance gpu is chosen if it exists, otherwise (in the example) there is a panic due to the unwrap().

CatCode79 avatar Feb 07 '23 19:02 CatCode79

Oh, I see, this is sentence is continuing the previous one 🤦‍♂️. So: if HighPerformance is chosen but there is no discrete option, it will fallback to integrated (then other, virt, cpu). What about something like this?

  • power_preference has two variants: LowPower, and HighPerformance.
    • LowPower will pick an adapter that favors battery life, such as an integrated GPU.
    • HighPerformance will pick an adapter for more power-hungry yet more performant GPU's such as a dedicated graphics card. But, if no high performance adapter is found it will favor a low power one.

Maybe is too much information at this stage, but what happens with neither can be fulfilled? It fallbacks to software rendering, it just panics, …?

doup avatar Feb 07 '23 20:02 doup

Reading the spec, it seems like these options only really matter if you have more than one GPU, such as in the case of laptops with a discrete GPU in addition to the integrated one. If either is picked, and only one GPU is available, wgpu should use that one.

sotrh avatar Feb 10 '23 01:02 sotrh