refactor(srp): make stage capability follow selected renderer
This commit is contained in:
@@ -1362,6 +1362,7 @@ public:
|
||||
m_ownedSceneRenderer->Shutdown();
|
||||
}
|
||||
m_ownedPipelineRendererAsset.reset();
|
||||
m_supportsStageContextualMethod = nullptr;
|
||||
m_supportsStageMethod = nullptr;
|
||||
m_recordStageMethod = nullptr;
|
||||
m_resolvedPipelineHandle = 0;
|
||||
@@ -1375,12 +1376,65 @@ public:
|
||||
}
|
||||
|
||||
bool SupportsStageRenderGraph(Rendering::CameraFrameStage stage) const override {
|
||||
if (!SupportsManagedRenderPipelineStageGraphRecording(stage) ||
|
||||
return SupportsStageRenderGraph(
|
||||
Rendering::RenderPipelineStageSupportContext{
|
||||
stage,
|
||||
-1 });
|
||||
}
|
||||
|
||||
bool SupportsStageRenderGraph(
|
||||
const Rendering::RenderPipelineStageSupportContext& context) const override {
|
||||
if (!SupportsManagedRenderPipelineStageGraphRecording(context.stage) ||
|
||||
!IsRuntimeAlive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoObject* const pipelineObject = GetManagedPipelineObject();
|
||||
if (!pipelineObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoMethod* const contextualMethod =
|
||||
ResolveSupportsStageContextualMethod(
|
||||
pipelineObject);
|
||||
if (contextualMethod != nullptr) {
|
||||
int32_t managedStage =
|
||||
static_cast<int32_t>(context.stage);
|
||||
int32_t rendererIndex =
|
||||
context.rendererIndex;
|
||||
void* args[2] = {
|
||||
&managedStage,
|
||||
&rendererIndex };
|
||||
MonoObject* result = nullptr;
|
||||
if (!m_runtime->InvokeManagedMethod(
|
||||
pipelineObject,
|
||||
contextualMethod,
|
||||
args,
|
||||
&result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsStage = false;
|
||||
return TryUnboxManagedBoolean(
|
||||
result,
|
||||
supportsStage) &&
|
||||
supportsStage;
|
||||
}
|
||||
|
||||
return SupportsStageRenderGraphFallback(
|
||||
pipelineObject,
|
||||
context.stage);
|
||||
}
|
||||
|
||||
private:
|
||||
bool SupportsStageRenderGraphFallback(
|
||||
MonoObject* pipelineObject,
|
||||
Rendering::CameraFrameStage stage) const {
|
||||
if (!SupportsManagedRenderPipelineStageGraphRecording(stage) ||
|
||||
!IsRuntimeAlive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoMethod* const method = ResolveSupportsStageMethod(pipelineObject);
|
||||
if (!pipelineObject || !method) {
|
||||
return false;
|
||||
@@ -1401,6 +1455,7 @@ public:
|
||||
return TryUnboxManagedBoolean(result, supportsStage) && supportsStage;
|
||||
}
|
||||
|
||||
public:
|
||||
bool RecordStageRenderGraph(
|
||||
const Rendering::RenderPipelineStageRenderGraphContext& context) override {
|
||||
if (!IsRuntimeAlive()) {
|
||||
@@ -1475,6 +1530,7 @@ private:
|
||||
}
|
||||
|
||||
if (pipelineHandle != m_resolvedPipelineHandle) {
|
||||
m_supportsStageContextualMethod = nullptr;
|
||||
m_supportsStageMethod = nullptr;
|
||||
m_recordStageMethod = nullptr;
|
||||
m_resolvedPipelineHandle = pipelineHandle;
|
||||
@@ -1483,6 +1539,19 @@ private:
|
||||
return m_runtime->GetManagedObject(pipelineHandle);
|
||||
}
|
||||
|
||||
MonoMethod* ResolveSupportsStageContextualMethod(
|
||||
MonoObject* pipelineObject) const {
|
||||
if (m_supportsStageContextualMethod == nullptr) {
|
||||
m_supportsStageContextualMethod =
|
||||
m_runtime->ResolveManagedMethod(
|
||||
pipelineObject,
|
||||
"SupportsStageRenderGraphContextual",
|
||||
2);
|
||||
}
|
||||
|
||||
return m_supportsStageContextualMethod;
|
||||
}
|
||||
|
||||
MonoMethod* ResolveSupportsStageMethod(MonoObject* pipelineObject) const {
|
||||
if (m_supportsStageMethod == nullptr) {
|
||||
m_supportsStageMethod =
|
||||
@@ -1615,6 +1684,7 @@ private:
|
||||
|
||||
std::shared_ptr<const MonoManagedRenderPipelineAssetRuntime> m_assetRuntime;
|
||||
MonoScriptRuntime* m_runtime = nullptr;
|
||||
mutable MonoMethod* m_supportsStageContextualMethod = nullptr;
|
||||
mutable MonoMethod* m_supportsStageMethod = nullptr;
|
||||
mutable MonoMethod* m_recordStageMethod = nullptr;
|
||||
mutable uint32_t m_resolvedPipelineHandle = 0;
|
||||
|
||||
Reference in New Issue
Block a user