diff --git a/.github/workflows/continuous-building.yml b/.github/workflows/continuous-building.yml index c9be5573..26566f4a 100644 --- a/.github/workflows/continuous-building.yml +++ b/.github/workflows/continuous-building.yml @@ -13,6 +13,7 @@ jobs: matrix: os: - ubuntu-22.04 + - ubuntu-24.04 - macos-12 - windows-2022 use-asan: @@ -33,6 +34,11 @@ jobs: run: | sudo apt update sudo apt install qtbase5-dev libqt5svg5-dev + - name: 'Linux: Install TBB and Embree, if using distro packages' + if: ${{ matrix.os == 'ubuntu-24.04' }} + run: | + sudo apt install libtbb-dev libembree-dev + echo "USE_SYSTEM_TBB_AND_EMBREE=1" >> $GITHUB_ENV - name: 'Linux: Build the artifact' if: startsWith(matrix.os, 'ubuntu-') run: ./build-linux-64.sh @@ -42,7 +48,7 @@ jobs: mkdir ericw-tools-linux unzip build-linux/*-Linux.zip -d ericw-tools-linux - name: 'Linux: Upload the artifact' - if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.use-asan == 'NO' }} + if: ${{ matrix.os == 'ubuntu-22.04' && matrix.use-asan == 'NO' }} uses: actions/upload-artifact@v4 with: path: ericw-tools-linux/ @@ -50,7 +56,7 @@ jobs: if-no-files-found: error - name: 'Linux: Create GitHub Release and upload build' uses: softprops/action-gh-release@v1 - if: ${{ startsWith(matrix.os, 'ubuntu-') && matrix.use-asan == 'NO' && startsWith(github.ref, 'refs/tags/') }} + if: ${{ matrix.os == 'ubuntu-22.04' && matrix.use-asan == 'NO' && startsWith(github.ref, 'refs/tags/') }} with: draft: true files: | diff --git a/build-linux-64.sh b/build-linux-64.sh index fd3c5598..47f9dd4c 100755 --- a/build-linux-64.sh +++ b/build-linux-64.sh @@ -14,20 +14,29 @@ cmake --version mkdir "$BUILD_DIR" cd "$BUILD_DIR" -wget -q https://github.com/embree/embree/releases/download/v3.13.1/embree-3.13.1.x86_64.linux.tar.gz -O embree.tgz -wget -q https://github.com/oneapi-src/oneTBB/releases/download/v2021.3.0/oneapi-tbb-2021.3.0-lin.tgz -O tbb.tgz -tar xf embree.tgz -tar xf tbb.tgz - -EMBREE_CMAKE_DIR="$(pwd)/embree-3.13.1.x86_64.linux/lib/cmake/embree-3.13.1" -TBB_CMAKE_DIR="$(pwd)/oneapi-tbb-2021.3.0/lib/cmake" - -# check USE_ASAN environment variable (see cmake.yml) -if [ "$USE_ASAN" == "YES" ]; then - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DENABLE_LIGHTPREVIEW=YES -DERICWTOOLS_ASAN=YES +if [ "$USE_SYSTEM_TBB_AND_EMBREE" == "1" ]; then + if [ "$USE_ASAN" == "YES" ]; then + cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DERICWTOOLS_ASAN=YES -DSKIP_EMBREE_INSTALL=YES -DSKIP_TBB_INSTALL=YES + else + cmake .. -DCMAKE_BUILD_TYPE=Release -DSKIP_EMBREE_INSTALL=YES -DSKIP_TBB_INSTALL=YES + fi else - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" + wget -q https://github.com/embree/embree/releases/download/v3.13.1/embree-3.13.1.x86_64.linux.tar.gz -O embree.tgz + wget -q https://github.com/oneapi-src/oneTBB/releases/download/v2021.3.0/oneapi-tbb-2021.3.0-lin.tgz -O tbb.tgz + + tar xf embree.tgz + tar xf tbb.tgz + + EMBREE_CMAKE_DIR="$(pwd)/embree-3.13.1.x86_64.linux/lib/cmake/embree-3.13.1" + TBB_CMAKE_DIR="$(pwd)/oneapi-tbb-2021.3.0/lib/cmake" + + # check USE_ASAN environment variable (see cmake.yml) + if [ "$USE_ASAN" == "YES" ]; then + cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" -DENABLE_LIGHTPREVIEW=YES -DERICWTOOLS_ASAN=YES + else + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" + fi fi # not yet free of memory leaks, so don't abort on leak detection diff --git a/common/fs.cc b/common/fs.cc index 2f98216e..cfc37618 100644 --- a/common/fs.cc +++ b/common/fs.cc @@ -159,8 +159,24 @@ struct wad_archive : archive_like uint8_t compression; padding<2> pad; std::array name; // must be null terminated + // NOTE: textures using all 16 exist in the wild, e.g. openquartzmirror + // in free_wad.wad auto stream_data() { return std::tie(filepos, disksize, size, type, compression, pad, name); } + + std::string name_as_string() const { + size_t length = 0; + + // count the number of leading non-null characters + for (int i = 0; i < 16; ++i) { + if (name[i] != 0) + ++length; + else + break; + } + + return std::string(name.data(), length); + } }; std::unordered_map, case_insensitive_hash, case_insensitive_equal> @@ -189,7 +205,11 @@ struct wad_archive : archive_like wadstream >= file; - files[file.name.data()] = std::make_tuple(file.filepos, file.disksize); + std::string tex_name = file.name_as_string(); + if (tex_name.size() == 16) { + logging::print("WARNING: texture name {} ({}) is not null-terminated\n", tex_name, pathname); + } + files[tex_name] = std::make_tuple(file.filepos, file.disksize); } } diff --git a/include/light/trace_embree.hh b/include/light/trace_embree.hh index e5c3c65e..bfe761dc 100644 --- a/include/light/trace_embree.hh +++ b/include/light/trace_embree.hh @@ -243,8 +243,8 @@ public: #ifdef HAVE_EMBREE4 RTCIntersectArguments embree4_args = ctx2.setup_intersection_arguments(); - for (int i = 0; i < _numrays; ++i) - rtcIntersect1(scene, &_rays[i], &embree4_args); + for (auto &ray : _rays) + rtcIntersect1(scene, &ray.ray, &embree4_args); #else rtcIntersect1M(scene, &ctx2, &_rays.data()->ray, _rays.size(), sizeof(_rays[0])); #endif @@ -310,8 +310,8 @@ public: ray_source_info ctx2(this, self, shadowmask); #ifdef HAVE_EMBREE4 RTCOccludedArguments embree4_args = ctx2.setup_occluded_arguments(); - for (int i = 0; i < _numrays; ++i) - rtcOccluded1(scene, &_rays[i], &embree4_args); + for (auto &ray : _rays) + rtcOccluded1(scene, &ray.ray.ray, &embree4_args); #else rtcOccluded1M(scene, &ctx2, &_rays.data()->ray.ray, _rays.size(), sizeof(_rays[0])); #endif