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

dxvk-ok1 #49

Draft
wants to merge 59 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
04e335e
[linux] add CI for Linux, dxvk_native, safeclib and 1st version for s…
q4a Jan 11, 2022
8630e43
[linux] fix build for matrix.h and rands.h
q4a Jan 11, 2022
4da3569
[linux] replace D3DXQUATERNION and D3DXMATRIX
q4a Jan 11, 2022
7332569
[linux] use custom sprintf_s instead of safeclib
q4a Jan 11, 2022
b394d94
[linux] FIX_LINUX s_debug.h
q4a Jan 13, 2022
3112fbf
[linux] use custom strcpy_s instead of safeclib
q4a Jan 15, 2022
08c5c99
[linux] fix for building dxvk with PATCH_COMMAND
q4a Jan 15, 2022
fb77858
[linux] FIX_LINUX __debugbreak
q4a Jan 15, 2022
4f41ef4
[linux] replace LOWORD
q4a Jan 16, 2022
6390a41
[linux] revert single FIX_LINUX ID3DXEffect
q4a Jan 16, 2022
53ddb04
[linux] FIX_LINUX ID3DXEffect
q4a Jan 16, 2022
305d196
[linux] FIX_LINUX _flushall
q4a Jan 16, 2022
21847a9
[linux] FIX_LINUX DirectXMath
q4a Jan 16, 2022
c3ba6d3
[linux] add explicit constructors for MovingLight, FindCharacter and …
q4a Jan 16, 2022
64c8c48
[linux] wrap <corecrt_io.h> and FIX_LINUX DxErr.h
q4a Jan 16, 2022
b2447ea
[linux] FIX_LINUX HBITMAP
q4a Jan 16, 2022
74f3926
[linux] replace GetKeyState and GetAsyncKeyState with core functions
q4a Jan 16, 2022
723113b
[linux] replace GetAsyncKeyState with core functions part 2
q4a Jan 16, 2022
7a33d69
[linux] FIX_LINUX ExitProcess
q4a Jan 16, 2022
fb23a36
[linux] FIX_LINUX RDTSC_*
q4a Jan 16, 2022
64c0348
[linux] FIX_LINUX Screenshot, HBITMAP, ReleaseDC, D3DXCreateTextureFr…
q4a Jan 16, 2022
8c10c75
[linux] FIX_LINUX ID3DXEffect part 2
q4a Jan 16, 2022
5496a79
[linux] replace MSVC _strupr and _strlwr with custom toupr and tolwr
q4a Jan 16, 2022
f57eee0
[linux] FIX_LINUX ddraw.h and amstream.h
q4a Jan 16, 2022
d3de3f5
replace GetLocalTime with std::localtime
q4a Jan 16, 2022
816cd9d
[linux] FIX_LINUX s_debug.h part 2
q4a Jan 16, 2022
66c2586
replace _strdup with strdup
q4a Jan 16, 2022
dc316a5
replace _splitpath with std::filesystem::path
q4a Jan 16, 2022
b541af0
replace __try + __except with try + catch
q4a Jan 16, 2022
bb8d69e
[linux] FIX_LINUX Cursor
q4a Jan 16, 2022
3802490
[linux] FIX_LINUX HINSTANCE
q4a Jan 16, 2022
3b4b764
[linux] FIX_LINUX CreateEventA
q4a Jan 16, 2022
0d6776f
[linux] replace MessageBoxA with SDL_ShowSimpleMessageBox
q4a Jan 16, 2022
41094c3
[linux] FIX_LINUX VirtualKey
q4a Jan 16, 2022
2030d59
remove unused struct tSoundDriverDescriptor, FILETIME ft_old,
q4a Jan 16, 2022
37fbc32
avoid error: non-const lvalue reference to type 'va_list' (aka '__bui…
q4a Jan 16, 2022
d125146
[linux] FIX_LINUX WideCharToMultiByte + MultiByteToWideChar
q4a Jan 16, 2022
a671b3b
[linux] FIX_LINUX sentry_options
q4a Jan 16, 2022
7bd9060
[linux] FIX_LINUX Beep
q4a Jan 16, 2022
f114a8c
[linux] FIX_LINUX 7za.exe
q4a Jan 16, 2022
5e2b42a
[linux] use inline wrapper for strcat_s, strcpy_s, strncpy_s
q4a Jan 16, 2022
5095b1c
[linux] add convert_path_sep, defines for MAX_* and MAKELONG
q4a Jan 16, 2022
a282692
[linux] temporary add winuser.h from Wine for VK_* defines
q4a Jan 16, 2022
651c212
[linux] FIX_LINUX SHGetKnownFolderPath
q4a Jan 16, 2022
66cac4a
[linux] add window flag and fix OSHandle for DXVK-Native
q4a Jan 16, 2022
e847046
[linux] FIX_LINUX D3DXLoadSurfaceFromSurface part 2
q4a Jan 16, 2022
71b7b65
[linux] FIX_LINUX GetWindowRect
q4a Jan 16, 2022
4f717af
[linux] fix includes for Linux
q4a Jan 16, 2022
899f4da
[linux] fix includes for Linux
q4a Jan 17, 2022
8b407c4
fix dependencies for input and fix linking on Linux
q4a Jan 17, 2022
5ee01fb
Revert "avoid error: non-const lvalue reference to type 'va_list' (ak…
q4a Jan 17, 2022
d90a2fe
[linux] FIX_LINUX GetTickCount
q4a Jan 17, 2022
a9a4a6e
[linux] add convert_path_sep to file_service.cpp and s_device.cpp
q4a Jan 17, 2022
62bf562
[linux] fix includes for Linux part 2
q4a Jan 20, 2022
ceb1f35
[linux] add explicit constructors for RS_LINE and tr_vertex
q4a Jan 20, 2022
3b73956
[linux] add explicit constructors for FunctionLocalVariablem,
q4a Jan 20, 2022
3683228
[linux] fix explicit constructors for structs
q4a Jan 20, 2022
d1c56c4
[linux] add D3DXLoadSurfaceFromSurface implementation from WINE
q4a Mar 15, 2022
0bfae09
[linux] first version for resource paths handling on linux
q4a Mar 15, 2022
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
43 changes: 43 additions & 0 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI Linux

on:
push:
paths-ignore:
- 'docs/**'
- 'tools/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- 'tools/**'
- '*.md'

jobs:
build-linux:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
configuration: [Debug]
name: 'build-linux [${{ matrix.configuration}}]'
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install libs
run: sudo apt update && sudo apt install meson libvulkan-dev glslang-tools libsdl2-dev libgl-dev libegl-dev
- name: Install Conan
run: pip install conan
- name: Configure with cmake
run: |
export CC=clang-11
export CXX=clang++-11
${CXX} --version
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.configuration}}
- name: Build dependencies
run: ninja dependencies
working-directory: build
- name: Build project
run: ninja
working-directory: build
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ conan_cmake_run(CONANFILE conanfile.py
steam=${STORM_ENABLE_STEAM}
)

if (NOT WIN32)
message("Using DXVK-native for D3D9 API")

include(ExternalProject)
#PATCH_COMMAND for ubuntu: https://bugs.launchpad.net/ubuntu/+source/libsdl2-ttf/+bug/1872023
ExternalProject_Add(dxvk-native
GIT_REPOSITORY https://github.com/Joshua-Ashton/dxvk-native
GIT_TAG a2dc99c407340432d4ba5bfa29efa685c27942ea
PATCH_COMMAND sed -i "s+directx')+directx', '/usr/include/SDL2')+g" meson.build
GIT_SHALLOW ON
BUILD_ALWAYS OFF
CONFIGURE_HANDLED_BY_BUILD ON
CONFIGURE_COMMAND meson ../dxvk-native
BUILD_COMMAND ninja
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)
include_directories("${DXVK_NATIVE_INCLUDE_DIRS}")
ADD_CUSTOM_TARGET(dependencies ALL DEPENDS dxvk-native)
endif()

### Define library ALIASes for use without CONAN_PKG:: prefix
foreach (conan_target ${CONAN_TARGETS})
string(REPLACE "CONAN_PKG::" "" unprefixed_target ${conan_target})
Expand Down
12 changes: 11 additions & 1 deletion cmake/StormSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ macro(STORM_SETUP)
${_SETUP_DEPENDENCIES})

if(${_SETUP_TYPE} STREQUAL "executable")
if(NOT WIN32)
list(APPEND target_link_flags "-Wl,--whole-archive")
endif()
foreach(dep ${_SETUP_DEPENDENCIES})
if(TARGET ${dep})
get_property(
Expand All @@ -231,10 +234,17 @@ macro(STORM_SETUP)
SET)
if(is_storm_module)
# TODO: make it portable? (at least for gcc it is --whole-archive)
list(APPEND target_link_flags "/WHOLEARCHIVE:${dep}")
if (WIN32)
list(APPEND target_link_flags "/WHOLEARCHIVE:${dep}")
else()
list(APPEND target_link_flags "${CMAKE_BINARY_DIR}/lib/lib${dep}.a")
endif()
endif()
endif()
endforeach()
if(NOT WIN32)
list(APPEND target_link_flags "-Wl,--no-whole-archive")
endif()
endif()
endif()

Expand Down
13 changes: 11 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ class StormEngine(ConanFile):

# dependencies used in deploy binaries
# conan-center
requires = ["zlib/1.2.11", "spdlog/1.9.2", "7zip/19.00", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3",
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3",
# storm.jfrog.io
"sentry-native/0.4.13@storm/patched", "directx/9.0@storm/prebuilt", "fmod/2.02.05@storm/prebuilt"]
# aux dependencies (e.g. for tests)
build_requires = "catch2/2.13.7"

# optional dependencies
def requirements(self):
if self.settings.os == "Windows":
# conan-center
self.requires("7zip/19.00")
else:
# conan-center
self.requires("libsafec/3.6.0")
if self.options.steam:
self.requires("steamworks/1.5.1@storm/prebuilt")

Expand All @@ -32,11 +38,14 @@ def requirements(self):
default_options = {
"sdl2:sdl2main": False,
"sentry-native:backend": "crashpad",
"sentry-native:transport": "winhttp",
"mimalloc:shared": True,
"mimalloc:override": True
}

def configure(self):
if self.settings.os == "Windows":
self.default_options["sentry-native:transport"] = "winhttp"

def imports(self):
self.__dest = str(self.options.output_directory) + "/" + getenv("CONAN_IMPORT_PATH", "bin")
self.__install_folder("/src/techniques", "/resource/techniques")
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (MSVC)
add_link_options("$<$<CONFIG:Release>:/OPT:ICF>") # Perform identical COMDAT folding, needs to be explicitly specified with /DEBUG
add_link_options("$<$<CONFIG:Release>:/LTCG>") # Enable link-time code generation
else()
add_definitions(-D_GLIBCXX_USE_TBB_PAR_BACKEND=0) # Don't use tbb
add_compile_options(-std=c++20)

# Verbose output
Expand Down
12 changes: 9 additions & 3 deletions src/apps/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ else()
set(MIMALLOC_DEP "$<IF:$<CONFIG:Release>,${CONAN_LIB_DIRS_MIMALLOC_RELEASE}/libmimalloc.so,${CONAN_LIB_DIRS_MIMALLOC_DEBUG}/libmimalloc-debug.so>")
endif()

if (WIN32)
set(SYSTEM_DEPS
"comctl32"
"dbghelp"
"winhttp"
)
endif()

STORM_SETUP(
TARGET_NAME engine
TYPE executable
Expand Down Expand Up @@ -69,7 +77,5 @@ STORM_SETUP(
zlib

# system
comctl32
dbghelp
winhttp
${SYSTEM_DEPS}
)
43 changes: 39 additions & 4 deletions src/apps/engine/src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

#include <zlib.h>

#ifdef _WIN32 // FIX_LINUX s_debug.h
#include "s_debug.h"
#else
#include "core_impl.h"
#endif
#include "logging.hpp"
#include "script_cache.h"
#include "storm_assert.h"
Expand Down Expand Up @@ -133,7 +137,9 @@ void COMPILER::SetProgramDirectory(const char *dir_name)
strcpy_s(ProgramDirectory, len, dir_name);
strcat_s(ProgramDirectory, len, "\\");
}
#ifdef _WIN32 // FIX_LINUX s_debug.h
CDebug->SetProgramDirectory(dir_name);
#endif
}

// load file into memory
Expand Down Expand Up @@ -327,8 +333,10 @@ void COMPILER::SetError(const char *data_PTR, ...)

logError_->error(ErrorBuffer);

#ifdef _WIN32 // FIX_LINUX s_debug.h
if (bBreakOnError)
CDebug->SetTraceMode(TMODE_MAKESTEP);
#endif
}

void COMPILER::SetWarning(const char *data_PTR, ...)
Expand Down Expand Up @@ -391,11 +399,13 @@ void COMPILER::LoadPreprocess()
// else bScriptTrace = true;
}

#ifdef _WIN32 // FIX_LINUX s_debug.h
auto ini = fio->OpenIniFile(PROJECT_NAME);
if (ini)
{
bBreakOnError = (ini->GetInt("options", "break_on_error", 0) == 1);
}
#endif
}

bool COMPILER::CreateProgram(const char *file_name)
Expand Down Expand Up @@ -615,8 +625,14 @@ VDATA *COMPILER::ProcessEvent(const char *event_name)

bEventsBreak = false;

#ifdef _WIN32 // FIX_LINUX GetTickCount
uint32_t nTimeOnEvent = GetTickCount();
#else
auto nStartEventTime = std::chrono::system_clock::now();
#endif
#ifdef _WIN32 // FIX_LINUX s_debug.h
current_debug_mode = CDebug->GetTraceMode();
#endif

pVD = nullptr;
if (event_name == nullptr)
Expand Down Expand Up @@ -683,14 +699,22 @@ VDATA *COMPILER::ProcessEvent(const char *event_name)
break;
}

#ifdef _WIN32 // FIX_LINUX GetTickCount
nTimeOnEvent = GetTickCount() - nTimeOnEvent;

nRuntimeTicks += nTimeOnEvent;
#else
std::chrono::duration<double, std::milli> nTimeOnEvent = std::chrono::system_clock::now() - nStartEventTime;

nRuntimeTicks += static_cast<uint32_t>(nTimeOnEvent.count());
#endif

pRun_fi = nullptr;

#ifdef _WIN32 // FIX_LINUX s_debug.h
if (current_debug_mode == TMODE_CONTINUE)
CDebug->SetTraceMode(TMODE_CONTINUE);
#endif
// SetFocus(core_internal.App_Hwnd); // VANO CHANGES

RDTSC_E(dwRDTSC);
Expand Down Expand Up @@ -816,7 +840,7 @@ bool COMPILER::BC_LoadSegment(const char *file_name)
// const auto len = strlen(file_name) + 1;
// SegmentTable[index].name = new char[len];
// memcpy(SegmentTable[index].name, file_name, len);
SegmentTable[index].name = _strdup(file_name);
SegmentTable[index].name = strdup(file_name);
SegmentTable[index].id = id;
SegmentTable[index].bUnload = false;
SegmentTable[index].pData = nullptr;
Expand Down Expand Up @@ -1895,7 +1919,8 @@ bool COMPILER::Compile(SEGMENT_DESC &Segment, char *pInternalCode, uint32_t pInt
uint32_t dwR;
if (bWriteCodeFile)
{
_splitpath(Segment.name.c_str(), nullptr, nullptr, file_name, nullptr);
auto fName = std::filesystem::path(Segment.name.c_str()).filename().string();
strcpy_s(file_name, fName.c_str());
strcat_s(file_name, ".b");
std::wstring FileNameW = utf8::ConvertUtf8ToWide(file_name);
auto fileS = fio->_CreateFile(file_name, std::ios::binary | std::ios::out);
Expand Down Expand Up @@ -3619,7 +3644,9 @@ bool COMPILER::BC_CallFunction(uint32_t func_code, uint32_t &ip, DATA *&pVResult
mem_pfi = pRun_fi;
mem_codebase = pRunCodeBase;

#ifdef _WIN32 // FIX_LINUX s_debug.h
nDebugEnterMode = CDebug->GetTraceMode();
#endif
uint64_t nTicks;
if (call_fi.segment_id == INTERNAL_SEGMENT_ID)
{
Expand Down Expand Up @@ -3670,10 +3697,12 @@ bool COMPILER::BC_CallFunction(uint32_t func_code, uint32_t &ip, DATA *&pVResult
core_internal.Trace("Invalid func_code = %u for AddTime", func_code);
}
}
#ifdef _WIN32 // FIX_LINUX s_debug.h
if (nDebugEnterMode == TMODE_MAKESTEP)
{
CDebug->SetTraceMode(TMODE_MAKESTEP);
}
#endif

if (pVResult)
{
Expand Down Expand Up @@ -3881,7 +3910,9 @@ bool COMPILER::BC_Execute(uint32_t function_code, DATA *&pVReturnResult, const c
switch (Token_type)
{
case ARGS_NUM:
#ifdef _WIN32 // FIX_LINUX __debugbreak
__debugbreak();
#endif
break;
case STACK_COMPARE:
pV = SStack.Read();
Expand Down Expand Up @@ -4230,6 +4261,7 @@ bool COMPILER::BC_Execute(uint32_t function_code, DATA *&pVReturnResult, const c
break;
if (bDebugExpressionRun)
break;
#ifdef _WIN32 // FIX_LINUX s_debug.h
memcpy(&nDebugTraceLineCode, &pCodeBase[ip], sizeof(uint32_t));
if (bTraceMode)
{
Expand Down Expand Up @@ -4279,6 +4311,7 @@ bool COMPILER::BC_Execute(uint32_t function_code, DATA *&pVReturnResult, const c
}
}
}
#endif
break;
case DEBUG_FILE_NAME:

Expand Down Expand Up @@ -6445,11 +6478,11 @@ void COMPILER::SaveVariable(DATA *pV, bool bdim)
break;
case VAR_AREFERENCE:
pString = nullptr;
__try
try
{
pA = TraceARoot(pV->AttributesClass, pString);
}
__except (EXCEPTION_EXECUTE_HANDLER)
catch (...)
{
SetError("Save - ARef to non existing attributes branch");
WriteVDword(0xffffffff);
Expand Down Expand Up @@ -7959,5 +7992,7 @@ void COMPILER::FormatDialog(char *file_name)

void STRING_CODEC::VariableChanged()
{
#ifdef _WIN32 // FIX_LINUX s_debug.h
CDebug->SetTraceMode(TMODE_MAKESTEP);
#endif
}
Loading