mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-11-30 16:48:41 +01:00
gpu: Make WebGPU device creation fail if Asyncify isn't linked & add Asyncify to requirements (#16853)
This commit is contained in:
+20
-10
@@ -276,20 +276,30 @@
|
||||
* WebGPU support is complicated and rapidly updating, so there's no exact
|
||||
* list. Generally speaking, if you're using a modern browser you can use
|
||||
* WebGPU.
|
||||
*
|
||||
* The WebGPU backend requires Asyncify if built with Emscripten.
|
||||
* It also requires these WebGPU features to run:
|
||||
*
|
||||
* The backend requires these WebGPU features to run: - `BGRA8UnormStorage` -
|
||||
* `CoreFeaturesAndLimits` - `Depth32FloatStencil8` - `DepthClipControl` -
|
||||
* `Float32Filterable` - `IndirectFirstInstance` - `RG11B10UfloatRenderable`
|
||||
* - `CoreFeaturesAndLimits`
|
||||
* - `Depth32FloatStencil8`
|
||||
* - `DepthClipControl`
|
||||
* - `Float32Filterable`
|
||||
* - `IndirectFirstInstance`
|
||||
* - `RG11B10UfloatRenderable`
|
||||
*
|
||||
* The backend also optionally supports some features. These features are not
|
||||
* required for the backend to run, but they are required for specific SDLGPU
|
||||
* functionality: - `Float32Blendable` Required for blending Float32 textures.
|
||||
* The backend will safely disable blending if this is unsupported. -
|
||||
* `TextureCompressionASTC` - `TextureCompressionASTCSliced3D` Required for
|
||||
* ASTC texture format support. - `TextureCompressionBC` -
|
||||
* `TextureCompressionBCSliced3D` Required for BC texture format support -
|
||||
* `TextureFormatsTier1` - `TextureFormatsTier2` Required for a lot of stuff,
|
||||
* mostly related to texture sampling & access. It's too much to list here.
|
||||
* functionality:
|
||||
*
|
||||
* - `BGRA8UnormStorage`: Required for BGRA8Unorm storage textures.
|
||||
* - `Float32Blendable`: Required for blending Float32 textures. The backend
|
||||
* will safely disable blending if this is unsupported.
|
||||
* - `TextureCompressionASTC` & `TextureCompressionASTCSliced3D`: Required
|
||||
* for ASTC support.
|
||||
* - `TextureCompressionBC` & `TextureCompressionBCSliced3D`: Required for
|
||||
* BC texture format support
|
||||
* - `TextureFormatsTier1` & `TextureFormatsTier2`: Required for a lot of
|
||||
* stuff, mostly related to texture sampling & access.
|
||||
*
|
||||
* Both all required and optional features will be requested automatically
|
||||
* during device creation. If debug mode is enabled, any unsupported features
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
#ifdef SDL_GPU_WEBGPU
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "emscripten.h"
|
||||
#endif
|
||||
|
||||
#include "../SDL_sysgpu.h"
|
||||
#include "webgpu.h"
|
||||
|
||||
@@ -5937,6 +5941,17 @@ static SDL_GPUDevice *WEBGPU_CreateDevice(bool debugMode, bool preferLowPower, S
|
||||
bool getAdapterSucceeded = false;
|
||||
bool getDeviceSucceeded = false;
|
||||
|
||||
#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
|
||||
|
||||
renderer = SDL_calloc(1, sizeof(*renderer));
|
||||
|
||||
if (renderer == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user