i965: Use the predicate enable bit for conditional rendering without stalling

Previously whenever a primitive is drawn the driver would call
_mesa_check_conditional_render which blocks waiting for the result of the
query to determine whether to render. On Gen7+ there is a bit in the
3DPRIMITIVE command which can be used to disable the primitive based on the
value of a state bit. This state bit can be set based on whether two registers
have different values using the MI_PREDICATE command. We can load these two
registers with the pixel count values stored in the query begin and end to
implement conditional rendering without stalling.

Unfortunately these two source registers are not in the whitelist of available
registers in the kernel driver so this needs a kernel patch to work. This
patch tries to check whether it is possible to write to this register by
creating a DRM buffer with a single command to write to the register and then
trying to exec it. The return value of the exec function (and hence the ioctl)
is checked.

There is a function with a similar goal just above to check whether the
OACONTROL register can be used. This works by putting the test command in the
regular batch buffer and trying to compare whether the value was successfully
written. I couldn't get this approach to work because intel_batchbuffer_flush
actually calls exit() if the ioctl fails. I am suspicious that this approach
doesn't work for OACONTROL either.

The predicate enable bit is currently only used for drawing 3D primitives. For
blits, clears, bitmaps, copypixels and drawpixels it still causes a stall. For
most of these it would probably just work to call the new
brw_check_conditional_render function instead of
_mesa_check_conditional_render because they already work in terms of rendering
primitives. However it's a bit trickier for blits because it can use the BLT
ring or the blorp codepath. I think these operations are less useful for
conditional rendering than rendering primitives so it might be best to leave
it for a later patch.