gallium: Add __DRIimageDriverExtension support to gallium

__DRIimageDriverExtension is used by GLX DRI3 and Wayland.

This patch is a rewrite of
http://lists.freedesktop.org/archives/mesa-dev/2014-May/060318.html
and
http://lists.freedesktop.org/archives/mesa-dev/2014-May/060317.html

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Marek Olšák<marek.olsak@amd.com>

Previous patches were:
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
gallium: Use base.stamp for all drawable invalidation checks.

Upper levels of the stack use base.stamp to tell when a drawable needs to be
revalidated, but the dri state tracker was using dPriv->lastStamp. Those two,
along with dri2.stamp, all get simultaneously incremented when a dri2
invalidate event was delivered, and so end up containing precisely the same
value.

This patch doesn't change the fact that there are three variables, rather it
switches all of the tests to use only base.stamp, which is functionally
equivalent to the previous code.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Loader: Add gpu selection code via DRI_PRIME.

v2: Fix the leak of device_name
v3: Rebased

Signed-off-by: Axel Davy <axel.davy@ens.fr>
drirc: Add string support

Signed-off-by: Axel Davy <axel.davy@ens.fr>
loader: Use drirc device_id parameter in complement to DRI_PRIME

DRI_PRIME is not very handy, because you have to launch the executable
with it set, which is not always easy to do.
By using drirc, the user specifies the target executable
and the device to use. After that the program will be launched everytime
on the target device.

v2: Fix compilation issue
v3: Add "-lm" and rebase.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
DRIimage: add blitImage to the specification

It allows to blit two __DRIimages.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Gallium/dri2: implement blitImage

V3: call flush_resource before flush

Signed-off-by: Axel Davy <axel.davy@ens.fr>
GLX/DRI3: Add Gpu offloading support.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Wayland/egl: Add Gpu offloading support

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Radeonsi: Use dma_copy when possible for si_blit.

This improves GLX DRI3 Gpu offloading significantly on cpu
bound benchmarks particularly.
No performance impact for DRI2 Gpu offloading.

v2: Add missing tests

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Marek Olšák<marek.olsak@amd.com>