-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.c
57 lines (45 loc) · 1.54 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#define WGPU_INLINE
#define WGPU_FUNC
#include "./../../ffi/wgpu-remote.h"
#include <stdio.h>
int main() {
WGPUInfrastructure infra = wgpu_client_new();
WGPUClient *client = infra.client;
if (!client || infra.error) {
printf("Cannot initialize WGPU client: %s\n", infra.error);
return 1;
}
WGPUGlobal* server = wgpu_server_new();
if (!server) {
printf("Cannot initialize WGPU client: %s\n", server);
return 1;
}
WGPUAdapterId adapterId = 0;
{
WGPUAdapterId ids[10];
int count = wgpu_client_make_adapter_ids(client, ids, 10);
WGPURequestAdapterOptions options = {
.power_preference = WGPUPowerPreference_LowPower,
};
char index = wgpu_server_instance_request_adapter(server, &options, ids, count);
if (index < 0) {
printf("No available GPU adapters!\n");
return 2;
}
wgpu_client_kill_adapter_ids(client, ids, index);
wgpu_client_kill_adapter_ids(client, ids+index+1, count-index-1);
adapterId = ids[index];
}
//TODO: do something meaningful
if (adapterId) {
//wgpu_server_destroy_adapter()
wgpu_client_kill_adapter_ids(client, &adapterId, 1);
}
wgpu_server_delete(server);
wgpu_client_delete(client);
printf("Done\n");
return 0;
}