diff --git a/.gitignore b/.gitignore index 558f9bdf..feb0f3cb 100755 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ bin /Build/System.Numerics.Vectors.dll /Build/System.Runtime.CompilerServices.Unsafe.dll /Build/Updater.ini +/Build.Native +/builder diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..cb9edb4f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,345 @@ +.COMMONENV: + variables: + BUILDTYPE: Release + CFLAGS: -Wall -Wextra -Werror + CXXFLAGS: -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-private-field + CPPFLAGS: -D NO_SSE + +default: + image: mono:slim + + cache: + - key: ccache-$CI_PROJECT_PATH_SLUG-$CI_JOB_NAME_SLUG + fallback_keys: + - cache-$CI_PROJECT_PATH_SLUG-$CI_DEFAULT_BRANCH + - cache-$CI_PROJECT_PATH_SLUG-default + paths: + - ccache + #- ccache_statslog + + - key: apt-$CI_JOB_IMAGE + paths: + - apt-cache + unprotect: true + + before_script: + - - | + # debconf + echo -e "\e[0Ksection_start:`date +%s`:debconf[collapsed=true]\r\e[0KSetup debconf's environment" + - export DEBIAN_FRONTEND="noninteractive" + - export DEBIAN_PRIORITY="low" + - export DEBCONF_NONINTERACTIVE_SEEN="true" + - | + # debconf + echo -e "\e[0Ksection_end:`date +%s`:debconf\r\e[0K" + + - - | + # dpkg_aa + echo -e "\e[0Ksection_start:`date +%s`:dpkg_aa[collapsed=true]\r\e[0KAdding architectures to dpkg" + - dpkg --add-architecture i386 + - dpkg --add-architecture amd64 + - dpkg --add-architecture arm64 + - | + # dpkg_aa + echo -e "\e[0Ksection_end:`date +%s`:dpkg_aa\r\e[0K" + + - - | + # apt_conf + echo -e "\e[0Ksection_start:`date +%s`:apt_conf[collapsed=true]\r\e[0KSetting up APT conf" + - export APT_CACHE_DIR=`pwd`/apt-cache + - mkdir --parents --verbose $APT_CACHE_DIR/partial/ + - touch /etc/apt/apt.conf.d/99build + - | + # apt.conf + echo Adding options to apt.conf':' + - | + # APT::Install-Recommends + echo APT::Install-Recommends "false"\; | tee --append /etc/apt/apt.conf.d/99build + - | + # quit + echo quiet "1"\; | tee --append /etc/apt/apt.conf.d/99build + - | + # APT::Get::Assume-Yes + echo APT::Get::Assume-Yes "true"\; | tee --append /etc/apt/apt.conf.d/99build + - | + # Dir::Cache::Archives + echo Dir::Cache::Archives "$APT_CACHE_DIR"\; | tee --append /etc/apt/apt.conf.d/99build + - | + # apt_conf + echo -e "\e[0Ksection_end:`date +%s`:apt_conf\r\e[0K" + + - - | + # apt_update + echo -e "\e[0Ksection_start:`date +%s`:apt_update[collapsed=true]\r\e[0KUpdating APT listing" + - apt-get update + - | + # apt_update + echo -e "\e[0Ksection_end:`date +%s`:apt_update\r\e[0K" + + - - | + # apt_pre + echo -e "\e[0Ksection_start:`date +%s`:apt_pre[collapsed=true]\r\e[0KInstalling pre packages" + - apt-get install apt-utils + - | + # apt_pre + echo -e "\e[0Ksection_end:`date +%s`:apt_pre\r\e[0K" + + - - | + # apt_upgrade + echo -e "\e[0Ksection_start:`date +%s`:apt_upgrade[collapsed=true]\r\e[0KUpdating existing packages" + - apt-get upgrade + - | + # apt_update + echo -e "\e[0Ksection_end:`date +%s`:apt_upgrade\r\e[0K" + + - - | + # apt_common + echo -e "\e[0Ksection_start:`date +%s`:apt_common[collapsed=true]\r\e[0KInstalling common packages" + - apt-get install make git ccache + - | + # apt_common + echo -e "\e[0Ksection_end:`date +%s`:apt_common\r\e[0K" + + - - | + # ccache_config + echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config" + - mkdir --parents --verbose ~/.ccache/ + - touch ~/.ccache/ccache.conf + - | + # cache.conf + echo Adding ccache configution option + - | + # base_dir + echo base_dir = $PWD | tee --append ~/.ccache/ccache.conf + - | + # cache_dir + echo cache_dir = $PWD/ccache | tee --append ~/.ccache/ccache.conf + - | + # compiler_check + echo compiler_check = content | tee --append ~/.ccache/ccache.conf + - | + # stats_log + echo #stats_log = $PWD/ccache_statslog | tee --append ~/.ccache/ccache.conf + - | + # max_size + echo max_size = 50M | tee --append ~/.ccache/ccache.conf + - | + # ccache_config + echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K" + + - - | + # cache_reset + echo -e "\e[0Ksection_start:`date +%s`:ccache_reset[collapsed=true]\r\e[0KResetting ccache statistics" + - ccache --zero-stats + - ccache --show-stats + - | + # ccache_reset + echo -e "\e[0Ksection_end:`date +%s`:ccache_reset\r\e[0K" + + artifacts: + paths: + - "Build/" + exclude: + - "Build/Source/Native/*.d" + - "Build/Source.Native/*.o" + - "Build/Source.Native/OpenGL/*.d" + - "Build/Source.Native/OpenGL/*.o" + - "Build/Source.Native/OpenGL/gl_load/*.d" + - "Build/Source.Native/OpenGL/gl_load/*.o" + - "Build/Source.Native/VPO/*.d" + - "Build/Source.Native/VPO/*.o" + - "Build/libBuilderNative.so" + expose_as: "Base" + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG" + + after_script: + - - | + # apt_clean + echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages" + - apt-get autoclean + - | + # apt_clean + echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K" + + - - | + # ccache_stats + echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:" + - ccache --show-stats --verbose || ccache --show-stats + - ccache --show-log-stats --verbose || ccache --show-log-stats || true + - | + # ccahe_stats + echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K" + +stages: + - build + +Release: + extends: + - .COMMONENV + + image: mono:latest + + stage: build + + variables: + CC: ccache clang + CXX: ccache clang + + script: + - - | + # apt_toolchain + echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages" + - apt-get install clang + - | + # apt_toolchain + echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K" + + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages" + - apt-get install mesa-common-dev + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling UZB" + - make --keep-going --silent || make --keep-going + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +i386: + extends: + - .COMMONENV + + stage: build + + variables: + CC: ccache i686-linux-gnu-gcc + CXX: ccache i686-linux-gnu-g++ + + artifacts: + paths: + - "Build/libBuilderNative.so" + expose_as: "Linux i386" + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG" + + script: + - - | + # apt_toolchain + echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages" + - apt-get install g++-i686-linux-gnu || apt-get install g++ + - | + # apt_toolchain + echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K" + + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages" + - apt-get install mesa-common-dev:i386 + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling Native" + - make --keep-going Build/libBuilderNative.so || make --keep-going Build/libBuilderNative.so + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +amd64: + extends: + - .COMMONENV + + stage: build + + variables: + CC: ccache x86_64-linux-gnu-gcc + CXX: ccache x86_64-linux-gnu-gcc + CPPFLAGS: -U NO_SSE + + artifacts: + paths: + - "Build/libBuilderNative.so" + expose_as: "Linux amd64" + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG" + + script: + - - | + # apt_toolchain + echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages" + - apt-get install g++-x86-64-linux-gnu || apt-get install g++ + - | + # apt_toolchain + echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K" + + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages" + - apt-get install mesa-common-dev:amd64 + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling Native" + - make --keep-going Build/libBuilderNative.so || make --keep-going Build/libBuilderNative.so + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +arm64: + extends: + - .COMMONENV + + stage: build + + variables: + CC: ccache aarch64-linux-gnu-gcc + CXX: ccache aarch64-linux-gnu-g++ + + artifacts: + paths: + - "Build/libBuilderNative.so" + expose_as: "Linux arm64" + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG" + + script: + - - | + # apt_toolchain + echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages" + - apt-get install g++-aarch64-linux-gnu || apt-get install g++ + - | + # apt_toolchain + echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K" + + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages" + - apt-get install mesa-common-dev:arm64 + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling Native" + - make --keep-going Build/libBuilderNative.so || make --keep-going Build/libBuilderNative.so + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +Debug: + extends: + - .COMMONENV + - Release + + allow_failure: true + + variables: + BUILDTYPE: Debug \ No newline at end of file diff --git a/Build/.gitignore b/Build/.gitignore index 01b16da6..b5e69f08 100755 --- a/Build/.gitignore +++ b/Build/.gitignore @@ -1,5 +1,6 @@ -Updater.exe -Updater.ini -Updater.pdb -DevIL.dll -Screenshots \ No newline at end of file +Updater.exe +Updater.ini +Updater.pdb +DevIL.dll +Screenshots +/Source diff --git a/Makefile b/Makefile index a057e9e7..727c76cb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,47 @@ - BUILDTYPE ?= Release -all: linux +TARGET_EXEC := libBuilderNative.so + +BUILD_DIR := ./Build.Native +SRC_DIRS := ./Source/Native + +SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s') + +OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) + +DEPS := $(OBJS:.o=.d) + +INC_DIRS := ./Source/Native + +INC_FLAGS := $(addprefix -I,$(INC_DIRS)) + +CPPFLAGS_ := $(INC_FLAGS) -MMD -MP + +CFLAGS_ = -O2 -g3 -fPIC + +CXXFLAGS_ = -std=c++14 $(CFLAGS_) + +LDFLAGS_ = --shared -ldl + +all: builder Build/libBuilderNative.so + +$(BUILD_DIR)/%.c.o: %.c + @mkdir -p $(dir $@) + $(CC) $(CPPFLAGS_) $(CPPFLAGS) $(CFLAGS_) $(CFLAGS) -c $< -o $@ + +$(BUILD_DIR)/%.cpp.o: %.cpp + @mkdir -p $(dir $@) + $(CXX) $(CPPFLAGS_) $(CPPFLAGS) $(CXXFLAGS_) $(CXXFLAGS) -c $< -o $@ + +$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) + $(CXX) $(OBJS) $(LDFLAGS_) $(LDFLAGS) -o $@ + +Build/libBuilderNative.so: $(BUILD_DIR)/$(TARGET_EXEC) + cp $< $@ + +.PHONY: clean +clean: + -rm --force --recursive $(BUILD_DIR)/Source $(BUILD_DIR)/$(TARGET_EXEC) $(BUILD_DIR)/builder $(BUILD_DIR)/Builder.exe Build/libBuilderNative.so run: cd Build && mono Builder.exe @@ -10,13 +50,19 @@ linux: builder native mac: builder nativemac -builder: +builder: $(BUILD_DIR)/Builder.exe Build/builder + +$(BUILD_DIR)/Builder.exe: BuilderMono.sln Build/builder msbuild /nologo /verbosity:minimal -p:Configuration=$(BUILDTYPE) BuilderMono.sln + +Build/builder: cp builder.sh Build/builder chmod +x Build/builder nativemac: - g++ -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -ldl + $(CXX) -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -ldl native: - g++ -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -lX11 -ldl + $(CXX) -std=c++14 -O2 --shared -g3 -o Build/libBuilderNative.so -fPIC -I Source/Native Source/Native/*.cpp Source/Native/OpenGL/*.cpp Source/Native/OpenGL/gl_load/*.c -lX11 -ldl + +-include $(DEPS) diff --git a/Source/Native/OpenGL/GLRenderDevice.cpp b/Source/Native/OpenGL/GLRenderDevice.cpp index 77e8382f..dd5ca9a1 100644 --- a/Source/Native/OpenGL/GLRenderDevice.cpp +++ b/Source/Native/OpenGL/GLRenderDevice.cpp @@ -566,11 +566,11 @@ void GLRenderDevice::GarbageCollectBuffer(int size, VertexFormat format) GLuint handle = old->GetVAO(); glDeleteVertexArrays(1, &handle); - if (handle == oldvao) oldvao = sharedbuf->GetVAO(); + if ((size_t)handle == (size_t)oldvao) oldvao = sharedbuf->GetVAO(); handle = old->GetBuffer(); glDeleteBuffers(1, &handle); - if (handle == oldarray) oldarray = sharedbuf->GetBuffer(); + if ((size_t)handle == (size_t)oldarray) oldarray = sharedbuf->GetBuffer(); glBindBuffer(GL_ARRAY_BUFFER, oldarray); glBindVertexArray(oldvao); diff --git a/Source/Native/OpenGL/gl_load/gl_load.c b/Source/Native/OpenGL/gl_load/gl_load.c index 364b2e5d..1a05e350 100644 --- a/Source/Native/OpenGL/gl_load/gl_load.c +++ b/Source/Native/OpenGL/gl_load/gl_load.c @@ -18,6 +18,7 @@ static void* AppleGLGetProcAddress (const char *name) #endif /* __APPLE__ */ /* BEGINNING OF MANUAL CHANGES, DO NOT REMOVE! */ +#if 0 // Unused function #if defined(__sgi) || defined (__sun) || defined(__unix__) #include #include @@ -39,6 +40,7 @@ static void* PosixGetProcAddress (const GLubyte* name) return dlsym(h, (const char*)name); } #endif /* __sgi || __sun || __unix__ */ +#endif #if defined(_WIN32) diff --git a/Source/Native/VPO/p_setup.cpp b/Source/Native/VPO/p_setup.cpp index e6d9e016..fc15ba6f 100644 --- a/Source/Native/VPO/p_setup.cpp +++ b/Source/Native/VPO/p_setup.cpp @@ -706,8 +706,8 @@ void Context::CalcDoorAltHeight(sector_t *sec) fixed_t door_h = sec->floorheight; // == sec->ceilingheight // compute lowest ceiling and highest floor of neighbor sectors - fixed_t low_ceil = 32767 << FRACBITS; - fixed_t high_floor = -32767 << FRACBITS; + fixed_t low_ceil = INT32_MAX; + fixed_t high_floor = INT32_MIN; int k, pass;