Skip to content

Commit af0f395

Browse files
authored
Filament targets c++20 by default (#9080)
1 parent f91ba08 commit af0f395

File tree

9 files changed

+45
-52
lines changed

9 files changed

+45
-52
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ endif()
331331
# ==================================================================================================
332332
# General compiler flags
333333
# ==================================================================================================
334-
set(CXX_STANDARD "-std=c++17")
334+
set(CXX_STANDARD "-std=c++20")
335335
if (WIN32)
336-
set(CXX_STANDARD "/std:c++17")
336+
set(CXX_STANDARD "/std:c++20")
337337
endif()
338338

339339
if (MSVC)

NEW_RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
1414
depth-only passes. [**Requires recompiling materials**]
1515
- material: fix specularFactor in `LOW_QUALITY` mode. [**Requires recompiling materials**] to take effect.
1616
- material: Add CRC32 validation for material packages [⚠️ **New Material Version**]
17+
- Filament is now targeting c++20 (was previously c++17)

filament/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,6 @@ else()
728728
-Wover-aligned
729729
-Werror
730730
)
731-
if (CMAKE_CXX_STANDARD EQUAL 20)
732-
# The lambdas for passes in PostProcessManager.cpp capture this
733-
# implicitly in a way that's deprecated in c++20, but can't easily be
734-
# fixed in a way that's backwards compatible with c++17:
735-
# https://www.nextptr.com/tutorial/ta1430524603/capture-this-in-lambda-expression-timeline-of-change
736-
list(APPEND FILAMENT_WARNINGS -Wno-deprecated-this-capture)
737-
endif()
738731
endif()
739732

740733
target_compile_options(${TARGET} PRIVATE

filament/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ main: main.o
9999
$(CC) -Llib/x86_64/ main.o $(FILAMENT_LIBS) -lpthread -lc++ -ldl -o main
100100
101101
main.o: main.cpp
102-
$(CC) -Iinclude/ -std=c++17 -pthread -c main.cpp
102+
$(CC) -Iinclude/ -std=c++20 -pthread -c main.cpp
103103
104104
clean:
105105
rm -f main main.o
@@ -119,7 +119,7 @@ main: main.o
119119
$(CC) -Llib/$(ARCH)/ main.o $(FILAMENT_LIBS) $(FRAMEWORKS) -o main
120120

121121
main.o: main.cpp
122-
$(CC) -Iinclude/ -std=c++17 -c main.cpp
122+
$(CC) -Iinclude/ -std=c++20 -c main.cpp
123123

124124
clean:
125125
rm -f main main.o
@@ -148,7 +148,7 @@ main.exe: main.obj
148148
gdi32.lib user32.lib opengl32.lib
149149

150150
main.obj: main.cpp
151-
$(CC) /MT /Iinclude\\ /std:c++17 /c main.cpp
151+
$(CC) /MT /Iinclude\\ /std:c++20 /c main.cpp
152152

153153
clean:
154154
del main.exe main.obj

filament/backend/include/private/backend/CommandStream.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ class NoopCommand : public CommandBase {
197197
#define DEBUG_COMMAND_END(methodName, sync) mDriver.debugCommandEnd(this, sync, #methodName)
198198
#else
199199
#define DEBUG_COMMAND_BEGIN(methodName, sync, ...)
200-
#define DEBUG_COMMAND_END(methodName, sync)
200+
// For the line "AutoExecute callOnExit([=, this](){",
201+
// "this" will be unused for release build since DEBUG_COMMAND_END is a no-op. So we add the
202+
// following workaround.
203+
#define DEBUG_COMMAND_END(methodName, sync) ((void)(this));
201204
#endif
202205

203206
class CommandStream {
@@ -229,7 +232,7 @@ class CommandStream {
229232
#define DECL_DRIVER_API_SYNCHRONOUS(RetType, methodName, paramsDecl, params) \
230233
inline RetType methodName(paramsDecl) { \
231234
DEBUG_COMMAND_BEGIN(methodName, true, params); \
232-
AutoExecute callOnExit([=](){ \
235+
AutoExecute callOnExit([=, this](){ \
233236
DEBUG_COMMAND_END(methodName, true); \
234237
}); \
235238
return apply(&Driver::methodName, mDriver, std::forward_as_tuple(params)); \

filament/src/PostProcessManager.cpp

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

filament/src/ShadowMapManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ FrameGraphId<FrameGraphTexture> ShadowMapManager::render(FEngine& engine, FrameG
337337
// "read" from one of its resource (only writes), so the FrameGraph culls it.
338338
builder.sideEffect();
339339
},
340-
[=, passBuilder = passBuilder,
340+
[=, this,
341+
passBuilder = passBuilder,
341342
&engine = const_cast<FEngine /*const*/ &>(engine), // FIXME: we want this const
342343
&view = const_cast<FView const&>(view)]
343344
(FrameGraphResources const&, auto const& data, DriverApi& driver) mutable {

libs/filamat/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ main: main.o
9393
$(CC) -Llib/x86_64/ -stdlib=libc++ main.o $(FILAMENT_LIBS) -lpthread -ldl -o main
9494
9595
main.o: main.cpp
96-
$(CC) -Iinclude/ -std=c++17 -stdlib=libc++ -pthread -c main.cpp
96+
$(CC) -Iinclude/ -std=c++20 -stdlib=libc++ -pthread -c main.cpp
9797
9898
clean:
9999
rm -f main main.o
@@ -111,7 +111,7 @@ main: main.o
111111
$(CC) -Llib/x86_64/ main.o $(FILAMENT_LIBS) -o main
112112

113113
main.o: main.cpp
114-
$(CC) -Iinclude/ -std=c++17 -c main.cpp
114+
$(CC) -Iinclude/ -std=c++20 -c main.cpp
115115

116116
clean:
117117
rm -f main main.o
@@ -138,7 +138,7 @@ main.exe: main.obj
138138
$(CC) main.obj $(FILAMENT_LIBS) gdi32.lib user32.lib opengl32.lib
139139

140140
main.obj: main.cpp
141-
$(CC) /MT /Iinclude/ /std:c++17 /c main.cpp
141+
$(CC) /MT /Iinclude/ /std:c++20 /c main.cpp
142142

143143
clean:
144144
del main.exe main.obj

libs/gltfio/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,6 @@ if (WEBGL_PTHREADS)
197197
endif()
198198

199199
set(GLTFIO_WARNINGS -Wall -Werror)
200-
if (CMAKE_CXX_STANDARD EQUAL 20)
201-
# The following things used by AssetLoader.cpp are deprecated in c++20:
202-
# wstring_convert and std::codecvt_utf8<char32_t>.
203-
list(APPEND GLTFIO_WARNINGS -Wno-deprecated-declarations)
204-
endif()
205200
if (NOT MSVC)
206201
target_compile_options(gltfio_core PRIVATE ${GLTFIO_WARNINGS})
207202
endif()

0 commit comments

Comments
 (0)