Add VisualServer methods to get the video adapter name and vendor

These methods can be used in scripts to retrieve the OpenGL
`GL_RENDERER` and `GL_VENDOR` strings (respectively).

This closes #28404.
This commit is contained in:
Hugo Locurcio 2019-09-13 20:08:05 +02:00
parent 61dd7748ca
commit 0cad2c0cd1
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
14 changed files with 70 additions and 4 deletions

View File

@ -1397,6 +1397,22 @@
Returns the id of the test texture. Creates one if none exists. Returns the id of the test texture. Creates one if none exists.
</description> </description>
</method> </method>
<method name="get_video_adapter_name" qualifiers="const">
<return type="String">
</return>
<description>
Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2").
[b]Note:[/b] When running a headless or server binary, this function returns an empty string.
</description>
</method>
<method name="get_video_adapter_vendor" qualifiers="const">
<return type="String">
</return>
<description>
Returns the vendor of the video adapter (e.g. "NVIDIA Corporation").
[b]Note:[/b] When running a headless or server binary, this function returns an empty string.
</description>
</method>
<method name="get_white_texture"> <method name="get_white_texture">
<return type="RID"> <return type="RID">
</return> </return>

View File

@ -742,6 +742,8 @@ public:
int get_captured_render_info(VS::RenderInfo p_info) { return 0; } int get_captured_render_info(VS::RenderInfo p_info) { return 0; }
int get_render_info(VS::RenderInfo p_info) { return 0; } int get_render_info(VS::RenderInfo p_info) { return 0; }
String get_video_adapter_name() const { return String(); }
String get_video_adapter_vendor() const { return String(); }
static RasterizerStorage *base_singleton; static RasterizerStorage *base_singleton;

View File

@ -263,8 +263,7 @@ void RasterizerGLES2::initialize() {
#endif // GLES_OVER_GL #endif // GLES_OVER_GL
#endif // CAN_DEBUG #endif // CAN_DEBUG
const GLubyte *renderer = glGetString(GL_RENDERER); print_line("OpenGL ES 2.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name());
print_line("OpenGL ES 2.0 Renderer: " + String((const char *)renderer));
storage->initialize(); storage->initialize();
canvas->initialize(); canvas->initialize();
scene->initialize(); scene->initialize();

View File

@ -5766,6 +5766,16 @@ int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) {
} }
} }
String RasterizerStorageGLES2::get_video_adapter_name() const {
return (const char *)glGetString(GL_RENDERER);
}
String RasterizerStorageGLES2::get_video_adapter_vendor() const {
return (const char *)glGetString(GL_VENDOR);
}
void RasterizerStorageGLES2::initialize() { void RasterizerStorageGLES2::initialize() {
RasterizerStorageGLES2::system_fbo = 0; RasterizerStorageGLES2::system_fbo = 0;

View File

@ -1307,6 +1307,8 @@ public:
virtual int get_captured_render_info(VS::RenderInfo p_info); virtual int get_captured_render_info(VS::RenderInfo p_info);
virtual int get_render_info(VS::RenderInfo p_info); virtual int get_render_info(VS::RenderInfo p_info);
virtual String get_video_adapter_name() const;
virtual String get_video_adapter_vendor() const;
RasterizerStorageGLES2(); RasterizerStorageGLES2();
}; };

View File

@ -186,8 +186,7 @@ void RasterizerGLES3::initialize() {
} }
*/ */
const GLubyte *renderer = glGetString(GL_RENDERER); print_line("OpenGL ES 3.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name());
print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer));
storage->initialize(); storage->initialize();
canvas->initialize(); canvas->initialize();
scene->initialize(); scene->initialize();

View File

@ -8095,6 +8095,16 @@ int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) {
} }
} }
String RasterizerStorageGLES3::get_video_adapter_name() const {
return (const char *)glGetString(GL_RENDERER);
}
String RasterizerStorageGLES3::get_video_adapter_vendor() const {
return (const char *)glGetString(GL_VENDOR);
}
void RasterizerStorageGLES3::initialize() { void RasterizerStorageGLES3::initialize() {
RasterizerStorageGLES3::system_fbo = 0; RasterizerStorageGLES3::system_fbo = 0;

View File

@ -1467,6 +1467,8 @@ public:
virtual int get_captured_render_info(VS::RenderInfo p_info); virtual int get_captured_render_info(VS::RenderInfo p_info);
virtual int get_render_info(VS::RenderInfo p_info); virtual int get_render_info(VS::RenderInfo p_info);
virtual String get_video_adapter_name() const;
virtual String get_video_adapter_vendor() const;
RasterizerStorageGLES3(); RasterizerStorageGLES3();
}; };

View File

@ -588,6 +588,8 @@ public:
virtual int get_captured_render_info(VS::RenderInfo p_info) = 0; virtual int get_captured_render_info(VS::RenderInfo p_info) = 0;
virtual int get_render_info(VS::RenderInfo p_info) = 0; virtual int get_render_info(VS::RenderInfo p_info) = 0;
virtual String get_video_adapter_name() const = 0;
virtual String get_video_adapter_vendor() const = 0;
static RasterizerStorage *base_singleton; static RasterizerStorage *base_singleton;
RasterizerStorage(); RasterizerStorage();

View File

@ -153,6 +153,16 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) {
return VSG::storage->get_render_info(p_info); return VSG::storage->get_render_info(p_info);
} }
String VisualServerRaster::get_video_adapter_name() const {
return VSG::storage->get_video_adapter_name();
}
String VisualServerRaster::get_video_adapter_vendor() const {
return VSG::storage->get_video_adapter_vendor();
}
/* TESTING */ /* TESTING */
void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {

View File

@ -680,6 +680,8 @@ public:
/* STATUS INFORMATION */ /* STATUS INFORMATION */
virtual int get_render_info(RenderInfo p_info); virtual int get_render_info(RenderInfo p_info);
virtual String get_video_adapter_name() const;
virtual String get_video_adapter_vendor() const;
virtual RID get_test_cube(); virtual RID get_test_cube();

View File

@ -602,6 +602,14 @@ public:
return visual_server->get_render_info(p_info); return visual_server->get_render_info(p_info);
} }
virtual String get_video_adapter_name() const {
return visual_server->get_video_adapter_name();
}
virtual String get_video_adapter_vendor() const {
return visual_server->get_video_adapter_vendor();
}
FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool) FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool)
FUNC1(set_default_clear_color, const Color &) FUNC1(set_default_clear_color, const Color &)

View File

@ -2032,6 +2032,8 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("init"), &VisualServer::init); ClassDB::bind_method(D_METHOD("init"), &VisualServer::init);
ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish); ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish);
ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info); ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info);
ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &VisualServer::get_video_adapter_name);
ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &VisualServer::get_video_adapter_vendor);
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh); ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);

View File

@ -1017,6 +1017,8 @@ public:
}; };
virtual int get_render_info(RenderInfo p_info) = 0; virtual int get_render_info(RenderInfo p_info) = 0;
virtual String get_video_adapter_name() const = 0;
virtual String get_video_adapter_vendor() const = 0;
/* Materials for 2D on 3D */ /* Materials for 2D on 3D */