Skip to content

Commit

Permalink
lib+python: Add a debug scene dump API
Browse files Browse the repository at this point in the history
It just dumps the state as JSON to stdout
  • Loading branch information
vkoskiv committed Dec 10, 2023
1 parent 4dbdc4b commit 3cd4f7d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings/blender_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def render(self, depsgraph):
renderer = c_ray.renderer()
cr_scene = self.sync_scene(renderer, depsgraph, b_scene)
print(cr_scene.totals())
renderer.debug_dump()
del(renderer)
# self.render_scene(scene)

Expand Down
3 changes: 3 additions & 0 deletions bindings/c_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ def render(self):
def scene_get(self):
return scene(_lib.renderer_scene_get(self.obj_ptr))

def debug_dump(self):
_lib.debug_dump_state(self.obj_ptr)

@classmethod
def from_param(cls, param):
if not isinstance(param, cls):
Expand Down
11 changes: 11 additions & 0 deletions bindings/cray_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,16 @@ static PyObject *py_cr_load_json(PyObject *self, PyObject *args) {
return PyBool_FromLong(ret);
}

static PyObject *py_debug_dump_state(PyObject *self, PyObject *args) {
(void)self;
PyObject *r_ext;
if (!PyArg_ParseTuple(args, "O", &r_ext)) {
return NULL;
}
struct cr_renderer *r = PyCapsule_GetPointer(r_ext, "cray.cr_renderer");
cr_debug_dump_state(r);
Py_RETURN_NONE;
}
static PyMethodDef cray_methods[] = {
{ "get_version", py_cr_get_version, METH_NOARGS, "" },
{ "get_git_hash", py_cr_get_git_hash, METH_NOARGS, "" },
Expand Down Expand Up @@ -579,6 +589,7 @@ static PyMethodDef cray_methods[] = {
{ "start_render_worker", py_cr_start_render_worker, METH_VARARGS, "" },
{ "send_shutdown_to_workers", py_cr_send_shutdown_to_workers, METH_VARARGS, "" },
{ "load_json", py_cr_load_json, METH_VARARGS, "" },
{ "debug_dump_state", py_debug_dump_state, METH_VARARGS, "" },
{ NULL, NULL, 0, NULL }
};

Expand Down
1 change: 1 addition & 0 deletions include/c-ray/c-ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ CR_EXPORT void cr_start_render_worker(int port, size_t thread_limit);
CR_EXPORT void cr_send_shutdown_to_workers(const char *node_list);
CR_EXPORT bool cr_load_json(struct cr_renderer *r_ext, const char *file_path);

CR_EXPORT void cr_debug_dump_state(struct cr_renderer *r_ext);
#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/lib/api/c-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,9 @@ bool cr_load_json(struct cr_renderer *r_ext, const char *file_path) {
}
return true;
}

CR_EXPORT void cr_debug_dump_state(struct cr_renderer *r_ext) {
if (!r_ext) return;
struct renderer *r = (struct renderer *)r_ext;
dump_renderer_state(r);
}

0 comments on commit 3cd4f7d

Please sign in to comment.