From 20f70533c0aebf214bc8db9045d84b6b69323381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 5 Feb 2023 15:03:48 +0100 Subject: [PATCH] Fix wasm ci (#391) * Update wasm-build.yml * Set embed_rendererbackends with wasm * wasm fixes * Fix CI * Update wasm-build.yml * More wasm fixes * Final fixes --- .github/workflows/wasm-build.yml | 8 ++------ README.md | 1 + include/Nazara/Audio/OpenALLibrary.hpp | 2 +- src/Nazara/Renderer/Renderer.cpp | 26 +++++++++++--------------- xmake.lua | 2 +- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/wasm-build.yml b/.github/workflows/wasm-build.yml index 4aff48f7d..bcc543715 100644 --- a/.github/workflows/wasm-build.yml +++ b/.github/workflows/wasm-build.yml @@ -59,7 +59,7 @@ jobs: - name: Setup emscripten uses: mymindstorm/setup-emsdk@v11 with: - version: 1.38.40 + version: 3.1.31 actions-cache-folder: emsdk-cache-${{ matrix.mode }}-${{ matrix.kind }} # Cache xmake dependencies @@ -71,16 +71,12 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake config --plat=wasm --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --ccache=n --assimp=n --ffmpeg=n --shadernodes=n --tests=y --yes + run: xmake config --plat=wasm --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --ccache=n --assimp=n --embed_rendererbackends=y --embed_plugins=y --link_openal=y --ffmpeg=n --shadernodes=n --tests=y --yes # Build the engine - name: Build Nazara run: xmake --yes - # Setup installation configuration - - name: Configure xmake for installation - run: xmake config --plat=wasm --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --ccache=n --assimp=n --ffmpeg=n --shadernodes=n --tests=y --yes - # Install the result files - name: Install Nazara run: xmake install -vo package diff --git a/README.md b/README.md index 65df5019b..f65fccf25 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Windows | [![Windows build status](https://github.com/NazaraEngine/NazaraEngine/ MSYS2 (MinGW64) | [![Windows build status](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/msys2-build.yml/badge.svg)](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/msys2-build.yml) Linux | [![Linux build status](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/linux-build.yml/badge.svg)](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/linux-build.yml) macOS | [![macOS build status](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/macos-build.yml/badge.svg)](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/macos-build.yml) +Emscripten | [![Emscripten build status](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/wasm-build.yml/badge.svg)](https://github.com/NazaraEngine/NazaraEngine/actions/workflows/wasm-build.yml) # Nazara Engine diff --git a/include/Nazara/Audio/OpenALLibrary.hpp b/include/Nazara/Audio/OpenALLibrary.hpp index 42a85607a..465fa626f 100644 --- a/include/Nazara/Audio/OpenALLibrary.hpp +++ b/include/Nazara/Audio/OpenALLibrary.hpp @@ -50,8 +50,8 @@ namespace Nz std::vector ParseDevices(const char* deviceString); DynLib m_library; - bool m_isLoaded; bool m_hasCaptureSupport; + bool m_isLoaded; }; } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 030b95ae9..7ffd78185 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -17,16 +17,17 @@ #include #ifdef NAZARA_RENDERER_EMBEDDEDBACKENDS + #include + +#ifndef NAZARA_PLATFORM_WEB #include #endif -#include - -#ifdef NAZARA_PLATFORM_WEB -#include #endif +#include + #ifdef NAZARA_COMPILER_MSVC #define NazaraRendererPrefix "" #else @@ -81,7 +82,6 @@ namespace Nz void Renderer::LoadBackend(const Config& config) { -#ifndef NAZARA_PLATFORM_WEB constexpr std::array rendererPaths = { NazaraRendererPrefix "NazaraDirect3DRenderer" NazaraRendererDebugSuffix, // Direct3D NazaraRendererPrefix "NazaraMantleRenderer" NazaraRendererDebugSuffix, // Mantle @@ -128,7 +128,10 @@ namespace Nz }; RegisterImpl(RenderAPI::OpenGL, [] { return 50; }, [] { return std::make_unique(); }); +#ifndef NAZARA_PLATFORM_WEB RegisterImpl(RenderAPI::Vulkan, [] { return 100; }, [] { return std::make_unique(); }); +#endif + #else auto RegisterImpl = [&](RenderAPI api, auto ComputeScore) { @@ -148,7 +151,10 @@ namespace Nz }; RegisterImpl(RenderAPI::OpenGL, [] { return 50; }); +#ifndef NAZARA_PLATFORM_WEB RegisterImpl(RenderAPI::Vulkan, [] { return 100; }); +#endif + #endif std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; }); @@ -206,16 +212,6 @@ namespace Nz m_rendererLib = std::move(chosenLib); #endif -#else - std::unique_ptr impl = std::make_unique(); - if (!impl || !impl->Prepare({})) - { - NazaraError("Failed to create renderer implementation"); - } - - m_rendererImpl = std::move(impl); -#endif - NazaraDebug("Using " + m_rendererImpl->QueryAPIString() + " as renderer"); } diff --git a/xmake.lua b/xmake.lua index 18a369280..672f2e9ec 100644 --- a/xmake.lua +++ b/xmake.lua @@ -189,7 +189,7 @@ NazaraModules = modules includes("xmake/**.lua") option("compile_shaders", { description = "Compile nzsl shaders into an includable binary version", default = true }) -option("embed_rendererbackends", { description = "Embed renderer backend code into NazaraRenderer instead of loading them dynamically", default = false }) +option("embed_rendererbackends", { description = "Embed renderer backend code into NazaraRenderer instead of loading them dynamically", default = is_plat("wasm") or false }) option("embed_resources", { description = "Turn builtin resources into includable headers", default = true }) option("embed_plugins", { description = "Embed enabled plugins code as static libraries", default = is_plat("wasm") or false }) option("link_openal", { description = "Link OpenAL in the executable instead of dynamically loading it", default = is_plat("wasm") or false })