diff --git a/.github/workflows/native-compile-platforms.yml b/.github/workflows/native-compile-platforms.yml index 450fe8be416..e17a552204b 100644 --- a/.github/workflows/native-compile-platforms.yml +++ b/.github/workflows/native-compile-platforms.yml @@ -512,33 +512,3 @@ jobs: cmake --build . --config Debug -- -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO fi echo "Compile iOS Done!" - - compile_wgpu_mac: - name: "Emscripten" - runs-on: macos-latest - if: contains( github.event.pull_request.title, 'WGPU_CI_ON' ) - steps: - - uses: actions/checkout@v2 - - name: Download external libraries - shell: bash - run: | - EXT_VERSION=`node ./.github/workflows/get-native-external-version.js` - git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external - - name: Setup Emscripten - run: | - NATIVE_ROOT=$GITHUB_WORKSPACE/native - git clone https://github.com/emscripten-core/emsdk.git NATIVE_ROOT/../../emsdk - cd NATIVE_ROOT/../../emsdk - ./emsdk install 3.1.17 - ./emsdk activate 3.1.17 - source ./emsdk_env.sh - emcc -v - - name: Compile - env: - COCOS_ENGINE_DEV: 1 - run: | - NATIVE_ROOT=$GITHUB_WORKSPACE/native - cd $NATIVE_ROOT/cocos/renderer/gfx-wgpu - $NATIVE_ROOT/../../emsdk/upstream/emscripten/emcmake cmake . - $NATIVE_ROOT/../../emsdk/upstream/emscripten/emmake make - echo "Compile WGPU by ems on MacOS Done!" diff --git a/.github/workflows/native-compile-webgpu.yml b/.github/workflows/native-compile-webgpu.yml new file mode 100644 index 00000000000..8ba473b42e3 --- /dev/null +++ b/.github/workflows/native-compile-webgpu.yml @@ -0,0 +1,64 @@ +name: Compile WebGPU + +on: + pull_request: + paths: + - 'native/external-config.json' + - 'native/cocos/base/**' + - 'native/cocos/renderer/gfx-base/**' + - 'native/cocos/renderer/gfx-wgpu/**' + - 'native/cocos/renderer/gfx-validator/**' + - 'native/cocos/renderer/gfx-empty/**' + - '.github/workflows/native-compile-webgpu.yml' + +# github.head_ref is only defined on pull_request events +concurrency: + group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + compile_wgpu: + name: "Emscripten" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Download external libraries + shell: bash + run: | + EXT_VERSION=`node ./.github/workflows/get-native-external-version.js` + git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external + + - name: Setup emsdk + uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846 + with: + version: 3.1.45 + actions-cache-folder: 'emsdk-cache' + + - name: Verify + run: | + which emcc + emcc -v + + - name: Install ninja + run: | + if ! command -v ninja &> /dev/null; then + echo "Ninja not found, installing..." + # sudo apt update + sudo apt install ninja-build + else + echo "Ninja is already installed." + fi + which ninja + + - name: Compile + # env: + # COCOS_ENGINE_DEV: 1 + run: | + NATIVE_ROOT=$GITHUB_WORKSPACE/native + cd $NATIVE_ROOT/cocos/renderer/gfx-wgpu + mkdir build + cd build + cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Debug + ninja + echo "============== Compile WGPU by ems on Ubuntu Done! ==============" diff --git a/native/cocos/renderer/gfx-wgpu/CMakeLists.txt b/native/cocos/renderer/gfx-wgpu/CMakeLists.txt index 2881f3643cd..f828214a099 100644 --- a/native/cocos/renderer/gfx-wgpu/CMakeLists.txt +++ b/native/cocos/renderer/gfx-wgpu/CMakeLists.txt @@ -14,9 +14,11 @@ include(${ENGINE_ROOT_DIR}/cmake/predefine.cmake) include (${ENGINE_ROOT_DIR}/external/CMakeLists.txt) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wextra -Wno-nonportable-include-path -fno-exceptions -v -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES=D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g3 -D_DEBUG=1 -Wno-unused -O0 -std=c++17 -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w -DNDEBUG=1 -O3 -std=c++17 -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES") +add_definitions(-DBOOST_NO_CXX98_FUNCTION_BASE) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-nonportable-include-path -fno-exceptions") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -D_DEBUG=1 -Wno-unused -O0 -std=c++17") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1 -O3 -std=c++17") message(${CMAKE_BUILD_TYPE}) diff --git a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h index d52ee6e23cd..175c81a4b62 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h @@ -96,8 +96,8 @@ class CCWGPUCommandBuffer final : public CommandBuffer { void updateBuffer(Buffer *buff, const emscripten::val &v, uint32_t size);) protected: - virtual void doInit(const CommandBufferInfo &info); - virtual void doDestroy(); + void doInit(const CommandBufferInfo &info) override; + void doDestroy() override; // delay binding. void bindStates(); diff --git a/native/cocos/renderer/gfx-wgpu/WGPUEMSImpl.cpp b/native/cocos/renderer/gfx-wgpu/WGPUEMSImpl.cpp index 44160fec98b..354ac4f3825 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUEMSImpl.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUEMSImpl.cpp @@ -22,7 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -#pragma once #include #include #include diff --git a/native/cocos/renderer/gfx-wgpu/WGPUSampler.h b/native/cocos/renderer/gfx-wgpu/WGPUSampler.h index 438846f582f..26911f1d774 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUSampler.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUSampler.h @@ -28,7 +28,7 @@ #endif #include "gfx-base/states/GFXSampler.h" -#include "WGPUobject.h" +#include "WGPUObject.h" namespace cc { namespace gfx { diff --git a/native/cocos/renderer/gfx-wgpu/WGPUUtils.h b/native/cocos/renderer/gfx-wgpu/WGPUUtils.h index eb3e7839a36..a593e062802 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUUtils.h +++ b/native/cocos/renderer/gfx-wgpu/WGPUUtils.h @@ -168,6 +168,7 @@ static WGPUTextureSampleType textureSampleTypeTrait(Format format) { return WGPUTextureSampleType::WGPUTextureSampleType_Depth; default: printf("unsupport texture sample type yet, github@hana-alice to fix."); + return WGPUTextureSampleType::WGPUTextureSampleType_Undefined; } } @@ -525,6 +526,7 @@ static WGPUVertexFormat toWGPUVertexFormat(Format format) { return WGPUVertexFormat_Sint32x4; default: printf("usvf %d\n", format); + return WGPUVertexFormat_Undefined; } }