Skip to content

Commit

Permalink
NativeType->NativeMarshall
Browse files Browse the repository at this point in the history
  • Loading branch information
ccummingsNV committed Jan 21, 2025
1 parent 18dd74f commit 6a517a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
26 changes: 13 additions & 13 deletions src/sgl/utils/python/slangpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern void write_shader_cursor(ShaderCursor& cursor, nb::object value);

namespace sgl::slangpy {

void NativeType::write_shader_cursor_pre_dispatch(
void NativeMarshall::write_shader_cursor_pre_dispatch(
CallContext* context,
NativeBoundVariableRuntime* binding,
ShaderCursor cursor,
Expand Down Expand Up @@ -665,28 +665,28 @@ SGL_PY_EXPORT(utils_slangpy)
D_NA(NativeSlangType, type_reflection)
);

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

.def_prop_rw(
"concrete_shape",
&NativeType::get_concrete_shape,
&NativeType::set_concrete_shape,
D_NA(NativeType, concrete_shape)
&NativeMarshall::get_concrete_shape,
&NativeMarshall::set_concrete_shape,
D_NA(NativeMarshall, concrete_shape)
)
.def(
"write_shader_cursor_pre_dispatch",
&NativeType::write_shader_cursor_pre_dispatch,
D_NA(NativeType, write_shader_cursor_pre_dispatch)
&NativeMarshall::write_shader_cursor_pre_dispatch,
D_NA(NativeMarshall, write_shader_cursor_pre_dispatch)
)
.def("create_calldata", &NativeType::create_calldata, D_NA(NativeType, create_calldata))
.def("read_calldata", &NativeType::read_calldata, D_NA(NativeType, read_calldata))
.def("create_output", &NativeType::create_output, D_NA(NativeType, create_output))
.def("read_output", &NativeType::read_output, D_NA(NativeType, read_output));
.def("create_calldata", &NativeMarshall::create_calldata, D_NA(NativeMarshall, create_calldata))
.def("read_calldata", &NativeMarshall::read_calldata, D_NA(NativeMarshall, read_calldata))
.def("create_output", &NativeMarshall::create_output, D_NA(NativeMarshall, create_output))
.def("read_output", &NativeMarshall::read_output, D_NA(NativeMarshall, read_output));

nb::class_<NativeBoundVariableRuntime, Object>(slangpy, "NativeBoundVariableRuntime") //
.def(nb::init<>(), D_NA(NativeBoundVariableRuntime, NativeBoundVariableRuntime))
Expand Down
16 changes: 8 additions & 8 deletions src/sgl/utils/python/slangpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class NativeSlangType : public Object {
};

/// Base class for a marshal to a slangpy supported type.
class NativeType : public Object {
class NativeMarshall : public Object {
public:
virtual ~NativeType() = default;
virtual ~NativeMarshall() = default;

/// Get the concrete shape of the type. For none-concrete types such as buffers,
/// this will return an invalid shape.
Expand Down Expand Up @@ -135,9 +135,9 @@ class NativeType : public Object {
Shape m_concrete_shape;
};

/// Nanobind trampoline class for NativeType
struct PyNativeType : public NativeType {
NB_TRAMPOLINE(NativeType, 10);
/// Nanobind trampoline class for NativeMarshall
struct PyNativeMarshall : public NativeMarshall {
NB_TRAMPOLINE(NativeMarshall, 10);

Shape get_shape(nb::object data) const override { NB_OVERRIDE(get_shape, data); }

Expand Down Expand Up @@ -196,10 +196,10 @@ class NativeBoundVariableRuntime : public Object {
void set_transform(const Shape& transform) { m_transform = transform; }

/// Get the python type marshal.
ref<NativeType> get_python_type() const { return m_python_type; }
ref<NativeMarshall> get_python_type() const { return m_python_type; }

/// Set the python type marshal.
void set_python_type(const ref<NativeType>& python_type) { m_python_type = python_type; }
void set_python_type(const ref<NativeMarshall>& python_type) { m_python_type = python_type; }

/// Get the vector slang type.
ref<NativeSlangType> get_vector_type() const { return m_vector_type; }
Expand Down Expand Up @@ -255,7 +255,7 @@ class NativeBoundVariableRuntime : public Object {
private:
std::pair<AccessType, AccessType> m_access{AccessType::none, AccessType::none};
Shape m_transform;
ref<NativeType> m_python_type;
ref<NativeMarshall> m_python_type;
Shape m_shape;
std::string m_variable_name;
std::optional<std::map<std::string, ref<NativeBoundVariableRuntime>>> m_children;
Expand Down

0 comments on commit 6a517a4

Please sign in to comment.