Merge pull request #103245 from bruvzg/rd_helper
[Windows] Offload `RenderingDevice` creation test to subprocess.
This commit is contained in:
@ -57,6 +57,10 @@ static void handle_crash(int sig) {
|
||||
abort();
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->is_crash_handler_silent()) {
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
||||
void *bt_buffer[256];
|
||||
size_t size = backtrace(bt_buffer, 256);
|
||||
String _execpath = OS::get_singleton()->get_executable_path();
|
||||
|
||||
@ -81,6 +81,10 @@ static void handle_crash(int sig) {
|
||||
abort();
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->is_crash_handler_silent()) {
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
||||
void *bt_buffer[256];
|
||||
size_t size = backtrace(bt_buffer, 256);
|
||||
String _execpath = OS::get_singleton()->get_executable_path();
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
// Backtrace code based on: https://stackoverflow.com/questions/6205981/windows-c-stack-trace-from-a-running-app
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -127,6 +128,10 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->is_crash_handler_silent()) {
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
||||
String msg;
|
||||
const ProjectSettings *proj_settings = ProjectSettings::get_singleton();
|
||||
if (proj_settings) {
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include <cxxabi.h>
|
||||
#include <signal.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -133,6 +134,10 @@ extern void CrashHandlerException(int signal) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->is_crash_handler_silent()) {
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
||||
String msg;
|
||||
const ProjectSettings *proj_settings = ProjectSettings::get_singleton();
|
||||
if (proj_settings) {
|
||||
|
||||
@ -62,6 +62,24 @@
|
||||
#include <wbemcli.h>
|
||||
#include <wincrypt.h>
|
||||
|
||||
#if defined(RD_ENABLED)
|
||||
#include "servers/rendering/rendering_device.h"
|
||||
#endif
|
||||
|
||||
#if defined(GLES3_ENABLED)
|
||||
#include "gl_manager_windows_native.h"
|
||||
#endif
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
#include "rendering_context_driver_vulkan_windows.h"
|
||||
#endif
|
||||
#if defined(D3D12_ENABLED)
|
||||
#include "drivers/d3d12/rendering_context_driver_d3d12.h"
|
||||
#endif
|
||||
#if defined(GLES3_ENABLED)
|
||||
#include "drivers/gles3/rasterizer_gles3.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
#pragma pack(push, before_imagehlp, 8)
|
||||
#include <imagehlp.h>
|
||||
@ -2346,6 +2364,99 @@ void OS_Windows::add_frame_delay(bool p_can_draw) {
|
||||
}
|
||||
}
|
||||
|
||||
bool OS_Windows::_test_create_rendering_device() const {
|
||||
// Tests Rendering Device creation.
|
||||
|
||||
bool ok = false;
|
||||
#if defined(RD_ENABLED)
|
||||
Error err;
|
||||
RenderingContextDriver *rcd = nullptr;
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
rcd = memnew(RenderingContextDriverVulkan);
|
||||
#endif
|
||||
#ifdef D3D12_ENABLED
|
||||
if (rcd == nullptr) {
|
||||
rcd = memnew(RenderingContextDriverD3D12);
|
||||
}
|
||||
#endif
|
||||
if (rcd != nullptr) {
|
||||
err = rcd->initialize();
|
||||
if (err == OK) {
|
||||
RenderingDevice *rd = memnew(RenderingDevice);
|
||||
err = rd->initialize(rcd);
|
||||
memdelete(rd);
|
||||
rd = nullptr;
|
||||
if (err == OK) {
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
memdelete(rcd);
|
||||
rcd = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool OS_Windows::_test_create_rendering_device_and_gl() const {
|
||||
// Tests OpenGL context and Rendering Device simultaneous creation. This function is expected to crash on some NVIDIA drivers.
|
||||
|
||||
WNDCLASSEXW wc_probe;
|
||||
memset(&wc_probe, 0, sizeof(WNDCLASSEXW));
|
||||
wc_probe.cbSize = sizeof(WNDCLASSEXW);
|
||||
wc_probe.style = CS_OWNDC | CS_DBLCLKS;
|
||||
wc_probe.lpfnWndProc = (WNDPROC)::DefWindowProcW;
|
||||
wc_probe.cbClsExtra = 0;
|
||||
wc_probe.cbWndExtra = 0;
|
||||
wc_probe.hInstance = GetModuleHandle(nullptr);
|
||||
wc_probe.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
|
||||
wc_probe.hCursor = nullptr;
|
||||
wc_probe.hbrBackground = nullptr;
|
||||
wc_probe.lpszMenuName = nullptr;
|
||||
wc_probe.lpszClassName = L"Engine probe window";
|
||||
|
||||
if (!RegisterClassExW(&wc_probe)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HWND hWnd = CreateWindowExW(WS_EX_WINDOWEDGE, L"Engine probe window", L"", WS_OVERLAPPEDWINDOW, 0, 0, 800, 600, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
||||
if (!hWnd) {
|
||||
UnregisterClassW(L"Engine probe window", GetModuleHandle(nullptr));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
#ifdef GLES3_ENABLED
|
||||
GLManagerNative_Windows *test_gl_manager_native = memnew(GLManagerNative_Windows);
|
||||
if (test_gl_manager_native->window_create(DisplayServer::MAIN_WINDOW_ID, hWnd, GetModuleHandle(nullptr), 800, 600) == OK) {
|
||||
RasterizerGLES3::make_current(true);
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
MSG msg = {};
|
||||
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ok = _test_create_rendering_device();
|
||||
}
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
if (test_gl_manager_native) {
|
||||
memdelete(test_gl_manager_native);
|
||||
}
|
||||
#endif
|
||||
|
||||
DestroyWindow(hWnd);
|
||||
UnregisterClassW(L"Engine probe window", GetModuleHandle(nullptr));
|
||||
return ok;
|
||||
}
|
||||
|
||||
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
|
||||
hInstance = _hInstance;
|
||||
|
||||
|
||||
@ -252,6 +252,9 @@ public:
|
||||
|
||||
void set_main_window(HWND p_main_window) { main_window = p_main_window; }
|
||||
|
||||
virtual bool _test_create_rendering_device_and_gl() const override;
|
||||
virtual bool _test_create_rendering_device() const override;
|
||||
|
||||
HINSTANCE get_hinstance() { return hInstance; }
|
||||
OS_Windows(HINSTANCE _hInstance);
|
||||
~OS_Windows();
|
||||
|
||||
Reference in New Issue
Block a user