forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyShaderStage.cpp
More file actions
46 lines (39 loc) · 2.29 KB
/
PyShaderStage.cpp
File metadata and controls
46 lines (39 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// TM & (c) 2019 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#include <PyMaterialX/PyMaterialX.h>
#include <MaterialXGenShader/ShaderStage.h>
namespace py = pybind11;
namespace mx = MaterialX;
void bindPyShaderStage(py::module& mod)
{
mod.attr("PIXEL_STAGE") = &mx::Stage::PIXEL;
py::class_<mx::ShaderPortPredicate>(mod, "ShaderPortPredicate");
py::class_<mx::VariableBlock, mx::VariableBlockPtr>(mod, "VariableBlock")
.def(py::init<const std::string&, const std::string&>())
.def("getName", &mx::VariableBlock::getName)
.def("getInstance", &mx::VariableBlock::getInstance)
.def("empty", &mx::VariableBlock::empty)
.def("size", &mx::VariableBlock::size)
.def("find", static_cast<mx::ShaderPort* (mx::VariableBlock::*)(const std::string&)>(&mx::VariableBlock::find))
.def("find", (mx::ShaderPort* (mx::VariableBlock::*)(const mx::ShaderPortPredicate& )) &mx::VariableBlock::find)
.def("__len__", &mx::VariableBlock::size)
.def("__getitem__", [](const mx::VariableBlock &vb, size_t i)
{
if (i >= vb.size()) throw py::index_error();
return vb[i];
}, py::return_value_policy::reference_internal);
py::class_<mx::ShaderStage>(mod, "ShaderStage")
.def(py::init<const std::string&, mx::ConstSyntaxPtr>())
.def("getName", &mx::ShaderStage::getName)
.def("getFunctionName", &mx::ShaderStage::getFunctionName)
.def("getSourceCode", &mx::ShaderStage::getSourceCode)
.def("getUniformBlock", static_cast<mx::VariableBlock& (mx::ShaderStage::*)(const std::string&)>(&mx::ShaderStage::getUniformBlock))
.def("getInputBlock", static_cast<mx::VariableBlock& (mx::ShaderStage::*)(const std::string&)>(&mx::ShaderStage::getInputBlock))
.def("getOutputBlock", static_cast<mx::VariableBlock& (mx::ShaderStage::*)(const std::string&)>(&mx::ShaderStage::getOutputBlock))
.def("getConstantBlock", static_cast<mx::VariableBlock& (mx::ShaderStage::*)()>(&mx::ShaderStage::getConstantBlock))
.def("getUniformBlocks", &mx::ShaderStage::getUniformBlocks)
.def("getInputBlocks", &mx::ShaderStage::getInputBlocks)
.def("getOutputBlocks", &mx::ShaderStage::getOutputBlocks);
}