Skip to content

Commit 1c4cae4

Browse files
WebGPU: ignore blocking synchronization calls on the Web
1 parent 1e6c1f7 commit 1c4cae4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Graphics/GraphicsEngineWebGPU/src/DeviceContextWebGPUImpl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,11 @@ void DeviceContextWebGPUImpl::DeviceWaitForFence(IFence* pFence, Uint64 Value)
12671267
void DeviceContextWebGPUImpl::WaitForIdle()
12681268
{
12691269
Flush();
1270+
#if PLATFORM_EMSCRIPTEN
1271+
LOG_ERROR_MESSAGE("IDeviceContext::WaitForIdle() is not supported on the Web. Use non-blocking synchronization methods.");
1272+
#else
12701273
m_pFence->Wait(m_FenceValue);
1274+
#endif
12711275
}
12721276

12731277
void DeviceContextWebGPUImpl::BeginQuery(IQuery* pQuery)

Graphics/GraphicsEngineWebGPU/src/FenceWebGPUImpl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ void FenceWebGPUImpl::Signal(Uint64 Value)
8686

8787
void FenceWebGPUImpl::Wait(Uint64 Value)
8888
{
89+
#if PLATFORM_EMSCRIPTEN
90+
LOG_ERROR_MESSAGE("IFence::Wait() is not supported on the Web. Use non-blocking synchronization methods.");
91+
#else
8992
while (GetCompletedValue() < Value)
9093
m_pDevice->DeviceTick();
94+
#endif
9195
}
9296

9397
void FenceWebGPUImpl::AppendSyncPoints(const std::vector<RefCntAutoPtr<SyncPointWebGPUImpl>>& SyncPoints, Uint64 Value)

Graphics/GraphicsEngineWebGPU/src/RenderDeviceWebGPUImpl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ RenderDeviceWebGPUImpl::~RenderDeviceWebGPUImpl()
126126
#if !DILIGENT_NO_GLSLANG
127127
GLSLangUtils::FinalizeGlslang();
128128
#endif
129+
#if !PLATFORM_EMSCRIPTEN
129130
IdleGPU();
131+
#endif
130132
}
131133

132134
void RenderDeviceWebGPUImpl::CreateBuffer(const BufferDesc& BuffDesc,
@@ -293,9 +295,13 @@ WGPUDevice RenderDeviceWebGPUImpl::GetWebGPUDevice() const
293295

294296
void RenderDeviceWebGPUImpl::IdleGPU()
295297
{
298+
#if PLATFORM_EMSCRIPTEN
299+
LOG_ERROR_MESSAGE("IRenderDevice::IdleGPU() is not supported on the Web. Use non-blocking synchronization methods.");
300+
#else
296301
VERIFY_EXPR(m_wpImmediateContexts.size() == 1);
297302
if (auto pImmediateCtx = m_wpImmediateContexts[0].Lock())
298303
pImmediateCtx->WaitForIdle();
304+
#endif
299305
}
300306

301307
void RenderDeviceWebGPUImpl::CreateTextureFromWebGPUTexture(WGPUTexture wgpuTexture,

0 commit comments

Comments
 (0)