-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_webgpu_c.cpp
More file actions
60 lines (49 loc) · 1.64 KB
/
hello_webgpu_c.cpp
File metadata and controls
60 lines (49 loc) · 1.64 KB
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
58
59
60
// Include WebGPU header
// #include <webgpu/webgpu.h>
#if ( WEBGPU_PROVIDER == WEBGPU_WGPU_NATIVE )
#include <webgpu-headers/webgpu.h>
#else
#include <webgpu/webgpu.h>
#endif
#include <iostream>
// AFTER ALL INCLUDES
#if 0 && (WEBGPU_PROVIDER == WEBGPU_WGPU_NATIVE )
// native-static-libs: advapi32.lib ws2_32.lib userenv.lib shell32.lib msvcrt.lib
#pragma comment(lib,"WS2_32")
#pragma comment(lib,"ntdll")
#pragma comment(lib,"userenv")
#pragma comment(lib,"advapi32")
#pragma comment(lib,"shell32")
#pragma comment(lib,"msvcrt")
#pragma comment(lib,"Opengl32")
#pragma comment(lib,"d3dcompiler")
#endif
int main (int, char**) {
#if ( WEBGPU_PROVIDER == WEBGPU_WGPU_NATIVE )
std::cout << "WEBGPU_WGPU_NATIVE\n";
#elif ( WEBGPU_PROVIDER == WEBGPU_DAWN )
std::cout << "WEBGPU_DAWN\n";
#else
std::cout << "UNKNOWN WEBGPU IMPL\n";
#endif
// We create a descriptor
WGPUInstanceDescriptor desc = {};
desc.nextInChain = nullptr;
// We create the instance using this descriptor
#ifdef WEBGPU_BACKEND_EMSCRIPTEN
WGPUInstance instance = wgpuCreateInstance(nullptr);
#else // WEBGPU_BACKEND_EMSCRIPTEN
WGPUInstance instance = wgpuCreateInstance(&desc);
#endif // WEBGPU_BACKEND_EMSCRIPTEN
// We can check whether there is actually an instance created
if (!instance) {
std::cerr << "Could not initialize WebGPU!" << std::endl;
return 1;
}
// Display the object (WGPUInstance is a simple pointer, it may be
// copied around without worrying about its size).
std::cout << "WGPU instance: " << instance << std::endl;
// We clean up the WebGPU instance
wgpuInstanceRelease(instance);
return 0;
}