Remove separate targets for classic and filament renderer.
The platform::Renderer now supports both implementations at runtime. PiperOrigin-RevId: 878427862 Change-Id: I2997c197c6eddbe177c77b435cc5848fd80f1839
This commit is contained in:
committed by
Copybara-Service
parent
84682a46b0
commit
13d164063c
@@ -381,20 +381,12 @@ jobs:
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: bash ./.github/workflows/build_steps.sh prepare_linux
|
||||
|
||||
- name: Configure Studio with legacy OpenGL rendering
|
||||
env:
|
||||
CMAKE_ARGS: ${{ matrix.cmake_args }}
|
||||
run: bash ./.github/workflows/build_steps.sh configure_studio_legacy_opengl
|
||||
|
||||
- name: Build Studio with legacy OpenGL rendering
|
||||
run: bash ./.github/workflows/build_steps.sh build_studio
|
||||
|
||||
- name: Configure Studio with Filament rendering
|
||||
- name: Configure Studio
|
||||
env:
|
||||
CMAKE_ARGS: ${{ matrix.cmake_args }}
|
||||
run: bash ./.github/workflows/build_steps.sh configure_studio
|
||||
|
||||
- name: Build Studio with Filament rendering
|
||||
- name: Build Studio
|
||||
run: bash ./.github/workflows/build_steps.sh build_studio
|
||||
|
||||
- name: Notify team chat
|
||||
|
||||
@@ -147,9 +147,8 @@ build_simulate() {
|
||||
}
|
||||
|
||||
|
||||
_configure_studio() {
|
||||
# Invoke cmake will all options OFF assuming that the caller will enable
|
||||
# needed options by running `export _CONFIGURE_STUDIO_CMAKE_ARGS=...` first
|
||||
configure_studio() {
|
||||
echo "Configuring Studio..."
|
||||
cmake -B build \
|
||||
-DCMAKE_BUILD_TYPE:STRING=Release \
|
||||
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF \
|
||||
@@ -157,28 +156,11 @@ _configure_studio() {
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DMUJOCO_BUILD_EXAMPLES=OFF \
|
||||
-DMUJOCO_BUILD_SIMULATE=OFF \
|
||||
-DMUJOCO_BUILD_STUDIO=OFF \
|
||||
-DMUJOCO_BUILD_STUDIO=ON \
|
||||
-DMUJOCO_BUILD_TESTS=OFF \
|
||||
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
|
||||
-DMUJOCO_WITH_USD=OFF \
|
||||
-DMUJOCO_USE_FILAMENT=OFF \
|
||||
-DMUJOCO_USE_FILAMENT_VULKAN=OFF \
|
||||
${_CONFIGURE_STUDIO_CMAKE_ARGS}
|
||||
}
|
||||
|
||||
|
||||
configure_studio_legacy_opengl() {
|
||||
echo "Configuring Studio (legacy OpenGL)..."
|
||||
export _CONFIGURE_STUDIO_CMAKE_ARGS="-DMUJOCO_BUILD_STUDIO=ON ${CMAKE_ARGS}"
|
||||
_configure_studio
|
||||
echo "Configuring Studio (legacy OpenGL)... DONE"
|
||||
}
|
||||
|
||||
|
||||
configure_studio() {
|
||||
echo "Configuring Studio..."
|
||||
export _CONFIGURE_STUDIO_CMAKE_ARGS="-DMUJOCO_BUILD_STUDIO=ON -DMUJOCO_USE_FILAMENT=ON ${CMAKE_ARGS}"
|
||||
_configure_studio
|
||||
-DMUJOCO_USE_FILAMENT=ON
|
||||
echo "Configuring Studio... DONE"
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -47,7 +47,8 @@ if(NOT EMSCRIPTEN)
|
||||
option(MUJOCO_TEST_PYTHON_UTIL "Build and test utility libraries for Python bindings" ON)
|
||||
option(MUJOCO_WITH_USD "Build with OpenUSD" OFF)
|
||||
option(MUJOCO_USE_FILAMENT "Use filament rendering" OFF)
|
||||
option(MUJOCO_USE_FILAMENT_VULKAN "Use vulkan backend for filament rendering" OFF)
|
||||
# Allows filament renderer to be used with mjr API; disables src/render to prevent conflicts.
|
||||
option(MUJOCO_USE_FILAMENT_MJR_COMPAT "Use filament mjr compatibility layer" OFF)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
@@ -114,19 +115,15 @@ add_subdirectory(src/engine)
|
||||
add_subdirectory(src/user)
|
||||
add_subdirectory(src/xml)
|
||||
add_subdirectory(src/thread)
|
||||
|
||||
if(MUJOCO_USE_FILAMENT AND NOT EMSCRIPTEN)
|
||||
# Note that, by default, the "src/render" and "src/ui" code is added directly
|
||||
# into the "mujoco" target. However, "mujoco::filament" is a separate,
|
||||
# explicit target. Therefore, if you want to use MuJoCo with Filament, you
|
||||
# will need to explicitly add the "mujoco::filament" target as a link
|
||||
# dependency in your project.
|
||||
add_subdirectory(src/experimental/filament)
|
||||
elseif(NOT EMSCRIPTEN)
|
||||
if(NOT EMSCRIPTEN AND NOT MUJOCO_USE_FILAMENT_MJR_COMPAT)
|
||||
add_subdirectory(src/render)
|
||||
add_subdirectory(src/ui)
|
||||
endif()
|
||||
|
||||
if(MUJOCO_USE_FILAMENT AND NOT EMSCRIPTEN)
|
||||
add_subdirectory(src/experimental/filament)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
add_subdirectory(wasm)
|
||||
if(MUJOCO_BUILD_TESTS_WASM)
|
||||
|
||||
@@ -21,7 +21,6 @@ target_compile_definitions(${MUJOCO_FILAMENT_TARGET_NAME} PRIVATE MJ_STATIC)
|
||||
|
||||
target_sources(${MUJOCO_FILAMENT_TARGET_NAME}
|
||||
PUBLIC
|
||||
mjr_compat.cc
|
||||
render_context_filament.h
|
||||
render_context_filament.cc
|
||||
filament/buffer_util.cc
|
||||
@@ -58,6 +57,13 @@ target_sources(${MUJOCO_FILAMENT_TARGET_NAME}
|
||||
filament/vertex_util.cc
|
||||
filament/vertex_util.h
|
||||
)
|
||||
if(MUJOCO_USE_FILAMENT_MJR_COMPAT)
|
||||
target_sources(${MUJOCO_FILAMENT_TARGET_NAME}
|
||||
PUBLIC
|
||||
mjr_compat.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(${MUJOCO_FILAMENT_TARGET_NAME}
|
||||
PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
|
||||
@@ -16,25 +16,8 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(MUJOCO_PLATFORM_TARGET_NAME mujoco_platform)
|
||||
|
||||
# Determine the render configuration and dependencies based options.
|
||||
if(MUJOCO_USE_FILAMENT AND MUJOCO_USE_FILAMENT_VULKAN)
|
||||
set(MUJOCO_PLATFORM_RENDER_CONFIG "MUJOCO_RENDERER_FILAMENT_VULKAN")
|
||||
set(MUJOCO_PLATFORM_RENDER_DEPS "mujoco::filament")
|
||||
elseif(MUJOCO_USE_FILAMENT)
|
||||
set(MUJOCO_PLATFORM_RENDER_CONFIG "MUJOCO_RENDERER_FILAMENT_OPENGL")
|
||||
set(MUJOCO_PLATFORM_RENDER_DEPS "mujoco::filament")
|
||||
else()
|
||||
set(MUJOCO_PLATFORM_RENDER_CONFIG "MUJOCO_RENDERER_CLASSIC_OPENGL")
|
||||
set(MUJOCO_PLATFORM_RENDER_DEPS "dear_imgui_OpenGL3")
|
||||
endif()
|
||||
|
||||
add_library(${MUJOCO_PLATFORM_TARGET_NAME} STATIC)
|
||||
|
||||
target_compile_definitions(${MUJOCO_PLATFORM_TARGET_NAME}
|
||||
PUBLIC
|
||||
-D${MUJOCO_PLATFORM_RENDER_CONFIG}
|
||||
)
|
||||
|
||||
target_sources(${MUJOCO_PLATFORM_TARGET_NAME}
|
||||
PUBLIC
|
||||
egl_utils.cc
|
||||
@@ -113,8 +96,10 @@ include(third_party_deps/libwebp)
|
||||
target_link_libraries(${MUJOCO_PLATFORM_TARGET_NAME}
|
||||
dear_imgui
|
||||
dear_imgui_SDL2
|
||||
dear_imgui_OpenGL3
|
||||
dear_imgui_stdlib
|
||||
implot
|
||||
mujoco::filament
|
||||
webp
|
||||
SDL2::SDL2-static
|
||||
${MUJOCO_PLATFORM_RENDER_DEPS}
|
||||
|
||||
@@ -50,6 +50,7 @@ include(third_party_deps/font_awesome)
|
||||
target_link_libraries(${MUJOCO_STUDIO_TARGET_NAME}
|
||||
PRIVATE
|
||||
absl::flags
|
||||
absl::flags_parse
|
||||
dear_imgui
|
||||
implot
|
||||
mujoco::mujoco
|
||||
|
||||
@@ -32,18 +32,6 @@ If you intend to develop the application you may prefer to work from an IDE:
|
||||
* [Visual Studio](https://visualstudio.microsoft.com/). Follow these
|
||||
[instructions](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170).
|
||||
|
||||
## Filament Rendering
|
||||
|
||||
Studio uses legacy OpenGL rendering by default but there is an option to use
|
||||
Physically Based Rendering via [Filament](https://google.github.io/filament/Filament.md.html).
|
||||
To enable Filament you need to `-DMUJOCO_USE_FILAMENT=ON` during the cmake
|
||||
configuration step. The Filament renderer has multiple rendering backends,
|
||||
on Linux OpenGL is the default but Vulkan can be used by also providing
|
||||
the `-DMUJOCO_USE_FILAMENT_VULKAN=ON` option.
|
||||
|
||||
Also note that you will need to run the application from the folder containing
|
||||
the executable so that the expected materials/assets can be found.
|
||||
|
||||
## Known Bugs
|
||||
|
||||
* MuJoCo Studio does not yet work using Wayland on Linux, use X11 instead.
|
||||
|
||||
@@ -62,7 +62,6 @@ if [[ "$do_configure" == true ]]; then
|
||||
"-DUSE_STATIC_LIBCXX=OFF"
|
||||
"-DBUILD_SHARED_LIB=OFF"
|
||||
"-DMUJOCO_USE_FILAMENT=ON"
|
||||
"-DMUJOCO_USE_FILAMENT_VULKAN=OFF"
|
||||
"-DMUJOCO_BUILD_EXAMPLES=OFF"
|
||||
"-DMUJOCO_BUILD_SIMULATE=OFF"
|
||||
"-DMUJOCO_BUILD_TESTS=OFF"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <absl/flags/flag.h>
|
||||
#include <absl/flags/parse.h>
|
||||
#include <mujoco/mujoco.h>
|
||||
#include "experimental/platform/graphics_mode.h"
|
||||
#include "experimental/studio/app.h"
|
||||
@@ -73,6 +74,7 @@ class FileResource {
|
||||
};
|
||||
|
||||
int main(int argc, char** argv, char** envp) {
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
|
||||
const char* home = getenv("HOME");
|
||||
const std::string ini_path = std::string(home ? home : ".") + "/.mujoco.ini";
|
||||
|
||||
Reference in New Issue
Block a user