nir: Add nir_lower_dsign as 64-bit fsign lowering.
Right now some drivers are doing dsign lowering in GLSL and haven't had to have a NIR path due to there not being a corresponding vulkan driver. We want this in NIR now so that we can retire that batch of GLSL lowering code. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25777>
This commit is contained in:
@@ -3471,7 +3471,8 @@ typedef enum {
|
||||
nir_lower_dmod = (1 << 8),
|
||||
nir_lower_dsub = (1 << 9),
|
||||
nir_lower_ddiv = (1 << 10),
|
||||
nir_lower_fp64_full_software = (1 << 11),
|
||||
nir_lower_dsign = (1 << 11),
|
||||
nir_lower_fp64_full_software = (1 << 12),
|
||||
} nir_lower_doubles_options;
|
||||
|
||||
typedef enum {
|
||||
|
@@ -921,6 +921,10 @@ optimizations.extend([
|
||||
|
||||
# Float sizes
|
||||
for s in [16, 32, 64]:
|
||||
if s == 64:
|
||||
match_fsign_cond = "!options->lower_fsign & !(options->lower_doubles_options & nir_lower_dsign)"
|
||||
else:
|
||||
match_fsign_cond = "!options->lower_fsign"
|
||||
optimizations.extend([
|
||||
# These derive from the previous patterns with the application of b < 0 <=>
|
||||
# 0 < -b. The transformation should be applied if either comparison is
|
||||
@@ -979,8 +983,8 @@ for s in [16, 32, 64]:
|
||||
(('~f2u{}'.format(s), ('i2f', 'a@{}'.format(s))), a),
|
||||
(('~f2u{}'.format(s), ('u2f', 'a@{}'.format(s))), a),
|
||||
|
||||
(('fadd', ('b2f{}'.format(s), ('flt', 0.0, 'a@{}'.format(s))), ('fneg', ('b2f{}'.format(s), ('flt', 'a@{}'.format(s), 0.0)))), ('fsign', a), '!options->lower_fsign'),
|
||||
(('iadd', ('b2i{}'.format(s), ('flt', 0, 'a@{}'.format(s))), ('ineg', ('b2i{}'.format(s), ('flt', 'a@{}'.format(s), 0)))), ('f2i{}'.format(s), ('fsign', a)), '!options->lower_fsign'),
|
||||
(('fadd', ('b2f{}'.format(s), ('flt', 0.0, 'a@{}'.format(s))), ('fneg', ('b2f{}'.format(s), ('flt', 'a@{}'.format(s), 0.0)))), ('fsign', a), match_fsign_cond),
|
||||
(('iadd', ('b2i{}'.format(s), ('flt', 0, 'a@{}'.format(s))), ('ineg', ('b2i{}'.format(s), ('flt', 'a@{}'.format(s), 0)))), ('f2i{}'.format(s), ('fsign', a)), match_fsign_cond),
|
||||
|
||||
# float? -> float? -> floatS ==> float? -> floatS
|
||||
(('~f2f{}'.format(s), ('f2f', a)), ('f2f{}'.format(s), a)),
|
||||
@@ -2217,6 +2221,7 @@ optimizations.extend([
|
||||
# Mark the new comparisons precise to prevent them being changed to 'a !=
|
||||
# 0' or 'a == 0'.
|
||||
(('fsign', a), ('fsub', ('b2f', ('!flt', 0.0, a)), ('b2f', ('!flt', a, 0.0))), 'options->lower_fsign'),
|
||||
(('fsign', 'a@64'), ('fsub', ('b2f', ('!flt', 0.0, a)), ('b2f', ('!flt', a, 0.0))), 'options->lower_doubles_options & nir_lower_dsign'),
|
||||
|
||||
# Address/offset calculations:
|
||||
# Drivers supporting imul24 should use the nir_lower_amul() pass, this
|
||||
|
@@ -752,7 +752,7 @@ vgpu10_get_shader_param(struct pipe_screen *screen,
|
||||
.use_interpolated_input_intrinsics = true
|
||||
|
||||
#define VGPU10_OPTIONS \
|
||||
.lower_doubles_options = nir_lower_dfloor, \
|
||||
.lower_doubles_options = nir_lower_dfloor | nir_lower_dsign, \
|
||||
.lower_fmod = true, \
|
||||
.lower_fpow = true
|
||||
|
||||
|
Reference in New Issue
Block a user