Merge pull request #77929 from MJacred/fix/gles_info_fetch

Replace get_rendering_device() call to prevent crashes on OpenGL.
This commit is contained in:
Rémi Verschelde 2023-06-07 11:02:12 +02:00
commit 9a489f4fdf
No known key found for this signature in database
GPG Key ID: C3336907360768E1
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); typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
void RasterizerGLES3::initialize() { 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()));
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")));
} }
void RasterizerGLES3::finalize() { 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 { 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 { 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 { 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 driver_name = GLOBAL_GET("rendering/rendering_device/driver");
String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method"); 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(); RenderingDevice::DeviceType device_type = RenderingServer::get_singleton()->get_video_adapter_type();
String device_type_string; 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 { 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>(); return Vector<String>();
} }
@ -261,8 +261,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
return info; 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_name = RenderingServer::get_singleton()->get_video_adapter_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_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` const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970`
String vendor_device_id_mappings; 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 { 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>(); return Vector<String>();
} }
@ -467,7 +467,7 @@ Vector<String> OS_Windows::get_video_adapter_driver_info() const {
String driver_name; String driver_name;
String driver_version; 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()) { if (device_name.is_empty()) {
return Vector<String>(); return Vector<String>();
} }