retro-go/base.cmake
Alex Duchesne bd22070c93 Enable the psram-cache-issue fix for all components
Cherry-pick:  06433c152c067f6c94c8ae7fd16d91edb087b812

Previously it was only enabled in DOOM and the launcher because they write to PSRAM a lot, triggering the bug often.

Other emulators tend to use it only to store their ROM in PSRAM, so the write bug doesn't usually occur. Which is why the fix was disabled until now.

But it definitely causes instability regardless. In this commit it is now enabled for all emulators, but not for the esp-idf side or libretro-go.

This should be a reasonable compromise. More testing is needed to see if it makes any emulator unusably slow...

So far I'm seeing 10-15% higher CPU usage which is... not great. Thankfully most emulators were at 50-60% usage, so there's headroom...
2025-11-07 15:21:02 -05:00

33 lines
1.4 KiB
CMake

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/components")
macro(rg_setup_compile_options)
component_compile_options(
-D${RG_BUILD_TARGET}=1
-DRETRO_GO=1
-fjump-tables -ftree-switch-conversion
${ARGV}
)
# The PSRAM cache bug is responsible for many subtile bugs and crashes. The workaround has a
# significant performance impact but the alternative is instability... Enabling the fix here
# instead of sdkconfig prevents the new libc and wifi from being linked in which increases
# size and reduces performance further. It's not entirely safe but retro-go has been built
# with the workaround fully disabled for years, so clearly this compromise should be "fine".
# memw seems to have the least impact both in terms of size and performance
if(IDF_TARGET STREQUAL "esp32")
component_compile_options(-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw)
endif()
if(RG_ENABLE_NETPLAY)
component_compile_options(-DRG_ENABLE_NETWORKING -DRG_ENABLE_NETPLAY)
elseif(RG_ENABLE_NETWORKING)
component_compile_options(-DRG_ENABLE_NETWORKING)
endif()
if(RG_ENABLE_PROFILING)
# Still debating whether -fno-inline is necessary or not...
component_compile_options(-DRG_ENABLE_PROFILING -finstrument-functions)
endif()
endmacro()