diff --git a/dawn/webgpu.cppm b/dawn/webgpu.cppm new file mode 100644 index 0000000..1ebeb66 --- /dev/null +++ b/dawn/webgpu.cppm @@ -0,0 +1,2 @@ +#define WEBGPU_CPP_MODULE +#include "webgpu.hpp" diff --git a/dawn/webgpu.hpp b/dawn/webgpu.hpp index edd1a0e..1c4295b 100644 --- a/dawn/webgpu.hpp +++ b/dawn/webgpu.hpp @@ -34,6 +34,16 @@ #pragma once +#ifdef WEBGPU_CPP_MODULE +#define EXPORT export +#else +#define EXPORT +#endif + +#ifdef WEBGPU_CPP_MODULE +module; +#endif + #include #include @@ -46,10 +56,14 @@ #include #endif +#ifdef WEBGPU_CPP_MODULE +export module webgpu; +#endif + /** * A namespace providing a more C++ idiomatic API to WebGPU. */ -namespace wgpu { +EXPORT namespace wgpu { struct DefaultFlag {}; constexpr DefaultFlag Default; @@ -1919,7 +1933,7 @@ END Instance createInstance(const InstanceDescriptor& descriptor); -#ifdef WEBGPU_CPP_IMPLEMENTATION +#if defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) Instance createInstance(const InstanceDescriptor& descriptor) { return wgpuCreateInstance(&descriptor); @@ -4078,12 +4092,13 @@ Device Adapter::requestDevice(const DeviceDescriptor& descriptor) { return device; } -#endif // WEBGPU_CPP_IMPLEMENTATION +#endif // defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) #undef HANDLE #undef DESCRIPTOR #undef ENUM #undef ENUM_ENTRY #undef END +#undef EXPORT } // namespace wgpu diff --git a/dawn/webgpu.template.hpp b/dawn/webgpu.template.hpp index 73b6890..3cc2288 100644 --- a/dawn/webgpu.template.hpp +++ b/dawn/webgpu.template.hpp @@ -34,6 +34,16 @@ #pragma once +#ifdef WEBGPU_CPP_MODULE +#define EXPORT export +#else +#define EXPORT +#endif + +#ifdef WEBGPU_CPP_MODULE +module; +#endif + #include #include @@ -46,10 +56,14 @@ #include #endif +#ifdef WEBGPU_CPP_MODULE +export module webgpu; +#endif + /** * A namespace providing a more C++ idiomatic API to WebGPU. */ -namespace wgpu { +EXPORT namespace wgpu { struct DefaultFlag {}; constexpr DefaultFlag Default; @@ -167,7 +181,7 @@ wgpuDevicePopErrorScope Instance createInstance(const InstanceDescriptor& descriptor); -#ifdef WEBGPU_CPP_IMPLEMENTATION +#if defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) Instance createInstance(const InstanceDescriptor& descriptor) { return wgpuCreateInstance(&descriptor); @@ -227,12 +241,13 @@ Device Adapter::requestDevice(const DeviceDescriptor& descriptor) { return device; } -#endif // WEBGPU_CPP_IMPLEMENTATION +#endif // defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) #undef HANDLE #undef DESCRIPTOR #undef ENUM #undef ENUM_ENTRY #undef END +#undef EXPORT } // namespace wgpu diff --git a/emscripten/webgpu.cppm b/emscripten/webgpu.cppm new file mode 100644 index 0000000..1ebeb66 --- /dev/null +++ b/emscripten/webgpu.cppm @@ -0,0 +1,2 @@ +#define WEBGPU_CPP_MODULE +#include "webgpu.hpp" diff --git a/wgpu-native/webgpu.cppm b/wgpu-native/webgpu.cppm new file mode 100644 index 0000000..1ebeb66 --- /dev/null +++ b/wgpu-native/webgpu.cppm @@ -0,0 +1,2 @@ +#define WEBGPU_CPP_MODULE +#include "webgpu.hpp" diff --git a/wgpu-native/webgpu.hpp b/wgpu-native/webgpu.hpp index c631a21..cf15629 100644 --- a/wgpu-native/webgpu.hpp +++ b/wgpu-native/webgpu.hpp @@ -34,6 +34,16 @@ #pragma once +#ifdef WEBGPU_CPP_MODULE +#define EXPORT export +#else +#define EXPORT +#endif + +#ifdef WEBGPU_CPP_MODULE +module; +#endif + #include #include @@ -47,10 +57,14 @@ #include #endif +#ifdef WEBGPU_CPP_MODULE +export module webgpu; +#endif + /** * A namespace providing a more C++ idiomatic API to WebGPU. */ -namespace wgpu { +EXPORT namespace wgpu { struct DefaultFlag {}; constexpr DefaultFlag Default; @@ -1398,7 +1412,7 @@ END Instance createInstance(const InstanceDescriptor& descriptor); -#ifdef WEBGPU_CPP_IMPLEMENTATION +#if defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) Instance createInstance(const InstanceDescriptor& descriptor) { return wgpuCreateInstance(&descriptor); @@ -2826,12 +2840,13 @@ Device Adapter::requestDevice(const DeviceDescriptor& descriptor) { return device; } -#endif // WEBGPU_CPP_IMPLEMENTATION +#endif // defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) #undef HANDLE #undef DESCRIPTOR #undef ENUM #undef ENUM_ENTRY #undef END +#undef EXPORT } // namespace wgpu diff --git a/wgpu-native/webgpu.template.hpp b/wgpu-native/webgpu.template.hpp index 4467fc7..148dbdf 100644 --- a/wgpu-native/webgpu.template.hpp +++ b/wgpu-native/webgpu.template.hpp @@ -34,6 +34,16 @@ #pragma once +#ifdef WEBGPU_CPP_MODULE +#define EXPORT export +#else +#define EXPORT +#endif + +#ifdef WEBGPU_CPP_MODULE +module; +#endif + #include #include @@ -47,10 +57,14 @@ #include #endif +#ifdef WEBGPU_CPP_MODULE +export module webgpu; +#endif + /** * A namespace providing a more C++ idiomatic API to WebGPU. */ -namespace wgpu { +EXPORT namespace wgpu { struct DefaultFlag {}; constexpr DefaultFlag Default; @@ -167,7 +181,7 @@ END Instance createInstance(const InstanceDescriptor& descriptor); -#ifdef WEBGPU_CPP_IMPLEMENTATION +#if defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) Instance createInstance(const InstanceDescriptor& descriptor) { return wgpuCreateInstance(&descriptor); @@ -227,12 +241,13 @@ Device Adapter::requestDevice(const DeviceDescriptor& descriptor) { return device; } -#endif // WEBGPU_CPP_IMPLEMENTATION +#endif // defined(WEBGPU_CPP_IMPLEMENTATION) || defined(WEBGPU_CPP_MODULE) #undef HANDLE #undef DESCRIPTOR #undef ENUM #undef ENUM_ENTRY #undef END +#undef EXPORT } // namespace wgpu