glsl/i965: move lower_offset_array up to GLSL compiler level.

This lowering pass will be useful for gallium drivers as well, in order to support
the GL TG4 oddity that is textureGatherOffsets.

Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Signed-off-by: Dave Airlie <airlied@redhat.com>
gallium: add texture gather support to gallium (v3)

This adds support to gallium for a TG4 instruction,
and two CAPs. The first CAP is required for GL_ARB_texture_gather.

The second CAP is required to expose GL_ARB_gpu_shader5.

However so far we haven't found any hardware that natively
exposes the textureGatherOffsets feature from GL, so just
lower it for now. If hardware appears for this we can add
another CAP to allow TG4 to take 4 offsets.

v2: add component selection src and a cap to say
hw can do it. (st can use to help control
GL_ARB_gpu_shader5/GLSL 4.00). Add docs.

v3: rename to SM5, add docs.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
st/mesa: add texture gather support. (v2)

This adds support for GL_ARB_texture_gather, and one step of
support for GL_ARB_gpu_shader5.

This adds support for passing the TG4 instruction, along
with non-constant texture offsets, and tracking them for the
optimisation passes.

This doesn't support native textureGatherOffsets hw, to do that
you'd need to add a CAP and if set disable the lowering pass,
and bump the MAX offsets to 4, then do the i0,j0 sampling using
those.

Signed-off-by: Dave Airlie <airlied@redhat.com>
nv50: correctly calculate the number of vertical blocks during transfer map

Cc: "10.0 10.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
mesa: remove unused driver hook BindBuffer

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
mesa: add storage flags parameter to Driver.BufferData

It will be used by glBufferStorage. The parameters are chosen according
to ARB_buffer_storage.

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
mesa: implement glBufferStorage, immutable buffers; add extension enable flag

Reviewed-by: Fredrik Höglund <fredrik@kde.org>

v2: dropped the error that DYNAMIC_STORAGE is required for MAP_WRITE_BIT,
    the error is removed in the latest revision of GL 4.4
glapi: add ARB_buffer_storage

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
mesa: add error checks to glMapBufferRange, glMapBuffer for ARB_buffer_storage

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
mesa: allow buffers mapped with the persistent flag to be used by the GPU

v2: also fixed InvalidateBufferData, added citations from the 4.4 spec

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
gallium: add interface for persistent and coherent buffer mappings

Required for ARB_buffer_storage.
st/mesa: implement ARB_buffer_storage

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
r300g,r600g,radeonsi: add support for ARB_buffer_storage

All GTT memory mappings are coherent and therefore can be persistent.

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
gallium: the other drivers don't support ARB_buffer_storage

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
gallium/upload_mgr: don't unmap buffers if persistent mappings are supported

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
gallium/upload_mgr: remove useless variable "size"

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
docs: update ARB_buffer_storage status

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
mesa: allow buffers to be mapped multiple times

OpenGL allows a buffer to be mapped only once, but we also map buffers
internally, e.g. in the software primitive restart fallback, for PBOs,
vbo_get_minmax_index, etc. This has always been a problem, but it will
be a bigger problem with persistent buffer mappings, which will prevent
all Mesa functions from mapping buffers for internal purposes.

This adds a driver interface to core Mesa which supports multiple buffer
mappings and allows 2 mappings: one for the GL user and one for Mesa.

Note that Gallium supports an unlimited number of buffer and texture
mappings, so it's not really an issue for Gallium.

v2: fix unmapping in xm_dd.c, remove the GL errors there
v3: fix the intel driver (by Fredrik)

Reviewed-by: Fredrik Höglund <fredrik@kde.org>
radeonsi: move PA_SU_POLY_OFFSET_DB_FMT_CNTL to framebuffer state

It doesn't depend on anything else.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
r600g,radeonsi: share r600_surface

I'm gonna use this in radeonsi.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>