VarAction2: Add extra DSG flag for early exit when executing CBs
For when some branches of a non CB switch DSG contain CB switches, but some don't and so would end up on the graphics chain, as there is no further CB switch to exit at
This commit is contained in:
@@ -2647,7 +2647,7 @@ void OptimiseVarAction2DeterministicSpriteGroup(VarAction2OptimiseState &state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sg != nullptr && sg->type == SGT_CALLBACK) {
|
if (sg != nullptr && sg->type == SGT_CALLBACK) {
|
||||||
if (!state.ignore_cb_handler) {
|
if (!state.ignore_cb_handler && static_cast<const CallbackResultSpriteGroup*>(sg)->result != CALLBACK_FAILED) {
|
||||||
group->dsg_flags |= DSGF_CB_RESULT;
|
group->dsg_flags |= DSGF_CB_RESULT;
|
||||||
state.have_cb_handler = true;
|
state.have_cb_handler = true;
|
||||||
}
|
}
|
||||||
@@ -2698,6 +2698,10 @@ void OptimiseVarAction2DeterministicSpriteGroup(VarAction2OptimiseState &state,
|
|||||||
}
|
}
|
||||||
if (possible_callback_handler) group->dsg_flags |= DSGF_CB_HANDLER;
|
if (possible_callback_handler) group->dsg_flags |= DSGF_CB_HANDLER;
|
||||||
|
|
||||||
|
if ((group->dsg_flags & (DSGF_CB_HANDLER | DSGF_CB_RESULT)) == 0) {
|
||||||
|
group->sg_flags |= SGF_SKIP_CB;
|
||||||
|
}
|
||||||
|
|
||||||
if (!HasGrfOptimiserFlag(NGOF_NO_OPT_VARACT2_GROUP_PRUNE) && group->ranges.empty() && !group->calculated_result && !seen_req_var1C) {
|
if (!HasGrfOptimiserFlag(NGOF_NO_OPT_VARACT2_GROUP_PRUNE) && group->ranges.empty() && !group->calculated_result && !seen_req_var1C) {
|
||||||
/* There is only one option, remove any redundant adjustments when the result will be ignored anyway */
|
/* There is only one option, remove any redundant adjustments when the result will be ignored anyway */
|
||||||
while (!group->adjusts.empty()) {
|
while (!group->adjusts.empty()) {
|
||||||
|
@@ -253,6 +253,11 @@ static bool RangeHighComparator(const DeterministicSpriteGroupRange& range, uint
|
|||||||
|
|
||||||
const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) const
|
const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) const
|
||||||
{
|
{
|
||||||
|
if ((this->sg_flags & SGF_SKIP_CB) != 0 && object.callback > 1) {
|
||||||
|
static CallbackResultSpriteGroup cbfail(CALLBACK_FAILED);
|
||||||
|
return &cbfail;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 last_value = 0;
|
uint32 last_value = 0;
|
||||||
uint32 value = 0;
|
uint32 value = 0;
|
||||||
|
|
||||||
@@ -615,6 +620,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi
|
|||||||
|
|
||||||
char extra_info[64] = "";
|
char extra_info[64] = "";
|
||||||
if (sg->sg_flags & SGF_ACTION6) strecat(extra_info, " (action 6 modified)", lastof(extra_info));
|
if (sg->sg_flags & SGF_ACTION6) strecat(extra_info, " (action 6 modified)", lastof(extra_info));
|
||||||
|
if (sg->sg_flags & SGF_SKIP_CB) strecat(extra_info, " (skip CB)", lastof(extra_info));
|
||||||
if (HasBit(_misc_debug_flags, MDF_NEWGRF_SG_DUMP_MORE_DETAIL)) {
|
if (HasBit(_misc_debug_flags, MDF_NEWGRF_SG_DUMP_MORE_DETAIL)) {
|
||||||
if (sg->sg_flags & SGF_INLINING) strecat(extra_info, " (inlining)", lastof(extra_info));
|
if (sg->sg_flags & SGF_INLINING) strecat(extra_info, " (inlining)", lastof(extra_info));
|
||||||
}
|
}
|
||||||
|
@@ -63,6 +63,7 @@ enum SpriteGroupFlags : uint8 {
|
|||||||
SGF_NONE = 0,
|
SGF_NONE = 0,
|
||||||
SGF_ACTION6 = 1 << 0,
|
SGF_ACTION6 = 1 << 0,
|
||||||
SGF_INLINING = 1 << 1,
|
SGF_INLINING = 1 << 1,
|
||||||
|
SGF_SKIP_CB = 1 << 2,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(SpriteGroupFlags)
|
DECLARE_ENUM_AS_BIT_SET(SpriteGroupFlags)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user