Commit Graph

72332 Commits

Author SHA1 Message Date
Axel Davy 1a747094ed st/nine: Fix the number of texture stages
The number of texture stages is 8.

'tex_stage' array was too big, and thus
the checks with 'Elements(state->ff.tex_stage)' were passing,
causing some invalid API calls to pass, and crash because of
out of bounds write since bumpmap_vars was just the correct size.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy f15ff98e2c st/nine: Use CSO cache for sampler views
The CSO cache unbinds views that are not needed anymore,
which we don't do.
It checks for change before committing the views.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy 98f786b270 st/nine: Calculate dummy sampler state only once
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy f5effeb8ea st/nine: Better check shader constant limits
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy bae2c7c154 st/nine: Remove NINED3DRS_ZBIASSCALE
It wasn't giving the expected result.

This fixes some object being transparents
in games like FEAR.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy 6379a28aa7 st/nine: Implement special DOTPRODUCT3 behaviour
Taken from wine tests

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy 791b794a84 st/nine: Implement ff vertex data passthrough
Fixes Wine tests

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy fb6c76f1ba st/nine: Change nine_state_update order
nine_update_state called every draw call.

This patch attemps to change the order
of the checks to have better control flow

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy 4a00e4cdc9 st/nine: Programmable ps D3DTTSS_PROJECTED support
The implementation used Wine tests for conformance

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy b7261528ea st/nine: Complete ff texture transform implementation
Wine tests were used to get it right.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:48 +02:00
Axel Davy dcb6f764cf st/nine: Change a few advertised caps
There were flags all sm3 cards do advertise,
and we weren't.
Some games can trigger buggy rendering path
if the caps are not what they expect.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy c2480bbab1 st/nine: Advertise Fog flags
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy fcca7ff38a st/nine: Revert to userbuf path when needed
Automatically switch to userbuf path when
we would need to upload fog or bumpmat
constants

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 8f39ffc11e st/nine: Finish Fog implementation
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 69de5d626f st/nine: Rework shader states
Separate state setting and commit
Changes how the shader key is computed

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 854778ea0f st/nine: Remove some useless variables
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: David Heidelberg <david@ixit.cz>
2015-08-21 22:21:47 +02:00
Axel Davy cb0816c0f6 st/nine: Fix nine_ff_ps_key padding
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy dd4802c8de st/nine: Begin programmable shader fog support
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 2dd59a2d28 st/nine: Fix fixed function fog support
Previous code had only a subcase of fog working right.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 87ec6b56b2 st/nine: Rework ff constant buffers
Always use a user constant buffer for ff.
It means we have to:
. commit the user constant buffer for ff when we use it
. commit back the non-ff constant buffer when we stop using it

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 993e68fa6a st/nine: Rework constant buffer state handling
We have two paths:
. One that uses a fixed constant buffer, and updates it when needed
. One that uses a user constant buffer, and uploads it when needed.

This patch separates the preparation of the constant buffer
and the commit.

It also removes NineDevice9_RestoreNonCSOState, which was
used to restore all states. Instead the commit of the constant
buffer is moved to nine_state, and the other field settings
moved to other functions where more appropriate.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy a3f0d21da9 st/nine: Rework blend states
Separate state preparation and state commit

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy b06f3ee6f4 st/nine: Improve fallback when driver doesn't support user buffers.
For now the path updated is only used by Amd drivers, but a later
patch will make it used by all drivers. Some drivers like llvmpipe
doesn't support the uploading of constants from user buffers, so improve
the path to work for all drivers

Inspired from the gl state tracker.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy a7ce3cd0d3 st/nine: Avoid useless updates in SetSamplerState
Check for redundant settings

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: David Heidelberg <david@ixit.cz>
2015-08-21 22:21:47 +02:00
Axel Davy 5a2302b5ec st/nine: Rework rasterizer states
Separate state preparation and state commit

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 71616d0c50 st/nine: Reorder DSA state settings
Separate state preparation and state commit

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 0628553056 st/nine: Reorder nine_state.
Instead of mixing state preparation (filling pipe_****)
and state commit (pipe->set_*****),
begin doing so in two separate functions.

This will allow to implement efficient Stateblocks,
and eventually lead to optimisation where the complete
pipe_*** structure is only partially updated.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:47 +02:00
Axel Davy 99537f68db st/nine: Remove group_mask argument from nine_update_state
It was only used to discriminate update framebuffer vs update
everything. Instead use two functions.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Tiziano Bacocco 360ba5b748 st/nine: Implement TEXBEM,TEXBEML and BEM
Signed-off-by: Tiziano Bacocco <tizbac2@gmail.com>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 620f3e9bfe st/nine: Fix use of uninitialized values
Set all values to 0 after allocation. Found using valgrind.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 248833ff40 st/nine: Prevent possible crash
In case NineBaseTexture9_ctor returns an error
This->surfaces[l] might be NULL.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph bc6c80e547 st/nine: Return correct error codes in NineDevice9_Reset
Allow more than two errors, and return D3DERR_INVALIDCALL
for failed display resolution changes.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph d0a4374e1a st/nine: Fail on D3DUSAGE_DYNAMIC for D3DPOOL_SCRATCH textures
Texture with pool D3DPOOL_SCRATCH and D3DPOOL_MANAGED
cannot be used with flag D3DUSAGE_DYNAMIC.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Axel Davy f396cd43ab st/nine: Fix Lock Checks for Compressed textures
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy d0daec1797 st/nine: Impose restrictions on DXTN texture sizes
This is the expected behaviour.

Fixes wine tests.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: David Heidelberg <david@ixit.cz>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 48d895aa4b st/nine: Return NULL pointer in lock error cases
Tests showed, that in case of errors, the pBits pointer is set to NULL.
The pBits field isn't set to NULL in case of an already locked object.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 74a77a4c1a st/nine: Fix resource SetPriority/GetPriority
Return 0 for non MANAGED textures and surfaces.
Fixes failing wine d3d9 tests device.c test_resource_priority.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 40a8943f53 st/nine: Clean GetPrivateData
Move the assert to return error codes in the correct order.
Always set the pSizeOfData to the required buffer size.
Fixes failing wine test device.c test_private_data()

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph 9ba3f83592 st/nine: Allow lock coordinates outside range
This fixes wine test device.c test_lockrect_invalid()

Mimic WindowsXp behaviour and allow negative values in the rectangle passed.
Add comment to point out behaviour used.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Patrick Rudolph bb1c2c2aa3 st/nine: Fix GenerateMipSubLevels potential crash
For the case of D3DPOOL_MANAGED textures, This->base.resource can be NULL
at the start of the function. In This case, UploadSelf will take care
of the defining. Assign resource after the UploadSelf call
to prevent NULL pointer exception.

Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2015-08-21 22:21:46 +02:00
Axel Davy 3bcab9ba75 st/nine: Fix FillColor Flag check
IT is better check if the surface was created with RT flag,
instead of checking capability (llvmpipe was complaining)

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy ef8ade6f09 st/nine: Fix StretchRect checks
Fixes Wine tests

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy c57f777b09 st/nine: Implement EvictManagedResources
EvictManagedResources is used by apps to free
the gpu memory of MANAGED textures (which have
a cpu memory backing)

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy 4c126f0b58 st/nine: Track managed textures
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy 41f54040e2 st/nine: Only update dirty rect for UpdateTexture
UpdateTexture is supposed to optimise by uploading only for the
dirty region of the source (d3d9 doc, wine tests).
This patch adds the behaviour for surfaces, but not entirely for
volumes.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy 43d5c5a11b st/nine: Textures start dirty
According to the spec all textures start
dirty.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy e139e0debd st/nine: Track dirty region for SYSTEMMEM too
Dirty regions should be tracked for both MANAGED
and SYSTEMMEM.
Until now we didn't bother to track for SYSTEMMEM,
because we hadn't implemented using the dirty region
to avoid some copies

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy 8a61894cdb st/nine: Add missing BASETEX_REGISTER_UPDATE calls
If the texture is bound and dirty_mip is true,
BASETEX_REGISTER_UPDATE adds the texture to the list
of things to update before the next draw call.

Some calls to it were missing.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy e4f69bc394 st/nine: SetAutoGenFilterType should regenerate the sublevels
It should regenerate the sublevels according to the spec

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00
Axel Davy b75f830166 st/nine: Simplify NineVolume9_CopyVolume
We had only one usage for this function.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-08-21 22:21:46 +02:00