refactor(srp): move scene setup ownership into managed renderer
This commit is contained in:
@@ -49,8 +49,6 @@ using DirectionalShadowPlanningPolicyRegistry =
|
||||
std::unordered_map<std::string, DirectionalShadowPlanningPolicy>;
|
||||
using CameraFramePlanPolicyRegistry =
|
||||
std::unordered_map<std::string, CameraFramePlanPolicy>;
|
||||
using RenderSceneSetupPolicyRegistry =
|
||||
std::unordered_map<std::string, RenderSceneSetupPolicy>;
|
||||
using DirectionalShadowExecutionPolicyRegistry =
|
||||
std::unordered_map<std::string, DirectionalShadowExecutionPolicy>;
|
||||
|
||||
@@ -70,18 +68,11 @@ GetDirectionalShadowPlanningPolicyRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
CameraFramePlanPolicyRegistry&
|
||||
GetCameraFramePlanPolicyRegistry() {
|
||||
CameraFramePlanPolicyRegistry& GetCameraFramePlanPolicyRegistry() {
|
||||
static CameraFramePlanPolicyRegistry registry = {};
|
||||
return registry;
|
||||
}
|
||||
|
||||
RenderSceneSetupPolicyRegistry&
|
||||
GetRenderSceneSetupPolicyRegistry() {
|
||||
static RenderSceneSetupPolicyRegistry registry = {};
|
||||
return registry;
|
||||
}
|
||||
|
||||
DirectionalShadowExecutionPolicyRegistry&
|
||||
GetDirectionalShadowExecutionPolicyRegistry() {
|
||||
static DirectionalShadowExecutionPolicyRegistry registry = {};
|
||||
@@ -108,11 +99,6 @@ std::unordered_set<std::string>& GetBuiltinCameraFramePlanPolicyKeys() {
|
||||
return builtinKeys;
|
||||
}
|
||||
|
||||
std::unordered_set<std::string>& GetBuiltinRenderSceneSetupPolicyKeys() {
|
||||
static std::unordered_set<std::string> builtinKeys = {};
|
||||
return builtinKeys;
|
||||
}
|
||||
|
||||
std::unordered_set<std::string>&
|
||||
GetBuiltinDirectionalShadowExecutionPolicyKeys() {
|
||||
static std::unordered_set<std::string> builtinKeys = {};
|
||||
@@ -139,11 +125,6 @@ std::mutex& GetCameraFramePlanPolicyRegistryMutex() {
|
||||
return mutex;
|
||||
}
|
||||
|
||||
std::mutex& GetRenderSceneSetupPolicyRegistryMutex() {
|
||||
static std::mutex mutex;
|
||||
return mutex;
|
||||
}
|
||||
|
||||
std::mutex& GetDirectionalShadowExecutionPolicyRegistryMutex() {
|
||||
static std::mutex mutex;
|
||||
return mutex;
|
||||
@@ -227,25 +208,6 @@ void EnsureBuiltinCameraFramePlanPolicyRegistryInitialized() {
|
||||
(void)initialized;
|
||||
}
|
||||
|
||||
void EnsureBuiltinRenderSceneSetupPolicyRegistryInitialized() {
|
||||
static const bool initialized = []() {
|
||||
RenderSceneSetupPolicyRegistry& registry =
|
||||
GetRenderSceneSetupPolicyRegistry();
|
||||
registry.emplace(
|
||||
"BuiltinDefaultSceneSetup",
|
||||
[](const CameraFramePlan& plan,
|
||||
RenderSceneData& sceneData) {
|
||||
ApplyDefaultRenderPipelineSceneSetupPolicy(
|
||||
plan,
|
||||
sceneData);
|
||||
});
|
||||
GetBuiltinRenderSceneSetupPolicyKeys().insert(
|
||||
"BuiltinDefaultSceneSetup");
|
||||
return true;
|
||||
}();
|
||||
(void)initialized;
|
||||
}
|
||||
|
||||
void EnsureBuiltinDirectionalShadowExecutionPolicyRegistryInitialized() {
|
||||
static const bool initialized = []() {
|
||||
DirectionalShadowExecutionPolicyRegistry& registry =
|
||||
@@ -557,72 +519,6 @@ bool ApplyCameraFramePlanPolicyByKey(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegisterRenderSceneSetupPolicy(
|
||||
const std::string& key,
|
||||
RenderSceneSetupPolicy policy) {
|
||||
if (key.empty() || !policy) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureBuiltinRenderSceneSetupPolicyRegistryInitialized();
|
||||
|
||||
std::lock_guard<std::mutex> lock(
|
||||
GetRenderSceneSetupPolicyRegistryMutex());
|
||||
RenderSceneSetupPolicyRegistry& registry =
|
||||
GetRenderSceneSetupPolicyRegistry();
|
||||
if (registry.find(key) != registry.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
registry.emplace(key, std::move(policy));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnregisterRenderSceneSetupPolicy(
|
||||
const std::string& key) {
|
||||
if (key.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureBuiltinRenderSceneSetupPolicyRegistryInitialized();
|
||||
|
||||
std::lock_guard<std::mutex> lock(
|
||||
GetRenderSceneSetupPolicyRegistryMutex());
|
||||
if (GetBuiltinRenderSceneSetupPolicyKeys().find(key) !=
|
||||
GetBuiltinRenderSceneSetupPolicyKeys().end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderSceneSetupPolicyRegistry& registry =
|
||||
GetRenderSceneSetupPolicyRegistry();
|
||||
return registry.erase(key) != 0u;
|
||||
}
|
||||
|
||||
bool ApplyRenderSceneSetupPolicyByKey(
|
||||
const std::string& key,
|
||||
const CameraFramePlan& plan,
|
||||
RenderSceneData& sceneData) {
|
||||
if (key.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureBuiltinRenderSceneSetupPolicyRegistryInitialized();
|
||||
|
||||
std::lock_guard<std::mutex> lock(
|
||||
GetRenderSceneSetupPolicyRegistryMutex());
|
||||
const RenderSceneSetupPolicyRegistry& registry =
|
||||
GetRenderSceneSetupPolicyRegistry();
|
||||
const auto it = registry.find(key);
|
||||
if (it == registry.end() || !it->second) {
|
||||
return false;
|
||||
}
|
||||
|
||||
it->second(
|
||||
plan,
|
||||
sceneData);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RegisterDirectionalShadowExecutionPolicy(
|
||||
const std::string& key,
|
||||
DirectionalShadowExecutionPolicy policy) {
|
||||
|
||||
Reference in New Issue
Block a user