mesa/src
Axel Davy 133e7ba571 frontend/nine: fix wfog
When wfog support is advertised, unless an orthogonal
projection matrix is detected, w is supposed to be used
instead of z for the fog equation when done in the pixel
shader.

Due to the spec being ambiguous, and tests being incomplete,
it seems we had got things wrong.
New tests confirm the behaviour.

For the explanation we will denote z_vs and w_vs the position
output's z and w channels in the vertex shader, and
z_ps, w_ps the position input z and w channels in the pixel shader.
w_ps = 1/w_vs
z_ps = z_vs/w_vs

In the programmable pixel shader, we used z_ps/w_ps, thus z_vs.
As basically z_vs and w_vs are usually in the same range, we didn't
notice an obvious difference with the correct behaviour.

In the ff pixel shader, we used z_ps for zfog and w_vs else.
z_ps was always used if a programmable vertex shader was detected.
This latter behaviour led to issue
https://gitlab.freedesktop.org/mesa/mesa/-/issues/8341

While using z_ps/w_ps like for programmable ps fixes the issue visually
for the same reason as it did for programmable ps, it breaks
wine tests using XYZRHW. These tests show that when passing
pre-transformed vertices and an orthogonal projection matrix,
z_vs is used, and due to the XYZRHW property, this is not
recovered by the z_ps/w_ps computation (instead z_ps=z_vs).
For the game affected by the issue, the projection matrix set
is not orthogonal.

The direct3D spec indicates that the projection matrix must be
set correctly for fog to work properly, even if we do not use the
transformation pipeline (could be related to xyzrhw, or programmable vs
or both). Previous tests had shown that the projection matrix
has the last two values of the last column tested against 0 and 1,
in order to activate zfog or wfog.
The R500 spec indicates that either z or 1/1/w can be used as source
for the fog computation, but it is not clear whether this is z_vs or
z_ps.

Tests confirmed the intuition that the correct behaviour
is to use z_ps (zfog) when an orthogonal projection matrix is set
(the spec spirit being that in that case z_ps=z_vs),
and 1/w_ps (wfog) else (even if programmable shaders are used).

This patch introduces this behaviour.
Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8341

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22583>
2023-04-22 21:09:07 +00:00
..
amd Revert "ci/radv: Demote navi21 to manual until recent flakiness resolves." 2023-04-21 18:47:14 +00:00
android_stub util/log: improve logger_android 2023-02-22 17:55:40 +00:00
asahi asahi: Add resource debugging 2023-04-07 03:23:04 +00:00
broadcom v3dv/ci: rename waiver test 2023-04-22 19:43:11 +02:00
c11 c11: Remove _MTX_INITIALIZER_NP for windows 2022-11-09 04:38:28 +00:00
compiler spirv: Rework structured control flow handling 2023-04-20 07:02:42 +00:00
drm-shim drm-shim: Use hide_drm_device_path() to hide other drm devices 2022-12-30 15:51:11 -08:00
egl egl: inline driver.GetProcAddress() as it's always _glapi_get_proc_address() 2023-04-19 13:57:59 +00:00
etnaviv ci/etnaviv: Polish the gc2000 xfails a bit. 2023-03-29 07:52:45 +00:00
freedreno freedreno/registers: updte HDMI registers to include CEC details 2023-04-20 06:03:53 +00:00
gallium frontend/nine: fix wfog 2023-04-22 21:09:07 +00:00
gbm gbm: drop unnecessary vulkan dependency 2023-02-23 18:31:22 +00:00
getopt
glx glx: Fix error handling yet again in CreateContextAttribs 2023-04-06 21:29:54 +00:00
gtest
imagination pvr: fix typo in pvr_rt_get_region_headers_stride_size() 2023-04-20 13:17:01 +00:00
imgui
intel anv: rework Wa_14017076903 to only apply with occlusion queries 2023-04-21 12:48:52 +00:00
loader loader: Add Xe KMD support 2023-04-12 10:41:21 +00:00
mapi mesa: Add EXT_instanced_arrays support 2023-04-11 10:22:35 +00:00
mesa mesa: fix ms fallback texture creation 2023-04-21 13:21:46 +00:00
microsoft dzn: Support aniso-with-point-mip samplers 2023-04-20 21:02:15 +00:00
nouveau nv50/ir: ignore CL system values 2023-04-14 07:41:54 +00:00
panfrost pan/va: fix typo in IADD_IMM.i32 description 2023-04-18 19:44:48 +03:00
tool pps: Fix build errors. 2023-03-13 01:22:46 +00:00
util util: Add mesa_blake3 wrappers. 2023-04-22 01:28:38 +00:00
virtio venus: forward ARM driverVersion for ANGLE workarounds 2023-04-11 03:17:56 +00:00
vulkan wsi/x11: Fix present ID signal when IDLE comes before COMPLETE. 2023-04-21 19:15:06 +00:00
meson.build hgl: remove 2023-02-18 00:44:43 +00:00