Skip to content

Commit e00be09

Browse files
committed
Revert "Set multiview as the default for stereoscopic rendering (#9682)" (#9713)
This reverts commit f10a7d9.
1 parent 7ea1f97 commit e00be09

File tree

14 files changed

+154
-10
lines changed

14 files changed

+154
-10
lines changed

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ 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+
5254
option(FILAMENT_SUPPORTS_OSMESA "Enable OSMesa (headless GL context) for Filament" OFF)
5355

5456
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
@@ -605,6 +607,23 @@ else()
605607
option(FILAMENT_DISABLE_MATOPT "Disable material optimizations" ON)
606608
endif()
607609

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+
608627
# Define backend flag for debug only
609628
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT FILAMENT_BACKEND_DEBUG_FLAG STREQUAL "")
610629
add_definitions(-DFILAMENT_BACKEND_DEBUG_FLAG=${FILAMENT_BACKEND_DEBUG_FLAG})

build.sh

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

215215
BACKEND_DEBUG_FLAG_OPTION=""
216216

217+
STEREOSCOPIC_OPTION=""
218+
217219
OSMESA_OPTION=""
218220

219221
IOS_BUILD_SIMULATOR=false
@@ -314,6 +316,7 @@ function build_desktop_target {
314316
${ASAN_UBSAN_OPTION} \
315317
${COVERAGE_OPTION} \
316318
${BACKEND_DEBUG_FLAG_OPTION} \
319+
${STEREOSCOPIC_OPTION} \
317320
${OSMESA_OPTION} \
318321
${architectures} \
319322
../..
@@ -452,6 +455,7 @@ function build_android_target {
452455
${VULKAN_ANDROID_OPTION} \
453456
${WEBGPU_OPTION} \
454457
${BACKEND_DEBUG_FLAG_OPTION} \
458+
${STEREOSCOPIC_OPTION} \
455459
${ENABLE_PERFETTO} \
456460
../..
457461
ln -sf "out/cmake-android-${lc_target}-${arch}/compile_commands.json" \
@@ -693,6 +697,7 @@ function build_ios_target {
693697
${WEBGPU_OPTION} \
694698
${MATDBG_OPTION} \
695699
${MATOPT_OPTION} \
700+
${STEREOSCOPIC_OPTION} \
696701
../..
697702
ln -sf "out/cmake-ios-${lc_target}-${arch}/compile_commands.json" \
698703
../../compile_commands.json
@@ -1006,6 +1011,20 @@ while getopts ":hacCfgimp:q:uvWslwedtk:bVx:S:X:Py:" opt; do
10061011
;;
10071012
x) BACKEND_DEBUG_FLAG_OPTION="-DFILAMENT_BACKEND_DEBUG_FLAG=${OPTARG}"
10081013
;;
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+
;;
10091028
X) OSMESA_OPTION="-DFILAMENT_OSMESA_PATH=${OPTARG}"
10101029
;;
10111030
y)

filament/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ 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+
317323
# ==================================================================================================
318324
# Configuration
319325
# ==================================================================================================
@@ -338,6 +344,11 @@ if (FILAMENT_ENABLE_FEATURE_LEVEL_0)
338344
add_definitions(-DFILAMENT_ENABLE_FEATURE_LEVEL_0)
339345
endif()
340346

347+
# Whether to include MULTIVIEW materials.
348+
if (FILAMENT_ENABLE_MULTIVIEW)
349+
add_definitions(-DFILAMENT_ENABLE_MULTIVIEW)
350+
endif()
351+
341352
# Whether to force the profiling mode.
342353
if (FILAMENT_FORCE_PROFILING_MODE)
343354
add_definitions(-DFILAMENT_FORCE_PROFILING_MODE)
@@ -428,6 +439,21 @@ foreach(mat_dir ${MATERIAL_DIRS})
428439
list(APPEND FILAMAT_FILES_FOR_GROUP ${output_path_fl0})
429440
list(APPEND FILAMAT_TARGETS_FOR_GROUP ${output_path_fl0})
430441
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()
431457
endforeach()
432458

433459
# Generate a single resource file for the whole group

filament/src/details/Engine.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,22 @@ void FEngine::init() {
462462
#endif
463463
{
464464
FMaterial::DefaultMaterialBuilder defaultMaterialBuilder;
465-
defaultMaterialBuilder.package(
466-
MATERIALS_DEFAULTMATERIAL_DATA, MATERIALS_DEFAULTMATERIAL_SIZE);
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+
}
467481
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*this));
468482
}
469483

filament/src/details/Skybox.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,20 @@ FMaterial const* FSkybox::createMaterial(FEngine& engine) {
138138
} else
139139
#endif
140140
{
141-
builder.package(MATERIALS_SKYBOX_DATA, MATERIALS_SKYBOX_SIZE);
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+
}
142155
}
143156
auto material = builder.build(engine);
144157
return downcast(material);

libs/filagui/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@ 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+
4350
foreach (mat_src ${MATERIAL_SRCS})
4451
get_filename_component(localname "${mat_src}" NAME_WE)
4552
get_filename_component(fullname "${mat_src}" ABSOLUTE)
4653
set(output_path "${MATERIAL_DIR}/${localname}.filamat")
4754
add_custom_command(
4855
OUTPUT ${output_path}
49-
COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname}
56+
COMMAND matc ${MATC_FLAGS} -o ${output_path} ${fullname}
5057
DEPENDS ${mat_src} matc
5158
COMMENT "Compiling material ${mat_src} to ${output_path}"
5259
)

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::MULTIVIEW;
942+
StereoscopicType mStereoscopicType = StereoscopicType::INSTANCED;
943943
uint8_t mStereoscopicEyeCount = 2;
944944

945945
filament::AttributeBitset mRequiredAttributes;

libs/filamentapp/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,22 @@ 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+
117126
foreach (mat_src ${MATERIAL_SRCS})
118127
get_filename_component(localname "${mat_src}" NAME_WE)
119128
get_filename_component(fullname "${mat_src}" ABSOLUTE)
120129
set(output_path "${MATERIAL_DIR}/${localname}.filamat")
121130
add_custom_command(
122131
OUTPUT ${output_path}
123-
COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname}
132+
COMMAND matc ${MATC_FLAGS} -o ${output_path} ${fullname}
124133
MAIN_DEPENDENCY ${mat_src}
125134
DEPENDS matc
126135
COMMENT "Compiling material ${mat_src} to ${output_path}"

libs/filamentapp/src/FilamentApp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,13 @@ 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)
744747
engineConfig.stereoscopicType = Engine::StereoscopicType::MULTIVIEW;
748+
#else
749+
engineConfig.stereoscopicType = Engine::StereoscopicType::NONE;
750+
#endif
745751

746752
backend::Platform* platform = nullptr;
747753
#if defined(FILAMENT_DRIVER_SUPPORTS_VULKAN)

libs/gltfio/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ 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+
8289
function(build_ubershader NAME SRC SHADINGMODEL BLENDING)
8390
set(DEST "${RESOURCE_DIR}/${NAME}")
8491
configure_file(materials/${SRC}.mat.in "${DEST}.mat" COPYONLY)
@@ -95,7 +102,7 @@ function(build_ubershader NAME SRC SHADINGMODEL BLENDING)
95102

96103
add_custom_command(
97104
OUTPUT "${NAME}.filamat"
98-
COMMAND matc ${MATC_BASE_FLAGS} ${TEMPLATE_ARGS} -o "${NAME}.filamat" "${NAME}.mat"
105+
COMMAND matc ${MATC_FLAGS} ${TEMPLATE_ARGS} -o "${NAME}.filamat" "${NAME}.mat"
99106
DEPENDS matc "${DEST}.mat"
100107
WORKING_DIRECTORY ${RESOURCE_DIR}
101108
COMMENT "Compiling material ${NAME}")

0 commit comments

Comments
 (0)