From 609d85c390f1f24e37747121643854a0be2a4e30 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:14:49 +0800 Subject: [PATCH 1/6] Fix some warnings of gfx-webgpu. --- native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.h | 4 ++-- native/cocos/renderer/gfx-wgpu/WGPUSampler.h | 2 +- native/cocos/renderer/gfx-wgpu/WGPUUtils.h | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) 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/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; } } From c670c5ab58548b50b987a3a0ff65e76e4b7eb289 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:15:57 +0800 Subject: [PATCH 2/6] Move gfx-webgpu compilation to another yml --- .../workflows/native-compile-platforms.yml | 30 --------- .github/workflows/native-compile-webgpu.yml | 64 +++++++++++++++++++ 2 files changed, 64 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/native-compile-webgpu.yml 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..5a7ba7383d2 --- /dev/null +++ b/.github/workflows/native-compile-webgpu.yml @@ -0,0 +1,64 @@ +name: Compile WebGPU + +on: + push: + 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_mac: + 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!" From d5e7691060f722de4aa4ec330f1301a3377fe359 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:22:08 +0800 Subject: [PATCH 3/6] Update CMakeLists.txt --- native/cocos/renderer/gfx-wgpu/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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}) From fbf7cb65c87d0f7cacf018046a931d2163d5e377 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:37:22 +0800 Subject: [PATCH 4/6] Update webgpu yml --- .github/workflows/native-compile-webgpu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/native-compile-webgpu.yml b/.github/workflows/native-compile-webgpu.yml index 5a7ba7383d2..3d8caed7b55 100644 --- a/.github/workflows/native-compile-webgpu.yml +++ b/.github/workflows/native-compile-webgpu.yml @@ -17,7 +17,7 @@ concurrency: cancel-in-progress: true jobs: - compile_wgpu_mac: + compile_wgpu: name: "Emscripten" runs-on: ubuntu-latest steps: @@ -61,4 +61,4 @@ jobs: 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!" + echo "============== Compile WGPU by ems on Ubuntu Done! ==============" From bb7e2444e67ffc5d2cbe2d3a158b913edf726a0d Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:41:51 +0800 Subject: [PATCH 5/6] Fix a mistake in native-compile-webgpu.yml --- .github/workflows/native-compile-webgpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native-compile-webgpu.yml b/.github/workflows/native-compile-webgpu.yml index 3d8caed7b55..8ba473b42e3 100644 --- a/.github/workflows/native-compile-webgpu.yml +++ b/.github/workflows/native-compile-webgpu.yml @@ -1,7 +1,7 @@ name: Compile WebGPU on: - push: + pull_request: paths: - 'native/external-config.json' - 'native/cocos/base/**' From 90ed955f02f36c13519d540aa62c44a3fbc276b3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Sep 2023 17:44:20 +0800 Subject: [PATCH 6/6] Remove unused `#pragma once` for WGPUEMSImpl.cpp --- native/cocos/renderer/gfx-wgpu/WGPUEMSImpl.cpp | 1 - 1 file changed, 1 deletion(-) 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