Replace get_rendering_device() call to prevent crashes on OpenGL.

And make OpenGL video adapter info align with Vulkan.
This commit is contained in:
MJacred 2023-06-06 23:29:36 +02:00
parent 0a0132ccf4
commit 2c5e2196bd
5 changed files with 13 additions and 10 deletions

View file

@ -180,8 +180,7 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
void RasterizerGLES3::initialize() {
// NVIDIA suffixes all GPU model names with "/PCIe/SSE2" in OpenGL (but not Vulkan). This isn't necessary to display nowadays, so it can be trimmed.
print_line(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name().trim_suffix("/PCIe/SSE2")));
print_line(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name()));
}
void RasterizerGLES3::finalize() {

View file

@ -328,11 +328,15 @@ uint64_t Utilities::get_rendering_info(RS::RenderingInfo p_info) {
}
String Utilities::get_video_adapter_name() const {
return (const char *)glGetString(GL_RENDERER);
const String rendering_device_name = (const char *)glGetString(GL_RENDERER);
// NVIDIA suffixes all GPU model names with "/PCIe/SSE2" in OpenGL (but not Vulkan). This isn't necessary to display nowadays, so it can be trimmed.
return rendering_device_name.trim_suffix("/PCIe/SSE2");
}
String Utilities::get_video_adapter_vendor() const {
return (const char *)glGetString(GL_VENDOR);
const String rendering_device_vendor = (const char *)glGetString(GL_VENDOR);
// NVIDIA suffixes its vendor name with " Corporation". This is neither necessary to process nor display.
return rendering_device_vendor.trim_suffix(" Corporation");
}
RenderingDevice::DeviceType Utilities::get_video_adapter_type() const {

View file

@ -4382,7 +4382,7 @@ String EditorNode::_get_system_info() const {
String driver_name = GLOBAL_GET("rendering/rendering_device/driver");
String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method");
const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name();
const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name();
RenderingDevice::DeviceType device_type = RenderingServer::get_singleton()->get_video_adapter_type();
String device_type_string;

View file

@ -252,7 +252,7 @@ String OS_LinuxBSD::get_version() const {
}
Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) {
if (RenderingServer::get_singleton() == nullptr) {
return Vector<String>();
}
@ -261,8 +261,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
return info;
}
const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); // e.g. `NVIDIA GeForce GTX 970`
const String rendering_device_vendor = RenderingServer::get_singleton()->get_rendering_device()->get_device_vendor_name(); // e.g. `NVIDIA`
const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); // e.g. `NVIDIA GeForce GTX 970`
const String rendering_device_vendor = RenderingServer::get_singleton()->get_video_adapter_vendor(); // e.g. `NVIDIA`
const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970`
String vendor_device_id_mappings;

View file

@ -449,7 +449,7 @@ String OS_Windows::get_version() const {
}
Vector<String> OS_Windows::get_video_adapter_driver_info() const {
if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) {
if (RenderingServer::get_singleton() == nullptr) {
return Vector<String>();
}
@ -467,7 +467,7 @@ Vector<String> OS_Windows::get_video_adapter_driver_info() const {
String driver_name;
String driver_version;
const String device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name();
const String device_name = RenderingServer::get_singleton()->get_video_adapter_name();
if (device_name.is_empty()) {
return Vector<String>();
}