MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / createFromString

Method createFromString

Source/Falcor/RenderGraph/RenderGraph.cpp:80–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80ref<RenderGraph> RenderGraph::createFromString(ref<Device> pDevice, const std::string_view script)
81{
82 using namespace pybind11::literals;
83
84 ref<RenderGraph> pGraph;
85
86 // Setup a temporary scripting context that defines a local variable 'm' that
87 // has a 'addGraph' function exposed. This mimmicks the old Mogwai Python API
88 // allowing to load python based render graph scripts.
89 auto addGraph = pybind11::cpp_function([&pGraph](ref<RenderGraph> graph) { pGraph = graph; });
90
91 auto SimpleNamespace = pybind11::module_::import("types").attr("SimpleNamespace");
92 pybind11::object m = SimpleNamespace("addGraph"_a = addGraph);
93
94 Scripting::Context ctx;
95 ctx.setObject("m", m);
96
97 ref<Device> pPrevDevice = getActivePythonRenderGraphDevice();
98 setActivePythonRenderGraphDevice(pDevice);
99 Scripting::runScript(script, ctx);
100 setActivePythonRenderGraphDevice(pPrevDevice);
101
102 return pGraph;
103}
104
105uint32_t RenderGraph::getPassIndex(const std::string& name) const
106{

Callers

nothing calls this directly

Calls 4

runScriptFunction · 0.85
setObjectMethod · 0.80

Tested by

no test coverage detected