glsl/glcpp: rename ERROR to ERROR_TOKEN to fix MSVC build

ERROR is a #define in the MSVC WinGDI.h header file.
Add the _TOKEN suffix as we do for a few other lexer tokens.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st/gbm: retrieve the driver-name via dd_driver_name()

... on static targets. Otherwise we'll crash badly as gdrm->dev is
NULL when we try to copy the string driver_name.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
st/gbm: don't segfault if the fail to create the screen

Whenever dd_create_screen/pipe_loader_* fails, gdrm->dev may be NULL.
Thus peeking inside the struct will lead to a crash.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Add support for swrast to the DRM EGL platform

Turn GBM into a swrast loader (providing putimage/getimage backed
by a dumb KMS buffer). This allows to run KMS+DRM GL applications
(such as weston or mutter-wayland) unmodified on cards that don't
have any client side HW acceleration component but that can do
modeset (examples include simpledrm and qxl)

[Emil Velikov]
 - Fix make check.
 - Split dri_open_driver() from dri_load_driver().
 - Don't try to bind the swrast extensions when using dri.
 - Handle swrast->CreateNewScreen() failure.
 - strdup the driver_name, as it's free'd at destruction.
 - s/LIBGL_ALWAYS_SOFTWARE/GBM_ALWAYS_SOFTWARE/
 - Move gbm_dri_bo_map/unmap to gbm_driiint.h.
 - Correct swrast fallback logic.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
gallium: Add a dumb drm/kms winsys backed swrast provider

Add a new winsys and target that can be used with a dri2 state tracker
and loader instead of drisw. This allows to use gbm as a dri2/image
loader and avoid the extra copy from the backbuffer to the shadow
frontbuffer.

The new driver is called "kms_swrast", and is loaded by gbm as a
fallback, because it is only useful with the gbm platform (as no buffer
sharing is possible)

To force select the driver set the environment variable
GBM_ALWAYS_SOFTWARE

[Emil Velikov]
 - Rebase on top of gallium megadriver.
 - s/text/test/ in configure.ac (Spotted by Andreas Pokorny).
 - Add scons support for winsys/sw/kms-dri and fix the build.
 - Provide separate DriverAPI, due to different InitScreen hook.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
dri: Add a new capabilities for drivers that can't share buffers

The kms-dri swrast driver cannot share buffers using the GEM,
so it must tell the loader to disable extensions relying on
that, without disabling the image DRI extension altogether
(which would prevent the loader from working at all).
This requires a new gallium capability (which is queried on
the pipe_screen and for swrast drivers it's forwarded to the
winsys), and requires a new version of the DRI image extension.

[Emil Velikov]
 - Rebased on top of gallium-dri megadrivers.
 - Drop PIPE_CAP_BUFFER_SHARE and sw_winsys::get_param hook.
The can_share_buffer cap is set at InitScreen. We use a different
InitScreen (and thus value for the cap) function for kms_dri, due to
deeper differences originating from dri megadrivers.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
gallivm: fix up out-of-bounds level when using conformant out-of-bound behavior

When using (d3d10) conformant out-of-bound behavior for texel fetching
(currently always enabled) the level still needs to be set to a safe value
even though the offset in the end won't get used because the level is used
to look up the mip offset itself and the actual strides, which might otherwise
crash.
For simplicity, we'll use level 0 in this case (this ought to be safe, llvmpipe
does not actually fill in level 0 information if first_level is larger, but
some random strides / offsets shouldn't hurt as ultimately we always use
offset 0 in this case).
Fixes a crash in some in-house test where random huge levels appear in
lp_build_fetch_texel() (the test actually uses level 0 always but if the
fetching happens in a block with a execution mask random values may appear).

CC: <mesa-stable@lists.freedesktop.org>

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>