diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91606ff36..a126d4034 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -771,3 +771,272 @@ jobs: unreal-plugins-path: "C:/Program Files/Epic Games/UE_5.2/Engine/Plugins" test-package-base-name: "CesiumForUnreal-52" secrets: inherit + Windows53: + uses: ./.github/workflows/buildWindows.yml + with: + unreal-engine-version: "5.3.0" + unreal-runner-label: "unreal-53" + unreal-batch-files-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Build/BatchFiles" + upload-package-base-name: "CesiumForUnreal-53-windows" + TestWindows53: + needs: [Windows53] + uses: ./.github/workflows/testWindows.yml + with: + unreal-runner-label: "unreal-53" + unreal-binaries-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Binaries/Win64" + unreal-plugins-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Plugins" + test-package-base-name: "CesiumForUnreal-53-windows" + secrets: inherit + Android53: + runs-on: ["self-hosted","windows","x64","unreal-53"] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # so that `git describe` works. + - name: Set environment variables + run: | + $ENV:CESIUM_UNREAL_VERSION=$(git describe) + $ENV:BUILD_CESIUM_UNREAL_PACKAGE_NAME="CesiumForUnreal-53-android-${ENV:CESIUM_UNREAL_VERSION}" + # Make these available to subsequent steps + echo "CESIUM_UNREAL_VERSION=${ENV:CESIUM_UNREAL_VERSION}" >> $ENV:GITHUB_ENV + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=${ENV:BUILD_CESIUM_UNREAL_PACKAGE_NAME}" >> $ENV:GITHUB_ENV + - name: Install nasm + uses: ilammy/setup-nasm@v1.4.0 + - name: Build cesium-native + run: | + cd extern + cmake -B build-android -S . -G Ninja -DCMAKE_TOOLCHAIN_FILE="unreal-android-toolchain.cmake" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release + cmake --build build-android --config Release --target install -j8 + - name: Build plugin + run: | + ((Get-Content -path CesiumForUnreal.uplugin -Raw) -replace '"EngineVersion": "5.0.0"','"EngineVersion": "5.3.0"') | Set-Content -Path CesiumForUnreal.uplugin + cd "C:/Program Files/Epic Games/UE_5.3/Engine/Build/BatchFiles" + ./RunUAT.bat BuildPlugin -Plugin="$ENV:GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$ENV:GITHUB_WORKSPACE/packages/CesiumForUnreal" -CreateSubFolder -TargetPlatforms=Android -NoHostPlatform + - name: Publish plugin package artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} + path: packages + Linux53: + runs-on: ["self-hosted","linux","x64","unreal-53"] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # so that `git describe` works. + - name: Set environment variables + run: | + export CESIUM_UNREAL_VERSION=$(git describe) + export BUILD_CESIUM_UNREAL_PACKAGE_NAME="CesiumForUnreal-53-linux-${CESIUM_UNREAL_VERSION}" + # Make these available to subsequent steps + echo "CESIUM_UNREAL_VERSION=${CESIUM_UNREAL_VERSION}" >> "$GITHUB_ENV" + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=${BUILD_CESIUM_UNREAL_PACKAGE_NAME}" >> "$GITHUB_ENV" + - name: Install nasm + uses: ilammy/setup-nasm@v1.4.0 + - name: Build cesium-native + run: | + export UNREAL_ENGINE_DIR="/opt/ue53" + export LINUX_MULTIARCH_ROOT="/opt/ue53/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v22_clang-16.0.6-centos7/" + export UNREAL_ENGINE_COMPILER_DIR="${LINUX_MULTIARCH_ROOT}x86_64-unknown-linux-gnu" + export UNREAL_ENGINE_LIBCXX_DIR="${UNREAL_ENGINE_DIR}/Engine/Source/ThirdParty/Unix/LibCxx" + # TODO: Move this to the image instead + export PATH=$PATH:/usr/local/bin + cd extern + cmake -B build -S . -G Ninja -DCMAKE_TOOLCHAIN_FILE="unreal-linux-toolchain.cmake" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release --target install -j8 + cd .. + rm -rf extern + - name: Build plugin + run: | + sed -i 's/\"EngineVersion\": \"5.0.0\"/\"EngineVersion\": \"5.3.0\"/g' CesiumForUnreal.uplugin + export LINUX_MULTIARCH_ROOT="/opt/ue53/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v22_clang-16.0.6-centos7/" + cd /opt/ue53/Engine/Build/BatchFiles + # UnrealBuildTool writes to write to ~/.config and loses its mind if it doesn't exist. So create it. + # TODO: move this to the image instead + mkdir -p ~/.config + ./RunUAT.sh BuildPlugin -Plugin="$GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$GITHUB_WORKSPACE/packages/CesiumForUnreal" -CreateSubFolder -TargetPlatforms=Linux + - name: Fix RPATH + run: | + sudo yum install -y patchelf + cd $GITHUB_WORKSPACE/packages/CesiumForUnreal/Binaries/Linux + patchelf --print-rpath libUnrealEditor-CesiumRuntime.so + export UPDATED_RPATH=`patchelf --print-rpath libUnrealEditor-CesiumRuntime.so | sed 's/${ORIGIN}[^:]*\/SunPosition\/Binaries\/Linux/${ORIGIN}\/..\/..\/..\/..\/Runtime\/SunPosition\/Binaries\/Linux/'` + patchelf --force-rpath --set-rpath "$UPDATED_RPATH" libUnrealEditor-CesiumRuntime.so + - name: Publish plugin package artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} + path: packages + macOS53: + runs-on: macos-12 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: us-east-1 + steps: + - name: Get Unreal Engine + run: | + aws s3 cp s3://cesium-unreal-engine/5.3.0/UE_53_macOS.zip . + unzip -q UE_53_macOS.zip -d $HOME + rm UE_53_macOS.zip + - name: Check out repository code + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # so that `git describe` works. + - name: Set environment variables + run: | + export CESIUM_UNREAL_VERSION=$(git describe) + export BUILD_CESIUM_UNREAL_PACKAGE_NAME="CesiumForUnreal-53-macos-${CESIUM_UNREAL_VERSION}" + # Make these available to subsequent steps + echo "CESIUM_UNREAL_VERSION=${CESIUM_UNREAL_VERSION}" >> $GITHUB_ENV + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=${BUILD_CESIUM_UNREAL_PACKAGE_NAME}" >> $GITHUB_ENV + - name: Install nasm + uses: ilammy/setup-nasm@v1.4.0 + - name: Build cesium-native + run: | + mkdir -p extern/build + cd extern/build + INSTALL_LIBDIR=`cmake .. -LA | grep CMAKE_INSTALL_LIBDIR` + INSTALL_LIBDIR=${INSTALL_LIBDIR##CMAKE_INSTALL_LIBDIR:PATH=} + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=arm64 + cmake --build . -j4 --target install + mv $INSTALL_LIBDIR ${INSTALL_LIBDIR}-silicon + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=x86_64 + cmake --build . -j4 --target install + for f in ${INSTALL_LIBDIR}/*.a + do + lipo -create -output $f ${INSTALL_LIBDIR}-silicon/$(basename -- $f) $f + done + rm -r -f ${INSTALL_LIBDIR}-silicon + cd ../.. + rm -rf extern + - name: Build plugin + run: | + sed -i '' 's/\"EngineVersion\": \"5.0.0\"/\"EngineVersion\": \"5.3.0\"/g' CesiumForUnreal.uplugin + export UNREAL_ENGINE_DIR=$HOME/UE_5.3 + cd $UNREAL_ENGINE_DIR/Engine/Build/BatchFiles + ./RunUAT.sh BuildPlugin -Plugin="$GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$GITHUB_WORKSPACE/packages/CesiumForUnreal" -CreateSubFolder -TargetPlatforms=Mac + - name: Publish plugin package artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} + path: packages + iOS53: + runs-on: macos-12 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: us-east-1 + steps: + - name: Get Unreal Engine + run: | + aws s3 cp s3://cesium-unreal-engine/5.3.0/UE_53_macOS.zip . + unzip -q UE_53_macOS.zip -d $HOME + rm UE_53_macOS.zip + - name: Check out repository code + uses: actions/checkout@v3 + with: + submodules: recursive + fetch-depth: 0 # so that `git describe` works. + - name: Set environment variables + run: | + export CESIUM_UNREAL_VERSION=$(git describe) + export BUILD_CESIUM_UNREAL_PACKAGE_NAME="CesiumForUnreal-53-ios-${CESIUM_UNREAL_VERSION}" + # Make these available to subsequent steps + echo "CESIUM_UNREAL_VERSION=${CESIUM_UNREAL_VERSION}" >> $GITHUB_ENV + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=${BUILD_CESIUM_UNREAL_PACKAGE_NAME}" >> $GITHUB_ENV + - name: Install nasm + uses: ilammy/setup-nasm@v1.4.0 + - name: Build cesium-native + run: | + mkdir -p extern/build-ios + cd extern + cmake -B build-ios -S . -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-fembed-bitcode" -DCMAKE_C_FLAGS="-fembed-bitcode" + cmake --build build-ios -j 4 --target install --config Release -- -quiet # XCode output maxes out Travis log - Need to make it quiet + cd .. + rm -rf extern + - name: Build plugin + run: | + sed -i '' 's/\"EngineVersion\": \"5.0.0\"/\"EngineVersion\": \"5.3.0\"/g' CesiumForUnreal.uplugin + export UNREAL_ENGINE_DIR=$HOME/UE_5.3 + cd $UNREAL_ENGINE_DIR/Engine/Build/BatchFiles + ./RunUAT.sh BuildPlugin -Plugin="$GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$GITHUB_WORKSPACE/packages/CesiumForUnreal" -CreateSubFolder -TargetPlatforms=iOS -NoHostPlatform + - name: Publish plugin package artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} + path: packages + Combine53: + runs-on: ubuntu-latest + needs: [Windows53, Android53, Linux53, MacOS53, iOS53] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # so that `git describe` works. + - name: Set environment variables + run: | + export CESIUM_UNREAL_VERSION=$(git describe) + export BUILD_CESIUM_UNREAL_PACKAGE_NAME="CesiumForUnreal-53-${CESIUM_UNREAL_VERSION}" + # Make these available to subsequent steps + echo "CESIUM_UNREAL_VERSION=$CESIUM_UNREAL_VERSION" >> $GITHUB_ENV + echo "BUILD_CESIUM_UNREAL_PACKAGE_NAME=$BUILD_CESIUM_UNREAL_PACKAGE_NAME" >> $GITHUB_ENV + - name: Download iOS build + uses: actions/download-artifact@v3 + with: + name: CesiumForUnreal-53-ios-${{ env.CESIUM_UNREAL_VERSION}} + path: combine + - name: Download macOS build + uses: actions/download-artifact@v3 + with: + name: CesiumForUnreal-53-macos-${{ env.CESIUM_UNREAL_VERSION}} + path: combine + - name: Download Android build + uses: actions/download-artifact@v3 + with: + name: CesiumForUnreal-53-android-${{ env.CESIUM_UNREAL_VERSION}} + path: combine + - name: Download Linux build + uses: actions/download-artifact@v3 + with: + name: CesiumForUnreal-53-linux-${{ env.CESIUM_UNREAL_VERSION}} + path: combine + - name: Download Windows build + uses: actions/download-artifact@v3 + with: + name: CesiumForUnreal-53-windows-${{ env.CESIUM_UNREAL_VERSION}} + path: combine + - name: Unreal Marketplace Workaround + run: | + # The UE Marketplace deletes our Intermediates directory and fails to produces new + # intermediates for the Linux platform. The Marketplace team has suggested we copy + # them to the LinuxIntermediate directory instead, as a workaround. Users still have + # to move these files to the correct place manually, though, in order for Linux builds + # to succeed. + mkdir -p combine/CesiumForUnreal/LinuxIntermediate/Build/Linux + cp -r combine/CesiumForUnreal/Intermediate/Build/Linux/* combine/CesiumForUnreal/LinuxIntermediate/Build/Linux + - name: Publish combined package artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} + path: combine + TestPackage53: + needs: [Combine53] + uses: ./.github/workflows/testPackageOnWindows.yml + with: + unreal-engine-association: "5.3" + unreal-runner-label: "unreal-53" + unreal-binaries-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Binaries/Win64" + unreal-batch-files-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Build/BatchFiles" + unreal-plugins-path: "C:/Program Files/Epic Games/UE_5.3/Engine/Plugins" + test-package-base-name: "CesiumForUnreal-53" + secrets: inherit diff --git a/.github/workflows/buildWindows.yml b/.github/workflows/buildWindows.yml index 7d8b87633..2b4c54d6d 100644 --- a/.github/workflows/buildWindows.yml +++ b/.github/workflows/buildWindows.yml @@ -15,6 +15,10 @@ on: upload-package-base-name: required: true type: string + extra-choco-packages: + required: false + type: string + default: '' jobs: build: runs-on: ["self-hosted","windows","x64","${{ inputs.unreal-runner-label }}"] @@ -24,9 +28,10 @@ jobs: with: submodules: recursive fetch-depth: 0 # so that `git describe` works. - - name: Install dotnetcore-sdk + - name: Install Extra Dependencies + if: ${{ inputs.extra-choco-packages }} run: | - choco install -y dotnetcore-sdk + choco install -y ${{ inputs.extra-choco-packages }} - name: Set environment variables run: | $env:CESIUM_UNREAL_VERSION=$(git describe) @@ -55,7 +60,7 @@ jobs: run: | ((Get-Content -path CesiumForUnreal.uplugin -Raw) -replace '"EngineVersion": "5.0.0"','"EngineVersion": "${{ inputs.unreal-engine-version }}"') | Set-Content -Path CesiumForUnreal.uplugin - name: Build CesiumForUnreal plugin - timeout-minutes: 120 + timeout-minutes: 120 run: | cd "$env:UNREAL_BATCH_FILES_PATH" ./RunUAT.bat BuildPlugin -Plugin="$env:GITHUB_WORKSPACE/CesiumForUnreal.uplugin" -Package="$env:BUILD_CESIUM_UNREAL_PACKAGE_PATH" -CreateSubFolder -TargetPlatforms=Win64 @@ -64,4 +69,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ env.BUILD_CESIUM_UNREAL_PACKAGE_NAME}} - path: packages \ No newline at end of file + path: packages diff --git a/Config/Engine.ini b/Config/Engine.ini index 2652f1c9c..508da79d6 100644 --- a/Config/Engine.ini +++ b/Config/Engine.ini @@ -1,3 +1,10 @@ +# UE 5.3+ defaults this to 11, which is not really high enough. +# 100 is probably high enough for reasonable values of Cesium3DTileset's 'MaximumSimultaneousTileLoads property, +# but if you get log messages like "Warning: Reached threaded request limit", and you're sure you want to use +# such a high value, you may need to increase this. +[HTTP.HttpThread] +RunningThreadedRequestLimit=100 + [CoreRedirects] +FunctionRedirects=(OldName="CesiumMetadataFeatureTableBlueprintLibrary.GetPropertiesForFeatureID",NewName="GetMetadataValuesForFeatureID") diff --git a/Source/CesiumRuntime/CesiumRuntime.Build.cs b/Source/CesiumRuntime/CesiumRuntime.Build.cs index d2b708b65..0cc5588a6 100644 --- a/Source/CesiumRuntime/CesiumRuntime.Build.cs +++ b/Source/CesiumRuntime/CesiumRuntime.Build.cs @@ -12,6 +12,7 @@ public class CesiumRuntime : ModuleRules public CesiumRuntime(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + ShadowVariableWarningLevel = WarningLevel.Off; PublicIncludePaths.AddRange( new string[] { diff --git a/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.cpp b/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.cpp index 9f1254f76..0729cc18f 100644 --- a/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.cpp +++ b/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.cpp @@ -13,7 +13,12 @@ #include "MaterialDomain.h" #endif +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 +void FCesiumPointAttenuationIndexBuffer::InitRHI( + FRHICommandListBase& RHICmdList) { +#else void FCesiumPointAttenuationIndexBuffer::InitRHI() { +#endif if (!bAttenuationSupported) { return; } @@ -121,25 +126,36 @@ class FCesiumPointAttenuationVertexFactoryShaderParameters */ class FCesiumPointAttenuationDummyVertexBuffer : public FVertexBuffer { public: - virtual void InitRHI() override { - FRHIResourceCreateInfo CreateInfo( - TEXT("FCesiumPointAttenuationDummyVertexBuffer")); - VertexBufferRHI = RHICreateBuffer( - sizeof(FVector3f) * 4, - BUF_Static | BUF_VertexBuffer, - 0, - ERHIAccess::VertexOrIndexBuffer, - CreateInfo); - FVector3f* DummyContents = (FVector3f*) - RHILockBuffer(VertexBufferRHI, 0, sizeof(FVector3f) * 4, RLM_WriteOnly); - DummyContents[0] = FVector3f(0.0f, 0.0f, 0.0f); - DummyContents[1] = FVector3f(1.0f, 0.0f, 0.0f); - DummyContents[2] = FVector3f(0.0f, 1.0f, 0.0f); - DummyContents[3] = FVector3f(1.0f, 1.0f, 0.0f); - RHIUnlockBuffer(VertexBufferRHI); - } +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + virtual void InitRHI(FRHICommandListBase& RHICmdList) override; +#else + virtual void InitRHI() override; +#endif }; +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 +void FCesiumPointAttenuationDummyVertexBuffer::InitRHI( + FRHICommandListBase& RHICmdList) { +#else +void FCesiumPointAttenuationDummyVertexBuffer::InitRHI() { +#endif + FRHIResourceCreateInfo CreateInfo( + TEXT("FCesiumPointAttenuationDummyVertexBuffer")); + VertexBufferRHI = RHICreateBuffer( + sizeof(FVector3f) * 4, + BUF_Static | BUF_VertexBuffer, + 0, + ERHIAccess::VertexOrIndexBuffer, + CreateInfo); + FVector3f* DummyContents = (FVector3f*) + RHILockBuffer(VertexBufferRHI, 0, sizeof(FVector3f) * 4, RLM_WriteOnly); + DummyContents[0] = FVector3f(0.0f, 0.0f, 0.0f); + DummyContents[1] = FVector3f(1.0f, 0.0f, 0.0f); + DummyContents[2] = FVector3f(0.0f, 1.0f, 0.0f); + DummyContents[3] = FVector3f(1.0f, 1.0f, 0.0f); + RHIUnlockBuffer(VertexBufferRHI); +} + TGlobalResource GCesiumPointAttenuationDummyVertexBuffer; @@ -161,7 +177,12 @@ bool FCesiumPointAttenuationVertexFactory::ShouldCompilePermutation( Parameters.MaterialParameters.bIsSpecialEngineMaterial; } +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 +void FCesiumPointAttenuationVertexFactory::InitRHI( + FRHICommandListBase& RHICmdList) { +#else void FCesiumPointAttenuationVertexFactory::InitRHI() { +#endif FVertexDeclarationElementList Elements; Elements.Add(AccessStreamComponent( FVertexStreamComponent( diff --git a/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.h b/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.h index 5e5c42bb4..2992f58ca 100644 --- a/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.h +++ b/Source/CesiumRuntime/Private/CesiumPointAttenuationVertexFactory.h @@ -7,6 +7,7 @@ #include "RHIDefinitions.h" #include "RHIResources.h" #include "Rendering/PositionVertexBuffer.h" +#include "Runtime/Launch/Resources/Version.h" #include "SceneManagement.h" /** @@ -19,7 +20,11 @@ class FCesiumPointAttenuationIndexBuffer : public FIndexBuffer { const int32& NumPoints, const bool bAttenuationSupported) : NumPoints(NumPoints), bAttenuationSupported(bAttenuationSupported) {} +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + virtual void InitRHI(FRHICommandListBase& RHICmdList) override; +#else virtual void InitRHI() override; +#endif private: // The number of points in the original point mesh. Not to be confused with @@ -62,6 +67,10 @@ class FCesiumPointAttenuationVertexFactory : public FLocalVertexFactory { const FVertexFactoryShaderPermutationParameters& Parameters); private: +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + virtual void InitRHI(FRHICommandListBase& RHICmdList) override; +#else virtual void InitRHI() override; +#endif virtual void ReleaseRHI() override; }; diff --git a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp index e7106ac6a..288263f1a 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp +++ b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp @@ -276,7 +276,11 @@ class FCesiumTextureResource : public FTextureResource { uint32 GetSizeY() const override { return this->_height; } +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + virtual void InitRHI(FRHICommandListBase& RHICmdList) override { +#else virtual void InitRHI() override { +#endif FSamplerStateInitializerRHI samplerStateInitializer( this->_filter, this->_addressX, @@ -344,6 +348,20 @@ class FCesiumTextureResource : public FTextureResource { // RHICreateTexture2D can actually copy over all the mips in one shot, // but it expects a particular memory layout. Might be worth configuring // Cesium Native's mip-map generation to obey a standard memory layout. +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + rhiTexture = RHICreateTexture( + FRHITextureCreateDesc::Create2D(createInfo.DebugName) + .SetExtent(int32(this->_width), int32(this->_height)) + .SetFormat(this->_format) + .SetNumMips(uint8(mipCount)) + .SetNumSamples(1) + .SetFlags(textureFlags) + .SetInitialState(ERHIAccess::Unknown) + .SetExtData(createInfo.ExtData) + .SetBulkData(createInfo.BulkData) + .SetGPUMask(createInfo.GPUMask) + .SetClearValue(createInfo.ClearValueBinding)); +#else rhiTexture = RHICreateTexture2D( this->_width, this->_height, @@ -352,6 +370,7 @@ class FCesiumTextureResource : public FTextureResource { 1, textureFlags, createInfo); +#endif // Copies over rest of the mips for (uint32 i = 1; i < mipCount; ++i) { @@ -388,6 +407,48 @@ class FCesiumTextureResource : public FTextureResource { uint32 _platformExtData; }; +namespace { + +FTexture2DRHIRef createAsyncTextureAndWait( + uint32 SizeX, + uint32 SizeY, + uint8 Format, + uint32 NumMips, + ETextureCreateFlags Flags, + void** InitialMipData, + uint32 NumInitialMips) { +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + FGraphEventRef CompletionEvent; + + FTexture2DRHIRef result = RHIAsyncCreateTexture2D( + SizeX, + SizeY, + Format, + NumMips, + Flags, + InitialMipData, + NumInitialMips, + CompletionEvent); + + if (CompletionEvent) { + CompletionEvent->Wait(); + } + + return result; +#else + return RHIAsyncCreateTexture2D( + SizeX, + SizeY, + Format, + NumMips, + Flags, + InitialMipData, + NumInitialMips); +#endif +} + +} // namespace + /** * @brief Create an RHI texture on this thread. This requires * GRHISupportsAsyncTextureCreation to be true. @@ -424,7 +485,7 @@ FTexture2DRHIRef CreateRHITexture2D_Async( mipsData[i] = (void*)(&image.pixelData[mipPos.byteOffset]); } - return RHIAsyncCreateTexture2D( + return createAsyncTextureAndWait( static_cast(image.width), static_cast(image.height), format, @@ -434,7 +495,7 @@ FTexture2DRHIRef CreateRHITexture2D_Async( mipCount); } else { void* pTextureData = (void*)(image.pixelData.data()); - return RHIAsyncCreateTexture2D( + return createAsyncTextureAndWait( static_cast(image.width), static_cast(image.height), format, diff --git a/Source/CesiumRuntime/Private/CesiumViewExtension.cpp b/Source/CesiumRuntime/Private/CesiumViewExtension.cpp index 26711fd9b..5b064b42d 100644 --- a/Source/CesiumRuntime/Private/CesiumViewExtension.cpp +++ b/Source/CesiumRuntime/Private/CesiumViewExtension.cpp @@ -2,6 +2,7 @@ #include "CesiumViewExtension.h" #include "Cesium3DTileset.h" +#include "Runtime/Launch/Resources/Version.h" using namespace Cesium3DTilesSelection; @@ -91,6 +92,19 @@ void CesiumViewExtension::PreRenderView_RenderThread( FRHICommandListImmediate& RHICmdList, FSceneView& InView) {} +namespace { + +const TSet& +getOcclusionHistorySet(const FSceneViewState* pViewState) { +#if ENGINE_MAJOR_VERSION > 5 || ENGINE_MINOR_VERSION >= 3 + return pViewState->Occlusion.PrimitiveOcclusionHistorySet; +#else + return pViewState->PrimitiveOcclusionHistorySet; +#endif +} + +} // namespace + void CesiumViewExtension::PostRenderViewFamily_RenderThread( FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily) { @@ -114,7 +128,7 @@ void CesiumViewExtension::PostRenderViewFamily_RenderThread( continue; const FSceneViewState* pViewState = pView->State->GetConcreteViewState(); - if (pViewState && pViewState->PrimitiveOcclusionHistorySet.Num()) { + if (pViewState && getOcclusionHistorySet(pViewState).Num()) { SceneViewOcclusionResults& occlusionResults = _currentAggregation_renderThread.occlusionResultsByView .emplace_back(); @@ -133,8 +147,8 @@ void CesiumViewExtension::PostRenderViewFamily_RenderThread( } occlusionResults.PrimitiveOcclusionResults.Reserve( - pViewState->PrimitiveOcclusionHistorySet.Num()); - for (const auto& element : pViewState->PrimitiveOcclusionHistorySet) { + getOcclusionHistorySet(pViewState).Num()); + for (const auto& element : getOcclusionHistorySet(pViewState)) { occlusionResults.PrimitiveOcclusionResults.Emplace(element); } diff --git a/extern/cesium-native b/extern/cesium-native index 1248522db..35365bde3 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 1248522dba50e06e13800baae8169592971308a9 +Subproject commit 35365bde3d1b2d49936dda24265ba2944130817d