Debian Codegraph @

servers/rendering/renderer_rd/storage_rd/utilities.h

raw symbols SCIP
1 /**************************************************************************/
2 /* utilities.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/templates/rid_owner.h"
34 #include "servers/rendering/storage/utilities.h"
35
36 namespace RendererRD {
37
38 /* VISIBILITY NOTIFIER */
39
40 struct VisibilityNotifier {
41 AABB aabb;
42 Callable enter_callback;
43 Callable exit_callback;
44 Dependency dependency;
45 };
46
47 class Utilities : public RendererUtilities {
48 private:
49 static Utilities *singleton;
50
51 /* VISIBILITY NOTIFIER */
52
53 mutable RID_Owner<VisibilityNotifier> visibility_notifier_owner;
54
55 /* MISC */
56
57 //keep cached since it can be called form any thread
58 uint64_t texture_mem_cache = 0;
59 uint64_t buffer_mem_cache = 0;
60 uint64_t total_mem_cache = 0;
61
62 public:
63 static Utilities *get_singleton() { return singleton; }
64
65 Utilities();
66 virtual ~Utilities() override;
67
68 /* INSTANCES */
69
70 virtual RS::InstanceType get_base_type(RID p_rid) const override;
71 virtual bool free(RID p_rid) override;
72
73 /* DEPENDENCIES */
74
75 virtual void base_update_dependency(RID p_base, DependencyTracker *p_instance) override;
76
77 /* VISIBILITY NOTIFIER */
78
79 VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); }
80 bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); }
81
82 virtual RID visibility_notifier_allocate() override;
83 virtual void visibility_notifier_initialize(RID p_notifier) override;
84 virtual void visibility_notifier_free(RID p_notifier) override;
85
86 virtual void visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) override;
87 virtual void visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) override;
88
89 virtual AABB visibility_notifier_get_aabb(RID p_notifier) const override;
90 virtual void visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) override;
91
92 /* TIMING */
93
94 virtual void capture_timestamps_begin() override;
95 virtual void capture_timestamp(const String &p_name) override;
96 virtual uint32_t get_captured_timestamps_count() const override;
97 virtual uint64_t get_captured_timestamps_frame() const override;
98 virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const override;
99 virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const override;
100 virtual String get_captured_timestamp_name(uint32_t p_index) const override;
101
102 /* MISC */
103
104 virtual void update_dirty_resources() override;
105 virtual void set_debug_generate_wireframes(bool p_generate) override {}
106
107 virtual bool has_os_feature(const String &p_feature) const override;
108
109 virtual void update_memory_info() override;
110
111 virtual uint64_t get_rendering_info(RS::RenderingInfo p_info) override;
112
113 virtual String get_video_adapter_name() const override;
114 virtual String get_video_adapter_vendor() const override;
115 virtual RenderingDevice::DeviceType get_video_adapter_type() const override;
116 virtual String get_video_adapter_api_version() const override;
117
118 virtual Size2i get_maximum_viewport_size() const override;
119 virtual uint32_t get_maximum_shader_varyings() const override;
120 virtual uint64_t get_maximum_uniform_buffer_size() const override;
121 };
122
123 } // namespace RendererRD