i965: Fix segfault in WebGL Conformance on Ivybridge

Fixes regression of WebGL Conformance test texture-size-limit [1] on
Ivybridge Mobile GT2 0x0166 with Google Chrome R38.

Regression introduced by

    commit 6c044231535b93c5d16404528946cad618d96bd9
    Author: Kenneth Graunke <kenneth@whitecape.org>
    Date:   Sun Feb 2 02:58:42 2014 -0800

        i965: Bump GL_MAX_CUBE_MAP_TEXTURE_SIZE to 8192.

The test regressed because the pointer offset arithmetic in
intel_miptree_map_gtt() overflows for large textures. The pointer
arithmetic is not 64-bit safe.

[1] https://github.com/KhronosGroup/WebGL/blob/52f0dc240f04dce31b1b8e2b8107fe2b8332dc90/sdk/tests/conformance/textures/texture-size-limit.html

Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=78770
Fixes: Intel CHRMOS-1377
Reported-by: Lu Hua <huax.lu@intel.com>
Reviewed-by: Ian Romanic <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit b69c7c5dac4e2615e89cef773173484421830a8f)
nine: Clean Resource9 BaseTexture9 Surface9 and Texture9 initialization

Also fixed a bug with hl2 lost coast.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
nine: propertly declare constants

Fixes "Error : CONST[20]: Undeclared source register" when running
dx9_alpha_blending_material. Also artifacts on ilo.

Tested-by: David Heidelberg <david@ixit.cz>
nine: Add pool check to SetTexture

D3DPOOL_SCRATCH is disallowed according to spec.
D3DPOOL_SYSTEMMEM should be allowed but we don't handle it right for now.

v2: Fixes segfault in SetTexture when unsetting the texture

Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
nine: handle D3DISSUE_END without previous D3DISSUE_BEGIN

This patch fixes black screen with games based on the Unreal Engine 3.
It was tested that it fixed the issue in Tera Online, Borderlands 2 and Homefront.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: David Heidelberg <david@ixit.cz>
Signed-off-by: John Ettedgui <john.ettedgui@gmail.com>
nine: call DBG() at more external entry points

Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Reviewed-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Axel Davy <axel.davy@ens.fr>