diff --git a/CMakeLists.txt b/CMakeLists.txt index 36974bcc24..54907209ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,15 @@ if (USE_AVX2) endif() endif(USE_AVX2) +# Default to enabling PIONEER_TARGET_RASPBERRY_PI if we're compiling on ARM64 +option(PIONEER_TARGET_RASPBERRY_PI "Compile for Raspberry Pi specifically (degrades to OpenGL 3.1)" ${PIONEER_TARGET_ARM64}) + +if (PIONEER_TARGET_RASPBERRY_PI) + add_definitions(-DPIONEER_TARGET_RASPBERRY_PI) + # add_compile_options("-mcpu=cortex-a76") + add_compile_options("-ffast-math") +endif(PIONEER_TARGET_RASPBERRY_PI) + option(USE_LLD_LINKER "Use the LLVM lld linker instead of gcc's linker" OFF) if (CMAKE_COMPILER_IS_GNUCXX) add_compile_options( diff --git a/CMakePresets.json b/CMakePresets.json index 228711f3fd..9fa7a056ba 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -77,8 +77,7 @@ "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": true, "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", - "CMAKE_BUILD_TYPE": "Debug", - "PROFILER_ENABLED": "1" + "CMAKE_BUILD_TYPE": "Debug" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -138,8 +137,7 @@ "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", "CMAKE_BUILD_TYPE": "Debug", "CMAKE_C_COMPILER": "/usr/bin/clang", - "CMAKE_CXX_COMPILER": "/usr/bin/clang++", - "PROFILER_ENABLED": "1" + "CMAKE_CXX_COMPILER": "/usr/bin/clang++" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { diff --git a/scripts/CMakeExperimentalPresets.json b/scripts/CMakeExperimentalPresets.json new file mode 100644 index 0000000000..e2291b2359 --- /dev/null +++ b/scripts/CMakeExperimentalPresets.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "RPi-Linux-Debug", + "displayName": "Linux RPi Debug", + "description": "Use system compiler; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_BUILD_TYPE": "Debug", + "USE_SSE42": false, + "USE_AVX2": false, + "PIONEER_TARGET_RASPBERRY_PI": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + }, + { + "name": "RPi-Linux-Profiler", + "displayName": "Linux RPi Profiling", + "description": "Use system compiler; Profiler=yes", + "binaryDir": "${sourceDir}/build/", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "PROFILER_ENABLED": "1", + "USE_SSE42": false, + "USE_AVX2": false, + "PIONEER_TARGET_RASPBERRY_PI": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + }, + { + "name": "RPi-linux-release", + "displayName": "Linux RPi Release", + "description": "Use system compiler; Opt=yes; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_BUILD_TYPE": "Release", + "USE_SSE42": false, + "USE_AVX2": false, + "PIONEER_TARGET_RASPBERRY_PI": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + } + ] +} diff --git a/src/graphics/opengl/RendererGL.cpp b/src/graphics/opengl/RendererGL.cpp index 5f6a47094a..64673b0c47 100644 --- a/src/graphics/opengl/RendererGL.cpp +++ b/src/graphics/opengl/RendererGL.cpp @@ -49,9 +49,16 @@ namespace Graphics { Uint32 winFlags = 0; winFlags |= SDL_WINDOW_OPENGL; - // We'd like a context that implements OpenGL 3.2 to allow creation of multisampled textures + // We'd like a context that implements OpenGL 3.1 to allow creation of multisampled textures SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); +#if defined(PIONEER_TARGET_RASPBERRY_PI) + // on Arm and other platforms we attempt to create an OpenGL 3.1 context as this is what Raspberry Pi 4 & 5 currently support + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); +#else + // x86/x64 we use newer OpenGL SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); +#endif + // Request core profile as we're uninterested in old fixed-function API // also cannot initialise 3.x context on OSX with anything but CORE profile SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); @@ -194,11 +201,19 @@ namespace Graphics { if (vs.enableDebugMessages) GLDebug::Enable(); +#if defined(PIONEER_TARGET_RASPBERRY_PI) + // on Arm and other platforms we attempt to create an OpenGL 3.1 context as this is what Raspberry Pi 4 & 5 currently support + if (!glewIsSupported("GL_VERSION_3_1")) { + Error("Pioneer can not run on your device (Raspberry Pi?) as it does not appear to support OpenGL 3.1"); + } +#else + // x86/x64 we use newer OpenGL if (!glewIsSupported("GL_VERSION_3_2")) { Error( "Pioneer can not run on your graphics card as it does not appear to support OpenGL 3.2\n" "Please check to see if your GPU driver vendor has an updated driver - or that drivers are installed correctly."); } +#endif if (!glewIsSupported("GL_EXT_texture_compression_s3tc")) { if (glewIsSupported("GL_ARB_texture_compression")) {