核心模板架构

This commit is contained in:
2026-08-04 16:24:41 +08:00
parent 68476882a3
commit f1b9cadd47
121 changed files with 4782 additions and 210 deletions
@@ -0,0 +1,41 @@
#include "Renderable_Base.hpp"
#include "renderive/scene/base/Scene_Base.hpp"
Renderable_Base::Renderable_Base(Scene_Base& scene, Renderable_Configuration configuration) noexcept
: scene(&scene), layer_node(this), dependency_node(this), configuration(configuration) {}
Renderable_Base::~Renderable_Base() = default;
void Renderable_Base::render(const Scene_Render_Context&) {}
void Renderable_Base::invalidate_cache() noexcept {
cache_revision_.fetch_add(1, std::memory_order_release);
}
std::uint64_t Renderable_Base::cache_revision() const noexcept {
return cache_revision_.load(std::memory_order_acquire);
}
std::uint64_t Renderable_Base::rendered_cache_revision() const noexcept {
return rendered_cache_revision_.load(std::memory_order_acquire);
}
bool Renderable_Base::cache_valid() const noexcept {
return configuration.cache_enabled && rendered_cache_revision() == cache_revision();
}
void Renderable_Base::rebuild_task_graph() noexcept {
task_graph_ready_.store(false, std::memory_order_release);
invalidate_cache();
}
const Renderable_Task_Graph& Renderable_Base::task_graph() {
if (!task_graph_ready_.load(std::memory_order_acquire)) {
task_graph_.clear();
build_task_graph(task_graph_);
task_graph_ready_.store(true, std::memory_order_release);
}
return task_graph_;
}
void Renderable_Base::build_task_graph(Renderable_Task_Graph& graph) {
graph.emplace([this](const Scene_Render_Context& context) {
render(context);
}, "render");
}
bool Renderable_Base::requires_render() const noexcept {
return !configuration.cache_enabled || !cache_valid();
}
void Renderable_Base::mark_rendered() noexcept {
rendered_cache_revision_.store(cache_revision(), std::memory_order_release);
}