learn-wgpu
                                
                                
                                
                                    learn-wgpu copied to clipboard
                            
                            
                            
                        Clarify `power_preference` in Surface chapter
In the Surface chapter, when explaining power_preference, the last sentence is not clear:
power_preferencehas two variants:LowPower, andHighPerformance.LowPowerwill pick an adapter that favors battery life, such as an integrated GPU.HighPerformancewill pick an adapter for more power-hungry yet more performant GPU's such as a dedicated graphics card. WGPU will favorLowPowerif there is no adapter for theHighPerformanceoption. (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
LowPowerwhen both aLowPowerandHighPerformanceoptions are available.
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().
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_preferencehas two variants:LowPower, andHighPerformance.
LowPowerwill pick an adapter that favors battery life, such as an integrated GPU.HighPerformancewill 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, …?
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.