nine: Add state tracker nine for Direct3D9

Work of Joakim Sindholt (zhasha) and Christoph Bumiller (chrisbmr).
v2 Small fixies and sync with latest Mesa by David Heidelberger (okias).
v3 Build improvements by Emil Velikov (xexaxo).
v4 Modified to use directly PIPE_CAP_VIDEO_MEMORY
instead of PIPE_CAP_DEVICE_MEMORY_SIZE.
v5 Merged few small fixes by okias
v6 define to not use indirect drawing
v7 allow D3DLOCK_NOOVERWRITE for LockRect, make Osu game works
v8 build fixes by okias

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: fixed problems with using more buffers than available

Hardcoded value 32 worked on nv50+ and r600, but on radeonsi or
others with <= 16 failed and asserted in debug mode.

Reported-and-tested-by: Nick Sarnie (sarnex) on IRC
Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: deal with D3DFMT_NULL

Fixed CS:GO on r600g.
More information about NULL format here aras-p.info/texts/D3D9GPUHacks.html

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: correctly divide maximum constant numbers

We get from driver number already multiplied by sizeof(float[4]) = 16.
This patch shouldn't affect any modern card with
PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE > 256

Reported-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: get real MaxStreamStride

At this moment, most gallium drivers set 2048.
Wine set default value 1024.

Reported-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: prevent assert on Shader Model 2.0 cards

Fixed r300g and other non-SM3.0 cards.

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: always allocate maximum space for constant registers

On SM3.0 cards (>r600g, nv50+) doesn't matter (always NINE_MAX_CONST_ALL),
but on SM2.0 (r300g) causes segfault even for simplest demos.

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: correct D24 <-> Z24 format conversion

This change behaviour only for transfer_map().
Also fixes Unigine Sanctuary loading on RS690 (r300g).

Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
nine: fix D3DTOP_DOTPRODUCT3

Fixes Dot3 Per-Pixel Bump Mapping sample
http://www.codesampler.com/dx9src/dx9src_4.htm#dx9_dot3_bump_mapping

Wine handle this same way.

Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
Signed-off-by: Tiziano Bacocco <tizbac2@gmail.com>