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

Method createFromFile

Source/Falcor/RenderGraph/RenderGraph.cpp:55–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55ref<RenderGraph> RenderGraph::createFromFile(ref<Device> pDevice, const std::filesystem::path& path)
56{
57 using namespace pybind11::literals;
58
59 ref<RenderGraph> pGraph;
60
61 // Setup a temporary scripting context that defines a local variable 'm' that
62 // has a 'addGraph' function exposed. This mimmicks the old Mogwai Python API
63 // allowing to load python based render graph scripts.
64 auto addGraph = pybind11::cpp_function([&pGraph](ref<RenderGraph> graph) { pGraph = graph; });
65
66 auto SimpleNamespace = pybind11::module_::import("types").attr("SimpleNamespace");
67 pybind11::object m = SimpleNamespace("addGraph"_a = addGraph);
68
69 Scripting::Context ctx;
70 ctx.setObject("m", m);
71
72 ref<Device> pPrevDevice = getActivePythonRenderGraphDevice();
73 setActivePythonRenderGraphDevice(pDevice);
74 Scripting::runScriptFromFile(path, ctx);
75 setActivePythonRenderGraphDevice(pPrevDevice);
76
77 return pGraph;
78}
79
80ref<RenderGraph> RenderGraph::createFromString(ref<Device> pDevice, const std::string_view script)
81{

Callers

nothing calls this directly

Calls 3

setObjectMethod · 0.80

Tested by

no test coverage detected