Skip to content

Commit 7fe0206

Browse files
GPUTestFramework: Added WebGPU device attachment for Emscripten
1 parent b5345ea commit 7fe0206

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Platforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ elseif(PLATFORM_APPLE)
3333
elseif(PLATFORM_WEB)
3434
add_subdirectory(Emscripten)
3535
add_library(Diligent-TargetPlatform ALIAS Diligent-EmscriptenPlatform)
36+
target_compile_options(Diligent-EmscriptenPlatform PUBLIC "SHELL: -s DISABLE_EXCEPTION_CATCHING=0'")
3637
target_link_options(Diligent-EmscriptenPlatform PUBLIC "SHELL: -s DISABLE_EXCEPTION_CATCHING=0'")
3738
else()
3839
message(FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first")

Tests/GPUTestFramework/src/GPUTestingEnvironment.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959

6060
#if WEBGPU_SUPPORTED
6161
# include "EngineFactoryWebGPU.h"
62+
# if PLATFORM_WEB
63+
# include <webgpu/webgpu.h>
64+
# endif
6265
#endif
6366

6467
#if ARCHIVER_SUPPORTED
@@ -469,7 +472,13 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
469472
EngineWebGPUCreateInfo EngineCI{};
470473
EngineCI.Features = EnvCI.Features;
471474
ppContexts.resize((std::max)(size_t{1}, ContextCI.size()) + NumDeferredCtx);
475+
# if PLATFORM_WEB
476+
WGPUDevice wgpuDevice = emscripten_webgpu_get_device();
477+
WGPUInstance wgpuInstance = wgpuCreateInstance(nullptr);
478+
pFactoryWGPU->AttachToWebGPUDevice(wgpuInstance, nullptr, wgpuDevice, EngineCI, &m_pDevice, ppContexts.data());
479+
# else
472480
pFactoryWGPU->CreateDeviceAndContextsWebGPU(EngineCI, &m_pDevice, ppContexts.data());
481+
# endif
473482
}
474483
#endif
475484
break;

0 commit comments

Comments
 (0)