radeonsi: restrict cube map derivative computations to the correct plane
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 10 Jan 2017 10:47:22 +0000 (11:47 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 12 Jan 2017 23:38:59 +0000 (00:38 +0100)
commit205ad5234af5a3a5dd6f584b0814cd5a9ce7f10c
treea92fed4c34c9366a74955cde9892fba165925ffb
parente01deee42f1a7b939be15e96f9a037145d570c62
radeonsi: restrict cube map derivative computations to the correct plane

As remarked by the comment in the original code, the old algorithm fails when
(tc + deriv) points at a different cube face. Instead, simply project the
derivative directly to the plane of the selected cube face.

The new code is based on exactly differentiating (using the chain rule)
the projection onto a plane corresponding to a fixed cube map face (which
is still selected in the usual way based on the texture coordinate itself).
The computations end up fairly involved, but we do save two reciprocal
computations.

Fixes GL45-CTS.texture_cube_map_array.sampling.

v2: add 0.5 offset to tex coords only after derivative calculation
v3: go back to 1.5 offset

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> (v2)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c