On Wed, 20 Feb 2019 at 16:47, Sven Baars sven.wine@gmail.com wrote:
On 20-02-19 14:05, Henri Verbeet wrote: In device_init is says
device->adapter = wined3d->adapter_count ? adapter : NULL;
meaning that device->adapter can be NULL if adapter_count can be 0.
All callers validate that adapter_idx < adapter_count. The check in that line is redundant.
However, then I would actually expect the first line of device_init, which is
struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
also to fail.
Why would it?
assume it is always 1, but then why does it say
device->adapter = wined3d->adapter_count ? adapter : NULL;
in the first place? Or is this part of some cleanup that still has to be done?
History, mostly. At some point we didn't create adapters when using the GDI renderer. For reference, see commit 12788f6fc8987687453092cb3914fb46f2a4e4d1, which introduced the code in question.