Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_codegen.c:
- if (instr->type != HLSL_IR_EXPR)
return false;
- expr = hlsl_ir_expr(instr);
- if (expr->op != HLSL_OP1_CAST)
return false;
- arg = expr->operands[0].node;
- if (instr->data_type->base_type != HLSL_TYPE_INT && instr->data_type->base_type != HLSL_TYPE_UINT)
return false;
- if (arg->data_type->base_type != HLSL_TYPE_FLOAT && arg->data_type->base_type != HLSL_TYPE_HALF)
return false;
- /* Check that the argument is not already a FLOOR */
- if (arg->type == HLSL_IR_EXPR && hlsl_ir_expr(arg)->op == HLSL_OP1_FLOOR)
return false;
It's ok for now, but it would be nice if this would eventually become another optimization pass, so that it covers other cases of double floors (or double whatever other idempotent operation).