Skip to content

Commit

Permalink
Bugfix for draw command merging
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyGaul committed Oct 22, 2024
1 parent c76e683 commit 47a2091
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/cute_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2778,35 +2778,33 @@ static void s_process_command(CF_Canvas canvas, CF_Command* cmd, CF_Command* nex
}

// Merge with the next command if identical.
bool same = true;
if (next) {
if (next->u.size != cmd->u.size) {
return;
}
if (next->u.type != cmd->u.type) {
return;
}
if (next->u.texture.id != cmd->u.texture.id) {
return;
}
if (next->u.name != cmd->u.name) {
return;
}
if (CF_MEMCMP(next->u.data, cmd->u.data, next->u.size)) {
return;
}
if (next->alpha_discard == cmd->alpha_discard &&
same = false;
} else if (next->u.type != cmd->u.type) {
same = false;
} else if (next->u.texture.id != cmd->u.texture.id) {
same = false;
} else if (next->u.name != cmd->u.name) {
same = false;
} else if (CF_MEMCMP(next->u.data, cmd->u.data, next->u.size)) {
same = false;
} else if (next->alpha_discard == cmd->alpha_discard &&
next->render_state == cmd->render_state &&
next->scissor == cmd->scissor &&
next->shader == cmd->shader &&
next->viewport == cmd->viewport) {
return;
same = false;
}
}

// Process the collated drawable items. Might get split up into multiple draw calls depending on
// the atlas compiler.
draw->need_flush = false;
spritebatch_flush(&draw->sb);
if (!same) {
// Process the collated drawable items. Might get split up into multiple draw calls depending on
// the atlas compiler.
draw->need_flush = false;
spritebatch_flush(&draw->sb);
}
}

void cf_render_layers_to(CF_Canvas canvas, int layer_lo, int layer_hi, bool clear)
Expand Down

0 comments on commit 47a2091

Please sign in to comment.