2019-06-22 16:34:26 +00:00
|
|
|
/**************************************************************************/
|
2022-06-21 00:08:33 +00:00
|
|
|
/* utilities.cpp */
|
2019-06-22 16:34:26 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
2020-02-11 13:01:43 +00:00
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
2019-06-22 16:34:26 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
#include "utilities.h"
|
|
|
|
#include "../environment/fog.h"
|
|
|
|
#include "../environment/gi.h"
|
|
|
|
#include "light_storage.h"
|
|
|
|
#include "mesh_storage.h"
|
|
|
|
#include "particles_storage.h"
|
|
|
|
#include "texture_storage.h"
|
2021-10-03 11:28:55 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
using namespace RendererRD;
|
2021-10-03 11:28:55 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
Utilities *Utilities::singleton = nullptr;
|
2021-10-03 11:28:55 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
Utilities::Utilities() {
|
|
|
|
singleton = this;
|
2021-10-03 11:28:55 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
Utilities::~Utilities() {
|
|
|
|
singleton = nullptr;
|
2021-10-03 11:28:55 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
/* INSTANCES */
|
2021-10-03 11:28:55 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
RS::InstanceType Utilities::get_base_type(RID p_rid) const {
|
2022-04-02 05:29:04 +00:00
|
|
|
if (RendererRD::MeshStorage::get_singleton()->owns_mesh(p_rid)) {
|
2020-03-27 18:21:27 +00:00
|
|
|
return RS::INSTANCE_MESH;
|
2019-08-20 20:54:03 +00:00
|
|
|
}
|
2022-04-02 05:29:04 +00:00
|
|
|
if (RendererRD::MeshStorage::get_singleton()->owns_multimesh(p_rid)) {
|
2020-03-27 18:21:27 +00:00
|
|
|
return RS::INSTANCE_MULTIMESH;
|
2019-09-14 03:37:42 +00:00
|
|
|
}
|
2022-04-09 09:34:31 +00:00
|
|
|
if (RendererRD::LightStorage::get_singleton()->owns_reflection_probe(p_rid)) {
|
2020-03-27 18:21:27 +00:00
|
|
|
return RS::INSTANCE_REFLECTION_PROBE;
|
2019-09-07 01:51:27 +00:00
|
|
|
}
|
2022-04-07 14:00:51 +00:00
|
|
|
if (RendererRD::TextureStorage::get_singleton()->owns_decal(p_rid)) {
|
2020-04-14 03:05:21 +00:00
|
|
|
return RS::INSTANCE_DECAL;
|
|
|
|
}
|
2022-05-20 02:52:19 +00:00
|
|
|
if (RendererRD::GI::get_singleton()->owns_voxel_gi(p_rid)) {
|
2021-06-04 22:47:26 +00:00
|
|
|
return RS::INSTANCE_VOXEL_GI;
|
2019-10-03 20:39:08 +00:00
|
|
|
}
|
2022-04-09 09:34:31 +00:00
|
|
|
if (RendererRD::LightStorage::get_singleton()->owns_light(p_rid)) {
|
2020-03-27 18:21:27 +00:00
|
|
|
return RS::INSTANCE_LIGHT;
|
2019-09-07 01:51:27 +00:00
|
|
|
}
|
2022-04-09 09:34:31 +00:00
|
|
|
if (RendererRD::LightStorage::get_singleton()->owns_lightmap(p_rid)) {
|
2020-05-01 12:34:23 +00:00
|
|
|
return RS::INSTANCE_LIGHTMAP;
|
|
|
|
}
|
2022-04-12 11:41:50 +00:00
|
|
|
if (RendererRD::ParticlesStorage::get_singleton()->owns_particles(p_rid)) {
|
2020-08-19 13:38:24 +00:00
|
|
|
return RS::INSTANCE_PARTICLES;
|
|
|
|
}
|
2022-04-12 11:41:50 +00:00
|
|
|
if (RendererRD::ParticlesStorage::get_singleton()->owns_particles_collision(p_rid)) {
|
2020-10-08 00:29:49 +00:00
|
|
|
return RS::INSTANCE_PARTICLES_COLLISION;
|
|
|
|
}
|
2022-06-21 00:08:33 +00:00
|
|
|
if (RendererRD::Fog::get_singleton()->owns_fog_volume(p_rid)) {
|
2021-10-03 11:28:55 +00:00
|
|
|
return RS::INSTANCE_FOG_VOLUME;
|
|
|
|
}
|
2022-06-21 00:08:33 +00:00
|
|
|
if (owns_visibility_notifier(p_rid)) {
|
2021-06-16 18:43:02 +00:00
|
|
|
return RS::INSTANCE_VISIBLITY_NOTIFIER;
|
|
|
|
}
|
2019-09-07 01:51:27 +00:00
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
return RS::INSTANCE_NONE;
|
2019-08-20 20:54:03 +00:00
|
|
|
}
|
2020-04-14 03:05:21 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
bool Utilities::free(RID p_rid) {
|
2022-09-12 09:44:48 +00:00
|
|
|
if (RendererRD::LightStorage::get_singleton()->free(p_rid)) {
|
|
|
|
return true;
|
|
|
|
} else if (RendererRD::MaterialStorage::get_singleton()->free(p_rid)) {
|
|
|
|
return true;
|
|
|
|
} else if (RendererRD::MeshStorage::get_singleton()->free(p_rid)) {
|
|
|
|
return true;
|
|
|
|
} else if (RendererRD::ParticlesStorage::get_singleton()->free(p_rid)) {
|
|
|
|
return true;
|
|
|
|
} else if (RendererRD::TextureStorage::get_singleton()->free(p_rid)) {
|
|
|
|
return true;
|
2022-05-20 02:52:19 +00:00
|
|
|
} else if (RendererRD::GI::get_singleton()->owns_voxel_gi(p_rid)) {
|
|
|
|
RendererRD::GI::get_singleton()->voxel_gi_free(p_rid);
|
2022-09-12 09:44:48 +00:00
|
|
|
return true;
|
|
|
|
} else if (RendererRD::Fog::get_singleton()->owns_fog_volume(p_rid)) {
|
|
|
|
RendererRD::Fog::get_singleton()->fog_volume_free(p_rid);
|
|
|
|
return true;
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (owns_visibility_notifier(p_rid)) {
|
|
|
|
visibility_notifier_free(p_rid);
|
2022-09-12 09:44:48 +00:00
|
|
|
return true;
|
2022-09-29 05:37:10 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
2019-06-16 02:45:24 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-21 14:31:30 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
/* DEPENDENCIES */
|
|
|
|
|
|
|
|
void Utilities::base_update_dependency(RID p_base, DependencyTracker *p_instance) {
|
|
|
|
if (MeshStorage::get_singleton()->owns_mesh(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = MeshStorage::get_singleton()->mesh_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (MeshStorage::get_singleton()->owns_multimesh(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = MeshStorage::get_singleton()->multimesh_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
|
|
|
|
|
|
|
RID mesh = MeshStorage::get_singleton()->multimesh_get_mesh(p_base);
|
|
|
|
if (mesh.is_valid()) {
|
|
|
|
base_update_dependency(mesh, p_instance);
|
2022-06-21 00:08:33 +00:00
|
|
|
}
|
|
|
|
} else if (LightStorage::get_singleton()->owns_reflection_probe(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = LightStorage::get_singleton()->reflection_probe_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (TextureStorage::get_singleton()->owns_decal(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = TextureStorage::get_singleton()->decal_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (GI::get_singleton()->owns_voxel_gi(p_base)) {
|
2022-08-04 08:40:39 +00:00
|
|
|
Dependency *dependency = GI::get_singleton()->voxel_gi_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (LightStorage::get_singleton()->owns_lightmap(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = LightStorage::get_singleton()->lightmap_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (LightStorage::get_singleton()->owns_light(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = LightStorage::get_singleton()->light_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (ParticlesStorage::get_singleton()->owns_particles(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = ParticlesStorage::get_singleton()->particles_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (ParticlesStorage::get_singleton()->owns_particles_collision(p_base)) {
|
2022-08-01 01:59:14 +00:00
|
|
|
Dependency *dependency = ParticlesStorage::get_singleton()->particles_collision_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (Fog::get_singleton()->owns_fog_volume(p_base)) {
|
2022-09-12 09:44:48 +00:00
|
|
|
Dependency *dependency = Fog::get_singleton()->fog_volume_get_dependency(p_base);
|
|
|
|
p_instance->update_dependency(dependency);
|
2022-06-21 00:08:33 +00:00
|
|
|
} else if (owns_visibility_notifier(p_base)) {
|
|
|
|
VisibilityNotifier *vn = get_visibility_notifier(p_base);
|
|
|
|
p_instance->update_dependency(&vn->dependency);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VISIBILITY NOTIFIER */
|
|
|
|
|
|
|
|
RID Utilities::visibility_notifier_allocate() {
|
|
|
|
return visibility_notifier_owner.allocate_rid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Utilities::visibility_notifier_initialize(RID p_notifier) {
|
|
|
|
visibility_notifier_owner.initialize_rid(p_notifier, VisibilityNotifier());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Utilities::visibility_notifier_free(RID p_notifier) {
|
|
|
|
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
|
|
|
vn->dependency.deleted_notify(p_notifier);
|
|
|
|
visibility_notifier_owner.free(p_notifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Utilities::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) {
|
|
|
|
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
2023-09-09 15:04:18 +00:00
|
|
|
ERR_FAIL_NULL(vn);
|
2022-06-21 00:08:33 +00:00
|
|
|
vn->aabb = p_aabb;
|
|
|
|
vn->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_AABB);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Utilities::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) {
|
|
|
|
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
2023-09-09 15:04:18 +00:00
|
|
|
ERR_FAIL_NULL(vn);
|
2022-06-21 00:08:33 +00:00
|
|
|
vn->enter_callback = p_enter_callbable;
|
|
|
|
vn->exit_callback = p_exit_callable;
|
|
|
|
}
|
|
|
|
|
|
|
|
AABB Utilities::visibility_notifier_get_aabb(RID p_notifier) const {
|
|
|
|
const VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
2023-09-09 15:04:18 +00:00
|
|
|
ERR_FAIL_NULL_V(vn, AABB());
|
2022-06-21 00:08:33 +00:00
|
|
|
return vn->aabb;
|
2021-07-20 11:40:16 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
void Utilities::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) {
|
|
|
|
VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
|
2023-09-09 15:04:18 +00:00
|
|
|
ERR_FAIL_NULL(vn);
|
2022-06-21 00:08:33 +00:00
|
|
|
|
|
|
|
if (p_enter) {
|
2024-04-27 09:56:39 +00:00
|
|
|
if (vn->enter_callback.is_valid()) {
|
2022-06-21 00:08:33 +00:00
|
|
|
if (p_deferred) {
|
2022-10-21 21:40:06 +00:00
|
|
|
vn->enter_callback.call_deferred();
|
2022-06-21 00:08:33 +00:00
|
|
|
} else {
|
2023-07-11 14:18:10 +00:00
|
|
|
vn->enter_callback.call();
|
2022-06-21 00:08:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2024-04-27 09:56:39 +00:00
|
|
|
if (vn->exit_callback.is_valid()) {
|
2022-06-21 00:08:33 +00:00
|
|
|
if (p_deferred) {
|
2022-10-21 21:40:06 +00:00
|
|
|
vn->exit_callback.call_deferred();
|
2022-06-21 00:08:33 +00:00
|
|
|
} else {
|
2023-07-11 14:18:10 +00:00
|
|
|
vn->exit_callback.call();
|
2022-06-21 00:08:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-27 13:23:24 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
/* TIMING */
|
|
|
|
|
|
|
|
void Utilities::capture_timestamps_begin() {
|
2021-01-26 00:52:58 +00:00
|
|
|
RD::get_singleton()->capture_timestamp("Frame Begin");
|
2019-09-20 20:58:06 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
void Utilities::capture_timestamp(const String &p_name) {
|
2021-01-26 00:52:58 +00:00
|
|
|
RD::get_singleton()->capture_timestamp(p_name);
|
2019-09-20 20:58:06 +00:00
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
uint32_t Utilities::get_captured_timestamps_count() const {
|
2019-09-20 20:58:06 +00:00
|
|
|
return RD::get_singleton()->get_captured_timestamps_count();
|
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
uint64_t Utilities::get_captured_timestamps_frame() const {
|
2019-09-20 20:58:06 +00:00
|
|
|
return RD::get_singleton()->get_captured_timestamps_frame();
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
uint64_t Utilities::get_captured_timestamp_gpu_time(uint32_t p_index) const {
|
2019-09-20 20:58:06 +00:00
|
|
|
return RD::get_singleton()->get_captured_timestamp_gpu_time(p_index);
|
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
uint64_t Utilities::get_captured_timestamp_cpu_time(uint32_t p_index) const {
|
2019-09-20 20:58:06 +00:00
|
|
|
return RD::get_singleton()->get_captured_timestamp_cpu_time(p_index);
|
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
String Utilities::get_captured_timestamp_name(uint32_t p_index) const {
|
2019-09-20 20:58:06 +00:00
|
|
|
return RD::get_singleton()->get_captured_timestamp_name(p_index);
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
/* MISC */
|
|
|
|
|
|
|
|
void Utilities::update_dirty_resources() {
|
2022-04-03 16:56:43 +00:00
|
|
|
MaterialStorage::get_singleton()->_update_global_shader_uniforms(); //must do before materials, so it can queue them for update
|
2022-06-21 00:08:33 +00:00
|
|
|
MaterialStorage::get_singleton()->_update_queued_materials();
|
|
|
|
MeshStorage::get_singleton()->_update_dirty_multimeshes();
|
|
|
|
MeshStorage::get_singleton()->_update_dirty_skeletons();
|
|
|
|
TextureStorage::get_singleton()->update_decal_atlas();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Utilities::has_os_feature(const String &p_feature) const {
|
|
|
|
if (!RD::get_singleton()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_feature == "rgtc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC5_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-08-08 14:51:31 +00:00
|
|
|
#if !defined(ANDROID_ENABLED) && !defined(IOS_ENABLED)
|
2022-08-04 16:27:56 +00:00
|
|
|
// Some Android devices report support for S3TC but we don't expect that and don't export the textures.
|
|
|
|
// This could be fixed but so few devices support it that it doesn't seem useful (and makes bigger APKs).
|
|
|
|
// For good measure we do the same hack for iOS, just in case.
|
2022-06-21 00:08:33 +00:00
|
|
|
if (p_feature == "s3tc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC1_RGB_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-08-04 16:27:56 +00:00
|
|
|
#endif
|
2022-06-21 00:08:33 +00:00
|
|
|
|
|
|
|
if (p_feature == "bptc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC7_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-02-14 13:43:10 +00:00
|
|
|
if (p_feature == "etc2" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
2022-06-21 00:08:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-01-25 11:17:11 +00:00
|
|
|
if (p_feature == "astc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ASTC_4x4_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Utilities::update_memory_info() {
|
2021-07-02 23:14:19 +00:00
|
|
|
texture_mem_cache = RenderingDevice::get_singleton()->get_memory_usage(RenderingDevice::MEMORY_TEXTURES);
|
|
|
|
buffer_mem_cache = RenderingDevice::get_singleton()->get_memory_usage(RenderingDevice::MEMORY_BUFFERS);
|
|
|
|
total_mem_cache = RenderingDevice::get_singleton()->get_memory_usage(RenderingDevice::MEMORY_TOTAL);
|
|
|
|
}
|
2022-06-21 00:08:33 +00:00
|
|
|
|
|
|
|
uint64_t Utilities::get_rendering_info(RS::RenderingInfo p_info) {
|
2021-07-02 23:14:19 +00:00
|
|
|
if (p_info == RS::RENDERING_INFO_TEXTURE_MEM_USED) {
|
|
|
|
return texture_mem_cache;
|
|
|
|
} else if (p_info == RS::RENDERING_INFO_BUFFER_MEM_USED) {
|
|
|
|
return buffer_mem_cache;
|
|
|
|
} else if (p_info == RS::RENDERING_INFO_VIDEO_MEM_USED) {
|
|
|
|
return total_mem_cache;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
String Utilities::get_video_adapter_name() const {
|
2021-07-02 23:14:19 +00:00
|
|
|
return RenderingDevice::get_singleton()->get_device_name();
|
|
|
|
}
|
2021-12-10 16:01:51 +00:00
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
String Utilities::get_video_adapter_vendor() const {
|
2021-07-02 23:14:19 +00:00
|
|
|
return RenderingDevice::get_singleton()->get_device_vendor_name();
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
RenderingDevice::DeviceType Utilities::get_video_adapter_type() const {
|
2021-12-10 16:01:51 +00:00
|
|
|
return RenderingDevice::get_singleton()->get_device_type();
|
|
|
|
}
|
|
|
|
|
2022-06-21 00:08:33 +00:00
|
|
|
String Utilities::get_video_adapter_api_version() const {
|
2021-07-31 13:39:46 +00:00
|
|
|
return RenderingDevice::get_singleton()->get_device_api_version();
|
|
|
|
}
|
2022-08-21 22:16:56 +00:00
|
|
|
|
|
|
|
Size2i Utilities::get_maximum_viewport_size() const {
|
|
|
|
RenderingDevice *device = RenderingDevice::get_singleton();
|
|
|
|
|
|
|
|
int max_x = device->limit_get(RenderingDevice::LIMIT_MAX_VIEWPORT_DIMENSIONS_X);
|
|
|
|
int max_y = device->limit_get(RenderingDevice::LIMIT_MAX_VIEWPORT_DIMENSIONS_Y);
|
|
|
|
return Size2i(max_x, max_y);
|
|
|
|
}
|