Skip to content

Commit d0ab752

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

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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)