Исправил неопределённое поведение и добавил агрессивные оптимизации для Release конфигурации
This commit is contained in:
@@ -49,25 +49,6 @@ CoreInstance::CoreInstance()
|
||||
SaveMap load_main_config(payload);
|
||||
|
||||
main_config_.load(std::make_shared<SaveMap>(load_main_config));
|
||||
|
||||
// if (glfwInit() == GLFW_FALSE)
|
||||
// throw std::runtime_error("Fail init glfw");
|
||||
//
|
||||
// glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
// glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
// window_ = glfwCreateWindow(800, 600, main_config_.game_name.c_str(), nullptr, nullptr);
|
||||
// if (window_ == nullptr)
|
||||
// {
|
||||
// std::cout << "[!] Init render engine: Fail create window\n";
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// render_engine_ = new RenderEngine(*this, window_);
|
||||
// } catch (const std::exception& e)
|
||||
// {
|
||||
// std::cout << "[!] Init render engine: " << e.what() << '\n';
|
||||
// return;
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -10,26 +10,27 @@
|
||||
#include <stdexcept>
|
||||
|
||||
int System::getCountCPU() {
|
||||
DWORD len = 0;
|
||||
DWORD len = 0; // In bytes
|
||||
GetLogicalProcessorInformation(nullptr, &len);
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw std::runtime_error(std::to_string(GetLastError()).c_str());
|
||||
}
|
||||
DWORD count = len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
|
||||
|
||||
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> buffer(len);
|
||||
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> buffer(count);
|
||||
if (!GetLogicalProcessorInformation(buffer.data(), &len)) {
|
||||
throw std::runtime_error(std::to_string(GetLastError()).c_str());
|
||||
}
|
||||
|
||||
DWORD count = len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
|
||||
int physicalCoreCount = 0;
|
||||
|
||||
for (DWORD i = 0; i < count; ++i) {
|
||||
if (buffer[i].Relationship == RelationProcessorCore) {
|
||||
physicalCoreCount++;
|
||||
for (auto& i : buffer)
|
||||
{
|
||||
if (i.Relationship == RelationProcessorCore)
|
||||
{
|
||||
++physicalCoreCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return physicalCoreCount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user