Skip to content

Commit

Permalink
Workaround for issue with nanobind size check (#158)
Browse files Browse the repository at this point in the history
* Workaround for issue with nanobind size check

* Add link to github issue
  • Loading branch information
ccummingsNV authored Jan 23, 2025
1 parent da904ba commit b32ced5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/sgl/utils/python/slangpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,13 @@ SGL_PY_EXPORT(utils_slangpy)
)
.def_prop_rw("shape", &NativeSlangType::get_shape, &NativeSlangType::set_shape, D_NA(NativeSlangType, shape));

nb::class_<NativeMarshall, PyNativeMarshall, Object>(slangpy, "NativeMarshall") //
// This exposing of NativeMarshall as NativeMarshallBase, and the corresponding
// trampoline below is not how it is recommended in nanobind. It is a workaround
// for issue https://github.com/shader-slang/sgl/issues/159
nb::class_<NativeMarshall, Object>(slangpy, "NativeMarshallBase") //
.def(
"__init__",
[](NativeMarshall& self) { new (&self) PyNativeMarshall(); },
[](NativeMarshall& self) { new (&self) NativeMarshall(); },
D_NA(NativeMarshall, NativeMarshall)
)

Expand Down Expand Up @@ -658,6 +661,13 @@ SGL_PY_EXPORT(utils_slangpy)
.def("create_output", &NativeMarshall::create_output, D_NA(NativeMarshall, create_output))
.def("read_output", &NativeMarshall::read_output, D_NA(NativeMarshall, read_output));

nb::class_<PyNativeMarshall, NativeMarshall>(slangpy, "NativeMarshall") //
.def(
"__init__",
[](PyNativeMarshall& self) { new (&self) PyNativeMarshall(); },
D_NA(PyNativeMarshall, PyNativeMarshall)
);

nb::class_<NativeBoundVariableRuntime, Object>(slangpy, "NativeBoundVariableRuntime") //
.def(nb::init<>(), D_NA(NativeBoundVariableRuntime, NativeBoundVariableRuntime))
.def_prop_rw(
Expand Down

0 comments on commit b32ced5

Please sign in to comment.