|
|
@ -9,15 +9,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "debug_fmt.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "sound/sound_driver.hpp"
|
|
|
|
#include "sound/sound_driver.hpp"
|
|
|
|
#include "music/music_driver.hpp"
|
|
|
|
#include "music/music_driver.hpp"
|
|
|
|
#include "video/video_driver.hpp"
|
|
|
|
#include "video/video_driver.hpp"
|
|
|
|
#include "string_func.h"
|
|
|
|
#include "string_func.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
|
|
#include "fileio_func.h"
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
# include <windows.h>
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# include <unistd.h>
|
|
|
|
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
|
|
|
|
#include "safeguards.h"
|
|
|
|
#include "safeguards.h"
|
|
|
|
|
|
|
|
|
|
|
|
std::string _ini_videodriver; ///< The video driver a stored in the configuration file.
|
|
|
|
std::string _ini_videodriver; ///< The video driver a stored in the configuration file.
|
|
|
@ -32,6 +40,8 @@ std::string _ini_musicdriver; ///< The music driver a stored in the confi
|
|
|
|
std::string _ini_blitter; ///< The blitter as stored in the configuration file.
|
|
|
|
std::string _ini_blitter; ///< The blitter as stored in the configuration file.
|
|
|
|
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
|
|
|
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const std::string HWACCELERATION_TEST_FILE = "hwaccel.dat"; ///< Filename to test if we crashed last time we tried to use hardware acceleration.
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get a string parameter the list of parameters.
|
|
|
|
* Get a string parameter the list of parameters.
|
|
|
|
* @param parm The parameters.
|
|
|
|
* @param parm The parameters.
|
|
|
@ -114,6 +124,27 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
|
|
|
|
|
|
|
|
|
|
|
|
if (type == Driver::DT_VIDEO && !_video_hw_accel && d->UsesHardwareAcceleration()) continue;
|
|
|
|
if (type == Driver::DT_VIDEO && !_video_hw_accel && d->UsesHardwareAcceleration()) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) {
|
|
|
|
|
|
|
|
/* Check if we have already tried this driver in last run.
|
|
|
|
|
|
|
|
* If it is here, it most likely means we crashed. So skip
|
|
|
|
|
|
|
|
* hardware acceleration. */
|
|
|
|
|
|
|
|
auto filename = FioFindFullPath(BASE_DIR, HWACCELERATION_TEST_FILE);
|
|
|
|
|
|
|
|
if (!filename.empty()) {
|
|
|
|
|
|
|
|
unlink(filename.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debug(driver, 1, "Probing {} driver '{}' skipped due to earlier crash", GetDriverTypeName(type), d->name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_video_hw_accel = false;
|
|
|
|
|
|
|
|
ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_HARDWARE_ACCELERATION_CRASH, true);
|
|
|
|
|
|
|
|
ScheduleErrorMessage(msg);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Write empty file to note we are attempting hardware acceleration. */
|
|
|
|
|
|
|
|
auto f = FioFOpenFile(HWACCELERATION_TEST_FILE, "w", BASE_DIR);
|
|
|
|
|
|
|
|
FioFCloseFile(f);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Driver *oldd = *GetActiveDriver(type);
|
|
|
|
Driver *oldd = *GetActiveDriver(type);
|
|
|
|
Driver *newd = d->CreateInstance();
|
|
|
|
Driver *newd = d->CreateInstance();
|
|
|
|
*GetActiveDriver(type) = newd;
|
|
|
|
*GetActiveDriver(type) = newd;
|
|
|
@ -131,7 +162,7 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
|
|
|
|
|
|
|
|
|
|
|
|
if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) {
|
|
|
|
if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) {
|
|
|
|
_video_hw_accel = false;
|
|
|
|
_video_hw_accel = false;
|
|
|
|
ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION);
|
|
|
|
ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION, true);
|
|
|
|
ScheduleErrorMessage(msg);
|
|
|
|
ScheduleErrorMessage(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -177,6 +208,18 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Mark the current video driver as operational.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DriverFactoryBase::MarkVideoDriverOperational()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* As part of the detection whether the GPU driver crashes the game,
|
|
|
|
|
|
|
|
* and as we are operational now, remove the hardware acceleration
|
|
|
|
|
|
|
|
* test-file. */
|
|
|
|
|
|
|
|
auto filename = FioFindFullPath(BASE_DIR, HWACCELERATION_TEST_FILE);
|
|
|
|
|
|
|
|
if (!filename.empty()) unlink(filename.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Build a human readable list of available drivers, grouped by type.
|
|
|
|
* Build a human readable list of available drivers, grouped by type.
|
|
|
|
* @param p The buffer to write to.
|
|
|
|
* @param p The buffer to write to.
|
|
|
|