mirror of https://github.com/OpenTTD/OpenTTD
(svn r26217) -Change: blitter autoselection based on full animation state, so the non-animated optimizations can actually be used in an easy manner (based on patch by MJP)
parent
1d4565a666
commit
f480c5a623
|
@ -137,6 +137,7 @@ void SetDirtyBlocks(int left, int top, int right, int bottom);
|
||||||
void MarkWholeScreenDirty();
|
void MarkWholeScreenDirty();
|
||||||
|
|
||||||
void GfxInitPalettes();
|
void GfxInitPalettes();
|
||||||
|
void CheckBlitter();
|
||||||
|
|
||||||
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
|
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "3rdparty/md5/md5.h"
|
#include "3rdparty/md5/md5.h"
|
||||||
#include "fontcache.h"
|
#include "fontcache.h"
|
||||||
#include "gfx_func.h"
|
#include "gfx_func.h"
|
||||||
|
#include "transparency.h"
|
||||||
#include "blitter/factory.hpp"
|
#include "blitter/factory.hpp"
|
||||||
#include "video/video_driver.hpp"
|
#include "video/video_driver.hpp"
|
||||||
|
|
||||||
|
@ -225,14 +226,15 @@ static void LoadSpriteTables()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check blitter needed by NewGRF config and switch if needed.
|
* Check blitter needed by NewGRF config and switch if needed.
|
||||||
|
* @return False when nothing changed, true otherwise.
|
||||||
*/
|
*/
|
||||||
static void SwitchNewGRFBlitter()
|
static bool SwitchNewGRFBlitter()
|
||||||
{
|
{
|
||||||
/* Never switch if the blitter was specified by the user. */
|
/* Never switch if the blitter was specified by the user. */
|
||||||
if (!_blitter_autodetected) return;
|
if (!_blitter_autodetected) return false;
|
||||||
|
|
||||||
/* Null driver => dedicated server => do nothing. */
|
/* Null driver => dedicated server => do nothing. */
|
||||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return;
|
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return false;
|
||||||
|
|
||||||
/* Get preferred depth. */
|
/* Get preferred depth. */
|
||||||
uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
|
uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
|
||||||
|
@ -245,23 +247,32 @@ static void SwitchNewGRFBlitter()
|
||||||
/* Search the best blitter. */
|
/* Search the best blitter. */
|
||||||
struct {
|
struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
uint animation; ///< 0: no support, 1: do support, 2: both
|
||||||
uint min_base_depth, max_base_depth, min_grf_depth, max_grf_depth;
|
uint min_base_depth, max_base_depth, min_grf_depth, max_grf_depth;
|
||||||
} replacement_blitters[] = {
|
} replacement_blitters[] = {
|
||||||
#ifdef WITH_SSE
|
#ifdef WITH_SSE
|
||||||
{ "32bpp-sse4-anim", 32, 32, 8, 32 },
|
{ "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
|
#endif
|
||||||
{ "8bpp-optimized", 8, 8, 8, 8 },
|
{ "8bpp-optimized", 2, 8, 8, 8, 8 },
|
||||||
{ "32bpp-anim", 8, 32, 8, 32 },
|
{ "32bpp-optimized", 0, 8, 32, 8, 32 },
|
||||||
|
{ "32bpp-anim", 1, 8, 32, 8, 32 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
|
||||||
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
|
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
|
||||||
|
|
||||||
for (uint i = 0; i < lengthof(replacement_blitters); i++) {
|
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;
|
||||||
|
|
||||||
if (!IsInsideMM(depth_wanted_by_base, replacement_blitters[i].min_base_depth, replacement_blitters[i].max_base_depth + 1)) continue;
|
if (!IsInsideMM(depth_wanted_by_base, replacement_blitters[i].min_base_depth, replacement_blitters[i].max_base_depth + 1)) continue;
|
||||||
if (!IsInsideMM(depth_wanted_by_grf, replacement_blitters[i].min_grf_depth, replacement_blitters[i].max_grf_depth + 1)) continue;
|
if (!IsInsideMM(depth_wanted_by_grf, replacement_blitters[i].min_grf_depth, replacement_blitters[i].max_grf_depth + 1)) continue;
|
||||||
const char *repl_blitter = replacement_blitters[i].name;
|
const char *repl_blitter = replacement_blitters[i].name;
|
||||||
|
|
||||||
if (strcmp(repl_blitter, cur_blitter) == 0) return;
|
if (strcmp(repl_blitter, cur_blitter) == 0) return false;
|
||||||
if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
|
if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
|
||||||
|
|
||||||
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
||||||
|
@ -275,6 +286,17 @@ static void SwitchNewGRFBlitter()
|
||||||
/* Failed to switch blitter, let's hope we can return to the old one. */
|
/* Failed to switch blitter, let's hope we can return to the old one. */
|
||||||
if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !_video_driver->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !_video_driver->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check whether we still use the right blitter, or use another (better) one. */
|
||||||
|
void CheckBlitter()
|
||||||
|
{
|
||||||
|
if (!SwitchNewGRFBlitter()) return;
|
||||||
|
|
||||||
|
ClearFontCache();
|
||||||
|
GfxClearSpriteCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialise and load all the sprites. */
|
/** Initialise and load all the sprites. */
|
||||||
|
|
|
@ -351,7 +351,7 @@ static CallBackFunction MenuClickSettings(int index)
|
||||||
ToggleBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
ToggleBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
||||||
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
|
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
|
||||||
break;
|
break;
|
||||||
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); break;
|
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
|
||||||
case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
|
case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
|
||||||
case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
|
case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
|
||||||
case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
|
case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
|
||||||
|
|
Loading…
Reference in New Issue