Merge remote-tracking branch 'upstream/1.11' into 1.11
This commit is contained in:
@@ -265,11 +265,13 @@ static bool SwitchNewGRFBlitter()
|
||||
* between multiple 32bpp blitters, which perform differently with 8bpp sprites.
|
||||
*/
|
||||
uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
|
||||
uint depth_wanted_by_grf = _support8bpp == S8BPP_NONE ? 32 : 8;
|
||||
uint depth_wanted_by_grf = _support8bpp != S8BPP_NONE ? 8 : 32;
|
||||
for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
|
||||
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_INIT_ONLY)) continue;
|
||||
if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32;
|
||||
}
|
||||
/* We need a 32bpp blitter for font anti-alias. */
|
||||
if (HasAntialiasedFonts()) depth_wanted_by_grf = 32;
|
||||
|
||||
/* Search the best blitter. */
|
||||
static const struct {
|
||||
@@ -277,13 +279,14 @@ static bool SwitchNewGRFBlitter()
|
||||
uint animation; ///< 0: no support, 1: do support, 2: both
|
||||
uint min_base_depth, max_base_depth, min_grf_depth, max_grf_depth;
|
||||
} replacement_blitters[] = {
|
||||
{ "8bpp-optimized", 2, 8, 8, 8, 8 },
|
||||
{ "40bpp-anim", 2, 8, 32, 8, 32 },
|
||||
#ifdef WITH_SSE
|
||||
{ "32bpp-sse4", 0, 32, 32, 8, 32 },
|
||||
{ "32bpp-ssse3", 0, 32, 32, 8, 32 },
|
||||
{ "32bpp-sse2", 0, 32, 32, 8, 32 },
|
||||
{ "32bpp-sse4-anim", 1, 32, 32, 8, 32 },
|
||||
#endif
|
||||
{ "8bpp-optimized", 2, 8, 8, 8, 8 },
|
||||
{ "32bpp-optimized", 0, 8, 32, 8, 32 },
|
||||
#ifdef WITH_SSE
|
||||
{ "32bpp-sse2-anim", 1, 8, 32, 8, 32 },
|
||||
@@ -294,8 +297,6 @@ static bool SwitchNewGRFBlitter()
|
||||
const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
|
||||
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
|
||||
|
||||
VideoDriver::GetInstance()->AcquireBlitterLock();
|
||||
|
||||
for (uint i = 0; i < lengthof(replacement_blitters); i++) {
|
||||
if (animation_wanted && (replacement_blitters[i].animation == 0)) continue;
|
||||
if (!animation_wanted && (replacement_blitters[i].animation == 1)) continue;
|
||||
@@ -305,25 +306,15 @@ static bool SwitchNewGRFBlitter()
|
||||
const char *repl_blitter = replacement_blitters[i].name;
|
||||
|
||||
if (strcmp(repl_blitter, cur_blitter) == 0) {
|
||||
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
||||
return false;
|
||||
}
|
||||
if (BlitterFactory::GetBlitterFactory(repl_blitter) == nullptr) continue;
|
||||
|
||||
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
||||
Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
|
||||
if (new_blitter == nullptr) NOT_REACHED();
|
||||
DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
|
||||
/* Inform the video driver we want to switch blitter as soon as possible. */
|
||||
VideoDriver::GetInstance()->ChangeBlitter(repl_blitter);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
|
||||
/* Failed to switch blitter, let's hope we can return to the old one. */
|
||||
if (BlitterFactory::SelectBlitter(cur_blitter) == nullptr || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
||||
}
|
||||
|
||||
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -343,6 +334,7 @@ void GfxLoadSprites()
|
||||
DEBUG(sprite, 2, "Loading sprite set %d", _settings_game.game_creation.landscape);
|
||||
|
||||
SwitchNewGRFBlitter();
|
||||
VideoDriver::GetInstance()->ClearSystemSprites();
|
||||
ClearFontCache();
|
||||
GfxInitSpriteMem();
|
||||
LoadSpriteTables();
|
||||
|
||||
Reference in New Issue
Block a user