-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final results of collaboration with Google and The Forge #90284
base: master
Are you sure you want to change the base?
Changes from all commits
0fc0325
b25b49e
16fe4ee
c1250b8
6cf9b26
b611cf8
3315786
39bb921
c9d9294
5b2369f
45e9cc5
bdc5a1d
2718c27
c2b1658
f103234
eecc81f
84c4eaf
aa4ed9b
35961df
b02cf06
07ecf9d
062d8f1
7ea1c92
9600903
390d12e
4f30636
09f9cd0
3bb0366
c64defe
4151bac
2a9ea57
27ee7b4
0be8ab1
db6c6aa
9fc7df4
d275e88
074848f
9f9e8a5
0ad217f
247cd05
55a9f4e
679d451
ca71b28
4e4acda
57f7647
e5b954a
7fa2420
6b0c8c6
4dc90d3
887ea97
e05686e
74302f4
6e5c134
2127b8f
d3889a9
6dbc22b
5bc9ac3
654841d
45dbf8c
62179b2
3d21db1
6e6e147
4b40e7b
6854421
062183e
95cc7c1
08064c7
22fd9a3
2f617bb
6e27edd
64939a0
e6894bb
62095d8
2d466bb
baa46a6
f3b94fb
1a153ed
3409532
a9da7e3
ecbe3c9
2d64d49
01656c5
e133787
3ce6ccb
fa2e079
e0b7815
fe8a243
bfbe4c0
76bc465
778f798
829da6c
b3dbdec
b05f59a
61db948
5b8c36a
16146f3
b451518
9fc2bf0
9b1c3fe
6d0e8bd
6e27db7
8d2587d
38a3753
2806d85
d613b80
730eb17
2d1d9e5
816a77b
0206947
c4d827f
ae5abe2
368de5f
3b79e68
3e2cfe5
1b4b41c
2b5f8af
566ffe6
12ef522
faf5ac8
1e469ab
6a7bb35
4638dfd
3b636c3
fb2e2cd
ff787c1
a7ec312
55659dd
a8abe64
9ef8c3e
97fdd8b
0ad3b3a
9a20b8d
72045eb
9aff40c
e939cc6
a8070b7
bf7b8c5
ac16158
af70976
a5141bd
266313a
c084f58
89ad7e4
095df16
0623cc1
e4ca8e8
b038d52
1f5d484
be47c6a
651aef8
459a180
f63d39a
5a78540
4ca458d
1e7ec83
931629d
5bb5f88
aad4c71
e4f87d1
cef59d7
a6fc5f2
75d6cd7
8ccf882
7e66978
ecf643e
b1bca37
9ee5068
52ccd58
abaf0b5
f1a04a8
d928c3f
c7452b2
c238452
4d97ca6
0b3fb61
bf44bf6
3f0ff05
207bd6c
dae972c
805780d
0a5efd0
f67d2c4
c0c7853
5ce0ddc
12d87ba
8529a3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,17 @@ | |
#include "core/os/thread_safe.h" | ||
#include "core/variant/typed_array.h" | ||
|
||
|
||
#if defined(VK_TRACK_DRIVER_MEMORY) || defined(VK_TRACK_DEVICE_MEMORY) | ||
#include "drivers/vulkan/rendering_context_driver_vulkan.h" | ||
#endif | ||
|
||
// <TF> | ||
// @ShadyTF script function to get performance report text | ||
#include "servers/rendering/rendering_device.h" | ||
// </TF> | ||
|
||
|
||
namespace core_bind { | ||
|
||
////// ResourceLoader ////// | ||
|
@@ -1594,6 +1605,12 @@ int Engine::get_max_fps() const { | |
double Engine::get_frames_per_second() const { | ||
return ::Engine::get_singleton()->get_frames_per_second(); | ||
} | ||
// <TF> | ||
// @ShadyTF script function to get performance report text | ||
String Engine::get_perf_report() const { | ||
return RenderingDevice::get_singleton()->get_perf_report(); | ||
} | ||
// </TF> | ||
|
||
uint64_t Engine::get_physics_frames() const { | ||
return ::Engine::get_singleton()->get_physics_frames(); | ||
|
@@ -1603,6 +1620,45 @@ uint64_t Engine::get_process_frames() const { | |
return ::Engine::get_singleton()->get_process_frames(); | ||
} | ||
|
||
#if defined(VK_TRACK_DRIVER_MEMORY) || defined(VK_TRACK_DEVICE_MEMORY) | ||
String Engine::get_tracked_object_name(uint32_t typeIndex) const { | ||
return RenderingContextDriverVulkan::get_tracked_object_name(typeIndex); | ||
} | ||
uint64_t Engine::get_tracked_object_type_count() const { | ||
return RenderingContextDriverVulkan::get_tracked_object_type_count(); | ||
} | ||
#endif | ||
|
||
#if defined(VK_TRACK_DRIVER_MEMORY) | ||
uint64_t Engine::get_driver_total_memory() const { | ||
return RenderingContextDriverVulkan::get_driver_total_memory(); | ||
} | ||
uint64_t Engine::get_driver_allocation_count() const { | ||
return RenderingContextDriverVulkan::get_driver_allocation_count(); | ||
} | ||
uint64_t Engine::get_driver_memory_by_object_type(uint32_t type) const { | ||
return RenderingContextDriverVulkan::get_driver_memory_by_object_type(type); | ||
} | ||
uint64_t Engine::get_driver_allocs_by_object_type(uint32_t type) const { | ||
return RenderingContextDriverVulkan::get_driver_allocs_by_object_type(type); | ||
} | ||
#endif | ||
|
||
#if defined(VK_TRACK_DEVICE_MEMORY) | ||
uint64_t Engine::get_device_total_memory() const { | ||
return RenderingContextDriverVulkan::get_device_total_memory(); | ||
} | ||
uint64_t Engine::get_device_allocation_count() const { | ||
return RenderingContextDriverVulkan::get_device_allocation_count(); | ||
} | ||
uint64_t Engine::get_device_memory_by_object_type(uint32_t type) const { | ||
return RenderingContextDriverVulkan::get_device_memory_by_object_type(type); | ||
} | ||
uint64_t Engine::get_device_allocs_by_object_type(uint32_t type) const { | ||
return RenderingContextDriverVulkan::get_device_allocs_by_object_type(type); | ||
} | ||
#endif | ||
|
||
void Engine::set_time_scale(double p_scale) { | ||
::Engine::get_singleton()->set_time_scale(p_scale); | ||
} | ||
|
@@ -1748,10 +1804,34 @@ void Engine::_bind_methods() { | |
ClassDB::bind_method(D_METHOD("get_time_scale"), &Engine::get_time_scale); | ||
|
||
ClassDB::bind_method(D_METHOD("get_frames_drawn"), &Engine::get_frames_drawn); | ||
// <TF> | ||
// @ShadyTF script function to get performance report text | ||
ClassDB::bind_method(D_METHOD("get_frames_per_second"), &Engine::get_frames_per_second); | ||
// </TF> | ||
|
||
ClassDB::bind_method(D_METHOD("get_perf_report"), &Engine::get_perf_report); | ||
ClassDB::bind_method(D_METHOD("get_physics_frames"), &Engine::get_physics_frames); | ||
ClassDB::bind_method(D_METHOD("get_process_frames"), &Engine::get_process_frames); | ||
|
||
#if defined(VK_TRACK_DRIVER_MEMORY) || defined(VK_TRACK_DEVICE_MEMORY) | ||
ClassDB::bind_method(D_METHOD("get_tracked_object_name"), &Engine::get_tracked_object_name); | ||
ClassDB::bind_method(D_METHOD("get_tracked_object_type_count"), &Engine::get_tracked_object_type_count); | ||
#endif | ||
|
||
#if defined(VK_TRACK_DRIVER_MEMORY) | ||
ClassDB::bind_method(D_METHOD("get_driver_total_memory"), &Engine::get_driver_total_memory); | ||
ClassDB::bind_method(D_METHOD("get_driver_allocation_count"), &Engine::get_driver_allocation_count); | ||
ClassDB::bind_method(D_METHOD("get_driver_memory_by_object_type"), &Engine::get_driver_memory_by_object_type); | ||
ClassDB::bind_method(D_METHOD("get_driver_allocs_by_object_type"), &Engine::get_driver_allocs_by_object_type); | ||
#endif | ||
|
||
#if defined(VK_TRACK_DEVICE_MEMORY) | ||
ClassDB::bind_method(D_METHOD("get_device_total_memory"), &Engine::get_device_total_memory); | ||
ClassDB::bind_method(D_METHOD("get_device_allocation_count"), &Engine::get_device_allocation_count); | ||
ClassDB::bind_method(D_METHOD("get_device_memory_by_object_type"), &Engine::get_device_memory_by_object_type); | ||
ClassDB::bind_method(D_METHOD("get_device_allocs_by_object_type"), &Engine::get_device_allocs_by_object_type); | ||
#endif | ||
Comment on lines
+1816
to
+1833
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will mess up documentation generation, so should not be |
||
|
||
ClassDB::bind_method(D_METHOD("get_main_loop"), &Engine::get_main_loop); | ||
|
||
ClassDB::bind_method(D_METHOD("get_version_info"), &Engine::get_version_info); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -65,6 +65,32 @@ SafeNumeric<uint64_t> Memory::max_usage; | |||||||||||
|
||||||||||||
SafeNumeric<uint64_t> Memory::alloc_count; | ||||||||||||
|
||||||||||||
void *Memory::alloc_aligned_static(size_t p_bytes, size_t p_alignment) { | ||||||||||||
void *p1, *p2; | ||||||||||||
if ((p1 = (void *)malloc(p_bytes + p_alignment - 1 + sizeof(uint32_t))) == NULL) | ||||||||||||
return NULL; | ||||||||||||
Comment on lines
+70
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason it's not using C11 |
||||||||||||
|
||||||||||||
p2 = (void *)(((uintptr_t)p1 + sizeof(uint32_t) + p_alignment - 1) & ~((p_alignment)-1)); | ||||||||||||
*((uint32_t *)p2 - 1) = (uint32_t)((uintptr_t)p2 - (uintptr_t)p1); | ||||||||||||
return p2; | ||||||||||||
} | ||||||||||||
|
||||||||||||
void *Memory::realloc_aligned_static(void* p_memory, size_t p_bytes, size_t p_prev_bytes, size_t p_alignment) { | ||||||||||||
if (p_memory == NULL) | ||||||||||||
return alloc_aligned_static(p_bytes, p_alignment); | ||||||||||||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
void *ret = alloc_aligned_static(p_bytes, p_alignment); | ||||||||||||
memcpy(ret, p_memory, p_prev_bytes); | ||||||||||||
free_aligned_static(p_memory); | ||||||||||||
return ret; | ||||||||||||
} | ||||||||||||
|
||||||||||||
void Memory::free_aligned_static(void* p_memory) { | ||||||||||||
uint32_t offset = *((uint32_t *)p_memory - 1); | ||||||||||||
void *p = (void *)((uint8_t *)p_memory - offset); | ||||||||||||
free(p); | ||||||||||||
} | ||||||||||||
|
||||||||||||
void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { | ||||||||||||
#ifdef DEBUG_ENABLED | ||||||||||||
bool prepad = true; | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be moved to
drivers/vulkan
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking into this PR.
It seems like it can't be moved there.
It appears that the
VK_TRACK_DEVICE_MEMORY
is a debug-only macro (it's only defined in debug & dev builds).When that macro is defined, objects from core inform the Vulkan subsystem what subsystem they belong to.
e.g. in core/core_bind.cpp we have things like:
Where
get_tracked_object_name
returns a string like "INSTANCE", "PHYSICAL_DEVICE", "DESCRIPTOR_SET_LAYOUT".I don't know if there is a better way yet, but it's not a simple thing of moving that line to a different header.