| 78 | } |
| 79 | |
| 80 | ref<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 | |
| 105 | uint32_t RenderGraph::getPassIndex(const std::string& name) const |
| 106 | { |
nothing calls this directly
no test coverage detected