Skip to content

Commit 054ea16

Browse files
committed
Add test for wgpu_device_supports_feature().
1 parent 2a04824 commit 054ea16

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/wgpu_device_supports_feature.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// flags: -sEXIT_RUNTIME=0
2+
3+
#include "lib_webgpu.h"
4+
#include <assert.h>
5+
#include <stdio.h>
6+
7+
void ObtainedWebGpuDevice(WGpuDevice device, void *userData)
8+
{
9+
assert(wgpu_device_supports_feature(device, WGPU_FEATURE_SHADER_F16));
10+
assert(wgpu_device_supports_feature(device, WGPU_FEATURE_DEPTH_CLIP_CONTROL));
11+
assert(!wgpu_device_supports_feature(device, WGPU_FEATURE_DEPTH32FLOAT_STENCIL8)); // We did not ask for this feature.
12+
13+
EM_ASM(window.close());
14+
}
15+
16+
void ObtainedWebGpuAdapter(WGpuAdapter adapter, void *userData)
17+
{
18+
WGpuDeviceDescriptor desc = {};
19+
desc.requiredFeatures = WGPU_FEATURE_SHADER_F16 | WGPU_FEATURE_DEPTH_CLIP_CONTROL; // Ask for two features. This test assumes that the test device can handle this.
20+
wgpu_adapter_request_device_async(adapter, &desc, ObtainedWebGpuDevice, 0);
21+
}
22+
23+
int main()
24+
{
25+
navigator_gpu_request_adapter_async_simple(ObtainedWebGpuAdapter);
26+
}

0 commit comments

Comments
 (0)