diff --git a/src/gpu/webgpu/SDL_gpu_webgpu.c b/src/gpu/webgpu/SDL_gpu_webgpu.c index 7baa16987e..18aa43a3ff 100644 --- a/src/gpu/webgpu/SDL_gpu_webgpu.c +++ b/src/gpu/webgpu/SDL_gpu_webgpu.c @@ -17,6 +17,10 @@ #ifdef SDL_GPU_WEBGPU +#ifdef __EMSCRIPTEN__ +#include +#endif + #include "../SDL_sysgpu.h" #include "webgpu.h" @@ -5931,6 +5935,17 @@ static SDL_GPUDevice *WEBGPU_CreateDevice(bool debugMode, bool preferLowPower, S WebGPURenderer *renderer; SDL_GPUDevice *result; +#ifdef __EMSCRIPTEN__ + if (!emscripten_has_asyncify()) { + if (debugMode) { + SDL_assert_release(!"SDL was not linked with Asyncify! The SDLGPU WebGPU backend requires Asyncify."); + } + + SDL_SetError("SDL was not linked with Asyncify! The SDLGPU WebGPU backend requires Asyncify."); + return NULL; + } +#endif + Sint64 bindGroupsExpireAfter = SDL_GetNumberProperty(props, SDL_PROP_GPU_DEVICE_CREATE_WEBGPU_BINDGROUP_EXPIRE_AFTER_N_SUBMITS, DEFAULT_BINDGROUP_EXPIRY); Sint64 pseudoMapThreshold = SDL_GetNumberProperty(props, SDL_PROP_GPU_DEVICE_CREATE_WEBGPU_PSEUDOMAP_BUFFERS_SMALLER_THAN, DEFAULT_PSEUDOMAP_SIZE_THRESHOLD);