Skip to content

Commit

Permalink
Use -O2 for render code even in release mode
Browse files Browse the repository at this point in the history
-O3 tries to vectorize blit loops too aggressively,
but our blit calls mostly loop only a few times.

`measure_timedemo_performance` on my machine:

* O1: 6.606 ± 0.060 seconds, 1109.520 ± 9.843 FPS
* O2: 6.484 ± 0.063 seconds, 1130.220 ± 10.909 FPS
* O3: 6.746 ± 0.017 seconds, 1086.260 ± 2.170 FPS
  • Loading branch information
glebm committed Jun 14, 2024
1 parent 0759707 commit aa0476b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ set(libdevilutionx_SRCS

# These files are responsible for most of the runtime in Debug mode.
# Apply some optimizations to them even in Debug mode to get reasonable performance.
#
# They also perform better with -O2 rather than -O3 even in Release mode.
set(_optimize_in_debug_srcs
engine/render/clx_render.cpp
engine/render/dun_render.cpp
engine/render/text_render.cpp
utils/cel_to_clx.cpp
utils/cl2_to_clx.cpp
utils/pcx_to_clx.cpp)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "-O2;--param=max-vartrack-size=900000000")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "-O2")
endif()

Expand Down

0 comments on commit aa0476b

Please sign in to comment.