void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options);
bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset);
-bool nir_lower_to_source_mods(nir_shader *shader);
+
+typedef enum {
+ nir_lower_int_source_mods = 1 << 0,
+ nir_lower_float_source_mods = 1 << 1,
+ nir_lower_all_source_mods = (1 << 2) - 1
+} nir_lower_to_source_mods_flags;
+
+
+bool nir_lower_to_source_mods(nir_shader *shader, nir_lower_to_source_mods_flags options);
bool nir_lower_gs_intrinsics(nir_shader *shader);
*/
static bool
-nir_lower_to_source_mods_block(nir_block *block)
+nir_lower_to_source_mods_block(nir_block *block,
+ nir_lower_to_source_mods_flags options)
{
bool progress = false;
switch (nir_alu_type_get_base_type(nir_op_infos[alu->op].input_types[i])) {
case nir_type_float:
+ if (!(options & nir_lower_float_source_mods))
+ continue;
if (parent->op != nir_op_fmov)
continue;
break;
case nir_type_int:
+ if (!(options & nir_lower_int_source_mods))
+ continue;
if (parent->op != nir_op_imov)
continue;
break;
progress = true;
}
- switch (alu->op) {
- case nir_op_fsat:
- alu->op = nir_op_fmov;
- alu->dest.saturate = true;
- break;
- case nir_op_ineg:
- alu->op = nir_op_imov;
- alu->src[0].negate = !alu->src[0].negate;
- break;
- case nir_op_fneg:
- alu->op = nir_op_fmov;
- alu->src[0].negate = !alu->src[0].negate;
- break;
- case nir_op_iabs:
- alu->op = nir_op_imov;
- alu->src[0].abs = true;
- alu->src[0].negate = false;
- break;
- case nir_op_fabs:
- alu->op = nir_op_fmov;
- alu->src[0].abs = true;
- alu->src[0].negate = false;
- break;
- default:
- break;
+ if (options & nir_lower_float_source_mods) {
+ switch (alu->op) {
+ case nir_op_fsat:
+ alu->op = nir_op_fmov;
+ alu->dest.saturate = true;
+ break;
+ case nir_op_fneg:
+ alu->op = nir_op_fmov;
+ alu->src[0].negate = !alu->src[0].negate;
+ break;
+ case nir_op_fabs:
+ alu->op = nir_op_fmov;
+ alu->src[0].abs = true;
+ alu->src[0].negate = false;
+ break;
+ default:
+ break;
+ }
}
+ if (options & nir_lower_int_source_mods) {
+ switch (alu->op) {
+ case nir_op_ineg:
+ alu->op = nir_op_imov;
+ alu->src[0].negate = !alu->src[0].negate;
+ break;
+ case nir_op_iabs:
+ alu->op = nir_op_imov;
+ alu->src[0].abs = true;
+ alu->src[0].negate = false;
+ break;
+ default:
+ break;
+ }
+ }
/* We've covered sources. Now we're going to try and saturate the
* destination if we can.
*/
nir_type_float)
continue;
+ if (!(options & nir_lower_float_source_mods))
+ continue;
+
if (!list_empty(&alu->dest.dest.ssa.if_uses))
continue;
}
static bool
-nir_lower_to_source_mods_impl(nir_function_impl *impl)
+nir_lower_to_source_mods_impl(nir_function_impl *impl,
+ nir_lower_to_source_mods_flags options)
{
bool progress = false;
nir_foreach_block(block, impl) {
- progress |= nir_lower_to_source_mods_block(block);
+ progress |= nir_lower_to_source_mods_block(block, options);
}
if (progress)
}
bool
-nir_lower_to_source_mods(nir_shader *shader)
+nir_lower_to_source_mods(nir_shader *shader,
+ nir_lower_to_source_mods_flags options)
{
bool progress = false;
nir_foreach_function(function, shader) {
if (function->impl) {
- progress |= nir_lower_to_source_mods_impl(function->impl);
+ progress |= nir_lower_to_source_mods_impl(function->impl, options);
}
}