What's the difference between HAL and REF devices?

HAL (Hardware Abstraction Layer) devices and REF (REFerence rasterizer) devices are the two main types of  Direct3D devices.

HAL

HAL is based around hardware support, and is very fast but might not support everything. With such devices, one should query the device for its capabilities, after which it can do one of 2 things:
1. Disable certain features that aren't supported by the device, if they're not necessary features
2. Destroy the device and exit, if the missing features are required.

REF

The REF device uses no hardware acceleration, so is very slow, but is guaranteed to support the entire set of Direct3D features, in the correct way.

In general you'll only ever need to use HAL devices, but:

1. If you're playing with some advanced feature that your card doesn't support (for example, the latest shader stuff) then you might need to fall back to REF. If I were you, though, I'd consider investing in a new graphics card; for most of the stuff you'd want to use it for, REF is so slow that it's almost..no, that it's REALLYpainful.

2. The other time you might want to use REF is if the HAL device is producing some weird results - that is, you're sure your code is correct, but the result is not what you're expecting. The REF device is guaranteed to behave correctly, so you may wish to test your app on the REF device and see if the weird behaviour continues. If it doesn't, it means one of the following:

(a) Your app is assuming that the graphics card supports something that it doesn't
(b) it's a driver bug. If it still doesn't work with the REF device, then it's an app bug, i.e. one of yours. (True, it could be a REF bug, but that's so rare as to be worth discounting. The Direct3D team implemented the REF rasterizer in a very straightforward way that isn't prone to bugs, and while the result is slow, it's also solid).