43
50
(('fcos', 'a'), ('fcos', ('ffract', ('fmul', 'a', 1 / (2 * pi))))),
53
# The is a pattern produced by wined3d for A0 register load.
54
# The specific pattern wined3d emits looks like this
55
# A0.x = (int(floor(abs(R0.x) + 0.5) * sign(R0.x)));
56
# however we lower both sign and floor so here we check for the already lowered
58
r300_nir_fuse_fround_d3d9 = [
59
(('fmul', ('fadd', ('fadd', ('fabs', 'a') , 0.5),
60
('fneg', ('ffract', ('fadd', ('fabs', 'a') , 0.5)))),
61
('fadd', ('b2f', ('!flt', 0.0, 'a')),
62
('fneg', ('b2f', ('!flt', 'a', 0.0))))),
47
67
parser = argparse.ArgumentParser()
48
68
parser.add_argument('-p', '--import-path', required=True)
51
71
sys.path.insert(0, args.import_path)
53
73
import nir_algebraic # pylint: disable=import-error
74
ignore_exact = nir_algebraic.ignore_exact
76
r300_nir_lower_bool_to_float = [
77
(('bcsel@32(is_only_used_as_float)', ignore_exact('feq', 'a@32', 'b@32'), c, d),
78
('fadd', ('fmul', c, ('seq', a, b)), ('fsub', d, ('fmul', d, ('seq', a, b)))),
79
"!options->has_fused_comp_and_csel"),
80
(('bcsel@32(is_only_used_as_float)', ignore_exact('fneu', 'a@32', 'b@32'), c, d),
81
('fadd', ('fmul', c, ('sne', a, b)), ('fsub', d, ('fmul', d, ('sne', a, b)))),
82
"!options->has_fused_comp_and_csel"),
83
(('bcsel@32(is_only_used_as_float)', ignore_exact('flt', 'a@32', 'b@32'), c, d),
84
('fadd', ('fmul', c, ('slt', a, b)), ('fsub', d, ('fmul', d, ('slt', a, b)))),
85
"!options->has_fused_comp_and_csel"),
86
(('bcsel@32(is_only_used_as_float)', ignore_exact('fge', 'a@32', 'b@32'), c, d),
87
('fadd', ('fmul', c, ('sge', a, b)), ('fsub', d, ('fmul', d, ('sge', a, b)))),
88
"!options->has_fused_comp_and_csel"),
55
91
with open(args.output, 'w') as f:
56
f.write('#include "r300_vs.h"')
92
f.write('#include "compiler/r300_nir.h"')
58
94
f.write(nir_algebraic.AlgebraicPass("r300_transform_vs_trig_input",
59
95
transform_trig_input_vs_r500).render())
61
97
f.write(nir_algebraic.AlgebraicPass("r300_transform_fs_trig_input",
62
98
transform_trig_input_fs_r500).render())
100
f.write(nir_algebraic.AlgebraicPass("r300_nir_fuse_fround_d3d9",
101
r300_nir_fuse_fround_d3d9).render())
103
f.write(nir_algebraic.AlgebraicPass("r300_nir_lower_bool_to_float",
104
r300_nir_lower_bool_to_float).render())
65
106
if __name__ == '__main__':