Add renderer info query API#3340
Conversation
|
|
||
| struct mjrRendererInfo_ { // active renderer identity | ||
| const char* renderer; // renderer family: classic, filament, noop | ||
| const char* backend; // graphics backend: opengl, vulkan, none |
There was a problem hiding this comment.
Leave empty if uninitialized (instead of an explicit "none" value).
| void mjr_defaultRendererInfo(mjrRendererInfo* info) { | ||
| memset(info, 0, sizeof(mjrRendererInfo)); | ||
| info->renderer = "filament"; | ||
| info->backend = GraphicsBackendName(mjGRAPHICS_API_DEFAULT); |
There was a problem hiding this comment.
By default, this should be "". It's only once the context is initialized that it gets a value.
|
|
||
| void mjr_getRendererInfo(mjrRendererInfo* info) { | ||
| mjr_defaultRendererInfo(info); | ||
| info->backend = GraphicsBackendName(g_graphics_api); |
There was a problem hiding this comment.
Let's implement a mjrf_getRendererInfo(mjrfContext* ctx) function and call that one here if the filament context has been created.
| void mjr_defaultRendererInfo(mjrRendererInfo* info) { | ||
| memset(info, 0, sizeof(mjrRendererInfo)); | ||
| info->renderer = "classic"; | ||
| info->backend = "opengl"; |
There was a problem hiding this comment.
Should only set to "opengl" once the context has been created.
| void mjr_defaultRendererInfo(mjrRendererInfo* info) { | ||
| memset(info, 0, sizeof(mjrRendererInfo)); | ||
| info->renderer = "noop"; | ||
| info->backend = "none"; |
There was a problem hiding this comment.
Same as others, use an empty string instead.
4a0c4ce to
4679fad
Compare
|
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. 🙌 |
|
Thanks! |
4679fad to
1b43bd1
Compare
|
Rebased this onto current Validated with:
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. |
1b43bd1 to
d23ff84
Compare
|
Rebased this onto current main and fixed the conflict in Local validation:
@haroonq once fresh CI goes green again, I think this is unblocked for submit. 🙏 |
Split out from #3254 in response to Haroon's request for smaller Filament PRs.
Summary
mjrRendererInfoplusmjr_defaultRendererInfoandmjr_getRendererInfoto report the active renderer family and graphics backend.classic/opengl, noop asnoop/none, and Filament asfilamentwith its selected backend.Validation
git diff --checkpython3 -m py_compile python/mujoco/introspect/functions.py python/mujoco/introspect/structs.py python/mujoco/bindings_test.pyPYTHONPATH=/tmp/mujoco-check-pydeps:python/mujoco python3 python/mujoco/codegen/generate_function_traits.py >/tmp/mujoco-function-traits-check.hPYTHONPATH=/tmp/mujoco-check-pydeps:python/mujoco python3 python/mujoco/codegen/generate_enum_traits.py >/tmp/mujoco-enum-traits-check.hcmake -S . -B /tmp/mujoco-renderer-info-build -DMUJOCO_BUILD_TESTS=ON -DMUJOCO_TEST_PYTHON_UTIL=OFF -DCMAKE_BUILD_TYPE=Releasecmake --build /tmp/mujoco-renderer-info-build --target mujoco -j2Notes
backend_versionis reserved and currently returns an empty string until backend-specific version extraction is added.