Skip to content

Commit

Permalink
Docstrings for PyMaterialXGenMsl. (#1567)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Habel <[email protected]>
  • Loading branch information
StefanHabel committed Oct 31, 2023
1 parent dfa106a commit f62be3a
Showing 1 changed file with 61 additions and 9 deletions.
70 changes: 61 additions & 9 deletions source/PyMaterialX/PyMaterialXGenMsl/PyMslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,36 @@ namespace mx = MaterialX;
void bindPyMslShaderGenerator(py::module& mod)
{
py::class_<mx::MslShaderGenerator, mx::HwShaderGenerator, mx::MslShaderGeneratorPtr>(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.
Expand All @@ -34,10 +59,37 @@ void bindPyMslShaderGenerator(py::module& mod)
void bindPyMslResourceBindingContext(py::module &mod)
{
py::class_<mx::MslResourceBindingContext, mx::HwResourceBindingContext, mx::MslResourceBindingContextPtr>(mod, "MslResourceBindingContext")
.def_static("create", &mx::MslResourceBindingContext::create)
.def(py::init<size_t, size_t>())
.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<size_t, size_t>(),
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");
Expand Down

0 comments on commit f62be3a

Please sign in to comment.