From 497759b4d6e69e83b0824f26a53e7a811f693815 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 21 Nov 2020 21:12:38 +1000 Subject: [PATCH 1/5] VulkanHostDisplay: Support 16-bit scanout --- src/common/vulkan/util.cpp | 2 ++ src/frontend-common/vulkan_host_display.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/vulkan/util.cpp b/src/common/vulkan/util.cpp index f7ee2d88d..c0f418873 100644 --- a/src/common/vulkan/util.cpp +++ b/src/common/vulkan/util.cpp @@ -83,6 +83,8 @@ u32 GetTexelSize(VkFormat format) case VK_FORMAT_R5G5B5A1_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16: + case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_B5G6R5_UNORM_PACK16: return 2; case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 60d0b793a..c4665acad 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -248,7 +248,7 @@ bool VulkanHostDisplay::DownloadTexture(const void* texture_handle, u32 x, u32 y } static constexpr std::array(HostDisplayPixelFormat::Count)> s_display_pixel_format_mapping = - {{VK_FORMAT_UNDEFINED, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B5G6R5_UNORM_PACK16, + {{VK_FORMAT_UNDEFINED, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16}}; bool VulkanHostDisplay::SupportsDisplayPixelFormat(HostDisplayPixelFormat format) const From a6529a9537b6ea990a45f74379485f279510b7dc Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 21 Nov 2020 22:44:35 +1000 Subject: [PATCH 2/5] Android: Enable armeabi-v7a builds --- CMakeLists.txt | 9 +++++++++ android/app/build.gradle | 4 ++-- src/core/gpu_sw.cpp | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3e04556e..98e161995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,15 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") set(CPU_ARCH "aarch64") elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") set(CPU_ARCH "aarch32") + if(ANDROID) + # Force ARM mode, since apparently ANDROID_ARM_MODE isn't working.. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm") + else() + # Enable NEON. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -march=armv7-a+simd -mfpu=neon-vfpv3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a+simd -mfpu=neon-vfpv3") + endif() else() message(FATAL_ERROR "Unknown system processor: " ${CMAKE_SYSTEM_PROCESSOR}) endif() diff --git a/android/app/build.gradle b/android/app/build.gradle index 929a33daf..7bac3f3f7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -30,8 +30,8 @@ android { defaultConfig { externalNativeBuild { cmake { - arguments "-DCMAKE_BUILD_TYPE=RelWithDebInfo" - abiFilters "arm64-v8a" + arguments "-DCMAKE_BUILD_TYPE=Release -DANDROID_ARM_NEON=ON" + abiFilters "arm64-v8a", "armeabi-v7a" } } } diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 5a69c1cb8..a38bdf40b 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -11,6 +11,8 @@ Log_SetChannel(GPU_SW); #if defined(CPU_X64) #include +#elif defined(CPU_AARCH32) +#include #elif defined(CPU_AARCH64) #ifdef _MSC_VER #include @@ -155,7 +157,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16 _mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value); dst_ptr += 8; } -#elif defined(CPU_AARCH64) +#elif defined(CPU_AARCH32) || defined(CPU_AARCH64) const u32 aligned_width = Common::AlignDownPow2(width, 8); for (; col < aligned_width; col += 8) { @@ -195,7 +197,7 @@ ALWAYS_INLINE void CopyOutRow16(const u16* _mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value); dst_ptr += 8; } -#elif defined(CPU_AARCH64) +#elif defined(CPU_AARCH32) || defined(CPU_AARCH64) const u32 aligned_width = Common::AlignDownPow2(width, 8); const uint16x8_t single_mask = vdupq_n_u16(0x1F); for (; col < aligned_width; col += 8) From 2ee22071065dde4ecb30448d70ccc82aa647a8ab Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 21 Nov 2020 22:45:57 +1000 Subject: [PATCH 3/5] CI: Output Android apk as duckstation-android.apk --- .github/workflows/rolling-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index 24da77020..c3f544e39 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -224,14 +224,14 @@ jobs: shell: bash run: | cd android - mv app/build/outputs/apk/release/app-release-unsigned-signed.apk ../duckstation-android-aarch64.apk + mv app/build/outputs/apk/release/app-release-unsigned-signed.apk ../duckstation-android.apk - name: Upload APK if: github.ref == 'refs/heads/master' uses: actions/upload-artifact@v1 with: name: "android" - path: "duckstation-android-aarch64.apk" + path: "duckstation-android.apk" macos-build: runs-on: macos-10.15 @@ -350,7 +350,7 @@ jobs: linux-libretro/duckstation_libretro_x64.so.zip linux-libretro/duckstation_libretro_linux_aarch64.so.zip linux-libretro/duckstation_libretro_android_aarch64.so.zip - android/duckstation-android-aarch64.apk + android/duckstation-android.apk macos-x64/duckstation-mac-release.zip macos-x64/duckstation_libretro_mac.dylib.zip From 3797d2acbca0100663bdaa1bcbb781d98dfaba59 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 22 Nov 2020 01:23:11 +1000 Subject: [PATCH 4/5] CI: Generate armv7 libretro cores --- .github/workflows/rolling-release.yml | 36 ++++++++++++++++++++++-- CMakeModules/armv7-cross-toolchain.cmake | 14 +++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 CMakeModules/armv7-cross-toolchain.cmake diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index c3f544e39..37e8552ce 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -148,7 +148,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf - name: Compile and zip Linux x64 libretro core shell: bash @@ -165,6 +165,21 @@ jobs: name: "linux-libretro" path: "build-libretro-linux-x64/duckstation_libretro_x64.so.zip" + - name: Compile and zip Linux armv7 libretro core + shell: bash + run: | + mkdir build-libretro-linux-armv7 + cd build-libretro-linux-armv7 + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeModules/armv7-cross-toolchain.cmake .. + cmake --build . --parallel 2 + zip -j duckstation_libretro_linux_armv7.so.zip duckstation_libretro.so + + - name: Upload Linux AArch64 libretro core + uses: actions/upload-artifact@v1 + with: + name: "linux-libretro" + path: "build-libretro-linux-armv7/duckstation_libretro_linux_armv7.so.zip" + - name: Compile and zip Linux AArch64 libretro core shell: bash run: | @@ -173,13 +188,28 @@ jobs: cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeModules/aarch64-cross-toolchain.cmake .. cmake --build . --parallel 2 zip -j duckstation_libretro_linux_aarch64.so.zip duckstation_libretro.so - + - name: Upload Linux AArch64 libretro core uses: actions/upload-artifact@v1 with: name: "linux-libretro" path: "build-libretro-linux-aarch64/duckstation_libretro_linux_aarch64.so.zip" + - name: Compile and zip Android armv7 libretro core + shell: bash + run: | + mkdir build-libretro-android-armv7 + cd build-libretro-android-armv7 + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBRETRO_CORE=ON -DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK_ROOT}/ndk-bundle/build/cmake/android.toolchain.cmake .. + cmake --build . --parallel 2 + zip -j duckstation_libretro_android_armv7.so.zip duckstation_libretro_android.so + + - name: Upload Android armv7 libretro core + uses: actions/upload-artifact@v1 + with: + name: "linux-libretro" + path: "build-libretro-android-armv7/duckstation_libretro_android_armv7.so.zip" + - name: Compile and zip Android AArch64 libretro core shell: bash run: | @@ -348,7 +378,9 @@ jobs: linux-x64-appimage-qt/duckstation-qt-x64.AppImage linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync linux-libretro/duckstation_libretro_x64.so.zip + linux-libretro/duckstation_libretro_linux_armv7.so.zip linux-libretro/duckstation_libretro_linux_aarch64.so.zip + linux-libretro/duckstation_libretro_android_armv7.so.zip linux-libretro/duckstation_libretro_android_aarch64.so.zip android/duckstation-android.apk macos-x64/duckstation-mac-release.zip diff --git a/CMakeModules/armv7-cross-toolchain.cmake b/CMakeModules/armv7-cross-toolchain.cmake new file mode 100644 index 000000000..25eba97c5 --- /dev/null +++ b/CMakeModules/armv7-cross-toolchain.cmake @@ -0,0 +1,14 @@ +# Source: https://github.com/stenzek/duckstation/issues/626#issuecomment-660718306 + +# Target system +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_PROCESSOR armv7l) +SET(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_CROSSCOMPILING TRUE) + +# Cross compiler +SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) +set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf) + +set(THREADS_PTHREAD_ARG "0" CACHE STRING "Result from TRY_RUN" FORCE) From 7e7ec86f91a90b33fc9d4257e2ec4c66c29f220e Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 22 Nov 2020 01:23:39 +1000 Subject: [PATCH 5/5] GPU/Software: Remove a couple of unused variables --- src/core/gpu_sw_backend.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/gpu_sw_backend.cpp b/src/core/gpu_sw_backend.cpp index fc4d2d2f6..e87a262d2 100644 --- a/src/core/gpu_sw_backend.cpp +++ b/src/core/gpu_sw_backend.cpp @@ -102,8 +102,6 @@ void ALWAYS_INLINE_RELEASE GPU_SW_Backend::ShadePixel(const GPUBackendDrawComman (cmd->draw_mode.GetTexturePageBaseY() + ZeroExtend32(texcoord_y)) % VRAM_HEIGHT); const u16 palette_index = (palette_value >> ((texcoord_x % 4) * 4)) & 0x0Fu; - const u32 px = (cmd->palette.GetXBase() + ZeroExtend32(palette_index)) % VRAM_WIDTH; - const u32 py = cmd->palette.GetYBase(); texture_color.bits = GetPixel((cmd->palette.GetXBase() + ZeroExtend32(palette_index)) % VRAM_WIDTH, cmd->palette.GetYBase()); }