python/module.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | /// @file module.cpp | ||
| 3 | /// @brief The _ernie Python extension module. | ||
| 4 | #include "ernie/device/device.h" | ||
| 5 | #include "ernie/python/device.h" | ||
| 6 | #include "ernie/python/render.h" | ||
| 7 | #include "ernie/python/scene.h" | ||
| 8 | #include "ernie/util/version.h" | ||
| 9 | |||
| 10 | #include <nanobind/nanobind.h> | ||
| 11 | #include <nanobind/stl/string.h> | ||
| 12 | #include <nanobind/stl/vector.h> | ||
| 13 | |||
| 14 | namespace nb = nanobind; | ||
| 15 | |||
| 16 | 24 | NB_MODULE(_ernie, module) { | |
| 17 | 6 | module.doc() = "Ernie's native module."; | |
| 18 | 12 | module.attr("__version__") = std::string(ernie::Version()); | |
| 19 | |||
| 20 | 6 | nb::enum_<ernie::VulkanDeviceType>(module, "VulkanDeviceType") | |
| 21 | 6 | .value("OTHER", ernie::VulkanDeviceType::Other) | |
| 22 | 6 | .value("INTEGRATED_GPU", ernie::VulkanDeviceType::IntegratedGpu) | |
| 23 | 6 | .value("DISCRETE_GPU", ernie::VulkanDeviceType::DiscreteGpu) | |
| 24 | 6 | .value("VIRTUAL_GPU", ernie::VulkanDeviceType::VirtualGpu) | |
| 25 | 6 | .value("CPU", ernie::VulkanDeviceType::Cpu); | |
| 26 | |||
| 27 | 6 | nb::class_<ernie::VulkanDeviceInfo>(module, "VulkanDeviceInfo") | |
| 28 | 6 | .def_ro("name", &ernie::VulkanDeviceInfo::name) | |
| 29 | 6 | .def_ro("type", &ernie::VulkanDeviceInfo::type) | |
| 30 | 6 | .def_ro("api_major", &ernie::VulkanDeviceInfo::apiMajor) | |
| 31 | 6 | .def_ro("api_minor", &ernie::VulkanDeviceInfo::apiMinor) | |
| 32 | 6 | .def_prop_ro("ray_query", | |
| 33 | 6 | [](const ernie::VulkanDeviceInfo& info) { return info.capabilities.rayQuery; }) | |
| 34 | 6 | .def_ro("uuid", &ernie::VulkanDeviceInfo::uuid) | |
| 35 | 6 | .def_ro("supported", &ernie::VulkanDeviceInfo::supported); | |
| 36 | |||
| 37 | 6 | ernie::python::BindDevice(module); | |
| 38 | 6 | ernie::python::BindScene(module); | |
| 39 | 6 | ernie::python::BindRender(module); | |
| 40 | |||
| 41 | 6 | module.def("vulkan_devices", &ernie::ListVulkanDevices, | |
| 42 | "Lists the Vulkan devices of the installed drivers."); | ||
| 43 | 6 | } | |
| 44 |