Implement a "black board" for the framegraph
FrameGraph always keeps a default Blackboard, but additional ones can be created if needed. A blackboard is just a registry of FrameGraphHandles, queryable by name.
This commit is contained in:
committed by
Mathias Agopian
parent
2854c0627d
commit
fbad683810
@@ -44,6 +44,7 @@ set(SRCS
|
||||
src/components/LightManager.cpp
|
||||
src/components/RenderableManager.cpp
|
||||
src/components/TransformManager.cpp
|
||||
src/fg/Blackboard.cpp
|
||||
src/fg/FrameGraph.cpp
|
||||
src/fg/FrameGraphHandle.cpp
|
||||
src/fg/fg/RenderTarget.cpp
|
||||
@@ -90,6 +91,7 @@ set(PRIVATE_HDRS
|
||||
src/components/LightManager.h
|
||||
src/components/RenderableManager.h
|
||||
src/components/TransformManager.h
|
||||
src/fg/Blackboard.h
|
||||
src/fg/FrameGraph.h
|
||||
src/fg/FrameGraphPass.h
|
||||
src/fg/FrameGraphPassResources.h
|
||||
|
||||
35
filament/src/fg/Blackboard.cpp
Normal file
35
filament/src/fg/Blackboard.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Blackboard.h"
|
||||
|
||||
using namespace utils;
|
||||
|
||||
namespace filament {
|
||||
|
||||
FrameGraphHandle Blackboard::getHandle(utils::StaticString const& name) const noexcept {
|
||||
auto it = mMap.find(name);
|
||||
if (it != mMap.end()) {
|
||||
return it.value();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void Blackboard::remove(utils::StaticString const& name) noexcept {
|
||||
mMap.erase(name);
|
||||
}
|
||||
|
||||
} // namespace filament
|
||||
55
filament/src/fg/Blackboard.h
Normal file
55
filament/src/fg/Blackboard.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_FG_BLACKBOARD_H
|
||||
#define TNT_FILAMENT_FG_BLACKBOARD_H
|
||||
|
||||
#include "FrameGraphHandle.h"
|
||||
|
||||
#include <utils/CString.h>
|
||||
|
||||
#include <tsl/robin_map.h>
|
||||
|
||||
namespace filament {
|
||||
|
||||
class Blackboard {
|
||||
using Container = tsl::robin_map<utils::StaticString, FrameGraphHandle>;
|
||||
|
||||
public:
|
||||
auto& operator [](utils::StaticString const& name) noexcept {
|
||||
return mMap.insert_or_assign(name, FrameGraphHandle{}).first.value();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void put(utils::StaticString const& name, FrameGraphId<T> handle) noexcept {
|
||||
mMap.insert_or_assign(name, handle);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
FrameGraphId<T> get(utils::StaticString&& name) const noexcept {
|
||||
return static_cast<FrameGraphId<T>>(getHandle(std::forward<utils::StaticString>(name)));
|
||||
}
|
||||
|
||||
void remove(utils::StaticString const& name) noexcept;
|
||||
|
||||
private:
|
||||
FrameGraphHandle getHandle(utils::StaticString const& name) const noexcept;
|
||||
Container mMap;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
#endif //TNT_FILAMENT_FG_BLACKBOARD_H
|
||||
@@ -18,6 +18,7 @@
|
||||
#define TNT_FILAMENT_FRAMEGRAPH_H
|
||||
|
||||
|
||||
#include "Blackboard.h"
|
||||
#include "FrameGraphPass.h"
|
||||
#include "FrameGraphHandle.h"
|
||||
#include "FrameGraphPassResources.h"
|
||||
@@ -147,6 +148,9 @@ public:
|
||||
FrameGraph& operator = (FrameGraph const&) = delete;
|
||||
~FrameGraph();
|
||||
|
||||
Blackboard& getBlackboard() noexcept { return mBlackboard; }
|
||||
Blackboard const& getDefaultBlackboard() const noexcept { return mBlackboard; }
|
||||
|
||||
struct Empty{};
|
||||
|
||||
/*
|
||||
@@ -322,6 +326,7 @@ private:
|
||||
|
||||
FrameGraphHandle moveResource(FrameGraphHandle from, FrameGraphHandle to);
|
||||
|
||||
Blackboard mBlackboard;
|
||||
fg::ResourceAllocatorInterface& mResourceAllocator;
|
||||
details::LinearAllocatorArena mArena;
|
||||
Vector<fg::PassNode> mPassNodes; // list of frame graph passes
|
||||
|
||||
@@ -34,6 +34,7 @@ struct RenderTarget;
|
||||
struct RenderTargetResource;
|
||||
} // namespace fg
|
||||
|
||||
class Blackboard;
|
||||
class FrameGraph;
|
||||
class FrameGraphPassResources;
|
||||
|
||||
@@ -64,6 +65,7 @@ class FrameGraphId;
|
||||
class FrameGraphHandle {
|
||||
template<typename T>
|
||||
friend class FrameGraphId;
|
||||
friend class Blackboard;
|
||||
friend class FrameGraph;
|
||||
friend class FrameGraphPassResources;
|
||||
friend struct fg::PassNode;
|
||||
|
||||
Reference in New Issue
Block a user