nv50/ir: set neg modifiers on min/max args

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=86618
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
nv50,nvc0: actually check constbufs for invalidation

The number of vertex buffers has nothing to do with the number of bound
constbufs.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
nv50,nvc0: buffer resources can be bound as other things down the line

res->bind is not an indicator of how the resource is currently bound.
buffers can be rebound across different binding points without changing
underlying storage.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
st/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>
st/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>
st/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>
st/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>
st/nine: return GetAvailableTextureMem in bytes as expected (v2)

PIPE_CAP_VIDEO_MEMORY returns the amount of video memory in megabytes,
so need to converted it to bytes.

Fixed Warframe memory detection.

v2: also prepare for cards with more than 4GB memory

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: Yaroslav Andrusyak <pontostroy@gmail.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
st/nine: fix wrong variable reset

Error detected by Coverity (COPY_PAST_ERROR)

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
st/nine: remove unused pipe_viewport_state::translate[3] and scale[3]

2efabd9f5a711a7f6cd1846630244b7814bf25b3 removed them as unused.

This caused random memory overwrites (reported by Coverity).

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
st/nine: Fix setting of the shift modifier in nine_shader

It is an sint_4, but it was stored in a uint_8...
The code using it was acting as if it was signed.

Problem found thanks to Coverity

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
st/nine: Rework queries

From this moment we should handle errors same way as Wine does.

Original patch from John Ettedgui <john.ettedgui@gmail.com>

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
st/nine: Handle queries not supported by the driver

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
st/nine: return S_FALSE instead of INVALIDCALL when in building query state

It is the same behaviour as wine has.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>