Merge branch 'et_spe2397'

This commit is contained in:
Lukas Matena 2024-08-12 15:48:35 +02:00
commit 56e53828e9
2 changed files with 18 additions and 9 deletions

View File

@ -292,16 +292,16 @@ void GCodeProcessor::TimeMachine::calculate_time(GCodeProcessorResult& result, P
assert(keep_last_n_blocks <= blocks.size());
// forward_pass
for (size_t i = 0; i + 1 < blocks.size(); ++i) {
planner_forward_pass_kernel(blocks[i], blocks[i + 1]);
}
// reverse_pass
for (int i = static_cast<int>(blocks.size()) - 1; i > 0; --i) {
planner_reverse_pass_kernel(blocks[i - 1], blocks[i]);
}
// forward_pass
for (size_t i = 0; i + 1 < blocks.size(); ++i) {
planner_forward_pass_kernel(blocks[i], blocks[i + 1]);
}
recalculate_trapezoids(blocks);
const size_t n_blocks_process = blocks.size() - keep_last_n_blocks;
@ -2730,8 +2730,9 @@ void GCodeProcessor::process_G1(const std::array<std::optional<double>, 4>& axes
for (unsigned char a = X; a <= E; ++a) {
const float axis_max_acceleration = get_axis_max_acceleration(static_cast<PrintEstimatedStatistics::ETimeMode>(i), static_cast<Axis>(a));
if (acceleration * std::abs(delta_pos[a]) * inv_distance > axis_max_acceleration)
acceleration = axis_max_acceleration;
const float scale = std::abs(delta_pos[a]) * inv_distance;
if (acceleration * scale > axis_max_acceleration)
acceleration = axis_max_acceleration / scale;
}
block.acceleration = acceleration;

View File

@ -367,8 +367,16 @@ namespace Slic3r {
struct Planner
{
// Size of the firmware planner queue. The old 8-bit Marlins usually just managed 16 trapezoidal blocks.
// Let's be conservative and plan for newer boards with more memory.
static constexpr size_t queue_size = 64;
// ! WARNING !
// The previous implementation:
// Let's be conservative and plan for newer boards with more memory.
// static constexpr size_t queue_size = 64;
// was generating artifacts, see: https://dev.prusa3d.com/browse/SPE-2397 because the time blocks shared by two consecutive batches
// may end up being processed multiple times, giving rise to discontinuities.
// Keeping all the time blocks in memory may result in a huge buffer (i.e. greater than 1GB for huge slices), so we set an arbitrary
// batch size of around 128MB.
// This should result in a reduced number of artifacts visible only for objects whose buffers exceed this size.
static constexpr size_t queue_size = 32 * 1024 * 1024 / sizeof(TimeBlock);
// The firmware recalculates last planner_queue_size trapezoidal blocks each time a new block is added.
// We are not simulating the firmware exactly, we calculate a sequence of blocks once a reasonable number of blocks accumulate.
static constexpr size_t refresh_threshold = queue_size * 4;