Add `get_video_adapter_api_version()` to RenderingServer

This method can be used to get the graphics API version currently in
use (such as Vulkan). It can be used by projects for troubleshooting
or statistical purposes.
This commit is contained in:
Hugo Locurcio 2021-07-31 15:39:46 +02:00
parent 8762286110
commit 31194f5b1c
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
16 changed files with 39 additions and 0 deletions

View File

@ -1252,6 +1252,13 @@
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_api_version" qualifiers="const">
<return type="String" />
<description>
Returns the version of the graphics video adapter [i]currently in use[/i] (e.g. "1.2.189" for Vulkan, "3.3.0 NVIDIA 510.60.02" for OpenGL). This version may be different from the actual latest version supported by the hardware, as Godot may not always request the latest version.
[b]Note:[/b] When running a headless or server binary, this function returns an empty string.
</description>
</method>
<method name="get_video_adapter_name" qualifiers="const"> <method name="get_video_adapter_name" qualifiers="const">
<return type="String" /> <return type="String" />
<description> <description>

View File

@ -627,6 +627,10 @@ RenderingDevice::DeviceType RasterizerStorageGLES3::get_video_adapter_type() con
return RenderingDevice::DeviceType::DEVICE_TYPE_OTHER; return RenderingDevice::DeviceType::DEVICE_TYPE_OTHER;
} }
String RasterizerStorageGLES3::get_video_adapter_api_version() const {
return (const char *)glGetString(GL_VERSION);
}
void RasterizerStorageGLES3::initialize() { void RasterizerStorageGLES3::initialize() {
config = GLES3::Config::get_singleton(); config = GLES3::Config::get_singleton();

View File

@ -234,6 +234,7 @@ public:
String get_video_adapter_name() const override; String get_video_adapter_name() const override;
String get_video_adapter_vendor() const override; String get_video_adapter_vendor() const override;
RenderingDevice::DeviceType get_video_adapter_type() const override; RenderingDevice::DeviceType get_video_adapter_type() const override;
String get_video_adapter_api_version() const override;
void capture_timestamps_begin() override {} void capture_timestamps_begin() override {}
void capture_timestamp(const String &p_name) override {} void capture_timestamp(const String &p_name) override {}

View File

@ -8649,6 +8649,7 @@ void RenderingDeviceVulkan::draw_command_end_label() {
String RenderingDeviceVulkan::get_device_vendor_name() const { String RenderingDeviceVulkan::get_device_vendor_name() const {
return context->get_device_vendor_name(); return context->get_device_vendor_name();
} }
String RenderingDeviceVulkan::get_device_name() const { String RenderingDeviceVulkan::get_device_name() const {
return context->get_device_name(); return context->get_device_name();
} }
@ -8657,6 +8658,10 @@ RenderingDevice::DeviceType RenderingDeviceVulkan::get_device_type() const {
return context->get_device_type(); return context->get_device_type();
} }
String RenderingDeviceVulkan::get_device_api_version() const {
return context->get_device_api_version();
}
String RenderingDeviceVulkan::get_device_pipeline_cache_uuid() const { String RenderingDeviceVulkan::get_device_pipeline_cache_uuid() const {
return context->get_device_pipeline_cache_uuid(); return context->get_device_pipeline_cache_uuid();
} }

View File

@ -1229,6 +1229,7 @@ public:
virtual String get_device_vendor_name() const; virtual String get_device_vendor_name() const;
virtual String get_device_name() const; virtual String get_device_name() const;
virtual RenderingDevice::DeviceType get_device_type() const; virtual RenderingDevice::DeviceType get_device_type() const;
virtual String get_device_api_version() const;
virtual String get_device_pipeline_cache_uuid() const; virtual String get_device_pipeline_cache_uuid() const;
virtual uint64_t get_driver_resource(DriverResource p_resource, RID p_rid = RID(), uint64_t p_index = 0); virtual uint64_t get_driver_resource(DriverResource p_resource, RID p_rid = RID(), uint64_t p_index = 0);

View File

@ -2364,6 +2364,7 @@ void VulkanContext::set_object_name(VkObjectType p_object_type, uint64_t p_objec
String VulkanContext::get_device_vendor_name() const { String VulkanContext::get_device_vendor_name() const {
return device_vendor; return device_vendor;
} }
String VulkanContext::get_device_name() const { String VulkanContext::get_device_name() const {
return device_name; return device_name;
} }
@ -2372,6 +2373,10 @@ RenderingDevice::DeviceType VulkanContext::get_device_type() const {
return RenderingDevice::DeviceType(device_type); return RenderingDevice::DeviceType(device_type);
} }
String VulkanContext::get_device_api_version() const {
return vformat("%d.%d.%d", vulkan_major, vulkan_minor, vulkan_patch);
}
String VulkanContext::get_device_pipeline_cache_uuid() const { String VulkanContext::get_device_pipeline_cache_uuid() const {
return pipeline_cache_id; return pipeline_cache_id;
} }

View File

@ -305,6 +305,7 @@ public:
String get_device_vendor_name() const; String get_device_vendor_name() const;
String get_device_name() const; String get_device_name() const;
RenderingDevice::DeviceType get_device_type() const; RenderingDevice::DeviceType get_device_type() const;
String get_device_api_version() const;
String get_device_pipeline_cache_uuid() const; String get_device_pipeline_cache_uuid() const;
void set_vsync_mode(DisplayServer::WindowID p_window, DisplayServer::VSyncMode p_mode); void set_vsync_mode(DisplayServer::WindowID p_window, DisplayServer::VSyncMode p_mode);

View File

@ -128,6 +128,7 @@ public:
String get_video_adapter_name() const override { return String(); } String get_video_adapter_name() const override { return String(); }
String get_video_adapter_vendor() const override { return String(); } String get_video_adapter_vendor() const override { return String(); }
RenderingDevice::DeviceType get_video_adapter_type() const override { return RenderingDevice::DeviceType::DEVICE_TYPE_OTHER; } RenderingDevice::DeviceType get_video_adapter_type() const override { return RenderingDevice::DeviceType::DEVICE_TYPE_OTHER; }
String get_video_adapter_api_version() const override { return String(); }
static RendererStorage *base_singleton; static RendererStorage *base_singleton;

View File

@ -727,6 +727,10 @@ RenderingDevice::DeviceType RendererStorageRD::get_video_adapter_type() const {
return RenderingDevice::get_singleton()->get_device_type(); return RenderingDevice::get_singleton()->get_device_type();
} }
String RendererStorageRD::get_video_adapter_api_version() const {
return RenderingDevice::get_singleton()->get_device_api_version();
}
RendererStorageRD *RendererStorageRD::base_singleton = nullptr; RendererStorageRD *RendererStorageRD::base_singleton = nullptr;
RendererStorageRD::RendererStorageRD() { RendererStorageRD::RendererStorageRD() {

View File

@ -284,6 +284,7 @@ public:
String get_video_adapter_name() const; String get_video_adapter_name() const;
String get_video_adapter_vendor() const; String get_video_adapter_vendor() const;
RenderingDevice::DeviceType get_video_adapter_type() const; RenderingDevice::DeviceType get_video_adapter_type() const;
String get_video_adapter_api_version() const;
virtual void capture_timestamps_begin(); virtual void capture_timestamps_begin();
virtual void capture_timestamp(const String &p_name); virtual void capture_timestamp(const String &p_name);

View File

@ -199,6 +199,7 @@ public:
virtual String get_video_adapter_name() const = 0; virtual String get_video_adapter_name() const = 0;
virtual String get_video_adapter_vendor() const = 0; virtual String get_video_adapter_vendor() const = 0;
virtual RenderingDevice::DeviceType get_video_adapter_type() const = 0; virtual RenderingDevice::DeviceType get_video_adapter_type() const = 0;
virtual String get_video_adapter_api_version() const = 0;
static RendererStorage *base_singleton; static RendererStorage *base_singleton;

View File

@ -1254,6 +1254,7 @@ public:
virtual String get_device_vendor_name() const = 0; virtual String get_device_vendor_name() const = 0;
virtual String get_device_name() const = 0; virtual String get_device_name() const = 0;
virtual RenderingDevice::DeviceType get_device_type() const = 0; virtual RenderingDevice::DeviceType get_device_type() const = 0;
virtual String get_device_api_version() const = 0;
virtual String get_device_pipeline_cache_uuid() const = 0; virtual String get_device_pipeline_cache_uuid() const = 0;
virtual uint64_t get_driver_resource(DriverResource p_resource, RID p_rid = RID(), uint64_t p_index = 0) = 0; virtual uint64_t get_driver_resource(DriverResource p_resource, RID p_rid = RID(), uint64_t p_index = 0) = 0;

View File

@ -265,6 +265,10 @@ RenderingDevice::DeviceType RenderingServerDefault::get_video_adapter_type() con
return RSG::storage->get_video_adapter_type(); return RSG::storage->get_video_adapter_type();
} }
String RenderingServerDefault::get_video_adapter_api_version() const {
return RSG::storage->get_video_adapter_api_version();
}
void RenderingServerDefault::set_frame_profiling_enabled(bool p_enable) { void RenderingServerDefault::set_frame_profiling_enabled(bool p_enable) {
RSG::storage->capturing_timestamps = p_enable; RSG::storage->capturing_timestamps = p_enable;
} }

View File

@ -939,6 +939,7 @@ public:
virtual String get_video_adapter_name() const override; virtual String get_video_adapter_name() const override;
virtual String get_video_adapter_vendor() const override; virtual String get_video_adapter_vendor() const override;
virtual RenderingDevice::DeviceType get_video_adapter_type() const override; virtual RenderingDevice::DeviceType get_video_adapter_type() const override;
virtual String get_video_adapter_api_version() const override;
virtual void set_frame_profiling_enabled(bool p_enable) override; virtual void set_frame_profiling_enabled(bool p_enable) override;
virtual Vector<FrameProfileArea> get_frame_profile() override; virtual Vector<FrameProfileArea> get_frame_profile() override;

View File

@ -2726,6 +2726,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name); ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);
ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor); ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);
ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type); ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type);
ClassDB::bind_method(D_METHOD("get_video_adapter_api_version"), &RenderingServer::get_video_adapter_api_version);
ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh); ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);
ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube); ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);

View File

@ -1487,6 +1487,7 @@ public:
virtual String get_video_adapter_name() const = 0; virtual String get_video_adapter_name() const = 0;
virtual String get_video_adapter_vendor() const = 0; virtual String get_video_adapter_vendor() const = 0;
virtual RenderingDevice::DeviceType get_video_adapter_type() const = 0; virtual RenderingDevice::DeviceType get_video_adapter_type() const = 0;
virtual String get_video_adapter_api_version() const = 0;
struct FrameProfileArea { struct FrameProfileArea {
String name; String name;