webgpu/dawn/include/dawn/webgpu_cpp.h
1#ifdef __EMSCRIPTEN__
2#error "Do not include this header. Emscripten already provides headers needed for WebGPU."
3#endif
4#ifndef WEBGPU_CPP_H_
5#define WEBGPU_CPP_H_
6
7#include "dawn/webgpu.h"
8#include "dawn/webgpu_cpp_chained_struct.h"
9#include "dawn/EnumClassBitmasks.h"
10#include <cmath>
11#include <cstddef>
12#include <cstdint>
13#include <functional>
14
15namespace wgpu {
16
17 static constexpr uint32_t kArrayLayerCountUndefined = WGPU_ARRAY_LAYER_COUNT_UNDEFINED;
18 static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED;
19 static constexpr uint32_t kLimitU32Undefined = WGPU_LIMIT_U32_UNDEFINED;
20 static constexpr uint64_t kLimitU64Undefined = WGPU_LIMIT_U64_UNDEFINED;
21 static constexpr uint32_t kMipLevelCountUndefined = WGPU_MIP_LEVEL_COUNT_UNDEFINED;
22 static constexpr size_t kWholeMapSize = WGPU_WHOLE_MAP_SIZE;
23 static constexpr uint64_t kWholeSize = WGPU_WHOLE_SIZE;
24
25 enum class AdapterType : uint32_t {
26 DiscreteGPU = 0x00000000,
27 IntegratedGPU = 0x00000001,
28 CPU = 0x00000002,
29 Unknown = 0x00000003,
30 };
31
32 enum class AddressMode : uint32_t {
33 Repeat = 0x00000000,
34 MirrorRepeat = 0x00000001,
35 ClampToEdge = 0x00000002,
36 };
37
38 enum class AlphaMode : uint32_t {
39 Premultiplied = 0x00000000,
40 Unpremultiplied = 0x00000001,
41 Opaque = 0x00000002,
42 };
43
44 enum class BackendType : uint32_t {
45 Undefined = 0x00000000,
46 Null = 0x00000001,
47 WebGPU = 0x00000002,
48 D3D11 = 0x00000003,
49 D3D12 = 0x00000004,
50 Metal = 0x00000005,
51 Vulkan = 0x00000006,
52 OpenGL = 0x00000007,
53 OpenGLES = 0x00000008,
54 };
55
56 enum class BlendFactor : uint32_t {
57 Zero = 0x00000000,
58 One = 0x00000001,
59 Src = 0x00000002,
60 OneMinusSrc = 0x00000003,
61 SrcAlpha = 0x00000004,
62 OneMinusSrcAlpha = 0x00000005,
63 Dst = 0x00000006,
64 OneMinusDst = 0x00000007,
65 DstAlpha = 0x00000008,
66 OneMinusDstAlpha = 0x00000009,
67 SrcAlphaSaturated = 0x0000000A,
68 Constant = 0x0000000B,
69 OneMinusConstant = 0x0000000C,
70 Src1 = 0x0000000D,
71 OneMinusSrc1 = 0x0000000E,
72 Src1Alpha = 0x0000000F,
73 OneMinusSrc1Alpha = 0x00000010,
74 };
75
76 enum class BlendOperation : uint32_t {
77 Add = 0x00000000,
78 Subtract = 0x00000001,
79 ReverseSubtract = 0x00000002,
80 Min = 0x00000003,
81 Max = 0x00000004,
82 };
83
84 enum class BufferBindingType : uint32_t {
85 Undefined = 0x00000000,
86 Uniform = 0x00000001,
87 Storage = 0x00000002,
88 ReadOnlyStorage = 0x00000003,
89 };
90
91 enum class BufferMapAsyncStatus : uint32_t {
92 Success = 0x00000000,
93 ValidationError = 0x00000001,
94 Unknown = 0x00000002,
95 DeviceLost = 0x00000003,
96 DestroyedBeforeCallback = 0x00000004,
97 UnmappedBeforeCallback = 0x00000005,
98 MappingAlreadyPending = 0x00000006,
99 OffsetOutOfRange = 0x00000007,
100 SizeOutOfRange = 0x00000008,
101 };
102
103 enum class BufferMapState : uint32_t {
104 Unmapped = 0x00000000,
105 Pending = 0x00000001,
106 Mapped = 0x00000002,
107 };
108
109 enum class CompareFunction : uint32_t {
110 Undefined = 0x00000000,
111 Never = 0x00000001,
112 Less = 0x00000002,
113 LessEqual = 0x00000003,
114 Greater = 0x00000004,
115 GreaterEqual = 0x00000005,
116 Equal = 0x00000006,
117 NotEqual = 0x00000007,
118 Always = 0x00000008,
119 };
120
121 enum class CompilationInfoRequestStatus : uint32_t {
122 Success = 0x00000000,
123 Error = 0x00000001,
124 DeviceLost = 0x00000002,
125 Unknown = 0x00000003,
126 };
127
128 enum class CompilationMessageType : uint32_t {
129 Error = 0x00000000,
130 Warning = 0x00000001,
131 Info = 0x00000002,
132 };
133
134 enum class ComputePassTimestampLocation : uint32_t {
135 Beginning = 0x00000000,
136 End = 0x00000001,
137 };
138
139 enum class CreatePipelineAsyncStatus : uint32_t {
140 Success = 0x00000000,
141 ValidationError = 0x00000001,
142 InternalError = 0x00000002,
143 DeviceLost = 0x00000003,
144 DeviceDestroyed = 0x00000004,
145 Unknown = 0x00000005,
146 };
147
148 enum class CullMode : uint32_t {
149 None = 0x00000000,
150 Front = 0x00000001,
151 Back = 0x00000002,
152 };
153
154 enum class DeviceLostReason : uint32_t {
155 Undefined = 0x00000000,
156 Destroyed = 0x00000001,
157 };
158
159 enum class ErrorFilter : uint32_t {
160 Validation = 0x00000000,
161 OutOfMemory = 0x00000001,
162 Internal = 0x00000002,
163 };
164
165 enum class ErrorType : uint32_t {
166 NoError = 0x00000000,
167 Validation = 0x00000001,
168 OutOfMemory = 0x00000002,
169 Internal = 0x00000003,
170 Unknown = 0x00000004,
171 DeviceLost = 0x00000005,
172 };
173
174 enum class ExternalTextureRotation : uint32_t {
175 Rotate0Degrees = 0x00000000,
176 Rotate90Degrees = 0x00000001,
177 Rotate180Degrees = 0x00000002,
178 Rotate270Degrees = 0x00000003,
179 };
180
181 enum class FeatureName : uint32_t {
182 Undefined = 0x00000000,
183 DepthClipControl = 0x00000001,
184 Depth32FloatStencil8 = 0x00000002,
185 TimestampQuery = 0x00000003,
186 PipelineStatisticsQuery = 0x00000004,
187 TextureCompressionBC = 0x00000005,
188 TextureCompressionETC2 = 0x00000006,
189 TextureCompressionASTC = 0x00000007,
190 IndirectFirstInstance = 0x00000008,
191 ShaderF16 = 0x00000009,
192 RG11B10UfloatRenderable = 0x0000000A,
193 BGRA8UnormStorage = 0x0000000B,
194 Float32Filterable = 0x0000000C,
195 DawnInternalUsages = 0x000003EA,
196 DawnMultiPlanarFormats = 0x000003EB,
197 DawnNative = 0x000003EC,
198 ChromiumExperimentalDp4a = 0x000003ED,
199 TimestampQueryInsidePasses = 0x000003EE,
200 ImplicitDeviceSynchronization = 0x000003EF,
201 SurfaceCapabilities = 0x000003F0,
202 TransientAttachments = 0x000003F1,
203 MSAARenderToSingleSampled = 0x000003F2,
204 DualSourceBlending = 0x000003F3,
205 D3D11MultithreadProtected = 0x000003F4,
206 ANGLETextureSharing = 0x000003F5,
207 SharedTextureMemoryVkDedicatedAllocation = 0x0000044C,
208 SharedTextureMemoryAHardwareBuffer = 0x0000044D,
209 SharedTextureMemoryDmaBuf = 0x0000044E,
210 SharedTextureMemoryOpaqueFD = 0x0000044F,
211 SharedTextureMemoryZirconHandle = 0x00000450,
212 SharedTextureMemoryDXGISharedHandle = 0x00000451,
213 SharedTextureMemoryD3D11Texture2D = 0x00000452,
214 SharedTextureMemoryIOSurface = 0x00000453,
215 SharedTextureMemoryEGLImage = 0x00000454,
216 SharedFenceVkSemaphoreOpaqueFD = 0x000004B0,
217 SharedFenceVkSemaphoreSyncFD = 0x000004B1,
218 SharedFenceVkSemaphoreZirconHandle = 0x000004B2,
219 SharedFenceDXGISharedHandle = 0x000004B3,
220 SharedFenceMTLSharedEvent = 0x000004B4,
221 };
222
223 enum class FilterMode : uint32_t {
224 Nearest = 0x00000000,
225 Linear = 0x00000001,
226 };
227
228 enum class FrontFace : uint32_t {
229 CCW = 0x00000000,
230 CW = 0x00000001,
231 };
232
233 enum class IndexFormat : uint32_t {
234 Undefined = 0x00000000,
235 Uint16 = 0x00000001,
236 Uint32 = 0x00000002,
237 };
238
239 enum class LoadOp : uint32_t {
240 Undefined = 0x00000000,
241 Clear = 0x00000001,
242 Load = 0x00000002,
243 };
244
245 enum class LoggingType : uint32_t {
246 Verbose = 0x00000000,
247 Info = 0x00000001,
248 Warning = 0x00000002,
249 Error = 0x00000003,
250 };
251
252 enum class MipmapFilterMode : uint32_t {
253 Nearest = 0x00000000,
254 Linear = 0x00000001,
255 };
256
257 enum class PipelineStatisticName : uint32_t {
258 VertexShaderInvocations = 0x00000000,
259 ClipperInvocations = 0x00000001,
260 ClipperPrimitivesOut = 0x00000002,
261 FragmentShaderInvocations = 0x00000003,
262 ComputeShaderInvocations = 0x00000004,
263 };
264
265 enum class PowerPreference : uint32_t {
266 Undefined = 0x00000000,
267 LowPower = 0x00000001,
268 HighPerformance = 0x00000002,
269 };
270
271 enum class PresentMode : uint32_t {
272 Immediate = 0x00000000,
273 Mailbox = 0x00000001,
274 Fifo = 0x00000002,
275 };
276
277 enum class PrimitiveTopology : uint32_t {
278 PointList = 0x00000000,
279 LineList = 0x00000001,
280 LineStrip = 0x00000002,
281 TriangleList = 0x00000003,
282 TriangleStrip = 0x00000004,
283 };
284
285 enum class QueryType : uint32_t {
286 Occlusion = 0x00000000,
287 PipelineStatistics = 0x00000001,
288 Timestamp = 0x00000002,
289 };
290
291 enum class QueueWorkDoneStatus : uint32_t {
292 Success = 0x00000000,
293 Error = 0x00000001,
294 Unknown = 0x00000002,
295 DeviceLost = 0x00000003,
296 };
297
298 enum class RenderPassTimestampLocation : uint32_t {
299 Beginning = 0x00000000,
300 End = 0x00000001,
301 };
302
303 enum class RequestAdapterStatus : uint32_t {
304 Success = 0x00000000,
305 Unavailable = 0x00000001,
306 Error = 0x00000002,
307 Unknown = 0x00000003,
308 };
309
310 enum class RequestDeviceStatus : uint32_t {
311 Success = 0x00000000,
312 Error = 0x00000001,
313 Unknown = 0x00000002,
314 };
315
316 enum class SType : uint32_t {
317 Invalid = 0x00000000,
318 SurfaceDescriptorFromMetalLayer = 0x00000001,
319 SurfaceDescriptorFromWindowsHWND = 0x00000002,
320 SurfaceDescriptorFromXlibWindow = 0x00000003,
321 SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004,
322 ShaderModuleSPIRVDescriptor = 0x00000005,
323 ShaderModuleWGSLDescriptor = 0x00000006,
324 PrimitiveDepthClipControl = 0x00000007,
325 SurfaceDescriptorFromWaylandSurface = 0x00000008,
326 SurfaceDescriptorFromAndroidNativeWindow = 0x00000009,
327 SurfaceDescriptorFromWindowsCoreWindow = 0x0000000B,
328 ExternalTextureBindingEntry = 0x0000000C,
329 ExternalTextureBindingLayout = 0x0000000D,
330 SurfaceDescriptorFromWindowsSwapChainPanel = 0x0000000E,
331 RenderPassDescriptorMaxDrawCount = 0x0000000F,
332 DawnTextureInternalUsageDescriptor = 0x000003E8,
333 DawnEncoderInternalUsageDescriptor = 0x000003EB,
334 DawnInstanceDescriptor = 0x000003EC,
335 DawnCacheDeviceDescriptor = 0x000003ED,
336 DawnAdapterPropertiesPowerPreference = 0x000003EE,
337 DawnBufferDescriptorErrorInfoFromWireClient = 0x000003EF,
338 DawnTogglesDescriptor = 0x000003F0,
339 DawnShaderModuleSPIRVOptionsDescriptor = 0x000003F1,
340 RequestAdapterOptionsLUID = 0x000003F2,
341 RequestAdapterOptionsGetGLProc = 0x000003F3,
342 DawnMultisampleStateRenderToSingleSampled = 0x000003F4,
343 DawnRenderPassColorAttachmentRenderToSingleSampled = 0x000003F5,
344 SharedTextureMemoryVkImageDescriptor = 0x0000044C,
345 SharedTextureMemoryVkDedicatedAllocationDescriptor = 0x0000044D,
346 SharedTextureMemoryAHardwareBufferDescriptor = 0x0000044E,
347 SharedTextureMemoryDmaBufDescriptor = 0x0000044F,
348 SharedTextureMemoryOpaqueFDDescriptor = 0x00000450,
349 SharedTextureMemoryZirconHandleDescriptor = 0x00000451,
350 SharedTextureMemoryDXGISharedHandleDescriptor = 0x00000452,
351 SharedTextureMemoryD3D11Texture2DDescriptor = 0x00000453,
352 SharedTextureMemoryIOSurfaceDescriptor = 0x00000454,
353 SharedTextureMemoryEGLImageDescriptor = 0x00000455,
354 SharedTextureMemoryInitializedBeginState = 0x000004B0,
355 SharedTextureMemoryInitializedEndState = 0x000004B1,
356 SharedTextureMemoryVkImageLayoutBeginState = 0x000004B2,
357 SharedTextureMemoryVkImageLayoutEndState = 0x000004B3,
358 SharedFenceVkSemaphoreOpaqueFDDescriptor = 0x000004B4,
359 SharedFenceVkSemaphoreOpaqueFDExportInfo = 0x000004B5,
360 SharedFenceVkSemaphoreSyncFDDescriptor = 0x000004B6,
361 SharedFenceVkSemaphoreSyncFDExportInfo = 0x000004B7,
362 SharedFenceVkSemaphoreZirconHandleDescriptor = 0x000004B8,
363 SharedFenceVkSemaphoreZirconHandleExportInfo = 0x000004B9,
364 SharedFenceDXGISharedHandleDescriptor = 0x000004BA,
365 SharedFenceDXGISharedHandleExportInfo = 0x000004BB,
366 SharedFenceMTLSharedEventDescriptor = 0x000004BC,
367 SharedFenceMTLSharedEventExportInfo = 0x000004BD,
368 };
369
370 enum class SamplerBindingType : uint32_t {
371 Undefined = 0x00000000,
372 Filtering = 0x00000001,
373 NonFiltering = 0x00000002,
374 Comparison = 0x00000003,
375 };
376
377 enum class SharedFenceType : uint32_t {
378 Undefined = 0x00000000,
379 VkSemaphoreOpaqueFD = 0x00000001,
380 VkSemaphoreSyncFD = 0x00000002,
381 VkSemaphoreZirconHandle = 0x00000003,
382 DXGISharedHandle = 0x00000004,
383 MTLSharedEvent = 0x00000005,
384 };
385
386 enum class StencilOperation : uint32_t {
387 Keep = 0x00000000,
388 Zero = 0x00000001,
389 Replace = 0x00000002,
390 Invert = 0x00000003,
391 IncrementClamp = 0x00000004,
392 DecrementClamp = 0x00000005,
393 IncrementWrap = 0x00000006,
394 DecrementWrap = 0x00000007,
395 };
396
397 enum class StorageTextureAccess : uint32_t {
398 Undefined = 0x00000000,
399 WriteOnly = 0x00000001,
400 };
401
402 enum class StoreOp : uint32_t {
403 Undefined = 0x00000000,
404 Store = 0x00000001,
405 Discard = 0x00000002,
406 };
407
408 enum class TextureAspect : uint32_t {
409 All = 0x00000000,
410 StencilOnly = 0x00000001,
411 DepthOnly = 0x00000002,
412 Plane0Only = 0x00000003,
413 Plane1Only = 0x00000004,
414 };
415
416 enum class TextureDimension : uint32_t {
417 e1D = 0x00000000,
418 e2D = 0x00000001,
419 e3D = 0x00000002,
420 };
421
422 enum class TextureFormat : uint32_t {
423 Undefined = 0x00000000,
424 R8Unorm = 0x00000001,
425 R8Snorm = 0x00000002,
426 R8Uint = 0x00000003,
427 R8Sint = 0x00000004,
428 R16Uint = 0x00000005,
429 R16Sint = 0x00000006,
430 R16Float = 0x00000007,
431 RG8Unorm = 0x00000008,
432 RG8Snorm = 0x00000009,
433 RG8Uint = 0x0000000A,
434 RG8Sint = 0x0000000B,
435 R32Float = 0x0000000C,
436 R32Uint = 0x0000000D,
437 R32Sint = 0x0000000E,
438 RG16Uint = 0x0000000F,
439 RG16Sint = 0x00000010,
440 RG16Float = 0x00000011,
441 RGBA8Unorm = 0x00000012,
442 RGBA8UnormSrgb = 0x00000013,
443 RGBA8Snorm = 0x00000014,
444 RGBA8Uint = 0x00000015,
445 RGBA8Sint = 0x00000016,
446 BGRA8Unorm = 0x00000017,
447 BGRA8UnormSrgb = 0x00000018,
448 RGB10A2Unorm = 0x00000019,
449 RG11B10Ufloat = 0x0000001A,
450 RGB9E5Ufloat = 0x0000001B,
451 RG32Float = 0x0000001C,
452 RG32Uint = 0x0000001D,
453 RG32Sint = 0x0000001E,
454 RGBA16Uint = 0x0000001F,
455 RGBA16Sint = 0x00000020,
456 RGBA16Float = 0x00000021,
457 RGBA32Float = 0x00000022,
458 RGBA32Uint = 0x00000023,
459 RGBA32Sint = 0x00000024,
460 Stencil8 = 0x00000025,
461 Depth16Unorm = 0x00000026,
462 Depth24Plus = 0x00000027,
463 Depth24PlusStencil8 = 0x00000028,
464 Depth32Float = 0x00000029,
465 Depth32FloatStencil8 = 0x0000002A,
466 BC1RGBAUnorm = 0x0000002B,
467 BC1RGBAUnormSrgb = 0x0000002C,
468 BC2RGBAUnorm = 0x0000002D,
469 BC2RGBAUnormSrgb = 0x0000002E,
470 BC3RGBAUnorm = 0x0000002F,
471 BC3RGBAUnormSrgb = 0x00000030,
472 BC4RUnorm = 0x00000031,
473 BC4RSnorm = 0x00000032,
474 BC5RGUnorm = 0x00000033,
475 BC5RGSnorm = 0x00000034,
476 BC6HRGBUfloat = 0x00000035,
477 BC6HRGBFloat = 0x00000036,
478 BC7RGBAUnorm = 0x00000037,
479 BC7RGBAUnormSrgb = 0x00000038,
480 ETC2RGB8Unorm = 0x00000039,
481 ETC2RGB8UnormSrgb = 0x0000003A,
482 ETC2RGB8A1Unorm = 0x0000003B,
483 ETC2RGB8A1UnormSrgb = 0x0000003C,
484 ETC2RGBA8Unorm = 0x0000003D,
485 ETC2RGBA8UnormSrgb = 0x0000003E,
486 EACR11Unorm = 0x0000003F,
487 EACR11Snorm = 0x00000040,
488 EACRG11Unorm = 0x00000041,
489 EACRG11Snorm = 0x00000042,
490 ASTC4x4Unorm = 0x00000043,
491 ASTC4x4UnormSrgb = 0x00000044,
492 ASTC5x4Unorm = 0x00000045,
493 ASTC5x4UnormSrgb = 0x00000046,
494 ASTC5x5Unorm = 0x00000047,
495 ASTC5x5UnormSrgb = 0x00000048,
496 ASTC6x5Unorm = 0x00000049,
497 ASTC6x5UnormSrgb = 0x0000004A,
498 ASTC6x6Unorm = 0x0000004B,
499 ASTC6x6UnormSrgb = 0x0000004C,
500 ASTC8x5Unorm = 0x0000004D,
501 ASTC8x5UnormSrgb = 0x0000004E,
502 ASTC8x6Unorm = 0x0000004F,
503 ASTC8x6UnormSrgb = 0x00000050,
504 ASTC8x8Unorm = 0x00000051,
505 ASTC8x8UnormSrgb = 0x00000052,
506 ASTC10x5Unorm = 0x00000053,
507 ASTC10x5UnormSrgb = 0x00000054,
508 ASTC10x6Unorm = 0x00000055,
509 ASTC10x6UnormSrgb = 0x00000056,
510 ASTC10x8Unorm = 0x00000057,
511 ASTC10x8UnormSrgb = 0x00000058,
512 ASTC10x10Unorm = 0x00000059,
513 ASTC10x10UnormSrgb = 0x0000005A,
514 ASTC12x10Unorm = 0x0000005B,
515 ASTC12x10UnormSrgb = 0x0000005C,
516 ASTC12x12Unorm = 0x0000005D,
517 ASTC12x12UnormSrgb = 0x0000005E,
518 R8BG8Biplanar420Unorm = 0x0000005F,
519 };
520
521 enum class TextureSampleType : uint32_t {
522 Undefined = 0x00000000,
523 Float = 0x00000001,
524 UnfilterableFloat = 0x00000002,
525 Depth = 0x00000003,
526 Sint = 0x00000004,
527 Uint = 0x00000005,
528 };
529
530 enum class TextureViewDimension : uint32_t {
531 Undefined = 0x00000000,
532 e1D = 0x00000001,
533 e2D = 0x00000002,
534 e2DArray = 0x00000003,
535 Cube = 0x00000004,
536 CubeArray = 0x00000005,
537 e3D = 0x00000006,
538 };
539
540 enum class VertexFormat : uint32_t {
541 Undefined = 0x00000000,
542 Uint8x2 = 0x00000001,
543 Uint8x4 = 0x00000002,
544 Sint8x2 = 0x00000003,
545 Sint8x4 = 0x00000004,
546 Unorm8x2 = 0x00000005,
547 Unorm8x4 = 0x00000006,
548 Snorm8x2 = 0x00000007,
549 Snorm8x4 = 0x00000008,
550 Uint16x2 = 0x00000009,
551 Uint16x4 = 0x0000000A,
552 Sint16x2 = 0x0000000B,
553 Sint16x4 = 0x0000000C,
554 Unorm16x2 = 0x0000000D,
555 Unorm16x4 = 0x0000000E,
556 Snorm16x2 = 0x0000000F,
557 Snorm16x4 = 0x00000010,
558 Float16x2 = 0x00000011,
559 Float16x4 = 0x00000012,
560 Float32 = 0x00000013,
561 Float32x2 = 0x00000014,
562 Float32x3 = 0x00000015,
563 Float32x4 = 0x00000016,
564 Uint32 = 0x00000017,
565 Uint32x2 = 0x00000018,
566 Uint32x3 = 0x00000019,
567 Uint32x4 = 0x0000001A,
568 Sint32 = 0x0000001B,
569 Sint32x2 = 0x0000001C,
570 Sint32x3 = 0x0000001D,
571 Sint32x4 = 0x0000001E,
572 };
573
574 enum class VertexStepMode : uint32_t {
575 Vertex = 0x00000000,
576 Instance = 0x00000001,
577 VertexBufferNotUsed = 0x00000002,
578 };
579
580
581 enum class BufferUsage : uint32_t {
582 None = 0x00000000,
583 MapRead = 0x00000001,
584 MapWrite = 0x00000002,
585 CopySrc = 0x00000004,
586 CopyDst = 0x00000008,
587 Index = 0x00000010,
588 Vertex = 0x00000020,
589 Uniform = 0x00000040,
590 Storage = 0x00000080,
591 Indirect = 0x00000100,
592 QueryResolve = 0x00000200,
593 };
594
595 enum class ColorWriteMask : uint32_t {
596 None = 0x00000000,
597 Red = 0x00000001,
598 Green = 0x00000002,
599 Blue = 0x00000004,
600 Alpha = 0x00000008,
601 All = 0x0000000F,
602 };
603
604 enum class MapMode : uint32_t {
605 None = 0x00000000,
606 Read = 0x00000001,
607 Write = 0x00000002,
608 };
609
610 enum class ShaderStage : uint32_t {
611 None = 0x00000000,
612 Vertex = 0x00000001,
613 Fragment = 0x00000002,
614 Compute = 0x00000004,
615 };
616
617 enum class TextureUsage : uint32_t {
618 None = 0x00000000,
619 CopySrc = 0x00000001,
620 CopyDst = 0x00000002,
621 TextureBinding = 0x00000004,
622 StorageBinding = 0x00000008,
623 RenderAttachment = 0x00000010,
624 TransientAttachment = 0x00000020,
625 };
626
627
628 using BufferMapCallback = WGPUBufferMapCallback;
629 using CompilationInfoCallback = WGPUCompilationInfoCallback;
630 using CreateComputePipelineAsyncCallback = WGPUCreateComputePipelineAsyncCallback;
631 using CreateRenderPipelineAsyncCallback = WGPUCreateRenderPipelineAsyncCallback;
632 using DeviceLostCallback = WGPUDeviceLostCallback;
633 using ErrorCallback = WGPUErrorCallback;
634 using LoggingCallback = WGPULoggingCallback;
635 using Proc = WGPUProc;
636 using QueueWorkDoneCallback = WGPUQueueWorkDoneCallback;
637 using RequestAdapterCallback = WGPURequestAdapterCallback;
638 using RequestDeviceCallback = WGPURequestDeviceCallback;
639
640 class Adapter;
641 class BindGroup;
642 class BindGroupLayout;
643 class Buffer;
644 class CommandBuffer;
645 class CommandEncoder;
646 class ComputePassEncoder;
647 class ComputePipeline;
648 class Device;
649 class ExternalTexture;
650 class Instance;
651 class PipelineLayout;
652 class QuerySet;
653 class Queue;
654 class RenderBundle;
655 class RenderBundleEncoder;
656 class RenderPassEncoder;
657 class RenderPipeline;
658 class Sampler;
659 class ShaderModule;
660 class SharedFence;
661 class SharedTextureMemory;
662 class Surface;
663 class SwapChain;
664 class Texture;
665 class TextureView;
666
667 struct AdapterProperties;
668 struct BindGroupEntry;
669 struct BlendComponent;
670 struct BufferBindingLayout;
671 struct BufferDescriptor;
672 struct Color;
673 struct CommandBufferDescriptor;
674 struct CommandEncoderDescriptor;
675 struct CompilationMessage;
676 struct ComputePassTimestampWrite;
677 struct ConstantEntry;
678 struct CopyTextureForBrowserOptions;
679 struct DawnAdapterPropertiesPowerPreference;
680 struct DawnBufferDescriptorErrorInfoFromWireClient;
681 struct DawnCacheDeviceDescriptor;
682 struct DawnEncoderInternalUsageDescriptor;
683 struct DawnMultisampleStateRenderToSingleSampled;
684 struct DawnRenderPassColorAttachmentRenderToSingleSampled;
685 struct DawnShaderModuleSPIRVOptionsDescriptor;
686 struct DawnTextureInternalUsageDescriptor;
687 struct DawnTogglesDescriptor;
688 struct Extent2D;
689 struct Extent3D;
690 struct ExternalTextureBindingEntry;
691 struct ExternalTextureBindingLayout;
692 struct InstanceDescriptor;
693 struct Limits;
694 struct MultisampleState;
695 struct Origin2D;
696 struct Origin3D;
697 struct PipelineLayoutDescriptor;
698 struct PrimitiveDepthClipControl;
699 struct PrimitiveState;
700 struct QuerySetDescriptor;
701 struct QueueDescriptor;
702 struct RenderBundleDescriptor;
703 struct RenderBundleEncoderDescriptor;
704 struct RenderPassDepthStencilAttachment;
705 struct RenderPassDescriptorMaxDrawCount;
706 struct RenderPassTimestampWrite;
707 struct RequestAdapterOptions;
708 struct SamplerBindingLayout;
709 struct SamplerDescriptor;
710 struct ShaderModuleDescriptor;
711 struct ShaderModuleSPIRVDescriptor;
712 struct ShaderModuleWGSLDescriptor;
713 struct SharedFenceDescriptor;
714 struct SharedFenceDXGISharedHandleDescriptor;
715 struct SharedFenceDXGISharedHandleExportInfo;
716 struct SharedFenceExportInfo;
717 struct SharedFenceMTLSharedEventDescriptor;
718 struct SharedFenceMTLSharedEventExportInfo;
719 struct SharedFenceVkSemaphoreOpaqueFDDescriptor;
720 struct SharedFenceVkSemaphoreOpaqueFDExportInfo;
721 struct SharedFenceVkSemaphoreSyncFDDescriptor;
722 struct SharedFenceVkSemaphoreSyncFDExportInfo;
723 struct SharedFenceVkSemaphoreZirconHandleDescriptor;
724 struct SharedFenceVkSemaphoreZirconHandleExportInfo;
725 struct SharedTextureMemoryAHardwareBufferDescriptor;
726 struct SharedTextureMemoryBeginAccessDescriptor;
727 struct SharedTextureMemoryDescriptor;
728 struct SharedTextureMemoryDmaBufDescriptor;
729 struct SharedTextureMemoryDXGISharedHandleDescriptor;
730 struct SharedTextureMemoryEGLImageDescriptor;
731 struct SharedTextureMemoryEndAccessState;
732 struct SharedTextureMemoryIOSurfaceDescriptor;
733 struct SharedTextureMemoryOpaqueFDDescriptor;
734 struct SharedTextureMemoryVkDedicatedAllocationDescriptor;
735 struct SharedTextureMemoryVkImageLayoutBeginState;
736 struct SharedTextureMemoryVkImageLayoutEndState;
737 struct SharedTextureMemoryZirconHandleDescriptor;
738 struct StencilFaceState;
739 struct StorageTextureBindingLayout;
740 struct SurfaceDescriptor;
741 struct SurfaceDescriptorFromAndroidNativeWindow;
742 struct SurfaceDescriptorFromCanvasHTMLSelector;
743 struct SurfaceDescriptorFromMetalLayer;
744 struct SurfaceDescriptorFromWaylandSurface;
745 struct SurfaceDescriptorFromWindowsCoreWindow;
746 struct SurfaceDescriptorFromWindowsHWND;
747 struct SurfaceDescriptorFromWindowsSwapChainPanel;
748 struct SurfaceDescriptorFromXlibWindow;
749 struct SwapChainDescriptor;
750 struct TextureBindingLayout;
751 struct TextureDataLayout;
752 struct TextureViewDescriptor;
753 struct VertexAttribute;
754 struct BindGroupDescriptor;
755 struct BindGroupLayoutEntry;
756 struct BlendState;
757 struct CompilationInfo;
758 struct ComputePassDescriptor;
759 struct DepthStencilState;
760 struct ExternalTextureDescriptor;
761 struct ImageCopyBuffer;
762 struct ImageCopyExternalTexture;
763 struct ImageCopyTexture;
764 struct ProgrammableStageDescriptor;
765 struct RenderPassColorAttachment;
766 struct RequiredLimits;
767 struct SharedTextureMemoryProperties;
768 struct SharedTextureMemoryVkImageDescriptor;
769 struct SupportedLimits;
770 struct TextureDescriptor;
771 struct VertexBufferLayout;
772 struct BindGroupLayoutDescriptor;
773 struct ColorTargetState;
774 struct ComputePipelineDescriptor;
775 struct DeviceDescriptor;
776 struct RenderPassDescriptor;
777 struct VertexState;
778 struct FragmentState;
779 struct RenderPipelineDescriptor;
780
781
782 // Special class for booleans in order to allow implicit conversions.
783 class Bool {
784 public:
785 constexpr Bool() = default;
786 // NOLINTNEXTLINE(runtime/explicit) allow implicit construction
787 constexpr Bool(bool value) : mValue(static_cast<WGPUBool>(value)) {}
788 // NOLINTNEXTLINE(runtime/explicit) allow implicit construction
789 Bool(WGPUBool value): mValue(value) {}
790
791 constexpr operator bool() const { return static_cast<bool>(mValue); }
792
793 private:
794 friend struct std::hash<Bool>;
795 // Default to false.
796 WGPUBool mValue = static_cast<WGPUBool>(false);
797 };
798
799 template<typename Derived, typename CType>
800 class ObjectBase {
801 public:
802 ObjectBase() = default;
803 ObjectBase(CType handle): mHandle(handle) {
804 if (mHandle) Derived::WGPUReference(mHandle);
805 }
806 ~ObjectBase() {
807 if (mHandle) Derived::WGPURelease(mHandle);
808 }
809
810 ObjectBase(ObjectBase const& other)
811 : ObjectBase(other.Get()) {
812 }
813 Derived& operator=(ObjectBase const& other) {
814 if (&other != this) {
815 if (mHandle) Derived::WGPURelease(mHandle);
816 mHandle = other.mHandle;
817 if (mHandle) Derived::WGPUReference(mHandle);
818 }
819
820 return static_cast<Derived&>(*this);
821 }
822
823 ObjectBase(ObjectBase&& other) {
824 mHandle = other.mHandle;
825 other.mHandle = 0;
826 }
827 Derived& operator=(ObjectBase&& other) {
828 if (&other != this) {
829 if (mHandle) Derived::WGPURelease(mHandle);
830 mHandle = other.mHandle;
831 other.mHandle = 0;
832 }
833
834 return static_cast<Derived&>(*this);
835 }
836
837 ObjectBase(std::nullptr_t) {}
838 Derived& operator=(std::nullptr_t) {
839 if (mHandle != nullptr) {
840 Derived::WGPURelease(mHandle);
841 mHandle = nullptr;
842 }
843 return static_cast<Derived&>(*this);
844 }
845
846 bool operator==(std::nullptr_t) const {
847 return mHandle == nullptr;
848 }
849 bool operator!=(std::nullptr_t) const {
850 return mHandle != nullptr;
851 }
852
853 explicit operator bool() const {
854 return mHandle != nullptr;
855 }
856 CType Get() const {
857 return mHandle;
858 }
859 // TODO(dawn:1639) Deprecate Release after uses have been removed.
860 CType Release() {
861 CType result = mHandle;
862 mHandle = 0;
863 return result;
864 }
865 CType MoveToCHandle() {
866 CType result = mHandle;
867 mHandle = 0;
868 return result;
869 }
870 static Derived Acquire(CType handle) {
871 Derived result;
872 result.mHandle = handle;
873 return result;
874 }
875
876 protected:
877 CType mHandle = nullptr;
878 };
879
880
881
882 class Adapter : public ObjectBase<Adapter, WGPUAdapter> {
883 public:
884 using ObjectBase::ObjectBase;
885 using ObjectBase::operator=;
886
887 Device CreateDevice(DeviceDescriptor const * descriptor = nullptr) const;
888 size_t EnumerateFeatures(FeatureName * features) const;
889 Instance GetInstance() const;
890 Bool GetLimits(SupportedLimits * limits) const;
891 void GetProperties(AdapterProperties * properties) const;
892 Bool HasFeature(FeatureName feature) const;
893 void RequestDevice(DeviceDescriptor const * descriptor, RequestDeviceCallback callback, void * userdata) const;
894
895 private:
896 friend ObjectBase<Adapter, WGPUAdapter>;
897 static void WGPUReference(WGPUAdapter handle);
898 static void WGPURelease(WGPUAdapter handle);
899 };
900
901 class BindGroup : public ObjectBase<BindGroup, WGPUBindGroup> {
902 public:
903 using ObjectBase::ObjectBase;
904 using ObjectBase::operator=;
905
906 void SetLabel(char const * label) const;
907
908 private:
909 friend ObjectBase<BindGroup, WGPUBindGroup>;
910 static void WGPUReference(WGPUBindGroup handle);
911 static void WGPURelease(WGPUBindGroup handle);
912 };
913
914 class BindGroupLayout : public ObjectBase<BindGroupLayout, WGPUBindGroupLayout> {
915 public:
916 using ObjectBase::ObjectBase;
917 using ObjectBase::operator=;
918
919 void SetLabel(char const * label) const;
920
921 private:
922 friend ObjectBase<BindGroupLayout, WGPUBindGroupLayout>;
923 static void WGPUReference(WGPUBindGroupLayout handle);
924 static void WGPURelease(WGPUBindGroupLayout handle);
925 };
926
927 class Buffer : public ObjectBase<Buffer, WGPUBuffer> {
928 public:
929 using ObjectBase::ObjectBase;
930 using ObjectBase::operator=;
931
932 void Destroy() const;
933 void const * GetConstMappedRange(size_t offset = 0, size_t size = WGPU_WHOLE_MAP_SIZE) const;
934 BufferMapState GetMapState() const;
935 void * GetMappedRange(size_t offset = 0, size_t size = WGPU_WHOLE_MAP_SIZE) const;
936 uint64_t GetSize() const;
937 BufferUsage GetUsage() const;
938 void MapAsync(MapMode mode, size_t offset, size_t size, BufferMapCallback callback, void * userdata) const;
939 void SetLabel(char const * label) const;
940 void Unmap() const;
941
942 private:
943 friend ObjectBase<Buffer, WGPUBuffer>;
944 static void WGPUReference(WGPUBuffer handle);
945 static void WGPURelease(WGPUBuffer handle);
946 };
947
948 class CommandBuffer : public ObjectBase<CommandBuffer, WGPUCommandBuffer> {
949 public:
950 using ObjectBase::ObjectBase;
951 using ObjectBase::operator=;
952
953 void SetLabel(char const * label) const;
954
955 private:
956 friend ObjectBase<CommandBuffer, WGPUCommandBuffer>;
957 static void WGPUReference(WGPUCommandBuffer handle);
958 static void WGPURelease(WGPUCommandBuffer handle);
959 };
960
961 class CommandEncoder : public ObjectBase<CommandEncoder, WGPUCommandEncoder> {
962 public:
963 using ObjectBase::ObjectBase;
964 using ObjectBase::operator=;
965
966 ComputePassEncoder BeginComputePass(ComputePassDescriptor const * descriptor = nullptr) const;
967 RenderPassEncoder BeginRenderPass(RenderPassDescriptor const * descriptor) const;
968 void ClearBuffer(Buffer const& buffer, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE) const;
969 void CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const;
970 void CopyBufferToTexture(ImageCopyBuffer const * source, ImageCopyTexture const * destination, Extent3D const * copySize) const;
971 void CopyTextureToBuffer(ImageCopyTexture const * source, ImageCopyBuffer const * destination, Extent3D const * copySize) const;
972 void CopyTextureToTexture(ImageCopyTexture const * source, ImageCopyTexture const * destination, Extent3D const * copySize) const;
973 CommandBuffer Finish(CommandBufferDescriptor const * descriptor = nullptr) const;
974 void InjectValidationError(char const * message) const;
975 void InsertDebugMarker(char const * markerLabel) const;
976 void PopDebugGroup() const;
977 void PushDebugGroup(char const * groupLabel) const;
978 void ResolveQuerySet(QuerySet const& querySet, uint32_t firstQuery, uint32_t queryCount, Buffer const& destination, uint64_t destinationOffset) const;
979 void SetLabel(char const * label) const;
980 void WriteBuffer(Buffer const& buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size) const;
981 void WriteTimestamp(QuerySet const& querySet, uint32_t queryIndex) const;
982
983 private:
984 friend ObjectBase<CommandEncoder, WGPUCommandEncoder>;
985 static void WGPUReference(WGPUCommandEncoder handle);
986 static void WGPURelease(WGPUCommandEncoder handle);
987 };
988
989 class ComputePassEncoder : public ObjectBase<ComputePassEncoder, WGPUComputePassEncoder> {
990 public:
991 using ObjectBase::ObjectBase;
992 using ObjectBase::operator=;
993
994 void DispatchWorkgroups(uint32_t workgroupCountX, uint32_t workgroupCountY = 1, uint32_t workgroupCountZ = 1) const;
995 void DispatchWorkgroupsIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const;
996 void End() const;
997 void InsertDebugMarker(char const * markerLabel) const;
998 void PopDebugGroup() const;
999 void PushDebugGroup(char const * groupLabel) const;
1000 void SetBindGroup(uint32_t groupIndex, BindGroup const& group, size_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const;
1001 void SetLabel(char const * label) const;
1002 void SetPipeline(ComputePipeline const& pipeline) const;
1003 void WriteTimestamp(QuerySet const& querySet, uint32_t queryIndex) const;
1004
1005 private:
1006 friend ObjectBase<ComputePassEncoder, WGPUComputePassEncoder>;
1007 static void WGPUReference(WGPUComputePassEncoder handle);
1008 static void WGPURelease(WGPUComputePassEncoder handle);
1009 };
1010
1011 class ComputePipeline : public ObjectBase<ComputePipeline, WGPUComputePipeline> {
1012 public:
1013 using ObjectBase::ObjectBase;
1014 using ObjectBase::operator=;
1015
1016 BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const;
1017 void SetLabel(char const * label) const;
1018
1019 private:
1020 friend ObjectBase<ComputePipeline, WGPUComputePipeline>;
1021 static void WGPUReference(WGPUComputePipeline handle);
1022 static void WGPURelease(WGPUComputePipeline handle);
1023 };
1024
1025 class Device : public ObjectBase<Device, WGPUDevice> {
1026 public:
1027 using ObjectBase::ObjectBase;
1028 using ObjectBase::operator=;
1029
1030 BindGroup CreateBindGroup(BindGroupDescriptor const * descriptor) const;
1031 BindGroupLayout CreateBindGroupLayout(BindGroupLayoutDescriptor const * descriptor) const;
1032 Buffer CreateBuffer(BufferDescriptor const * descriptor) const;
1033 CommandEncoder CreateCommandEncoder(CommandEncoderDescriptor const * descriptor = nullptr) const;
1034 ComputePipeline CreateComputePipeline(ComputePipelineDescriptor const * descriptor) const;
1035 void CreateComputePipelineAsync(ComputePipelineDescriptor const * descriptor, CreateComputePipelineAsyncCallback callback, void * userdata) const;
1036 Buffer CreateErrorBuffer(BufferDescriptor const * descriptor) const;
1037 ExternalTexture CreateErrorExternalTexture() const;
1038 ShaderModule CreateErrorShaderModule(ShaderModuleDescriptor const * descriptor, char const * errorMessage) const;
1039 Texture CreateErrorTexture(TextureDescriptor const * descriptor) const;
1040 ExternalTexture CreateExternalTexture(ExternalTextureDescriptor const * externalTextureDescriptor) const;
1041 PipelineLayout CreatePipelineLayout(PipelineLayoutDescriptor const * descriptor) const;
1042 QuerySet CreateQuerySet(QuerySetDescriptor const * descriptor) const;
1043 RenderBundleEncoder CreateRenderBundleEncoder(RenderBundleEncoderDescriptor const * descriptor) const;
1044 RenderPipeline CreateRenderPipeline(RenderPipelineDescriptor const * descriptor) const;
1045 void CreateRenderPipelineAsync(RenderPipelineDescriptor const * descriptor, CreateRenderPipelineAsyncCallback callback, void * userdata) const;
1046 Sampler CreateSampler(SamplerDescriptor const * descriptor = nullptr) const;
1047 ShaderModule CreateShaderModule(ShaderModuleDescriptor const * descriptor) const;
1048 SwapChain CreateSwapChain(Surface const& surface, SwapChainDescriptor const * descriptor) const;
1049 Texture CreateTexture(TextureDescriptor const * descriptor) const;
1050 void Destroy() const;
1051 size_t EnumerateFeatures(FeatureName * features) const;
1052 void ForceLoss(DeviceLostReason type, char const * message) const;
1053 Adapter GetAdapter() const;
1054 Bool GetLimits(SupportedLimits * limits) const;
1055 Queue GetQueue() const;
1056 TextureUsage GetSupportedSurfaceUsage(Surface const& surface) const;
1057 Bool HasFeature(FeatureName feature) const;
1058 SharedFence ImportSharedFence(SharedFenceDescriptor const * descriptor) const;
1059 SharedTextureMemory ImportSharedTextureMemory(SharedTextureMemoryDescriptor const * descriptor) const;
1060 void InjectError(ErrorType type, char const * message) const;
1061 void PopErrorScope(ErrorCallback callback, void * userdata) const;
1062 void PushErrorScope(ErrorFilter filter) const;
1063 void SetDeviceLostCallback(DeviceLostCallback callback, void * userdata) const;
1064 void SetLabel(char const * label) const;
1065 void SetLoggingCallback(LoggingCallback callback, void * userdata) const;
1066 void SetUncapturedErrorCallback(ErrorCallback callback, void * userdata) const;
1067 void Tick() const;
1068 void ValidateTextureDescriptor(TextureDescriptor const * descriptor) const;
1069
1070 private:
1071 friend ObjectBase<Device, WGPUDevice>;
1072 static void WGPUReference(WGPUDevice handle);
1073 static void WGPURelease(WGPUDevice handle);
1074 };
1075
1076 class ExternalTexture : public ObjectBase<ExternalTexture, WGPUExternalTexture> {
1077 public:
1078 using ObjectBase::ObjectBase;
1079 using ObjectBase::operator=;
1080
1081 void Destroy() const;
1082 void Expire() const;
1083 void Refresh() const;
1084 void SetLabel(char const * label) const;
1085
1086 private:
1087 friend ObjectBase<ExternalTexture, WGPUExternalTexture>;
1088 static void WGPUReference(WGPUExternalTexture handle);
1089 static void WGPURelease(WGPUExternalTexture handle);
1090 };
1091
1092 class Instance : public ObjectBase<Instance, WGPUInstance> {
1093 public:
1094 using ObjectBase::ObjectBase;
1095 using ObjectBase::operator=;
1096
1097 Surface CreateSurface(SurfaceDescriptor const * descriptor) const;
1098 void ProcessEvents() const;
1099 void RequestAdapter(RequestAdapterOptions const * options, RequestAdapterCallback callback, void * userdata) const;
1100
1101 private:
1102 friend ObjectBase<Instance, WGPUInstance>;
1103 static void WGPUReference(WGPUInstance handle);
1104 static void WGPURelease(WGPUInstance handle);
1105 };
1106
1107 class PipelineLayout : public ObjectBase<PipelineLayout, WGPUPipelineLayout> {
1108 public:
1109 using ObjectBase::ObjectBase;
1110 using ObjectBase::operator=;
1111
1112 void SetLabel(char const * label) const;
1113
1114 private:
1115 friend ObjectBase<PipelineLayout, WGPUPipelineLayout>;
1116 static void WGPUReference(WGPUPipelineLayout handle);
1117 static void WGPURelease(WGPUPipelineLayout handle);
1118 };
1119
1120 class QuerySet : public ObjectBase<QuerySet, WGPUQuerySet> {
1121 public:
1122 using ObjectBase::ObjectBase;
1123 using ObjectBase::operator=;
1124
1125 void Destroy() const;
1126 uint32_t GetCount() const;
1127 QueryType GetType() const;
1128 void SetLabel(char const * label) const;
1129
1130 private:
1131 friend ObjectBase<QuerySet, WGPUQuerySet>;
1132 static void WGPUReference(WGPUQuerySet handle);
1133 static void WGPURelease(WGPUQuerySet handle);
1134 };
1135
1136 class Queue : public ObjectBase<Queue, WGPUQueue> {
1137 public:
1138 using ObjectBase::ObjectBase;
1139 using ObjectBase::operator=;
1140
1141 void CopyExternalTextureForBrowser(ImageCopyExternalTexture const * source, ImageCopyTexture const * destination, Extent3D const * copySize, CopyTextureForBrowserOptions const * options) const;
1142 void CopyTextureForBrowser(ImageCopyTexture const * source, ImageCopyTexture const * destination, Extent3D const * copySize, CopyTextureForBrowserOptions const * options) const;
1143 void OnSubmittedWorkDone(uint64_t signalValue, QueueWorkDoneCallback callback, void * userdata) const;
1144 void SetLabel(char const * label) const;
1145 void Submit(size_t commandCount, CommandBuffer const * commands) const;
1146 void WriteBuffer(Buffer const& buffer, uint64_t bufferOffset, void const * data, size_t size) const;
1147 void WriteTexture(ImageCopyTexture const * destination, void const * data, size_t dataSize, TextureDataLayout const * dataLayout, Extent3D const * writeSize) const;
1148
1149 private:
1150 friend ObjectBase<Queue, WGPUQueue>;
1151 static void WGPUReference(WGPUQueue handle);
1152 static void WGPURelease(WGPUQueue handle);
1153 };
1154
1155 class RenderBundle : public ObjectBase<RenderBundle, WGPURenderBundle> {
1156 public:
1157 using ObjectBase::ObjectBase;
1158 using ObjectBase::operator=;
1159
1160 void SetLabel(char const * label) const;
1161
1162 private:
1163 friend ObjectBase<RenderBundle, WGPURenderBundle>;
1164 static void WGPUReference(WGPURenderBundle handle);
1165 static void WGPURelease(WGPURenderBundle handle);
1166 };
1167
1168 class RenderBundleEncoder : public ObjectBase<RenderBundleEncoder, WGPURenderBundleEncoder> {
1169 public:
1170 using ObjectBase::ObjectBase;
1171 using ObjectBase::operator=;
1172
1173 void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t firstVertex = 0, uint32_t firstInstance = 0) const;
1174 void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t firstIndex = 0, int32_t baseVertex = 0, uint32_t firstInstance = 0) const;
1175 void DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const;
1176 void DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const;
1177 RenderBundle Finish(RenderBundleDescriptor const * descriptor = nullptr) const;
1178 void InsertDebugMarker(char const * markerLabel) const;
1179 void PopDebugGroup() const;
1180 void PushDebugGroup(char const * groupLabel) const;
1181 void SetBindGroup(uint32_t groupIndex, BindGroup const& group, size_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const;
1182 void SetIndexBuffer(Buffer const& buffer, IndexFormat format, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE) const;
1183 void SetLabel(char const * label) const;
1184 void SetPipeline(RenderPipeline const& pipeline) const;
1185 void SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE) const;
1186
1187 private:
1188 friend ObjectBase<RenderBundleEncoder, WGPURenderBundleEncoder>;
1189 static void WGPUReference(WGPURenderBundleEncoder handle);
1190 static void WGPURelease(WGPURenderBundleEncoder handle);
1191 };
1192
1193 class RenderPassEncoder : public ObjectBase<RenderPassEncoder, WGPURenderPassEncoder> {
1194 public:
1195 using ObjectBase::ObjectBase;
1196 using ObjectBase::operator=;
1197
1198 void BeginOcclusionQuery(uint32_t queryIndex) const;
1199 void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t firstVertex = 0, uint32_t firstInstance = 0) const;
1200 void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t firstIndex = 0, int32_t baseVertex = 0, uint32_t firstInstance = 0) const;
1201 void DrawIndexedIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const;
1202 void DrawIndirect(Buffer const& indirectBuffer, uint64_t indirectOffset) const;
1203 void End() const;
1204 void EndOcclusionQuery() const;
1205 void ExecuteBundles(size_t bundleCount, RenderBundle const * bundles) const;
1206 void InsertDebugMarker(char const * markerLabel) const;
1207 void PopDebugGroup() const;
1208 void PushDebugGroup(char const * groupLabel) const;
1209 void SetBindGroup(uint32_t groupIndex, BindGroup const& group, size_t dynamicOffsetCount = 0, uint32_t const * dynamicOffsets = nullptr) const;
1210 void SetBlendConstant(Color const * color) const;
1211 void SetIndexBuffer(Buffer const& buffer, IndexFormat format, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE) const;
1212 void SetLabel(char const * label) const;
1213 void SetPipeline(RenderPipeline const& pipeline) const;
1214 void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) const;
1215 void SetStencilReference(uint32_t reference) const;
1216 void SetVertexBuffer(uint32_t slot, Buffer const& buffer, uint64_t offset = 0, uint64_t size = WGPU_WHOLE_SIZE) const;
1217 void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) const;
1218 void WriteTimestamp(QuerySet const& querySet, uint32_t queryIndex) const;
1219
1220 private:
1221 friend ObjectBase<RenderPassEncoder, WGPURenderPassEncoder>;
1222 static void WGPUReference(WGPURenderPassEncoder handle);
1223 static void WGPURelease(WGPURenderPassEncoder handle);
1224 };
1225
1226 class RenderPipeline : public ObjectBase<RenderPipeline, WGPURenderPipeline> {
1227 public:
1228 using ObjectBase::ObjectBase;
1229 using ObjectBase::operator=;
1230
1231 BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const;
1232 void SetLabel(char const * label) const;
1233
1234 private:
1235 friend ObjectBase<RenderPipeline, WGPURenderPipeline>;
1236 static void WGPUReference(WGPURenderPipeline handle);
1237 static void WGPURelease(WGPURenderPipeline handle);
1238 };
1239
1240 class Sampler : public ObjectBase<Sampler, WGPUSampler> {
1241 public:
1242 using ObjectBase::ObjectBase;
1243 using ObjectBase::operator=;
1244
1245 void SetLabel(char const * label) const;
1246
1247 private:
1248 friend ObjectBase<Sampler, WGPUSampler>;
1249 static void WGPUReference(WGPUSampler handle);
1250 static void WGPURelease(WGPUSampler handle);
1251 };
1252
1253 class ShaderModule : public ObjectBase<ShaderModule, WGPUShaderModule> {
1254 public:
1255 using ObjectBase::ObjectBase;
1256 using ObjectBase::operator=;
1257
1258 void GetCompilationInfo(CompilationInfoCallback callback, void * userdata) const;
1259 void SetLabel(char const * label) const;
1260
1261 private:
1262 friend ObjectBase<ShaderModule, WGPUShaderModule>;
1263 static void WGPUReference(WGPUShaderModule handle);
1264 static void WGPURelease(WGPUShaderModule handle);
1265 };
1266
1267 class SharedFence : public ObjectBase<SharedFence, WGPUSharedFence> {
1268 public:
1269 using ObjectBase::ObjectBase;
1270 using ObjectBase::operator=;
1271
1272 void ExportInfo(SharedFenceExportInfo * info) const;
1273
1274 private:
1275 friend ObjectBase<SharedFence, WGPUSharedFence>;
1276 static void WGPUReference(WGPUSharedFence handle);
1277 static void WGPURelease(WGPUSharedFence handle);
1278 };
1279
1280 class SharedTextureMemory : public ObjectBase<SharedTextureMemory, WGPUSharedTextureMemory> {
1281 public:
1282 using ObjectBase::ObjectBase;
1283 using ObjectBase::operator=;
1284
1285 void BeginAccess(Texture const& texture, SharedTextureMemoryBeginAccessDescriptor const * descriptor) const;
1286 Texture CreateTexture(TextureDescriptor const * descriptor) const;
1287 void EndAccess(Texture const& texture, SharedTextureMemoryEndAccessState * descriptor) const;
1288 void GetProperties(SharedTextureMemoryProperties * properties) const;
1289 void SetLabel(char const * label) const;
1290
1291 private:
1292 friend ObjectBase<SharedTextureMemory, WGPUSharedTextureMemory>;
1293 static void WGPUReference(WGPUSharedTextureMemory handle);
1294 static void WGPURelease(WGPUSharedTextureMemory handle);
1295 };
1296
1297 class Surface : public ObjectBase<Surface, WGPUSurface> {
1298 public:
1299 using ObjectBase::ObjectBase;
1300 using ObjectBase::operator=;
1301
1302
1303 private:
1304 friend ObjectBase<Surface, WGPUSurface>;
1305 static void WGPUReference(WGPUSurface handle);
1306 static void WGPURelease(WGPUSurface handle);
1307 };
1308
1309 class SwapChain : public ObjectBase<SwapChain, WGPUSwapChain> {
1310 public:
1311 using ObjectBase::ObjectBase;
1312 using ObjectBase::operator=;
1313
1314 Texture GetCurrentTexture() const;
1315 TextureView GetCurrentTextureView() const;
1316 void Present() const;
1317
1318 private:
1319 friend ObjectBase<SwapChain, WGPUSwapChain>;
1320 static void WGPUReference(WGPUSwapChain handle);
1321 static void WGPURelease(WGPUSwapChain handle);
1322 };
1323
1324 class Texture : public ObjectBase<Texture, WGPUTexture> {
1325 public:
1326 using ObjectBase::ObjectBase;
1327 using ObjectBase::operator=;
1328
1329 TextureView CreateView(TextureViewDescriptor const * descriptor = nullptr) const;
1330 void Destroy() const;
1331 uint32_t GetDepthOrArrayLayers() const;
1332 TextureDimension GetDimension() const;
1333 TextureFormat GetFormat() const;
1334 uint32_t GetHeight() const;
1335 uint32_t GetMipLevelCount() const;
1336 uint32_t GetSampleCount() const;
1337 TextureUsage GetUsage() const;
1338 uint32_t GetWidth() const;
1339 void SetLabel(char const * label) const;
1340
1341 private:
1342 friend ObjectBase<Texture, WGPUTexture>;
1343 static void WGPUReference(WGPUTexture handle);
1344 static void WGPURelease(WGPUTexture handle);
1345 };
1346
1347 class TextureView : public ObjectBase<TextureView, WGPUTextureView> {
1348 public:
1349 using ObjectBase::ObjectBase;
1350 using ObjectBase::operator=;
1351
1352 void SetLabel(char const * label) const;
1353
1354 private:
1355 friend ObjectBase<TextureView, WGPUTextureView>;
1356 static void WGPUReference(WGPUTextureView handle);
1357 static void WGPURelease(WGPUTextureView handle);
1358 };
1359
1360
1361 Instance CreateInstance(InstanceDescriptor const * descriptor = nullptr);
1362 Proc GetProcAddress(Device device, char const * procName);
1363
1364 struct AdapterProperties {
1365 AdapterProperties() = default;
1366 ~AdapterProperties();
1367 AdapterProperties(const AdapterProperties&) = delete;
1368 AdapterProperties& operator=(const AdapterProperties&) = delete;
1369 AdapterProperties(AdapterProperties&&);
1370 AdapterProperties& operator=(AdapterProperties&&);
1371 ChainedStructOut * nextInChain = nullptr;
1372 uint32_t const vendorID = {};
1373 char const * const vendorName = nullptr;
1374 char const * const architecture = nullptr;
1375 uint32_t const deviceID = {};
1376 char const * const name = nullptr;
1377 char const * const driverDescription = nullptr;
1378 AdapterType const adapterType = {};
1379 BackendType const backendType = {};
1380 Bool const compatibilityMode = false;
1381 };
1382
1383 struct BindGroupEntry {
1384 ChainedStruct const * nextInChain = nullptr;
1385 uint32_t binding;
1386 Buffer buffer;
1387 uint64_t offset = 0;
1388 uint64_t size = WGPU_WHOLE_SIZE;
1389 Sampler sampler;
1390 TextureView textureView;
1391 };
1392
1393 struct BlendComponent {
1394 BlendOperation operation = BlendOperation::Add;
1395 BlendFactor srcFactor = BlendFactor::One;
1396 BlendFactor dstFactor = BlendFactor::Zero;
1397 };
1398
1399 struct BufferBindingLayout {
1400 ChainedStruct const * nextInChain = nullptr;
1401 BufferBindingType type = BufferBindingType::Undefined;
1402 Bool hasDynamicOffset = false;
1403 uint64_t minBindingSize = 0;
1404 };
1405
1406 struct BufferDescriptor {
1407 ChainedStruct const * nextInChain = nullptr;
1408 char const * label = nullptr;
1409 BufferUsage usage;
1410 uint64_t size;
1411 Bool mappedAtCreation = false;
1412 };
1413
1414 struct Color {
1415 double r;
1416 double g;
1417 double b;
1418 double a;
1419 };
1420
1421 struct CommandBufferDescriptor {
1422 ChainedStruct const * nextInChain = nullptr;
1423 char const * label = nullptr;
1424 };
1425
1426 struct CommandEncoderDescriptor {
1427 ChainedStruct const * nextInChain = nullptr;
1428 char const * label = nullptr;
1429 };
1430
1431 struct CompilationMessage {
1432 ChainedStruct const * nextInChain = nullptr;
1433 char const * message = nullptr;
1434 CompilationMessageType type;
1435 uint64_t lineNum;
1436 uint64_t linePos;
1437 uint64_t offset;
1438 uint64_t length;
1439 uint64_t utf16LinePos;
1440 uint64_t utf16Offset;
1441 uint64_t utf16Length;
1442 };
1443
1444 struct ComputePassTimestampWrite {
1445 QuerySet querySet;
1446 uint32_t queryIndex;
1447 ComputePassTimestampLocation location;
1448 };
1449
1450 struct ConstantEntry {
1451 ChainedStruct const * nextInChain = nullptr;
1452 char const * key;
1453 double value;
1454 };
1455
1456 struct CopyTextureForBrowserOptions {
1457 ChainedStruct const * nextInChain = nullptr;
1458 Bool flipY = false;
1459 Bool needsColorSpaceConversion = false;
1460 AlphaMode srcAlphaMode = AlphaMode::Unpremultiplied;
1461 float const * srcTransferFunctionParameters = nullptr;
1462 float const * conversionMatrix = nullptr;
1463 float const * dstTransferFunctionParameters = nullptr;
1464 AlphaMode dstAlphaMode = AlphaMode::Unpremultiplied;
1465 Bool internalUsage = false;
1466 };
1467
1468 // Can be chained in AdapterProperties
1469 struct DawnAdapterPropertiesPowerPreference : ChainedStructOut {
1470 DawnAdapterPropertiesPowerPreference() {
1471 sType = SType::DawnAdapterPropertiesPowerPreference;
1472 }
1473 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(PowerPreference ));
1474 alignas(kFirstMemberAlignment) PowerPreference powerPreference = PowerPreference::Undefined;
1475 };
1476
1477 // Can be chained in BufferDescriptor
1478 struct DawnBufferDescriptorErrorInfoFromWireClient : ChainedStruct {
1479 DawnBufferDescriptorErrorInfoFromWireClient() {
1480 sType = SType::DawnBufferDescriptorErrorInfoFromWireClient;
1481 }
1482 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1483 alignas(kFirstMemberAlignment) Bool outOfMemory = false;
1484 };
1485
1486 // Can be chained in DeviceDescriptor
1487 struct DawnCacheDeviceDescriptor : ChainedStruct {
1488 DawnCacheDeviceDescriptor() {
1489 sType = SType::DawnCacheDeviceDescriptor;
1490 }
1491 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(char const * ));
1492 alignas(kFirstMemberAlignment) char const * isolationKey = "";
1493 };
1494
1495 // Can be chained in CommandEncoderDescriptor
1496 struct DawnEncoderInternalUsageDescriptor : ChainedStruct {
1497 DawnEncoderInternalUsageDescriptor() {
1498 sType = SType::DawnEncoderInternalUsageDescriptor;
1499 }
1500 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1501 alignas(kFirstMemberAlignment) Bool useInternalUsages = false;
1502 };
1503
1504 // Can be chained in MultisampleState
1505 struct DawnMultisampleStateRenderToSingleSampled : ChainedStruct {
1506 DawnMultisampleStateRenderToSingleSampled() {
1507 sType = SType::DawnMultisampleStateRenderToSingleSampled;
1508 }
1509 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1510 alignas(kFirstMemberAlignment) Bool enabled = false;
1511 };
1512
1513 // Can be chained in RenderPassColorAttachment
1514 struct DawnRenderPassColorAttachmentRenderToSingleSampled : ChainedStruct {
1515 DawnRenderPassColorAttachmentRenderToSingleSampled() {
1516 sType = SType::DawnRenderPassColorAttachmentRenderToSingleSampled;
1517 }
1518 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t ));
1519 alignas(kFirstMemberAlignment) uint32_t implicitSampleCount = 1;
1520 };
1521
1522 // Can be chained in ShaderModuleDescriptor
1523 struct DawnShaderModuleSPIRVOptionsDescriptor : ChainedStruct {
1524 DawnShaderModuleSPIRVOptionsDescriptor() {
1525 sType = SType::DawnShaderModuleSPIRVOptionsDescriptor;
1526 }
1527 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1528 alignas(kFirstMemberAlignment) Bool allowNonUniformDerivatives = false;
1529 };
1530
1531 // Can be chained in TextureDescriptor
1532 struct DawnTextureInternalUsageDescriptor : ChainedStruct {
1533 DawnTextureInternalUsageDescriptor() {
1534 sType = SType::DawnTextureInternalUsageDescriptor;
1535 }
1536 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(TextureUsage ));
1537 alignas(kFirstMemberAlignment) TextureUsage internalUsage = TextureUsage::None;
1538 };
1539
1540 // Can be chained in InstanceDescriptor
1541 // Can be chained in RequestAdapterOptions
1542 // Can be chained in DeviceDescriptor
1543 struct DawnTogglesDescriptor : ChainedStruct {
1544 DawnTogglesDescriptor() {
1545 sType = SType::DawnTogglesDescriptor;
1546 }
1547 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(size_t ));
1548 alignas(kFirstMemberAlignment) size_t enabledTogglesCount = 0;
1549 const char* const * enabledToggles;
1550 size_t disabledTogglesCount = 0;
1551 const char* const * disabledToggles;
1552 };
1553
1554 struct Extent2D {
1555 uint32_t width;
1556 uint32_t height;
1557 };
1558
1559 struct Extent3D {
1560 uint32_t width;
1561 uint32_t height = 1;
1562 uint32_t depthOrArrayLayers = 1;
1563 };
1564
1565 // Can be chained in BindGroupEntry
1566 struct ExternalTextureBindingEntry : ChainedStruct {
1567 ExternalTextureBindingEntry() {
1568 sType = SType::ExternalTextureBindingEntry;
1569 }
1570 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(ExternalTexture ));
1571 alignas(kFirstMemberAlignment) ExternalTexture externalTexture;
1572 };
1573
1574 // Can be chained in BindGroupLayoutEntry
1575 struct ExternalTextureBindingLayout : ChainedStruct {
1576 ExternalTextureBindingLayout() {
1577 sType = SType::ExternalTextureBindingLayout;
1578 }
1579 };
1580
1581 struct InstanceDescriptor {
1582 ChainedStruct const * nextInChain = nullptr;
1583 };
1584
1585 struct Limits {
1586 uint32_t maxTextureDimension1D = WGPU_LIMIT_U32_UNDEFINED;
1587 uint32_t maxTextureDimension2D = WGPU_LIMIT_U32_UNDEFINED;
1588 uint32_t maxTextureDimension3D = WGPU_LIMIT_U32_UNDEFINED;
1589 uint32_t maxTextureArrayLayers = WGPU_LIMIT_U32_UNDEFINED;
1590 uint32_t maxBindGroups = WGPU_LIMIT_U32_UNDEFINED;
1591 uint32_t maxBindGroupsPlusVertexBuffers = WGPU_LIMIT_U32_UNDEFINED;
1592 uint32_t maxBindingsPerBindGroup = WGPU_LIMIT_U32_UNDEFINED;
1593 uint32_t maxDynamicUniformBuffersPerPipelineLayout = WGPU_LIMIT_U32_UNDEFINED;
1594 uint32_t maxDynamicStorageBuffersPerPipelineLayout = WGPU_LIMIT_U32_UNDEFINED;
1595 uint32_t maxSampledTexturesPerShaderStage = WGPU_LIMIT_U32_UNDEFINED;
1596 uint32_t maxSamplersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED;
1597 uint32_t maxStorageBuffersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED;
1598 uint32_t maxStorageTexturesPerShaderStage = WGPU_LIMIT_U32_UNDEFINED;
1599 uint32_t maxUniformBuffersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED;
1600 uint64_t maxUniformBufferBindingSize = WGPU_LIMIT_U64_UNDEFINED;
1601 uint64_t maxStorageBufferBindingSize = WGPU_LIMIT_U64_UNDEFINED;
1602 uint32_t minUniformBufferOffsetAlignment = WGPU_LIMIT_U32_UNDEFINED;
1603 uint32_t minStorageBufferOffsetAlignment = WGPU_LIMIT_U32_UNDEFINED;
1604 uint32_t maxVertexBuffers = WGPU_LIMIT_U32_UNDEFINED;
1605 uint64_t maxBufferSize = WGPU_LIMIT_U64_UNDEFINED;
1606 uint32_t maxVertexAttributes = WGPU_LIMIT_U32_UNDEFINED;
1607 uint32_t maxVertexBufferArrayStride = WGPU_LIMIT_U32_UNDEFINED;
1608 uint32_t maxInterStageShaderComponents = WGPU_LIMIT_U32_UNDEFINED;
1609 uint32_t maxInterStageShaderVariables = WGPU_LIMIT_U32_UNDEFINED;
1610 uint32_t maxColorAttachments = WGPU_LIMIT_U32_UNDEFINED;
1611 uint32_t maxColorAttachmentBytesPerSample = WGPU_LIMIT_U32_UNDEFINED;
1612 uint32_t maxComputeWorkgroupStorageSize = WGPU_LIMIT_U32_UNDEFINED;
1613 uint32_t maxComputeInvocationsPerWorkgroup = WGPU_LIMIT_U32_UNDEFINED;
1614 uint32_t maxComputeWorkgroupSizeX = WGPU_LIMIT_U32_UNDEFINED;
1615 uint32_t maxComputeWorkgroupSizeY = WGPU_LIMIT_U32_UNDEFINED;
1616 uint32_t maxComputeWorkgroupSizeZ = WGPU_LIMIT_U32_UNDEFINED;
1617 uint32_t maxComputeWorkgroupsPerDimension = WGPU_LIMIT_U32_UNDEFINED;
1618 };
1619
1620 struct MultisampleState {
1621 ChainedStruct const * nextInChain = nullptr;
1622 uint32_t count = 1;
1623 uint32_t mask = 0xFFFFFFFF;
1624 Bool alphaToCoverageEnabled = false;
1625 };
1626
1627 struct Origin2D {
1628 uint32_t x = 0;
1629 uint32_t y = 0;
1630 };
1631
1632 struct Origin3D {
1633 uint32_t x = 0;
1634 uint32_t y = 0;
1635 uint32_t z = 0;
1636 };
1637
1638 struct PipelineLayoutDescriptor {
1639 ChainedStruct const * nextInChain = nullptr;
1640 char const * label = nullptr;
1641 size_t bindGroupLayoutCount;
1642 BindGroupLayout const * bindGroupLayouts;
1643 };
1644
1645 // Can be chained in PrimitiveState
1646 struct PrimitiveDepthClipControl : ChainedStruct {
1647 PrimitiveDepthClipControl() {
1648 sType = SType::PrimitiveDepthClipControl;
1649 }
1650 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1651 alignas(kFirstMemberAlignment) Bool unclippedDepth = false;
1652 };
1653
1654 struct PrimitiveState {
1655 ChainedStruct const * nextInChain = nullptr;
1656 PrimitiveTopology topology = PrimitiveTopology::TriangleList;
1657 IndexFormat stripIndexFormat = IndexFormat::Undefined;
1658 FrontFace frontFace = FrontFace::CCW;
1659 CullMode cullMode = CullMode::None;
1660 };
1661
1662 struct QuerySetDescriptor {
1663 ChainedStruct const * nextInChain = nullptr;
1664 char const * label = nullptr;
1665 QueryType type;
1666 uint32_t count;
1667 PipelineStatisticName const * pipelineStatistics;
1668 size_t pipelineStatisticsCount = 0;
1669 };
1670
1671 struct QueueDescriptor {
1672 ChainedStruct const * nextInChain = nullptr;
1673 char const * label = nullptr;
1674 };
1675
1676 struct RenderBundleDescriptor {
1677 ChainedStruct const * nextInChain = nullptr;
1678 char const * label = nullptr;
1679 };
1680
1681 struct RenderBundleEncoderDescriptor {
1682 ChainedStruct const * nextInChain = nullptr;
1683 char const * label = nullptr;
1684 size_t colorFormatsCount;
1685 TextureFormat const * colorFormats;
1686 TextureFormat depthStencilFormat = TextureFormat::Undefined;
1687 uint32_t sampleCount = 1;
1688 Bool depthReadOnly = false;
1689 Bool stencilReadOnly = false;
1690 };
1691
1692 struct RenderPassDepthStencilAttachment {
1693 TextureView view;
1694 LoadOp depthLoadOp = LoadOp::Undefined;
1695 StoreOp depthStoreOp = StoreOp::Undefined;
1696 float depthClearValue = NAN;
1697 Bool depthReadOnly = false;
1698 LoadOp stencilLoadOp = LoadOp::Undefined;
1699 StoreOp stencilStoreOp = StoreOp::Undefined;
1700 uint32_t stencilClearValue = 0;
1701 Bool stencilReadOnly = false;
1702 };
1703
1704 // Can be chained in RenderPassDescriptor
1705 struct RenderPassDescriptorMaxDrawCount : ChainedStruct {
1706 RenderPassDescriptorMaxDrawCount() {
1707 sType = SType::RenderPassDescriptorMaxDrawCount;
1708 }
1709 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint64_t ));
1710 alignas(kFirstMemberAlignment) uint64_t maxDrawCount = 50000000;
1711 };
1712
1713 struct RenderPassTimestampWrite {
1714 QuerySet querySet;
1715 uint32_t queryIndex;
1716 RenderPassTimestampLocation location;
1717 };
1718
1719 struct RequestAdapterOptions {
1720 ChainedStruct const * nextInChain = nullptr;
1721 Surface compatibleSurface;
1722 PowerPreference powerPreference = PowerPreference::Undefined;
1723 BackendType backendType = BackendType::Undefined;
1724 Bool forceFallbackAdapter = false;
1725 Bool compatibilityMode = false;
1726 };
1727
1728 struct SamplerBindingLayout {
1729 ChainedStruct const * nextInChain = nullptr;
1730 SamplerBindingType type = SamplerBindingType::Undefined;
1731 };
1732
1733 struct SamplerDescriptor {
1734 ChainedStruct const * nextInChain = nullptr;
1735 char const * label = nullptr;
1736 AddressMode addressModeU = AddressMode::ClampToEdge;
1737 AddressMode addressModeV = AddressMode::ClampToEdge;
1738 AddressMode addressModeW = AddressMode::ClampToEdge;
1739 FilterMode magFilter = FilterMode::Nearest;
1740 FilterMode minFilter = FilterMode::Nearest;
1741 MipmapFilterMode mipmapFilter = MipmapFilterMode::Nearest;
1742 float lodMinClamp = 0.0f;
1743 float lodMaxClamp = 32.0f;
1744 CompareFunction compare = CompareFunction::Undefined;
1745 uint16_t maxAnisotropy = 1;
1746 };
1747
1748 struct ShaderModuleDescriptor {
1749 ChainedStruct const * nextInChain = nullptr;
1750 char const * label = nullptr;
1751 };
1752
1753 // Can be chained in ShaderModuleDescriptor
1754 struct ShaderModuleSPIRVDescriptor : ChainedStruct {
1755 ShaderModuleSPIRVDescriptor() {
1756 sType = SType::ShaderModuleSPIRVDescriptor;
1757 }
1758 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t ));
1759 alignas(kFirstMemberAlignment) uint32_t codeSize;
1760 uint32_t const * code;
1761 };
1762
1763 // Can be chained in ShaderModuleDescriptor
1764 struct ShaderModuleWGSLDescriptor : ChainedStruct {
1765 ShaderModuleWGSLDescriptor() {
1766 sType = SType::ShaderModuleWGSLDescriptor;
1767 }
1768 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(char const * ));
1769 alignas(kFirstMemberAlignment) char const * code;
1770 };
1771
1772 struct SharedFenceDescriptor {
1773 ChainedStruct const * nextInChain = nullptr;
1774 char const * label = nullptr;
1775 };
1776
1777 // Can be chained in SharedFenceDescriptor
1778 struct SharedFenceDXGISharedHandleDescriptor : ChainedStruct {
1779 SharedFenceDXGISharedHandleDescriptor() {
1780 sType = SType::SharedFenceDXGISharedHandleDescriptor;
1781 }
1782 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1783 alignas(kFirstMemberAlignment) void * handle;
1784 };
1785
1786 // Can be chained in SharedFenceExportInfo
1787 struct SharedFenceDXGISharedHandleExportInfo : ChainedStructOut {
1788 SharedFenceDXGISharedHandleExportInfo() {
1789 sType = SType::SharedFenceDXGISharedHandleExportInfo;
1790 }
1791 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1792 alignas(kFirstMemberAlignment) void * handle;
1793 };
1794
1795 struct SharedFenceExportInfo {
1796 ChainedStructOut * nextInChain = nullptr;
1797 SharedFenceType type;
1798 };
1799
1800 // Can be chained in SharedFenceDescriptor
1801 struct SharedFenceMTLSharedEventDescriptor : ChainedStruct {
1802 SharedFenceMTLSharedEventDescriptor() {
1803 sType = SType::SharedFenceMTLSharedEventDescriptor;
1804 }
1805 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1806 alignas(kFirstMemberAlignment) void * sharedEvent;
1807 };
1808
1809 // Can be chained in SharedFenceExportInfo
1810 struct SharedFenceMTLSharedEventExportInfo : ChainedStructOut {
1811 SharedFenceMTLSharedEventExportInfo() {
1812 sType = SType::SharedFenceMTLSharedEventExportInfo;
1813 }
1814 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1815 alignas(kFirstMemberAlignment) void * sharedEvent;
1816 };
1817
1818 // Can be chained in SharedFenceDescriptor
1819 struct SharedFenceVkSemaphoreOpaqueFDDescriptor : ChainedStruct {
1820 SharedFenceVkSemaphoreOpaqueFDDescriptor() {
1821 sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor;
1822 }
1823 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1824 alignas(kFirstMemberAlignment) int handle;
1825 };
1826
1827 // Can be chained in SharedFenceExportInfo
1828 struct SharedFenceVkSemaphoreOpaqueFDExportInfo : ChainedStructOut {
1829 SharedFenceVkSemaphoreOpaqueFDExportInfo() {
1830 sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo;
1831 }
1832 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1833 alignas(kFirstMemberAlignment) int handle;
1834 };
1835
1836 // Can be chained in SharedFenceDescriptor
1837 struct SharedFenceVkSemaphoreSyncFDDescriptor : ChainedStruct {
1838 SharedFenceVkSemaphoreSyncFDDescriptor() {
1839 sType = SType::SharedFenceVkSemaphoreSyncFDDescriptor;
1840 }
1841 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1842 alignas(kFirstMemberAlignment) int handle;
1843 };
1844
1845 // Can be chained in SharedFenceExportInfo
1846 struct SharedFenceVkSemaphoreSyncFDExportInfo : ChainedStructOut {
1847 SharedFenceVkSemaphoreSyncFDExportInfo() {
1848 sType = SType::SharedFenceVkSemaphoreSyncFDExportInfo;
1849 }
1850 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1851 alignas(kFirstMemberAlignment) int handle;
1852 };
1853
1854 // Can be chained in SharedFenceDescriptor
1855 struct SharedFenceVkSemaphoreZirconHandleDescriptor : ChainedStruct {
1856 SharedFenceVkSemaphoreZirconHandleDescriptor() {
1857 sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor;
1858 }
1859 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t ));
1860 alignas(kFirstMemberAlignment) uint32_t handle;
1861 };
1862
1863 // Can be chained in SharedFenceExportInfo
1864 struct SharedFenceVkSemaphoreZirconHandleExportInfo : ChainedStructOut {
1865 SharedFenceVkSemaphoreZirconHandleExportInfo() {
1866 sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo;
1867 }
1868 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t ));
1869 alignas(kFirstMemberAlignment) uint32_t handle;
1870 };
1871
1872 // Can be chained in SharedTextureMemoryDescriptor
1873 struct SharedTextureMemoryAHardwareBufferDescriptor : ChainedStruct {
1874 SharedTextureMemoryAHardwareBufferDescriptor() {
1875 sType = SType::SharedTextureMemoryAHardwareBufferDescriptor;
1876 }
1877 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1878 alignas(kFirstMemberAlignment) void * handle;
1879 };
1880
1881 struct SharedTextureMemoryBeginAccessDescriptor {
1882 ChainedStruct const * nextInChain = nullptr;
1883 Bool initialized;
1884 size_t fenceCount;
1885 SharedFence const * fences;
1886 uint64_t const * signaledValues;
1887 };
1888
1889 struct SharedTextureMemoryDescriptor {
1890 ChainedStruct const * nextInChain = nullptr;
1891 char const * label = nullptr;
1892 };
1893
1894 // Can be chained in SharedTextureMemoryDescriptor
1895 struct SharedTextureMemoryDmaBufDescriptor : ChainedStruct {
1896 SharedTextureMemoryDmaBufDescriptor() {
1897 sType = SType::SharedTextureMemoryDmaBufDescriptor;
1898 }
1899 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1900 alignas(kFirstMemberAlignment) int memoryFD;
1901 uint64_t allocationSize;
1902 uint64_t drmModifier;
1903 size_t planeCount;
1904 uint64_t const * planeOffsets;
1905 uint32_t const * planeStrides;
1906 };
1907
1908 // Can be chained in SharedTextureMemoryDescriptor
1909 struct SharedTextureMemoryDXGISharedHandleDescriptor : ChainedStruct {
1910 SharedTextureMemoryDXGISharedHandleDescriptor() {
1911 sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor;
1912 }
1913 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1914 alignas(kFirstMemberAlignment) void * handle;
1915 };
1916
1917 // Can be chained in SharedTextureMemoryDescriptor
1918 struct SharedTextureMemoryEGLImageDescriptor : ChainedStruct {
1919 SharedTextureMemoryEGLImageDescriptor() {
1920 sType = SType::SharedTextureMemoryEGLImageDescriptor;
1921 }
1922 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1923 alignas(kFirstMemberAlignment) void * image;
1924 };
1925
1926 struct SharedTextureMemoryEndAccessState {
1927 SharedTextureMemoryEndAccessState() = default;
1928 ~SharedTextureMemoryEndAccessState();
1929 SharedTextureMemoryEndAccessState(const SharedTextureMemoryEndAccessState&) = delete;
1930 SharedTextureMemoryEndAccessState& operator=(const SharedTextureMemoryEndAccessState&) = delete;
1931 SharedTextureMemoryEndAccessState(SharedTextureMemoryEndAccessState&&);
1932 SharedTextureMemoryEndAccessState& operator=(SharedTextureMemoryEndAccessState&&);
1933 ChainedStructOut * nextInChain = nullptr;
1934 Bool const initialized = {};
1935 size_t const fenceCount = {};
1936 SharedFence const * const fences = {};
1937 uint64_t const * const signaledValues = {};
1938 };
1939
1940 // Can be chained in SharedTextureMemoryDescriptor
1941 struct SharedTextureMemoryIOSurfaceDescriptor : ChainedStruct {
1942 SharedTextureMemoryIOSurfaceDescriptor() {
1943 sType = SType::SharedTextureMemoryIOSurfaceDescriptor;
1944 }
1945 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
1946 alignas(kFirstMemberAlignment) void * ioSurface;
1947 };
1948
1949 // Can be chained in SharedTextureMemoryDescriptor
1950 struct SharedTextureMemoryOpaqueFDDescriptor : ChainedStruct {
1951 SharedTextureMemoryOpaqueFDDescriptor() {
1952 sType = SType::SharedTextureMemoryOpaqueFDDescriptor;
1953 }
1954 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int ));
1955 alignas(kFirstMemberAlignment) int memoryFD;
1956 uint64_t allocationSize;
1957 };
1958
1959 // Can be chained in SharedTextureMemoryDescriptor
1960 struct SharedTextureMemoryVkDedicatedAllocationDescriptor : ChainedStruct {
1961 SharedTextureMemoryVkDedicatedAllocationDescriptor() {
1962 sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor;
1963 }
1964 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool ));
1965 alignas(kFirstMemberAlignment) Bool dedicatedAllocation;
1966 };
1967
1968 // Can be chained in SharedTextureMemoryBeginAccessDescriptor
1969 struct SharedTextureMemoryVkImageLayoutBeginState : ChainedStruct {
1970 SharedTextureMemoryVkImageLayoutBeginState() {
1971 sType = SType::SharedTextureMemoryVkImageLayoutBeginState;
1972 }
1973 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t ));
1974 alignas(kFirstMemberAlignment) int32_t oldLayout;
1975 int32_t newLayout;
1976 };
1977
1978 // Can be chained in SharedTextureMemoryEndAccessState
1979 struct SharedTextureMemoryVkImageLayoutEndState : ChainedStructOut {
1980 SharedTextureMemoryVkImageLayoutEndState() {
1981 sType = SType::SharedTextureMemoryVkImageLayoutEndState;
1982 }
1983 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t ));
1984 alignas(kFirstMemberAlignment) int32_t oldLayout;
1985 int32_t newLayout;
1986 };
1987
1988 // Can be chained in SharedTextureMemoryDescriptor
1989 struct SharedTextureMemoryZirconHandleDescriptor : ChainedStruct {
1990 SharedTextureMemoryZirconHandleDescriptor() {
1991 sType = SType::SharedTextureMemoryZirconHandleDescriptor;
1992 }
1993 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t ));
1994 alignas(kFirstMemberAlignment) uint32_t memoryFD;
1995 uint64_t allocationSize;
1996 };
1997
1998 struct StencilFaceState {
1999 CompareFunction compare = CompareFunction::Always;
2000 StencilOperation failOp = StencilOperation::Keep;
2001 StencilOperation depthFailOp = StencilOperation::Keep;
2002 StencilOperation passOp = StencilOperation::Keep;
2003 };
2004
2005 struct StorageTextureBindingLayout {
2006 ChainedStruct const * nextInChain = nullptr;
2007 StorageTextureAccess access = StorageTextureAccess::Undefined;
2008 TextureFormat format = TextureFormat::Undefined;
2009 TextureViewDimension viewDimension = TextureViewDimension::Undefined;
2010 };
2011
2012 struct SurfaceDescriptor {
2013 ChainedStruct const * nextInChain = nullptr;
2014 char const * label = nullptr;
2015 };
2016
2017 // Can be chained in SurfaceDescriptor
2018 struct SurfaceDescriptorFromAndroidNativeWindow : ChainedStruct {
2019 SurfaceDescriptorFromAndroidNativeWindow() {
2020 sType = SType::SurfaceDescriptorFromAndroidNativeWindow;
2021 }
2022 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2023 alignas(kFirstMemberAlignment) void * window;
2024 };
2025
2026 // Can be chained in SurfaceDescriptor
2027 struct SurfaceDescriptorFromCanvasHTMLSelector : ChainedStruct {
2028 SurfaceDescriptorFromCanvasHTMLSelector() {
2029 sType = SType::SurfaceDescriptorFromCanvasHTMLSelector;
2030 }
2031 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(char const * ));
2032 alignas(kFirstMemberAlignment) char const * selector;
2033 };
2034
2035 // Can be chained in SurfaceDescriptor
2036 struct SurfaceDescriptorFromMetalLayer : ChainedStruct {
2037 SurfaceDescriptorFromMetalLayer() {
2038 sType = SType::SurfaceDescriptorFromMetalLayer;
2039 }
2040 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2041 alignas(kFirstMemberAlignment) void * layer;
2042 };
2043
2044 // Can be chained in SurfaceDescriptor
2045 struct SurfaceDescriptorFromWaylandSurface : ChainedStruct {
2046 SurfaceDescriptorFromWaylandSurface() {
2047 sType = SType::SurfaceDescriptorFromWaylandSurface;
2048 }
2049 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2050 alignas(kFirstMemberAlignment) void * display;
2051 void * surface;
2052 };
2053
2054 // Can be chained in SurfaceDescriptor
2055 struct SurfaceDescriptorFromWindowsCoreWindow : ChainedStruct {
2056 SurfaceDescriptorFromWindowsCoreWindow() {
2057 sType = SType::SurfaceDescriptorFromWindowsCoreWindow;
2058 }
2059 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2060 alignas(kFirstMemberAlignment) void * coreWindow;
2061 };
2062
2063 // Can be chained in SurfaceDescriptor
2064 struct SurfaceDescriptorFromWindowsHWND : ChainedStruct {
2065 SurfaceDescriptorFromWindowsHWND() {
2066 sType = SType::SurfaceDescriptorFromWindowsHWND;
2067 }
2068 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2069 alignas(kFirstMemberAlignment) void * hinstance;
2070 void * hwnd;
2071 };
2072
2073 // Can be chained in SurfaceDescriptor
2074 struct SurfaceDescriptorFromWindowsSwapChainPanel : ChainedStruct {
2075 SurfaceDescriptorFromWindowsSwapChainPanel() {
2076 sType = SType::SurfaceDescriptorFromWindowsSwapChainPanel;
2077 }
2078 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2079 alignas(kFirstMemberAlignment) void * swapChainPanel;
2080 };
2081
2082 // Can be chained in SurfaceDescriptor
2083 struct SurfaceDescriptorFromXlibWindow : ChainedStruct {
2084 SurfaceDescriptorFromXlibWindow() {
2085 sType = SType::SurfaceDescriptorFromXlibWindow;
2086 }
2087 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(void * ));
2088 alignas(kFirstMemberAlignment) void * display;
2089 uint32_t window;
2090 };
2091
2092 struct SwapChainDescriptor {
2093 ChainedStruct const * nextInChain = nullptr;
2094 char const * label = nullptr;
2095 TextureUsage usage;
2096 TextureFormat format;
2097 uint32_t width;
2098 uint32_t height;
2099 PresentMode presentMode;
2100 };
2101
2102 struct TextureBindingLayout {
2103 ChainedStruct const * nextInChain = nullptr;
2104 TextureSampleType sampleType = TextureSampleType::Undefined;
2105 TextureViewDimension viewDimension = TextureViewDimension::Undefined;
2106 Bool multisampled = false;
2107 };
2108
2109 struct TextureDataLayout {
2110 ChainedStruct const * nextInChain = nullptr;
2111 uint64_t offset = 0;
2112 uint32_t bytesPerRow = WGPU_COPY_STRIDE_UNDEFINED;
2113 uint32_t rowsPerImage = WGPU_COPY_STRIDE_UNDEFINED;
2114 };
2115
2116 struct TextureViewDescriptor {
2117 ChainedStruct const * nextInChain = nullptr;
2118 char const * label = nullptr;
2119 TextureFormat format = TextureFormat::Undefined;
2120 TextureViewDimension dimension = TextureViewDimension::Undefined;
2121 uint32_t baseMipLevel = 0;
2122 uint32_t mipLevelCount = WGPU_MIP_LEVEL_COUNT_UNDEFINED;
2123 uint32_t baseArrayLayer = 0;
2124 uint32_t arrayLayerCount = WGPU_ARRAY_LAYER_COUNT_UNDEFINED;
2125 TextureAspect aspect = TextureAspect::All;
2126 };
2127
2128 struct VertexAttribute {
2129 VertexFormat format;
2130 uint64_t offset;
2131 uint32_t shaderLocation;
2132 };
2133
2134 struct BindGroupDescriptor {
2135 ChainedStruct const * nextInChain = nullptr;
2136 char const * label = nullptr;
2137 BindGroupLayout layout;
2138 size_t entryCount;
2139 BindGroupEntry const * entries;
2140 };
2141
2142 struct BindGroupLayoutEntry {
2143 ChainedStruct const * nextInChain = nullptr;
2144 uint32_t binding;
2145 ShaderStage visibility;
2146 BufferBindingLayout buffer;
2147 SamplerBindingLayout sampler;
2148 TextureBindingLayout texture;
2149 StorageTextureBindingLayout storageTexture;
2150 };
2151
2152 struct BlendState {
2153 BlendComponent color;
2154 BlendComponent alpha;
2155 };
2156
2157 struct CompilationInfo {
2158 ChainedStruct const * nextInChain = nullptr;
2159 size_t messageCount;
2160 CompilationMessage const * messages;
2161 };
2162
2163 struct ComputePassDescriptor {
2164 ChainedStruct const * nextInChain = nullptr;
2165 char const * label = nullptr;
2166 size_t timestampWriteCount = 0;
2167 ComputePassTimestampWrite const * timestampWrites;
2168 };
2169
2170 struct DepthStencilState {
2171 ChainedStruct const * nextInChain = nullptr;
2172 TextureFormat format;
2173 Bool depthWriteEnabled;
2174 CompareFunction depthCompare;
2175 StencilFaceState stencilFront;
2176 StencilFaceState stencilBack;
2177 uint32_t stencilReadMask = 0xFFFFFFFF;
2178 uint32_t stencilWriteMask = 0xFFFFFFFF;
2179 int32_t depthBias = 0;
2180 float depthBiasSlopeScale = 0.0f;
2181 float depthBiasClamp = 0.0f;
2182 };
2183
2184 struct ExternalTextureDescriptor {
2185 ChainedStruct const * nextInChain = nullptr;
2186 char const * label = nullptr;
2187 TextureView plane0;
2188 TextureView plane1;
2189 Origin2D visibleOrigin;
2190 Extent2D visibleSize;
2191 Bool doYuvToRgbConversionOnly = false;
2192 float const * yuvToRgbConversionMatrix = nullptr;
2193 float const * srcTransferFunctionParameters;
2194 float const * dstTransferFunctionParameters;
2195 float const * gamutConversionMatrix;
2196 Bool flipY = false;
2197 ExternalTextureRotation rotation = ExternalTextureRotation::Rotate0Degrees;
2198 };
2199
2200 struct ImageCopyBuffer {
2201 ChainedStruct const * nextInChain = nullptr;
2202 TextureDataLayout layout;
2203 Buffer buffer;
2204 };
2205
2206 struct ImageCopyExternalTexture {
2207 ChainedStruct const * nextInChain = nullptr;
2208 ExternalTexture externalTexture;
2209 Origin3D origin;
2210 Extent2D naturalSize;
2211 };
2212
2213 struct ImageCopyTexture {
2214 ChainedStruct const * nextInChain = nullptr;
2215 Texture texture;
2216 uint32_t mipLevel = 0;
2217 Origin3D origin;
2218 TextureAspect aspect = TextureAspect::All;
2219 };
2220
2221 struct ProgrammableStageDescriptor {
2222 ChainedStruct const * nextInChain = nullptr;
2223 ShaderModule module;
2224 char const * entryPoint;
2225 size_t constantCount = 0;
2226 ConstantEntry const * constants;
2227 };
2228
2229 struct RenderPassColorAttachment {
2230 ChainedStruct const * nextInChain = nullptr;
2231 TextureView view;
2232 TextureView resolveTarget;
2233 LoadOp loadOp;
2234 StoreOp storeOp;
2235 Color clearValue;
2236 };
2237
2238 struct RequiredLimits {
2239 ChainedStruct const * nextInChain = nullptr;
2240 Limits limits;
2241 };
2242
2243 struct SharedTextureMemoryProperties {
2244 ChainedStructOut * nextInChain = nullptr;
2245 TextureUsage usage;
2246 Extent3D size;
2247 TextureFormat format;
2248 };
2249
2250 // Can be chained in SharedTextureMemoryDescriptor
2251 struct SharedTextureMemoryVkImageDescriptor : ChainedStruct {
2252 SharedTextureMemoryVkImageDescriptor() {
2253 sType = SType::SharedTextureMemoryVkImageDescriptor;
2254 }
2255 static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t ));
2256 alignas(kFirstMemberAlignment) int32_t vkFormat;
2257 int32_t vkUsageFlags;
2258 Extent3D vkExtent3D;
2259 };
2260
2261 struct SupportedLimits {
2262 ChainedStructOut * nextInChain = nullptr;
2263 Limits limits;
2264 };
2265
2266 struct TextureDescriptor {
2267 ChainedStruct const * nextInChain = nullptr;
2268 char const * label = nullptr;
2269 TextureUsage usage;
2270 TextureDimension dimension = TextureDimension::e2D;
2271 Extent3D size;
2272 TextureFormat format;
2273 uint32_t mipLevelCount = 1;
2274 uint32_t sampleCount = 1;
2275 size_t viewFormatCount = 0;
2276 TextureFormat const * viewFormats;
2277 };
2278
2279 struct VertexBufferLayout {
2280 uint64_t arrayStride;
2281 VertexStepMode stepMode = VertexStepMode::Vertex;
2282 size_t attributeCount;
2283 VertexAttribute const * attributes;
2284 };
2285
2286 struct BindGroupLayoutDescriptor {
2287 ChainedStruct const * nextInChain = nullptr;
2288 char const * label = nullptr;
2289 size_t entryCount;
2290 BindGroupLayoutEntry const * entries;
2291 };
2292
2293 struct ColorTargetState {
2294 ChainedStruct const * nextInChain = nullptr;
2295 TextureFormat format;
2296 BlendState const * blend = nullptr;
2297 ColorWriteMask writeMask = ColorWriteMask::All;
2298 };
2299
2300 struct ComputePipelineDescriptor {
2301 ChainedStruct const * nextInChain = nullptr;
2302 char const * label = nullptr;
2303 PipelineLayout layout;
2304 ProgrammableStageDescriptor compute;
2305 };
2306
2307 struct DeviceDescriptor {
2308 ChainedStruct const * nextInChain = nullptr;
2309 char const * label = nullptr;
2310 size_t requiredFeaturesCount = 0;
2311 FeatureName const * requiredFeatures = nullptr;
2312 RequiredLimits const * requiredLimits = nullptr;
2313 QueueDescriptor defaultQueue;
2314 DeviceLostCallback deviceLostCallback = nullptr;
2315 void * deviceLostUserdata = nullptr;
2316 };
2317
2318 struct RenderPassDescriptor {
2319 ChainedStruct const * nextInChain = nullptr;
2320 char const * label = nullptr;
2321 size_t colorAttachmentCount;
2322 RenderPassColorAttachment const * colorAttachments;
2323 RenderPassDepthStencilAttachment const * depthStencilAttachment = nullptr;
2324 QuerySet occlusionQuerySet;
2325 size_t timestampWriteCount = 0;
2326 RenderPassTimestampWrite const * timestampWrites;
2327 };
2328
2329 struct VertexState {
2330 ChainedStruct const * nextInChain = nullptr;
2331 ShaderModule module;
2332 char const * entryPoint;
2333 size_t constantCount = 0;
2334 ConstantEntry const * constants;
2335 size_t bufferCount = 0;
2336 VertexBufferLayout const * buffers;
2337 };
2338
2339 struct FragmentState {
2340 ChainedStruct const * nextInChain = nullptr;
2341 ShaderModule module;
2342 char const * entryPoint;
2343 size_t constantCount = 0;
2344 ConstantEntry const * constants;
2345 size_t targetCount;
2346 ColorTargetState const * targets;
2347 };
2348
2349 struct RenderPipelineDescriptor {
2350 ChainedStruct const * nextInChain = nullptr;
2351 char const * label = nullptr;
2352 PipelineLayout layout;
2353 VertexState vertex;
2354 PrimitiveState primitive;
2355 DepthStencilState const * depthStencil = nullptr;
2356 MultisampleState multisample;
2357 FragmentState const * fragment = nullptr;
2358 };
2359
2360
2361 // The operators of EnumClassBitmmasks in the dawn:: namespace need to be imported
2362 // in the wgpu namespace for Argument Dependent Lookup.
2363 DAWN_IMPORT_BITMASK_OPERATORS
2364} // namespace wgpu
2365
2366namespace dawn {
2367 template<>
2368 struct IsDawnBitmask<wgpu::BufferUsage> {
2369 static constexpr bool enable = true;
2370 };
2371
2372 template<>
2373 struct IsDawnBitmask<wgpu::ColorWriteMask> {
2374 static constexpr bool enable = true;
2375 };
2376
2377 template<>
2378 struct IsDawnBitmask<wgpu::MapMode> {
2379 static constexpr bool enable = true;
2380 };
2381
2382 template<>
2383 struct IsDawnBitmask<wgpu::ShaderStage> {
2384 static constexpr bool enable = true;
2385 };
2386
2387 template<>
2388 struct IsDawnBitmask<wgpu::TextureUsage> {
2389 static constexpr bool enable = true;
2390 };
2391
2392} // namespace dawn
2393
2394namespace std {
2395// Custom boolean class needs corresponding hash function so that it appears as a transparent bool.
2396template <>
2397struct hash<wgpu::Bool> {
2398 public:
2399 size_t operator()(const wgpu::Bool &v) const {
2400 return hash<bool>()(v);
2401 }
2402};
2403} // namespace std
2404
2405#endif // WEBGPU_CPP_H_