mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
nir/normalize_cubemap_coords: Handle the projector before the normalization
Applying the projector after the normalization breaks the coordinates, so
apply it early. Usually it's not even necessary for the cubemaps anyway,
but ARB_fragment_program and TGSI allow it.
Fixes: 52e71809 ("nir: Add a cubemap normalizing pass")
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39087>
This commit is contained in:
parent
84f294395e
commit
f3eb98ec57
1 changed files with 9 additions and 0 deletions
|
|
@ -43,6 +43,15 @@ normalize_cubemap_coords(nir_builder *b, nir_tex_instr *tex, void *data)
|
|||
nir_def *orig_coord = tex->src[idx].src.ssa;
|
||||
assert(orig_coord->num_components >= 3);
|
||||
|
||||
/* Handle the projection first, as applying it after the normalization
|
||||
* will give incorrect results.
|
||||
*/
|
||||
nir_def *proj = nir_steal_tex_src(tex, nir_tex_src_projector);
|
||||
if (proj) {
|
||||
nir_def *inv_proj = nir_frcp(b, proj);
|
||||
orig_coord = nir_fmul(b, orig_coord, inv_proj);
|
||||
}
|
||||
|
||||
nir_def *orig_xyz = nir_trim_vector(b, orig_coord, 3);
|
||||
nir_def *norm = nir_fmax_abs_vec_comp(b, orig_xyz);
|
||||
nir_def *normalized = nir_fmul(b, orig_coord, nir_frcp(b, norm));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue