driconf: Add a limit_trig_input_range option
With this option enabled range of input values for fsin and fcos is limited to [-2*pi : 2*pi] by calculating the reminder after 2*pi modulo division. This helps to improve calculation precision for large input arguments on Intel. -v2: Add limit_trig_input_range option to prog_key to update shader cache (Lionel) Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16388>
This commit is contained in:

committed by
Marge Bot

parent
0ff3517fb7
commit
55c71217ec
@@ -247,6 +247,13 @@ struct brw_base_prog_key {
|
||||
|
||||
enum brw_subgroup_size_type subgroup_size_type;
|
||||
bool robust_buffer_access;
|
||||
|
||||
/**
|
||||
* Apply workarounds for SIN and COS input range problems.
|
||||
* This limits input range for SIN and COS to [-2p : 2p] to
|
||||
* avoid precision issues.
|
||||
*/
|
||||
bool limit_trig_input_range;
|
||||
struct brw_sampler_prog_key_data tex;
|
||||
};
|
||||
|
||||
|
@@ -1409,6 +1409,9 @@ brw_nir_apply_key(nir_shader *nir,
|
||||
};
|
||||
OPT(nir_lower_subgroups, &subgroups_options);
|
||||
|
||||
if (key->limit_trig_input_range)
|
||||
OPT(brw_nir_limit_trig_input_range_workaround);
|
||||
|
||||
if (progress)
|
||||
brw_nir_optimize(nir, compiler, is_scalar, false);
|
||||
}
|
||||
|
@@ -142,6 +142,8 @@ bool brw_nir_apply_attribute_workarounds(nir_shader *nir,
|
||||
|
||||
bool brw_nir_apply_trig_workarounds(nir_shader *nir);
|
||||
|
||||
bool brw_nir_limit_trig_input_range_workaround(nir_shader *nir);
|
||||
|
||||
void brw_nir_apply_tcs_quads_workaround(nir_shader *nir);
|
||||
|
||||
void brw_nir_apply_key(nir_shader *nir,
|
||||
|
@@ -33,12 +33,17 @@
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from math import pi
|
||||
|
||||
TRIG_WORKAROUNDS = [
|
||||
(('fsin', 'x(is_not_const)'), ('fmul', ('fsin', 'x'), 0.99997)),
|
||||
(('fcos', 'x(is_not_const)'), ('fmul', ('fcos', 'x'), 0.99997)),
|
||||
]
|
||||
|
||||
LIMIT_TRIG_INPUT_RANGE_WORKAROUND = [
|
||||
(('fsin', 'x(is_not_const)'), ('fsin', ('fmod', 'x', 2.0 * pi))),
|
||||
(('fcos', 'x(is_not_const)'), ('fcos', ('fmod', 'x', 2.0 * pi))),
|
||||
]
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -54,6 +59,8 @@ def run():
|
||||
print('#include "brw_nir.h"')
|
||||
print(nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
|
||||
TRIG_WORKAROUNDS).render())
|
||||
print(nir_algebraic.AlgebraicPass("brw_nir_limit_trig_input_range_workaround",
|
||||
LIMIT_TRIG_INPUT_RANGE_WORKAROUND).render())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user