Skip to content

Commit

Permalink
initial check extended
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Nov 11, 2024
1 parent 2e8f1d6 commit 39f6111
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 42 deletions.
16 changes: 0 additions & 16 deletions source/Base/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,10 @@ class InitialCheckException : public std::runtime_error
{}
};

class CudaException : public std::runtime_error
{
public:
CudaException(std::string const& what)
: std::runtime_error(what.c_str())
{}
};

class CudaMemoryAllocationException : public std::runtime_error
{
public:
CudaMemoryAllocationException(std::string const& what)
: std::runtime_error(what.c_str())
{}
};

class SystemRequirementNotMetException : public std::runtime_error
{
public:
SystemRequirementNotMetException(std::string const& what)
: std::runtime_error(what.c_str())
{}
};
16 changes: 8 additions & 8 deletions source/Base/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ namespace Const
std::string const DiscordURL = "https://discord.gg/7bjyZdXXQ2";
std::string const AlienURL = "alien-project.org";

std::filesystem::path const BasePath = "resources";
std::filesystem::path const ResourcePath = "resources";

std::filesystem::path const LogFilename = "log.txt";
std::filesystem::path const AutosaveFileWithoutPath = "autosave.sim";
std::filesystem::path const AutosaveFile = BasePath / AutosaveFileWithoutPath;
std::filesystem::path const SettingsFilename = BasePath / "settings.json";
std::filesystem::path const AutosaveFile = ResourcePath / AutosaveFileWithoutPath;
std::filesystem::path const SettingsFilename = ResourcePath / "settings.json";
std::filesystem::path const SavepointTableFilename = "savepoints.json";

std::filesystem::path const SimulationFragmentShader = BasePath / "shader.fs";
std::filesystem::path const SimulationVertexShader = BasePath / "shader.vs";
std::filesystem::path const SimulationFragmentShader = ResourcePath / "shader.fs";
std::filesystem::path const SimulationVertexShader = ResourcePath / "shader.vs";

std::filesystem::path const EditorOnFilename = BasePath / "editor on.png";
std::filesystem::path const EditorOffFilename = BasePath / "editor off.png";
std::filesystem::path const EditorOnFilename = ResourcePath / "editor on.png";
std::filesystem::path const EditorOffFilename = ResourcePath / "editor off.png";

std::filesystem::path const LogoFilename = BasePath / "logo.png";
std::filesystem::path const LogoFilename = ResourcePath / "logo.png";
}
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/Macros.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void checkAndThrowError(T result, char const *const func, const char *const file
if (cudaError::cudaErrorMemoryAllocation == result) {
throw CudaMemoryAllocationException(text);
} else {
throw CudaException(text);
throw std::runtime_error(text);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions source/EngineGpuKernels/SimulationCudaFacade.cu
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void _SimulationCudaFacade::initCuda()

auto result = cudaSetDevice(_gpuInfo.deviceNumber);
if (result != cudaSuccess) {
throw SystemRequirementNotMetException("CUDA device could not be initialized.");
throw std::runtime_error("CUDA device could not be initialized.");
}

cudaGetLastError(); //reset error code
Expand All @@ -525,7 +525,7 @@ auto _SimulationCudaFacade::checkAndReturnGpuInfo() -> GpuInfo
int numberOfDevices;
CHECK_FOR_CUDA_ERROR(cudaGetDeviceCount(&numberOfDevices));
if (numberOfDevices < 1) {
throw SystemRequirementNotMetException("No CUDA device found.");
throw std::runtime_error("No CUDA device found.");
}
{
std::stringstream stream;
Expand Down Expand Up @@ -554,7 +554,7 @@ auto _SimulationCudaFacade::checkAndReturnGpuInfo() -> GpuInfo
}
}
if (highestComputeCapability < 600) {
throw SystemRequirementNotMetException("No CUDA device with compute capability of 6.0 or higher found.");
throw std::runtime_error("No CUDA device with compute capability of 6.0 or higher found.");
}

return *cachedResult;
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void AutosaveWindow::initIntern(SimulationFacade simulationFacade, PersisterFaca
_origNumberOfFiles = GlobalSettings::get().getValue("windows.autosave.number of files", _origNumberOfFiles);
_numberOfFiles = _origNumberOfFiles;

_origDirectory = GlobalSettings::get().getValue("windows.autosave.directory", (std::filesystem::current_path() / Const::BasePath).string());
_origDirectory = GlobalSettings::get().getValue("windows.autosave.directory", (std::filesystem::current_path() / Const::ResourcePath).string());
_directory = _origDirectory;

_origCatchPeaks = GlobalSettings::get().getValue("windows.autosave.catch peaks", _origCatchPeaks);
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void BrowserWindow::initIntern(SimulationFacade simulationFacade, PersisterFacad
}
for (int i = 1; i <= numEmojis; ++i) {
auto reactionName = "emoji" + std::to_string(i) + ".png";
_emojis.emplace_back(OpenGLHelper::loadTexture(Const::BasePath / std::filesystem::path(reactionName)));
_emojis.emplace_back(OpenGLHelper::loadTexture(Const::ResourcePath / std::filesystem::path(reactionName)));
}
for (NetworkResourceType resourceType = 0; resourceType < NetworkResourceType_Count; ++resourceType) {
for (WorkspaceType workspaceType = 0; workspaceType < WorkspaceType_Count; ++workspaceType) {
Expand Down
2 changes: 2 additions & 0 deletions source/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ PUBLIC
SimulationView.h
SpatialControlWindow.cpp
SpatialControlWindow.h
StartupCheckService.cpp
StartupCheckService.h
StatisticsWindow.cpp
StatisticsWindow.h
StyleRepository.cpp
Expand Down
6 changes: 6 additions & 0 deletions source/Gui/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include "Base/LoggingService.h"
#include "Base/FileLogger.h"
#include "Base/Exceptions.h"
#include "Base/Resources.h"
#include "PersisterInterface/SerializerService.h"
#include "EngineImpl/SimulationFacadeImpl.h"
#include "PersisterImpl/PersisterFacadeImpl.h"

#include "MainWindow.h"
#include "GuiLogger.h"
#include "HelpStrings.h"
#include "StartupCheckService.h"

namespace
{
Expand All @@ -38,8 +40,12 @@ int main(int argc, char** argv)
MainWindow mainWindow;

try {
log(Priority::Important, "starting ALIEN v" + Const::ProgramVersion);

simulationFacade = std::make_shared<_SimulationFacadeImpl>();
persisterFacade = std::make_shared<_PersisterFacadeImpl>();
StartupCheckService::get().check(simulationFacade);

mainWindow = std::make_shared<_MainWindow>(simulationFacade, persisterFacade, logger);
mainWindow->mainLoop();
mainWindow->shutdown();
Expand Down
1 change: 0 additions & 1 deletion source/Gui/MainLoopController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ void MainLoopController::setup(SimulationFacade const& simulationFacade, Persist
_simulationFacade = simulationFacade;
_persisterFacade = persisterFacade;

log(Priority::Important, "starting ALIEN v" + Const::ProgramVersion);
_logo = OpenGLHelper::loadTexture(Const::LogoFilename);
_saveOnExit = GlobalSettings::get().getValue("controllers.main loop.save on exit", _saveOnExit);
}
Expand Down
10 changes: 0 additions & 10 deletions source/Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ _MainWindow::_MainWindow(SimulationFacade const& simulationFacade, PersisterFaca
{
IMGUI_CHECKVERSION();

log(Priority::Important, "check directory");
checkDirectory();

log(Priority::Important, "initialize GLFW and OpenGL");
initGlfwAndOpenGL();

Expand Down Expand Up @@ -196,13 +193,6 @@ void _MainWindow::shutdown()
NetworkService::get().shutdown();
}

void _MainWindow::checkDirectory()
{
if (!std::filesystem::exists(Const::BasePath)) {
throw InitialCheckException("The resource folder has not been found. Please start ALIEN from the directory in which the folder `resource` is located.");
}
}

void _MainWindow::initGlfwAndOpenGL()
{
glfwSetErrorCallback(glfwErrorCallback);
Expand Down
1 change: 0 additions & 1 deletion source/Gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class _MainWindow
void shutdown();

private:
void checkDirectory();
void initGlfwAndOpenGL();
void initGlad();
void initFileDialogs();
Expand Down

0 comments on commit 39f6111

Please sign in to comment.