If it's queryable from the device and not the d3d9, it should be an interface on the device and not the d3d9.
Direct3DCreate9On12 returns IDirect3D9, not IDirect3DDevice9[Ex]. How would you handle the arguments? They need to be stored somewhere.
Store the flag in the d3d9 structure. Again, see the way we handle IID_IDirect3DDevice9Ex in d3d9_device_QueryInterface().
Also, I added a refcount test which shows struct d3d9on12 is its own object with its own refcount. I don't know how to add it to `struct d3d9_device` in Direct3DCreate9On12.
You can implement a separate refcount without needing a separate object (just use a separate refcount field), although it's not clear we need to care.