From f62be3ab0a5a9858872f2012fc9c30cb2edb06c4 Mon Sep 17 00:00:00 2001 From: Stefan Habel <19556655+StefanHabel@users.noreply.github.com> Date: Tue, 31 Oct 2023 00:04:42 -0700 Subject: [PATCH] Docstrings for PyMaterialXGenMsl. (#1567) Signed-off-by: Stefan Habel <19556655+StefanHabel@users.noreply.github.com> --- .../PyMslShaderGenerator.cpp | 70 ++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/source/PyMaterialX/PyMaterialXGenMsl/PyMslShaderGenerator.cpp b/source/PyMaterialX/PyMaterialXGenMsl/PyMslShaderGenerator.cpp index 01e174d61f..47df8f20d7 100644 --- a/source/PyMaterialX/PyMaterialXGenMsl/PyMslShaderGenerator.cpp +++ b/source/PyMaterialX/PyMaterialXGenMsl/PyMslShaderGenerator.cpp @@ -20,11 +20,36 @@ namespace mx = MaterialX; void bindPyMslShaderGenerator(py::module& mod) { py::class_(mod, "MslShaderGenerator") - .def_static("create", &mx::MslShaderGenerator::create) - .def(py::init<>()) - .def("generate", &mx::MslShaderGenerator::generate) - .def("getTarget", &mx::MslShaderGenerator::getTarget) - .def("getVersion", &mx::MslShaderGenerator::getVersion) + + .def_static("create", &mx::MslShaderGenerator::create, + PYMATERIALX_DOCSTRING(R"docstring( + Create an instance of this class. +)docstring")) + + .def(py::init<>(), + PYMATERIALX_DOCSTRING(R"docstring( + Initialize an instance of this class. +)docstring")) + + .def("generate", &mx::MslShaderGenerator::generate, + py::arg("name"), + py::arg("element"), + py::arg("context"), + PYMATERIALX_DOCSTRING(R"docstring( + Generate a shader starting from the given `element`, translating the + element and all dependencies upstream into shader code. +)docstring")) + + .def("getTarget", &mx::MslShaderGenerator::getTarget, + PYMATERIALX_DOCSTRING(R"docstring( + Return a unique identifier for the target this generator is for. +)docstring")) + + .def("getVersion", &mx::MslShaderGenerator::getVersion, + PYMATERIALX_DOCSTRING(R"docstring( + Return the version string for the MSL version this generator is for. +)docstring")) + .doc() = PYMATERIALX_DOCSTRING(R"docstring( Base class for MSL (Metal Shading Language) code generation. A generator for a specific MSL target should be derived from this class. @@ -34,10 +59,37 @@ void bindPyMslShaderGenerator(py::module& mod) void bindPyMslResourceBindingContext(py::module &mod) { py::class_(mod, "MslResourceBindingContext") - .def_static("create", &mx::MslResourceBindingContext::create) - .def(py::init()) - .def("emitDirectives", &mx::MslResourceBindingContext::emitDirectives) - .def("emitResourceBindings", &mx::MslResourceBindingContext::emitResourceBindings) + + .def_static("create", &mx::MslResourceBindingContext::create, + py::arg("uniformBindingLocation"), + py::arg("samplerBindingLocation"), + PYMATERIALX_DOCSTRING(R"docstring( + Create an instance of this class, initialized using the given binding + locations. +)docstring")) + + .def(py::init(), + py::arg("uniformBindingLocation"), + py::arg("samplerBindingLocation"), + PYMATERIALX_DOCSTRING(R"docstring( + Initialize an instance of this class using the given binding locations. +)docstring")) + + .def("emitDirectives", &mx::MslResourceBindingContext::emitDirectives, + py::arg("context"), + py::arg("stage"), + PYMATERIALX_DOCSTRING(R"docstring( + Emit directives required for binding support. +)docstring")) + + .def("emitResourceBindings", &mx::MslResourceBindingContext::emitResourceBindings, + py::arg("context"), + py::arg("uniforms"), + py::arg("stage"), + PYMATERIALX_DOCSTRING(R"docstring( + Emit uniforms with binding information. +)docstring")) + .doc() = PYMATERIALX_DOCSTRING(R"docstring( Class representing a resource binding for MSL shader resources. )docstring");