Path: blob/master/servers/rendering/renderer_rd/storage_rd/utilities.h
10279 views
/**************************************************************************/1/* utilities.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/templates/rid_owner.h"33#include "servers/rendering/storage/utilities.h"3435namespace RendererRD {3637/* VISIBILITY NOTIFIER */3839struct VisibilityNotifier {40AABB aabb;41Callable enter_callback;42Callable exit_callback;43Dependency dependency;44};4546class Utilities : public RendererUtilities {47private:48static Utilities *singleton;4950/* VISIBILITY NOTIFIER */5152mutable RID_Owner<VisibilityNotifier> visibility_notifier_owner;5354/* MISC */5556//keep cached since it can be called form any thread57uint64_t texture_mem_cache = 0;58uint64_t buffer_mem_cache = 0;59uint64_t total_mem_cache = 0;6061public:62static Utilities *get_singleton() { return singleton; }6364Utilities();65virtual ~Utilities() override;6667/* INSTANCES */6869virtual RS::InstanceType get_base_type(RID p_rid) const override;70virtual bool free(RID p_rid) override;7172/* DEPENDENCIES */7374virtual void base_update_dependency(RID p_base, DependencyTracker *p_instance) override;7576/* VISIBILITY NOTIFIER */7778VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); }79bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); }8081virtual RID visibility_notifier_allocate() override;82virtual void visibility_notifier_initialize(RID p_notifier) override;83virtual void visibility_notifier_free(RID p_notifier) override;8485virtual void visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) override;86virtual void visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) override;8788virtual AABB visibility_notifier_get_aabb(RID p_notifier) const override;89virtual void visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) override;9091/* TIMING */9293virtual void capture_timestamps_begin() override;94virtual void capture_timestamp(const String &p_name) override;95virtual uint32_t get_captured_timestamps_count() const override;96virtual uint64_t get_captured_timestamps_frame() const override;97virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const override;98virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const override;99virtual String get_captured_timestamp_name(uint32_t p_index) const override;100101/* MISC */102103virtual void update_dirty_resources() override;104virtual void set_debug_generate_wireframes(bool p_generate) override {}105106virtual bool has_os_feature(const String &p_feature) const override;107108virtual void update_memory_info() override;109110virtual uint64_t get_rendering_info(RS::RenderingInfo p_info) override;111112virtual String get_video_adapter_name() const override;113virtual String get_video_adapter_vendor() const override;114virtual RenderingDevice::DeviceType get_video_adapter_type() const override;115virtual String get_video_adapter_api_version() const override;116117virtual Size2i get_maximum_viewport_size() const override;118virtual uint32_t get_maximum_shader_varyings() const override;119virtual uint64_t get_maximum_uniform_buffer_size() const override;120};121122} // namespace RendererRD123124125