Skip to content

Add renderer info query API#3340

Open
devshahofficial wants to merge 1 commit into
google-deepmind:mainfrom
devshahofficial:devshahofficial/mjr-renderer-info
Open

Add renderer info query API#3340
devshahofficial wants to merge 1 commit into
google-deepmind:mainfrom
devshahofficial:devshahofficial/mjr-renderer-info

Conversation

@devshahofficial

Copy link
Copy Markdown
Contributor

Split out from #3254 in response to Haroon's request for smaller Filament PRs.

Summary

  • Adds mjrRendererInfo plus mjr_defaultRendererInfo and mjr_getRendererInfo to report the active renderer family and graphics backend.
  • Reports classic as classic / opengl, noop as noop / none, and Filament as filament with its selected backend.
  • Adds Python raw alias, pybind struct exposure, render function bindings, introspection metadata, and a binding smoke test.

Validation

  • git diff --check
  • python3 -m py_compile python/mujoco/introspect/functions.py python/mujoco/introspect/structs.py python/mujoco/bindings_test.py
  • PYTHONPATH=/tmp/mujoco-check-pydeps:python/mujoco python3 python/mujoco/codegen/generate_function_traits.py >/tmp/mujoco-function-traits-check.h
  • PYTHONPATH=/tmp/mujoco-check-pydeps:python/mujoco python3 python/mujoco/codegen/generate_enum_traits.py >/tmp/mujoco-enum-traits-check.h
  • cmake -S . -B /tmp/mujoco-renderer-info-build -DMUJOCO_BUILD_TESTS=ON -DMUJOCO_TEST_PYTHON_UTIL=OFF -DCMAKE_BUILD_TYPE=Release
  • cmake --build /tmp/mujoco-renderer-info-build --target mujoco -j2

Notes

  • Draft PR: full Python wheel/binding build was not completed locally; standalone Python CMake expects setup.py's copied source layout.
  • backend_version is reserved and currently returns an empty string until backend-specific version extraction is added.

Comment thread include/mujoco/mjrender.h Outdated

struct mjrRendererInfo_ { // active renderer identity
const char* renderer; // renderer family: classic, filament, noop
const char* backend; // graphics backend: opengl, vulkan, none

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave empty if uninitialized (instead of an explicit "none" value).

Comment thread src/experimental/filament/mjr_compat.cc Outdated
void mjr_defaultRendererInfo(mjrRendererInfo* info) {
memset(info, 0, sizeof(mjrRendererInfo));
info->renderer = "filament";
info->backend = GraphicsBackendName(mjGRAPHICS_API_DEFAULT);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, this should be "". It's only once the context is initialized that it gets a value.

Comment thread src/experimental/filament/mjr_compat.cc Outdated

void mjr_getRendererInfo(mjrRendererInfo* info) {
mjr_defaultRendererInfo(info);
info->backend = GraphicsBackendName(g_graphics_api);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's implement a mjrf_getRendererInfo(mjrfContext* ctx) function and call that one here if the filament context has been created.

Comment thread src/render/classic/render_context.c Outdated
void mjr_defaultRendererInfo(mjrRendererInfo* info) {
memset(info, 0, sizeof(mjrRendererInfo));
info->renderer = "classic";
info->backend = "opengl";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only set to "opengl" once the context has been created.

Comment thread src/render/noop/render_noop.c Outdated
void mjr_defaultRendererInfo(mjrRendererInfo* info) {
memset(info, 0, sizeof(mjrRendererInfo));
info->renderer = "noop";
info->backend = "none";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as others, use an empty string instead.

@haroonq haroonq self-assigned this Jun 15, 2026
@devshahofficial devshahofficial force-pushed the devshahofficial/mjr-renderer-info branch from 4a0c4ce to 4679fad Compare June 22, 2026 15:58
@BlGene

BlGene commented Jun 22, 2026

Copy link
Copy Markdown

I guess once this PR is merged, wheels will be built, and the render version will be queryable?

Leaving a note here so I get updated.

Looking forward to this functionality. 🙌

@haroonq

haroonq commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

@devshahofficial devshahofficial force-pushed the devshahofficial/mjr-renderer-info branch from 4679fad to 1b43bd1 Compare June 29, 2026 20:09
@devshahofficial devshahofficial marked this pull request as ready for review June 29, 2026 20:09
@devshahofficial

Copy link
Copy Markdown
Contributor Author

Rebased this onto current main and marked it ready.

Validated with:

  • git diff --check
  • python3 -m py_compile python/mujoco/introspect/functions.py python/mujoco/introspect/structs.py python/mujoco/bindings_test.py
  • PYTHONPATH=/tmp/mujoco-pr3340-pydeps:python/mujoco python3 python/mujoco/codegen/generate_function_traits.py >/tmp/mujoco-pr3340-function-traits.h
  • PYTHONPATH=/tmp/mujoco-pr3340-pydeps:python/mujoco python3 python/mujoco/codegen/generate_enum_traits.py >/tmp/mujoco-pr3340-enum-traits.h
  • cmake -S . -B /tmp/mujoco-pr3340-build -DMUJOCO_BUILD_TESTS=ON -DMUJOCO_TEST_PYTHON_UTIL=OFF -DCMAKE_BUILD_TYPE=Release
  • cmake --build /tmp/mujoco-pr3340-build --target mujoco -j2
  • small ctypes smoke against the built libmujoco.dylib: mjr_getRendererInfo returns classic, empty backend, empty backend version before a context exists.

I also tried a narrow Filament/MJR-compat configure. It still hits the separate dear_imgui/SDL2 source-build issue covered by #3252, so I’m not mixing that fix into this API PR.

@devshahofficial devshahofficial force-pushed the devshahofficial/mjr-renderer-info branch from 1b43bd1 to d23ff84 Compare July 7, 2026 18:45
@devshahofficial

Copy link
Copy Markdown
Contributor Author

Rebased this onto current main and fixed the conflict in filament_context.cc. The resolution keeps both sides: upstreams larger Filament command buffers and this PRs stored backend_ for the renderer info API.

Local validation:

  • git diff --check
  • python3 -m py_compile python/mujoco/introspect/functions.py python/mujoco/introspect/structs.py python/mujoco/bindings_test.py
  • PYTHONPATH=python/mujoco python/mujoco/codegen/generate_function_traits.py in a fresh venv

@haroonq once fresh CI goes green again, I think this is unblocked for submit. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants