nine: Refactor Resource9 BaseTexture9 Surface9 and Texture9 initialization

First change is to pass initResource argument to initialise the resource
field in Resource9 instead of in the parents.

Second change is to pass Usage argument, instead of letting the parent
classes set the usage field of the Resource9 structure.

Third change fixes a bug, preventing Half-Life 2 Lost Coast from working
properly, is to remove the data field from Resource9, put it in Surface9,
which was the only user, and add flag to Surface9 to know if it has created
the data or not. Surface9 dtor frees the data only if it created it.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
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.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
nine: Add pool check to SetTexture (v2)

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

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
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.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
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

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
nvc0: define numbers, make code better readable

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
mesa/gallium: API settings / rasterization rules
nvc0: use API settings / rasterization rules (v2)

v2: dropped part of clip_halfz handling implemented in upstream commit
    3bc42a09e2d13c42e15423a17b5c571049a11224
nv50,nvc0: handle TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION

Allow viewport bypass used by D3D9 applications.
nv50,nvc0: handle NULL vertex elements without fallback

This makes Gallium Nine faster.
nv50/ir/tgsi: implement TGSI_OPCODE_NRM,DP2A

Used by d3d9 st.
hack/nv50: don't emit buffer for skipped vertex elements

Grr, should forbid that and insert dummy elements in nine.
hack/nvc0: avoid fault in get_query_result if there was no begin_query
nv50: support for hackish viewport bypass
nv50,nvc0: d3d9 requires transfer stride to be aligned to 4
gallium: add blending to pipe blit

Following nouveau commit make use of these.

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nvc0: use blending to pipe blit
nvc0: NULL vertex buffers are allowed
nvc0: reset constant vertex attribute data after blit

To make wine's test_vshader_input happy.
nvc0: add fast-path for constant buffer upload

Saves a memcpy, and increased threshold for push method, which is
usually better because there's no subchannel switch.

Reviewed-by: David Heidelberger <david.heidelberger@ixit.cz>
Signed-off-by: Tiziano Bacocco <tizbac2@gmail.com>
Author: Christoph Bumiller <christoph.bumiller@speed.at>