Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM nine changes #65

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0878d3f
conan: use find_package to add SDL2 dependency in Linux (without conan)
q4a Nov 24, 2022
17889a0
linux: add basic support for Gallium Nine on Linux
q4a Nov 23, 2022
ccf7462
[arm] add sse2neon.h from
q4a Apr 29, 2022
73a11e0
arm: add arm support in *.cpp, *.h, *.hpp
q4a Nov 24, 2022
f429173
arm: add armhf support to cmake file
q4a Nov 24, 2022
803f797
nine-native: improve d3d9types.h to support Perimeter game
q4a Nov 24, 2022
f0bdb5f
conan: use find_package to add SDL2 dependency in Linux (without cona…
q4a Dec 4, 2022
1a1f42a
[arm] Add -fsigned-char to avoid differences between x86 and arm
q4a May 8, 2022
993ee43
nine: don't use Vulkan window if defined STORM_MESA_NINE
q4a Dec 13, 2022
046b498
gcc: fix unions in math3d/color.h and math3d/plane.h
q4a Dec 18, 2022
2d0f2d3
gcc: fix unions in matrix.h and math3d/matrix.h
q4a Dec 18, 2022
80a408b
gcc: fix unions in math3d/vector4.h
q4a Dec 18, 2022
640c70b
gcc: fix unions in math3d/sphere.h
q4a Dec 19, 2022
675b51d
gcc: add name cv to 2nd struct in SAILGEOMETRY from sailone.h
q4a Dec 19, 2022
902693f
gcc: fix few errors with static_cast and #include <cstdarg>
q4a Dec 19, 2022
cb0ba0d
gcc: replace "using struct" with "typedef struct" in types3d.h
q4a Dec 19, 2022
00eef03
arm: update sse2neon.h with version from 2022.12.11
q4a Dec 19, 2022
74a46e3
arm: rename _rdtsc to storm_rdtsc
q4a Dec 19, 2022
1f7bd57
arm: simple fix for aligning asm vldr
q4a Dec 19, 2022
cb67796
nine: add armhf and aarch64 search paths for d3dadapter9.so
q4a Dec 22, 2022
d807260
Revert "gcc: fix unions in matrix.h and math3d/matrix.h"
q4a Feb 20, 2023
2b0633a
gcc: fix unions in matrix.h and math3d/matrix.h
q4a Feb 20, 2023
57703c4
ci: add sdl2 ppa for sdl2 >= 2.0.18 on Linux
q4a Mar 13, 2023
dc875f3
nine: remove nine-native folder
q4a Mar 14, 2023
47e9db1
nine: add Gallium Nine support with ExternalProject Nine Native
q4a Mar 14, 2023
42ecc3a
nine: remove old #if* STORM_MESA_NINE
q4a Mar 14, 2023
11f3d1e
linux: improve dxvk CONFIGURE_COMMAND - build only d3d9
q4a Mar 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install libs
- name: Install sdl2 ppa and libs
run: |
sudo apt-get update && sudo apt-get install meson libstdc++-10-dev libvulkan-dev glslang-tools libsdl2-dev libgl-dev libegl-dev
sudo add-apt-repository ppa:savoury1/games
sudo apt-get update && sudo apt-get install meson libstdc++-10-dev libvulkan-dev glslang-tools libsdl2-dev libgl-dev libegl-dev clang-${{matrix.clang_version}}
# fix for conan ci
sudo apt-get install libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev
- name: Install Conan
Expand Down
72 changes: 66 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ include(StormSetup)
option(STORM_ENABLE_CRASH_REPORTS "Enable automatic crash reports" OFF)
option(STORM_ENABLE_STEAM "Enable Steam integration" OFF)
option(STORM_ENABLE_SAFE_MODE "Enable additional runtime checks" OFF)
if (NOT WIN32)
option(STORM_MESA_NINE "Use Gallium Nine from Mesa (without WINE) for D3D9 API" OFF)
endif()

### Set up output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
Expand All @@ -16,6 +19,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug

set(STORM_WATERMARK_FILE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/watermark.hpp CACHE FILEPATH "Include file containing build revision, etc." FORCE)

message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv*")
set(PROJECT_PLATFORM_ARM TRUE)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(PROJECT_PLATFORM_ARM64 TRUE)
endif()

if (PROJECT_PLATFORM_ARM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -fsigned-char")
endif()

### Set up third-party dependencies
set(ENV{CONAN_REVISIONS_ENABLED} 1)
conan_add_remote(NAME bincrafters
Expand All @@ -38,27 +53,72 @@ conan_cmake_run(CONANFILE conanfile.py
)

if (NOT WIN32)
message("Using DXVK-native for D3D9 API")
find_package(SDL2 REQUIRED)
message(STATUS "SDL2_LIBRARIES="${SDL2_LIBRARIES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${SDL2_INCLUDE_DIRS} -fsigned-char")
message(STATUS "CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS})
endif()

if (WIN32)
message("Using Windows D3D9 API")
set(SDL2_LIBRARIES "sdl")
elseif (STORM_MESA_NINE) # for Gallium Nine
message("Using Gallium Nine for native D3D9 API")

#sudo apt install libd3dadapter9-mesa-dev
find_package(PkgConfig REQUIRED)
pkg_check_modules(D3D REQUIRED IMPORTED_TARGET d3d)

include(ExternalProject)
ExternalProject_Add(nine-native
GIT_REPOSITORY https://github.com/q4a/nine-native
GIT_TAG main
GIT_SHALLOW ON
BUILD_ALWAYS OFF
BUILD_BYPRODUCTS <BINARY_DIR>/libnine-native.a
INSTALL_COMMAND ""
)
ExternalProject_Get_property(nine-native SOURCE_DIR BINARY_DIR)
set(NINE_NATIVE_INCLUDE_DIRS
"${SOURCE_DIR}/include"
"${SOURCE_DIR}/include/D3D9"
"${SOURCE_DIR}/include/windows"
)
set(NATIVE_D3D9_LIBS
"${BINARY_DIR}/libnine-native.a"
"PkgConfig::D3D"
X11
xcb
xcb-present
xcb-dri3
xcb-xfixes
X11-xcb
)
include_directories("${NINE_NATIVE_INCLUDE_DIRS}")
add_custom_target(dependencies ALL DEPENDS nine-native)
else() # for DXVK Native
message("Using DXVK Native for D3D9 API")

include(ExternalProject)
ExternalProject_Add(dxvk-native
GIT_REPOSITORY https://github.com/Joshua-Ashton/dxvk-native
GIT_TAG a2dc99c407340432d4ba5bfa29efa685c27942ea
GIT_REPOSITORY https://github.com/IonAgorria/dxvk-native
GIT_TAG 2e91e784a86bc1355100518cd90eee48433551ac
GIT_SHALLOW ON
BUILD_ALWAYS OFF
CONFIGURE_HANDLED_BY_BUILD ON
CONFIGURE_COMMAND meson ../dxvk-native
CONFIGURE_COMMAND meson setup ../dxvk-native --buildtype=release -Denable_d3d11=false -Denable_d3d10=false -Denable_dxgi=false
BUILD_COMMAND ninja
BUILD_BYPRODUCTS <BINARY_DIR>/src/d3d9/libdxvk_d3d9.so
INSTALL_COMMAND ""
)
ExternalProject_Get_property(dxvk-native SOURCE_DIR BINARY_DIR)
set(DXVK_NATIVE_INCLUDE_DIRS
"${SOURCE_DIR}/include/native/directx"
"${SOURCE_DIR}/include/native/windows"
)
set(DXVK_NATIVE_D3D9_LIB ${BINARY_DIR}/src/d3d9/libdxvk_d3d9.so)
set(NATIVE_D3D9_LIBS ${BINARY_DIR}/src/d3d9/libdxvk_d3d9.so)
include_directories("${DXVK_NATIVE_INCLUDE_DIRS}")
ADD_CUSTOM_TARGET(dependencies ALL DEPENDS dxvk-native)
add_custom_target(dependencies ALL DEPENDS dxvk-native)
endif()

### Define library ALIASes for use without CONAN_PKG:: prefix
Expand Down
3 changes: 2 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StormEngine(ConanFile):

# dependencies used in deploy binaries
# conan-center
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3", "sentry-native/0.5.0",
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "mimalloc/2.0.3", "sentry-native/0.5.0",
# storm.jfrog.io
"directx/9.0@storm/prebuilt", "fmod/2.02.05@storm/prebuilt"]
# aux dependencies (e.g. for tests)
Expand All @@ -27,6 +27,7 @@ def requirements(self):
if self.settings.os == "Windows":
# conan-center
self.requires("7zip/19.00")
self.requires("sdl/2.0.18")
else:
# conan-center
self.requires("openssl/1.1.1n")#fix for error: 'sentry-crashpad/0.4.13' requires 'openssl/1.1.1n' while 'pulseaudio/14.2' requires 'openssl/1.1.1q'
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if (STORM_ENABLE_STEAM)
add_definitions(-DSTORM_ENABLE_STEAM=1)
endif()

if (STORM_MESA_NINE)
add_definitions(-DSTORM_MESA_NINE=1)
endif()

if(STORM_ENABLE_CRASH_REPORTS)
add_definitions(-DSTORM_ENABLE_CRASH_REPORTS=1)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/apps/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ STORM_SETUP(
# external
mimalloc
sentry-native
sdl
${SDL2_LIBRARIES}
zlib

# system
${SYSTEM_DEPS}
)
)
4 changes: 3 additions & 1 deletion src/libs/battle_interface/src/spyglass/spyglass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ void ISPYGLASS::FindNewTargetShip()
continue;
Sphere sph;
const auto &vec = pSD->pShip->GetPos();
sph.pos = {vec.x, vec.y, vec.z};
sph.x = vec.x;
sph.y = vec.y;
sph.z = vec.z;
sph.r = 40.f;
if (sph.Intersection(vsrc, vdst))
{
Expand Down
6 changes: 4 additions & 2 deletions src/libs/battle_interface/src/timer/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ bool BITimer::ReadAndCreate()
BIUtils::ReadRectFromAttr(AttributesPointer, "timerforeuv", rForeUV, rForeUV);

// read texture & color
auto *pcBackTexture = AttributesPointer ? AttributesPointer->GetAttribute("timerbacktexture") : nullptr;
auto *pcForeTexture = AttributesPointer ? AttributesPointer->GetAttribute("timerforetexture") : nullptr;
auto *pcBackTexture =
AttributesPointer ? static_cast<const char *>(AttributesPointer->GetAttribute("timerbacktexture")) : nullptr;
auto *pcForeTexture =
AttributesPointer ? static_cast<const char *>(AttributesPointer->GetAttribute("timerforetexture")) : nullptr;
auto dwColorBack =
AttributesPointer ? AttributesPointer->GetAttributeAsDword("timerbackcolor", 0xFFFFFFFF) : 0xFFFFFFFF;
auto dwColorFore =
Expand Down
4 changes: 2 additions & 2 deletions src/libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STORM_SETUP(
TARGET_NAME core
TYPE library
DEPENDENCIES diagnostics math shared_headers steam_api fast_float sdl window
)
DEPENDENCIES diagnostics math shared_headers steam_api fast_float ${SDL2_LIBRARIES} window
)
4 changes: 3 additions & 1 deletion src/libs/core/src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3845,6 +3845,7 @@ bool COMPILER::BC_Execute(uint32_t function_code, DATA *&pVReturnResult, const c
S_TOKEN_TYPE Token_type;
FuncInfo fi;
const VarInfo *real_var;
float float_var;
DATA *pV;
DATA *pVResult;
// DATA ExpressionResult; // while compile expression not ready, each function have its own register
Expand Down Expand Up @@ -5386,7 +5387,8 @@ bool COMPILER::BC_Execute(uint32_t function_code, DATA *&pVReturnResult, const c
pV->Set(*((int32_t *)&pRunCodeBase[TLR_DataOffset]));
break;
case FLOAT_NUMBER:
pV->Set(*((float *)&pRunCodeBase[TLR_DataOffset]));
float_var = *((float *)&pRunCodeBase[TLR_DataOffset]);
pV->Set(float_var);
break;
case STRING:
pV->Set((char *)&pRunCodeBase[TLR_DataOffset + 4]); // 4 - string length
Expand Down
4 changes: 2 additions & 2 deletions src/libs/input/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STORM_SETUP(
TARGET_NAME input
TYPE library
DEPENDENCIES sdl util
)
DEPENDENCIES ${SDL2_LIBRARIES} util
)
2 changes: 1 addition & 1 deletion src/libs/input/src/sdl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ SDLInput::SDLInput()
keyStates_ = SDL_GetKeyboardState(nullptr);
#ifndef _WIN32
// since SDL 2.0.18 breaks WINAPI mouse api
SDL_SetRelativeMouseMode(SDL_TRUE);
//SDL_SetRelativeMouseMode(SDL_TRUE);
#endif
SDL_AddEventWatch(&SDLEventHandler, this);
OpenController();
Expand Down
2 changes: 1 addition & 1 deletion src/libs/location/src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5206,7 +5206,7 @@ void Character::FindNearCharacters(MESSAGE &message)
// Find the surrounding characters
auto *const location = GetLocation();
auto fndCharacter = location->supervisor.FindCharacters(this, rad, viewAng, planeDist, ax, isSort);
auto n = fndCharacter.size();
int32_t n = fndCharacter.size();
if (fndCharacter.empty())
{
num->Set(0);
Expand Down
16 changes: 8 additions & 8 deletions src/libs/location/src/location_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,10 @@ bool LocationCamera::LoadCameraTrack(const char *pcTrackFile, float fTrackTime)
Matrix view;
m_track.GetPoint(0.f, pos, ang);
ang.GetMatrix(view);
view.vx = -view.vx;
view.vz = -view.vz;
view.v.vx = -view.v.vx;
view.v.vz = -view.v.vz;
view.Inverse();
view.pos = view * -pos;
view.v.pos = view * -pos;
rs->SetView(*(CMatrix *)&view);
rs->SetPerspective(cameraPerspective);

Expand All @@ -786,8 +786,8 @@ void LocationCamera::TurnOffTrackCamera()
Matrix view;
m_track.GetPoint(0.99999f, pos, ang);
ang.GetMatrix(view);
view.vx = -view.vx;
view.vz = -view.vz;
view.v.vx = -view.v.vx;
view.v.vz = -view.v.vz;
view.Inverse();

oldPos = *(CVECTOR *)&pos;
Expand All @@ -811,10 +811,10 @@ void LocationCamera::ProcessTrackCamera()
Matrix view;
m_track.GetPoint(fTrackTime / m_fTrackMaxTime, pos, ang);
ang.GetMatrix(view);
view.vx = -view.vx;
view.vz = -view.vz;
view.v.vx = -view.v.vx;
view.v.vz = -view.v.vz;
view.Inverse();
view.pos = view * -pos;
view.v.pos = view * -pos;
rs->SetView(*(CMatrix *)&view);
rs->SetPerspective(cameraPerspective);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
STORM_SETUP(
TARGET_NAME math
TYPE library
)
)
7 changes: 7 additions & 0 deletions src/libs/math/include/math3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

#include <cstdint>

#include "platform/platform.hpp"
#if defined(ARCH_X86) || defined(ARCH_X64)
#include <xmmintrin.h> // espkk # remove inline asm # 30/Dec/2017
#elif defined(ARCH_ARM) || defined(ARCH_ARM64)
#include "sse2neon.h"
#else
#error Add your platform here
#endif

//#define inline __forceinline

Expand Down
Loading