Commit Graph

85639 Commits

Author SHA1 Message Date
Axel Davy 732cea09cd st/nine: Disable parts of lighting calculation if no normal provided
Behaviour found in Wine sources, and checked with some test apps.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy fc9bb19dce st/nine: Fix condition for specular lightning
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy c56c7c1fc8 st/nine: Do always accumulate diffuse
According to spec.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy c5bce80f50 st/nine: Initialize ps ff registers
Found with wine tests for the rTmp register.
Not sure for the other ones.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 4ed3d5ee57 st/nine: Do not pollute rTmp in ff ps
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy d9b8b3196e st/nine: Allocate temporaries on demand for ps ff
Same change than for vs ff.
This makes it easier to not introduce mistakes
reusing temporaries whose result shouldn't be
erased.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy f7dd27aed3 st/nine: Fix texbem
Error found with wine tests.
nine_shader was expecting another order
than the one device9 was using.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy 7afcbb49ba st/nine: Fix ff computation for inverse
Thanks to wine tests.
Apparently 4x4 inverse is to be used, and
if the inverse can't be calculated, the
input matrix is to be used.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 36399f9a7f st/nine: Used normed Vtx for reflectionvector
Fix deduced from the spec.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy eda1e6ece7 st/nine: Implement SPHEREMAP
Behaviour checked with a test app.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy a3ddc80ec8 st/nine: Enable passthrough only if positiont is used
Wine tests for the passthrough feature are for positiont.

Nothing seems to indicate passthrough happens when positiont
it not used. However having passthrough with positiont makes
sense (to be used with ProcessVertices outputs).

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 0b5bed774b st/nine: Fix wrong mask in ff vs
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy 028dab95f6 st/nine: Fix tweening factor computation
The computation was reversed.
Deduced by tests on windows.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 1fe055338d st/nine: Disable ff vertex blending if required inputs are missing
This behaviour has been partially tested on windows.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy aa69bb6848 st/nine: Use materials if source is not given.
Deduced by test on windows.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy ab068a78d3 st/nine: Fix ff SPECULARENABLE
We were (wrongly) adding specular to diffuse
in vertex shaders when SPECULARENABLE was set.

However the spec says specular has to be added
after texture processing (which is in ps).
Besides SPECULARENABLE is flagged as a pixel state.

There was unused support for SPECULARENABLE
in the ps ff code.
Remove the vs code, and use the ps code.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 1d7890a441 st/nine: Undefined specular should be full of zeros
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy d9330f9348 st/nine: Implement normal transformation with vertex blending
The formula is different from the one of the spec,
but otherwise nothing particular.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 305e8106ab st/nine: Increase MaxVertexBlendMatrixIndex
Modern cards do advertise 8.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 567be40de9 st/nine: Compact ff vs constants a bit
There are several holes. This patch reduces
the holes a bit, which reduces the size of
the constant buffer uploaded.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 07d1f32e0f st/nine: Fix vertex blending aVtx computation
There was an multiplication by the world matrix 0
which had nothing to do there.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy d9d8cb9f19 st/nine: Reorganize ff vtx processing
The new order simplified the code a bit for
next patches.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy cde74cba71 st/nine: Small simplification for position_t and fog
position_t disables fog computation.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 5d2a8e8a36 st/nine: Cleaning code for vs temporaries
This has been a real mess up to now: the temporaries
were allocated once, and shared after that between
the different parts of the code.

To help maintaining the code, the temporaries are now
allocated and released on need.

As surprising as it could be, this patch, which was
supposed to introduce no behaviour change, actually
solved a visual bug observed on a sample program.
This was due to ureg_normalize3 polluting a temporary
variable.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 1f18b6f351 st/nine: No need for the local flag for temporaries in ff
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy eb9ad8f969 st/nine: Handle D3DRS_NORMALIZENORMALS
When this state is set, the normals computed
in the vs ff shader should be normalized.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:50 +02:00
Axel Davy b9639c661f st/nine: Initial ProcessVertices support
For now only VS 3 support is implemented.

This enables The Sims 2 to work.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:50 +02:00
Axel Davy 3bf02d383f st/nine: Partial software vertex processing support
Software Vertex Processing allows:
. Less limitations for shaders (more loops, etc)
. Less limitations for ff (more enabled lights, 255
matrices for VertexBlend)

In particular shaders can get more constants.
This patch implements support for this (not using software
rendering, but hardware rendering, as llvmpipe and dx10+ hw
have the same limits...)

This is considered a second class path. Even apps asking for
"Mixed Vertex processing" (ie the ability to switch to swvp
on demand) do not use the feature much. Some just initialize
more constants than the normal limit at the start of the
application, but never use more than the normal limit.
When the apps do not need the software vertex processing
features, they do not seem to turn it on. This means it is
ok if that path is slow.
Thus no care has been made to make the path optimized.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy f8c8f44244 st/nine: Rework vs int and bool constants buffer
This will help to support swvp constants.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy a83dce0128 st/nine: Change dirty tracking for vs int and bool constants
This change makes easier to introduce tracking for
swvp constants.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy f78089b962 st/nine: Drop unused constant upload path
This path has been disabled for some time because
of some bugs with it. It hasn't been updated to the
new features, and is not faster.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:49 +02:00
Axel Davy 1604efa6fd st/nine: Add support for swvp constants in shaders
swvp has relaxed limits (more nested loops, etc).
In particular it enables more constants.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy 56ea3df7d4 st/nine: Initial mixed vertex processing support
In mixed vertex processing, the user can enable or disable
software vertex processing. It is on hardware by default.

This feature is not a state, and thus the setting doesn't
need to be recorded by stateblocks.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy 747f1ef8b6 st/nine: Implement SetNPatchMode
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy ded7a73eb3 st/nine: Implement D3DUSAGE_SOFTWAREPROCESSING
Buffers with this flag must be usable with both software
and hardware vertex processing. Use Staging for fast cpu access.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
2016-10-10 23:43:49 +02:00
Patrick Rudolph 19703f2a36 st/nine: Allocate more space for ATI1
ATIx are "unknown" formats that do not follow block format conventions.
Tests showed that pitch*height bytes are allocated.
apitrace used to depend on this behaviour.
It used to copy more bytes than it has to for the ATI1 block format,
but it didn't crash on Windows.

Increase buffersize for ATI1 to fix this crash.
The same issue was present in WINE but a patch has been sent by me.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Patrick Rudolph ec6c636722 st/nine: Add missing break
Add missing break instruction.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy 03f60a3357 st/nine: Implement relative addressing for ps inputs
To implement the feature we copy the ps inputs to a temp array.
This is not optimal for performance, but it is the simplest solution.

This is a feature that is very very rarely used.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy a5d308e51a st/nine: Wait for pending tasks to execute in swapchain
Fixes crash after Reset() when using thread_submit=true

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy f090705075 st/nine: Use fixed size arrays for swapchain buffers
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Patrick Rudolph a719800cb8 st/nine: Fix buffer count check for Ex devices
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy 9ff0dc3129 st/nine: Disable seamless cubemap for d3d
d3d9 doesn't have seamless cubemap.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy f0ec54ee32 st/nine: Fix some check flags
Uses the new defines introduced in previous commit.
See comment in the commit for more explanation.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:49 +02:00
Axel Davy 39e98d351f st/nine: Unify some check flags
The new defines will be reused in a later patch.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-10-10 23:43:48 +02:00
Axel Davy 2290eac84e gallium/util: Really allow aliasing of dst for u_box_union_*
Gallium nine relies on aliasing to work with this function.
Without this patch, dirty region tracking was incorrect, which
could lead to incorrect textures or vertex buffers.
Fixes several game bugs with nine.
Fixes https://github.com/iXit/Mesa-3D/issues/234

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
2016-10-10 23:43:48 +02:00
Axel Davy 5e7f0ebe29 softpipe: Cap to 2 GB on 32 bits
On 32 bits system, application memory is quite limited.
softpipe uses application memory. To help prevent memory
exhaustion, limit reported memory availability to 2GB.

Some gallium nine apps do check reported memory by allocating
resources until memory is full. Gallium nine refuses allocations
when 80% of the reported memory limit is used. This change
helps some apps to start.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2016-10-10 23:43:48 +02:00
Axel Davy 814ca96d0d llvmpipe: Cap to 2 GB on 32 bits
On 32 bits system, application memory is quite limited.
llvmpipe uses application memory. To help prevent memory
exhaustion, limit reported memory availability to 2GB.

Some gallium nine apps do check reported memory by allocating
resources until memory is full. Gallium nine refuses allocations
when 80% of the reported memory limit is used. This change
helps some apps to start.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
2016-10-10 23:43:48 +02:00
Axel Davy 218459771a gallium/os: Fix overflow on 32 bits
On systems with more than 4GB of ram,
os_get_total_physical_memory was triggering an integer
overflow for the linux and haiku path, when on
32 bits.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94561

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2016-10-10 23:43:48 +02:00
Axel Davy 9904581dc6 st/nine: Memset pipe_resource templates
Fixes regression introduced by
ecd6fce261
and is more future proof than just clearing the next
field.

Other nine usages did already zero out the templates.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Acked-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2016-10-10 23:43:48 +02:00
Samuel Pitoiset d43151318a nvc0: fix valid range for shader buffers
When offset != 0, the valid range was wrong because the second
argument of util_range_add() is end, not size.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
2016-10-10 21:32:16 +02:00