Skip to content

Commit f10a7d9

Browse files
authored
Set multiview as the default for stereoscopic rendering (#9682)
Enables the multiview implementation as the default for stereoscopic rendering. Now all STE variants use the multiview path. This change removes all CMake configurations, build scripts, and C++ preprocessors previously used for selecting stereoscopic rendering modes. And, all shaders are now compiled for multiview. The instanced rendering implementation is going to be removed. Note that this commit only handles switching the default. The actual removal of instanced rendering code will be submitted as a separate follow-up commit. BUGS=[470198472]
1 parent 358d594 commit f10a7d9

File tree

14 files changed

+10
-154
lines changed

14 files changed

+10
-154
lines changed

CMakeLists.txt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ option(FILAMENT_ENABLE_COVERAGE "Enable LLVM code coverage" OFF)
4949

5050
option(FILAMENT_ENABLE_FEATURE_LEVEL_0 "Enable Feature Level 0" ON)
5151

52-
option(FILAMENT_ENABLE_MULTIVIEW "Enable multiview for Filament" OFF)
53-
5452
option(FILAMENT_SUPPORTS_OSMESA "Enable OSMesa (headless GL context) for Filament" OFF)
5553

5654
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
@@ -607,23 +605,6 @@ else()
607605
option(FILAMENT_DISABLE_MATOPT "Disable material optimizations" ON)
608606
endif()
609607

610-
# This only affects the prebuilt shader files in gltfio and samples, not filament library.
611-
# The value can be either "instanced", "multiview", or "none"
612-
set(FILAMENT_SAMPLES_STEREO_TYPE "none" CACHE STRING
613-
"Stereoscopic type that shader files in gltfio and samples are built for."
614-
)
615-
string(TOLOWER "${FILAMENT_SAMPLES_STEREO_TYPE}" FILAMENT_SAMPLES_STEREO_TYPE)
616-
if (NOT FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "instanced"
617-
AND NOT FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview"
618-
AND NOT FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "none")
619-
message(FATAL_ERROR "Invalid stereo type: \"${FILAMENT_SAMPLES_STEREO_TYPE}\" choose either \"instanced\", \"multiview\", or \"none\" ")
620-
endif ()
621-
622-
# Compiling samples for multiview implies enabling multiview feature as well.
623-
if (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview")
624-
set(FILAMENT_ENABLE_MULTIVIEW ON)
625-
endif ()
626-
627608
# Define backend flag for debug only
628609
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT FILAMENT_BACKEND_DEBUG_FLAG STREQUAL "")
629610
add_definitions(-DFILAMENT_BACKEND_DEBUG_FLAG=${FILAMENT_BACKEND_DEBUG_FLAG})

build.sh

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ ENABLE_PERFETTO=""
214214

215215
BACKEND_DEBUG_FLAG_OPTION=""
216216

217-
STEREOSCOPIC_OPTION=""
218-
219217
OSMESA_OPTION=""
220218

221219
IOS_BUILD_SIMULATOR=false
@@ -316,7 +314,6 @@ function build_desktop_target {
316314
${ASAN_UBSAN_OPTION} \
317315
${COVERAGE_OPTION} \
318316
${BACKEND_DEBUG_FLAG_OPTION} \
319-
${STEREOSCOPIC_OPTION} \
320317
${OSMESA_OPTION} \
321318
${architectures} \
322319
../..
@@ -455,7 +452,6 @@ function build_android_target {
455452
${VULKAN_ANDROID_OPTION} \
456453
${WEBGPU_OPTION} \
457454
${BACKEND_DEBUG_FLAG_OPTION} \
458-
${STEREOSCOPIC_OPTION} \
459455
${ENABLE_PERFETTO} \
460456
../..
461457
ln -sf "out/cmake-android-${lc_target}-${arch}/compile_commands.json" \
@@ -697,7 +693,6 @@ function build_ios_target {
697693
${WEBGPU_OPTION} \
698694
${MATDBG_OPTION} \
699695
${MATOPT_OPTION} \
700-
${STEREOSCOPIC_OPTION} \
701696
../..
702697
ln -sf "out/cmake-ios-${lc_target}-${arch}/compile_commands.json" \
703698
../../compile_commands.json
@@ -1011,20 +1006,6 @@ while getopts ":hacCfgimp:q:uvWslwedtk:bVx:S:X:Py:" opt; do
10111006
;;
10121007
x) BACKEND_DEBUG_FLAG_OPTION="-DFILAMENT_BACKEND_DEBUG_FLAG=${OPTARG}"
10131008
;;
1014-
S) case $(echo "${OPTARG}" | tr '[:upper:]' '[:lower:]') in
1015-
instanced)
1016-
STEREOSCOPIC_OPTION="-DFILAMENT_SAMPLES_STEREO_TYPE=instanced"
1017-
;;
1018-
multiview)
1019-
STEREOSCOPIC_OPTION="-DFILAMENT_SAMPLES_STEREO_TYPE=multiview"
1020-
;;
1021-
*)
1022-
echo "Unknown stereoscopic type ${OPTARG}"
1023-
echo "Type must be one of [instanced|multiview]"
1024-
echo ""
1025-
exit 1
1026-
esac
1027-
;;
10281009
X) OSMESA_OPTION="-DFILAMENT_OSMESA_PATH=${OPTARG}"
10291010
;;
10301011
y)

filament/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ set(MATERIAL_FL0_SRCS
314314
src/materials/skybox.mat
315315
)
316316

317-
set(MATERIAL_MULTIVIEW_SRCS
318-
src/materials/clearDepth.mat
319-
src/materials/defaultMaterial.mat
320-
src/materials/skybox.mat
321-
)
322-
323317
# ==================================================================================================
324318
# Configuration
325319
# ==================================================================================================
@@ -344,11 +338,6 @@ if (FILAMENT_ENABLE_FEATURE_LEVEL_0)
344338
add_definitions(-DFILAMENT_ENABLE_FEATURE_LEVEL_0)
345339
endif()
346340

347-
# Whether to include MULTIVIEW materials.
348-
if (FILAMENT_ENABLE_MULTIVIEW)
349-
add_definitions(-DFILAMENT_ENABLE_MULTIVIEW)
350-
endif()
351-
352341
# Whether to force the profiling mode.
353342
if (FILAMENT_FORCE_PROFILING_MODE)
354343
add_definitions(-DFILAMENT_FORCE_PROFILING_MODE)
@@ -439,21 +428,6 @@ foreach(mat_dir ${MATERIAL_DIRS})
439428
list(APPEND FILAMAT_FILES_FOR_GROUP ${output_path_fl0})
440429
list(APPEND FILAMAT_TARGETS_FOR_GROUP ${output_path_fl0})
441430
endif()
442-
443-
# --- Multiview variant ---
444-
list(FIND MATERIAL_MULTIVIEW_SRCS ${mat_src} index)
445-
if (${index} GREATER -1 AND FILAMENT_ENABLE_MULTIVIEW)
446-
string(REGEX REPLACE "[.]filamat$" "_multiview.filamat" output_path_multiview ${output_path})
447-
add_custom_command(
448-
OUTPUT ${output_path_multiview}
449-
COMMAND matc ${MATC_BASE_FLAGS} -PstereoscopicType=multiview -o ${output_path_multiview} ${fullname}
450-
MAIN_DEPENDENCY ${fullname}
451-
DEPENDS matc
452-
COMMENT "Compiling material ${fullname} (Multiview)"
453-
)
454-
list(APPEND FILAMAT_FILES_FOR_GROUP ${output_path_multiview})
455-
list(APPEND FILAMAT_TARGETS_FOR_GROUP ${output_path_multiview})
456-
endif()
457431
endforeach()
458432

459433
# Generate a single resource file for the whole group

filament/src/details/Engine.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -462,22 +462,8 @@ void FEngine::init() {
462462
#endif
463463
{
464464
FMaterial::DefaultMaterialBuilder defaultMaterialBuilder;
465-
switch (mConfig.stereoscopicType) {
466-
case StereoscopicType::NONE:
467-
case StereoscopicType::INSTANCED:
468-
defaultMaterialBuilder.package(
469-
MATERIALS_DEFAULTMATERIAL_DATA, MATERIALS_DEFAULTMATERIAL_SIZE);
470-
break;
471-
case StereoscopicType::MULTIVIEW:
472-
#ifdef FILAMENT_ENABLE_MULTIVIEW
473-
defaultMaterialBuilder.package(
474-
MATERIALS_DEFAULTMATERIAL_MULTIVIEW_DATA,
475-
MATERIALS_DEFAULTMATERIAL_MULTIVIEW_SIZE);
476-
#else
477-
assert_invariant(false);
478-
#endif
479-
break;
480-
}
465+
defaultMaterialBuilder.package(
466+
MATERIALS_DEFAULTMATERIAL_DATA, MATERIALS_DEFAULTMATERIAL_SIZE);
481467
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*this));
482468
}
483469

filament/src/details/Skybox.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,7 @@ FMaterial const* FSkybox::createMaterial(FEngine& engine) {
138138
} else
139139
#endif
140140
{
141-
switch (engine.getConfig().stereoscopicType) {
142-
case Engine::StereoscopicType::NONE:
143-
case Engine::StereoscopicType::INSTANCED:
144-
builder.package(MATERIALS_SKYBOX_DATA, MATERIALS_SKYBOX_SIZE);
145-
break;
146-
case Engine::StereoscopicType::MULTIVIEW:
147-
#ifdef FILAMENT_ENABLE_MULTIVIEW
148-
builder.package(MATERIALS_SKYBOX_MULTIVIEW_DATA, MATERIALS_SKYBOX_MULTIVIEW_SIZE);
149-
#else
150-
PANIC_POSTCONDITION("Multiview is enabled in the Engine, but this build has not "
151-
"been compiled for multiview.");
152-
#endif
153-
break;
154-
}
141+
builder.package(MATERIALS_SKYBOX_DATA, MATERIALS_SKYBOX_SIZE);
155142
}
156143
auto material = builder.build(engine);
157144
return downcast(material);

libs/filagui/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@ endif()
4040

4141
file(MAKE_DIRECTORY ${MATERIAL_DIR})
4242

43-
set (MATC_FLAGS ${MATC_BASE_FLAGS})
44-
if (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "instanced")
45-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=instanced)
46-
elseif (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview")
47-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=multiview)
48-
endif ()
49-
5043
foreach (mat_src ${MATERIAL_SRCS})
5144
get_filename_component(localname "${mat_src}" NAME_WE)
5245
get_filename_component(fullname "${mat_src}" ABSOLUTE)
5346
set(output_path "${MATERIAL_DIR}/${localname}.filamat")
5447
add_custom_command(
5548
OUTPUT ${output_path}
56-
COMMAND matc ${MATC_FLAGS} -o ${output_path} ${fullname}
49+
COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname}
5750
DEPENDS ${mat_src} matc
5851
COMMENT "Compiling material ${mat_src} to ${output_path}"
5952
)

libs/filamat/include/filamat/MaterialBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ class UTILS_PUBLIC MaterialBuilder : public MaterialBuilderBase {
939939
Interpolation mInterpolation = Interpolation::SMOOTH;
940940
VertexDomain mVertexDomain = VertexDomain::OBJECT;
941941
TransparencyMode mTransparencyMode = TransparencyMode::DEFAULT;
942-
StereoscopicType mStereoscopicType = StereoscopicType::INSTANCED;
942+
StereoscopicType mStereoscopicType = StereoscopicType::MULTIVIEW;
943943
uint8_t mStereoscopicEyeCount = 2;
944944

945945
filament::AttributeBitset mRequiredAttributes;

libs/filamentapp/CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,13 @@ file(MAKE_DIRECTORY ${RESOURCE_DIR})
114114

115115
set(RESOURCE_BINS)
116116

117-
set (MATC_FLAGS ${MATC_BASE_FLAGS})
118-
if (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "instanced")
119-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=instanced)
120-
add_definitions(-DFILAMENT_SAMPLES_STEREO_TYPE_INSTANCED)
121-
elseif (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview")
122-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=multiview)
123-
add_definitions(-DFILAMENT_SAMPLES_STEREO_TYPE_MULTIVIEW)
124-
endif ()
125-
126117
foreach (mat_src ${MATERIAL_SRCS})
127118
get_filename_component(localname "${mat_src}" NAME_WE)
128119
get_filename_component(fullname "${mat_src}" ABSOLUTE)
129120
set(output_path "${MATERIAL_DIR}/${localname}.filamat")
130121
add_custom_command(
131122
OUTPUT ${output_path}
132-
COMMAND matc ${MATC_FLAGS} -o ${output_path} ${fullname}
123+
COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname}
133124
MAIN_DEPENDENCY ${mat_src}
134125
DEPENDS matc
135126
COMMENT "Compiling material ${mat_src} to ${output_path}"

libs/filamentapp/src/FilamentApp.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,13 +741,7 @@ FilamentApp::Window::Window(FilamentApp* filamentApp,
741741

742742
Engine::Config engineConfig = {};
743743
engineConfig.stereoscopicEyeCount = config.stereoscopicEyeCount;
744-
#if defined(FILAMENT_SAMPLES_STEREO_TYPE_INSTANCED)
745-
engineConfig.stereoscopicType = Engine::StereoscopicType::INSTANCED;
746-
#elif defined (FILAMENT_SAMPLES_STEREO_TYPE_MULTIVIEW)
747744
engineConfig.stereoscopicType = Engine::StereoscopicType::MULTIVIEW;
748-
#else
749-
engineConfig.stereoscopicType = Engine::StereoscopicType::NONE;
750-
#endif
751745

752746
backend::Platform* platform = nullptr;
753747
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)

libs/gltfio/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ set(TRANSPARENCY default)
7979

8080
set(UBERZ_OUTPUT_PATH "${RESOURCE_DIR}/default.uberz")
8181

82-
set (MATC_FLAGS ${MATC_BASE_FLAGS})
83-
if (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "instanced")
84-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=instanced)
85-
elseif (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview")
86-
set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=multiview)
87-
endif ()
88-
8982
function(build_ubershader NAME SRC SHADINGMODEL BLENDING)
9083
set(DEST "${RESOURCE_DIR}/${NAME}")
9184
configure_file(materials/${SRC}.mat.in "${DEST}.mat" COPYONLY)
@@ -102,7 +95,7 @@ function(build_ubershader NAME SRC SHADINGMODEL BLENDING)
10295

10396
add_custom_command(
10497
OUTPUT "${NAME}.filamat"
105-
COMMAND matc ${MATC_FLAGS} ${TEMPLATE_ARGS} -o "${NAME}.filamat" "${NAME}.mat"
98+
COMMAND matc ${MATC_BASE_FLAGS} ${TEMPLATE_ARGS} -o "${NAME}.filamat" "${NAME}.mat"
10699
DEPENDS matc "${DEST}.mat"
107100
WORKING_DIRECTORY ${RESOURCE_DIR}
108101
COMMENT "Compiling material ${NAME}")

0 commit comments

Comments
 (0)