diff --git a/example/src/App.tsx b/example/src/App.tsx index 9635e09778..416a0d252b 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -123,7 +123,13 @@ const App = () => { }} /> - + null, + }} + /> diff --git a/example/src/Examples/Breathe/Breathe.tsx b/example/src/Examples/Breathe/Breathe.tsx index 70ee72aa67..9c51add014 100644 --- a/example/src/Examples/Breathe/Breathe.tsx +++ b/example/src/Examples/Breathe/Breathe.tsx @@ -1,43 +1,91 @@ -import React, { useEffect, useRef } from "react"; -import { - gpu, - SkiaDomView, -} from "@shopify/react-native-skia"; -import { demo1 } from "./demo1/main"; +import React, { useEffect, useRef, useState } from "react"; +import { gpu, SkiaDomView, useImage } from "@shopify/react-native-skia"; +import { View } from "react-native"; +import { Gesture, GestureDetector } from "react-native-gesture-handler"; +import { useSharedValue, withSpring } from "react-native-reanimated"; +import type { SharedValue } from "react-native-reanimated"; -const triangleVertWGSL = `@vertex -fn main( - @builtin(vertex_index) VertexIndex : u32 -) -> @builtin(position) vec4f { - var pos = array( - vec2(0.0, 0.5), - vec2(-0.5, -0.5), - vec2(0.5, -0.5) - ); +import { demo3 } from "./demo3"; +import { demo2 } from "./demo2"; +import { demo1 } from "./demo1/main"; +import { demo4 } from "./demo1/demo4"; +import { demo5 } from "./demo1/demo5"; +import { Bitmap, demo7 } from "./demo1/demo7"; +import { demo6 } from "./demo6/main"; - return vec4f(pos[VertexIndex], 0.0, 1.0); -} -`; +const sf = 300; +const springConfig = (velocity: number) => { + "worklet"; + return { + mass: 1, + damping: 1, + stiffness: 100, + overshootClamping: false, + restDisplacementThreshold: 0.01, + restSpeedThreshold: 2, + velocity, + }; +}; +//import { demo6 } from "./demo6/main"; -const redFragWGSL = `@fragment -fn main() -> @location(0) vec4f { - return vec4(0.3, 0.6, 1.0, 1.0); -}`; +const draw = async ( + context: GPUCanvasContext, + image: Bitmap, + rotateX: SharedValue, + rotateY: SharedValue +) => { + const adapter = await gpu.requestAdapter(); + const device = await adapter!.requestDevice(); + const presentationFormat = "rgba8unorm"; + context.configure({ + device, + format: presentationFormat, + alphaMode: "premultiplied", + }); + //await demo5(device, context, image); + await demo7(device, context, image, rotateX, rotateY); + //context.present(); +}; -const draw = async (ctx: GPUCanvasContext) => { - await demo1(ctx); - ctx.present(); +const usePixels = (mod: number) => { + const image = useImage(mod); + if (!image) { + return null; + } + return new Bitmap( + image.readPixels() as Uint8Array, + image.width(), + image.height() + ); }; export const Breathe = () => { + const image = usePixels(require("./demo6/react.png")); + const rotateX = useSharedValue(0); + const rotateY = useSharedValue(0); const ref = useRef(null); + const gesture = Gesture.Pan() + .onChange((event) => { + rotateY.value += event.changeX / sf; + rotateX.value -= event.changeY / sf; + }) + .onEnd(({ velocityX, velocityY }) => { + rotateX.value = withSpring(0, springConfig(velocityY / sf)); + rotateY.value = withSpring(0, springConfig(velocityX / sf)); + }); useEffect(() => { setTimeout(() => { - const ctx = ref.current!.getWGPUContext(); - draw(ctx); + if (image && ref.current) { + const ctx = ref.current.getWGPUContext(); + draw(ctx, image, rotateX, rotateY); + } }, 1000); - }, []); + }, [image]); return ( - + + + + + ); }; diff --git a/example/src/Examples/Breathe/demo1/backup.ts b/example/src/Examples/Breathe/demo1/backup.ts new file mode 100644 index 0000000000..0c7e8e3b50 --- /dev/null +++ b/example/src/Examples/Breathe/demo1/backup.ts @@ -0,0 +1,175 @@ +import { mat4, vec3 } from 'wgpu-matrix'; + +import { + cubeVertexArray, + cubeVertexSize, + cubeUVOffset, + cubePositionOffset, + cubeVertexCount, +} from './cube'; + +import {basicVertWGSL, vertexPositionColorWGSL} from './shaders'; +import { Dimensions } from 'react-native'; + +const {width, height} = Dimensions.get("window"); + +export const demo1 = async (device: GPUDevice, context: GPUCanvasContext) => { + +// Create a vertex buffer from the cube data. +const verticesBuffer = device.createBuffer({ + size: cubeVertexArray.byteLength, + usage: 32,//GPUBufferUsage.VERTEX, + mappedAtCreation: true, +}); + +new Float32Array(verticesBuffer.getMappedRange(0, cubeVertexArray.byteLength)).set(cubeVertexArray); +verticesBuffer.unmap(); +const pipeline = device.createRenderPipeline({ + layout: 'auto', + vertex: { + module: device.createShaderModule({ + code: basicVertWGSL, + }), + entryPoint: "main", + buffers: [ + { + arrayStride: cubeVertexSize, + attributes: [ + { + // position + shaderLocation: 0, + offset: cubePositionOffset, + format: 'float32x4', + }, + { + // uv + shaderLocation: 1, + offset: cubeUVOffset, + format: 'float32x2', + }, + ], + }, + ], + }, + fragment: { + module: device.createShaderModule({ + code: vertexPositionColorWGSL, + }), + entryPoint: "main", + targets: [ + { + format: 'rgba8unorm', + }, + ], + }, + primitive: { + topology: 'triangle-list', + + // Backface culling since the cube is solid piece of geometry. + // Faces pointing away from the camera will be occluded by faces + // pointing toward the camera. + cullMode: 'back', + }, + + // Enable depth testing so that the fragment closest to the camera + // is rendered in front. + depthStencil: { + depthWriteEnabled: true, + depthCompare: 'less', + format: 'depth24plus', + }, +}); + +const depthTexture = device.createTexture({ + size: { width, height }, + format: 'depth24plus', + usage: 16,//GPUTextureUsage.RENDER_ATTACHMENT, +}); + +const uniformBufferSize = 4 * 16; // 4x4 matrix +const uniformBuffer = device.createBuffer({ + size: uniformBufferSize, + usage: 72,//GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + mappedAtCreation: false, +}); +const uniformBindGroup = device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [ + { + binding: 0, + buffer: uniformBuffer, + offset: 0, + size: uniformBufferSize, + }, + ], +}); + +const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ + { + view: undefined, // Assigned later + + clearValue: [0.5, 0.5, 0.5, 1.0], + loadOp: 'clear', + storeOp: 'store', + }, + ], + depthStencilAttachment: { + view: depthTexture.createView(), + + depthClearValue: 1.0, + depthLoadOp: 'clear', + depthStoreOp: 'store', + }, +}; + +const aspect = width / height; +const projectionMatrix = mat4.perspective((2 * Math.PI) / 5, aspect, 1, 100.0); +const modelViewProjectionMatrix = mat4.create(); + +function getTransformationMatrix() { + const viewMatrix = mat4.identity(); + mat4.translate(viewMatrix, vec3.fromValues(0, 0, -4), viewMatrix); + const now = Date.now() / 1000; + mat4.rotate( + viewMatrix, + vec3.fromValues(Math.sin(now), Math.cos(now), 0), + 1, + viewMatrix + ); + + mat4.multiply(projectionMatrix, viewMatrix, modelViewProjectionMatrix); + + return modelViewProjectionMatrix as Float32Array; +} + +async function frame() { + const transformationMatrix = getTransformationMatrix(); + device.queue.writeBuffer( + uniformBuffer, + 0, + transformationMatrix.buffer, + 0, + transformationMatrix.byteLength + ); + + renderPassDescriptor.colorAttachments[0].view = context + .getCurrentTexture() + .createView(); + + const commandEncoder = device.createCommandEncoder(); + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + //passEncoder.pushDebugGroup("mygroupmarker"); + passEncoder.setPipeline(pipeline); + passEncoder.setBindGroup(0, uniformBindGroup); + passEncoder.setVertexBuffer(0, verticesBuffer, 0, cubeVertexArray.byteLength); + passEncoder.draw(cubeVertexCount); + //passEncoder.popDebugGroup(); + passEncoder.end(); + device.queue.submit([commandEncoder.finish()]); + await device.queue.onSubmittedWorkDone(); + console.log("DONE!"); + //requestAnimationFrame(frame); +} +requestAnimationFrame(frame); +}; \ No newline at end of file diff --git a/example/src/Examples/Breathe/demo1/demo4.ts b/example/src/Examples/Breathe/demo1/demo4.ts new file mode 100644 index 0000000000..27700586cc --- /dev/null +++ b/example/src/Examples/Breathe/demo1/demo4.ts @@ -0,0 +1,177 @@ +import { mat4, vec3 } from "wgpu-matrix"; +import { Dimensions } from "react-native"; + +import { + cubeVertexArray, + cubeVertexSize, + cubeUVOffset, + cubePositionOffset, + cubeVertexCount, +} from "./cube"; +import { basicVertWGSL, vertexPositionColorWGSL } from "./shaders"; + +const { width, height } = Dimensions.get("window"); +const presentationFormat = "rgba8unorm"; +const aspect = width / height; + +export const demo4 = async (device: GPUDevice, context: GPUCanvasContext) => { + // Create a vertex buffer from the cube data. + + // Create a vertex buffer from the cube data. + const verticesBuffer = device.createBuffer({ + size: cubeVertexArray.byteLength, + usage: GPUBufferUsage.VERTEX, + mappedAtCreation: true, + }); + new Float32Array(verticesBuffer.getMappedRange()).set(cubeVertexArray); + verticesBuffer.unmap(); + + const pipeline = device.createRenderPipeline({ + layout: "auto", + vertex: { + module: device.createShaderModule({ + code: basicVertWGSL, + }), + entryPoint: "main", + buffers: [ + { + arrayStride: cubeVertexSize, + attributes: [ + { + // position + shaderLocation: 0, + offset: cubePositionOffset, + format: "float32x4", + }, + { + // uv + shaderLocation: 1, + offset: cubeUVOffset, + format: "float32x2", + }, + ], + }, + ], + }, + fragment: { + module: device.createShaderModule({ + code: vertexPositionColorWGSL, + }), + entryPoint: "main", + targets: [ + { + format: presentationFormat, + }, + ], + }, + primitive: { + topology: "triangle-list", + + // Backface culling since the cube is solid piece of geometry. + // Faces pointing away from the camera will be occluded by faces + // pointing toward the camera. + cullMode: "back", + }, + + // Enable depth testing so that the fragment closest to the camera + // is rendered in front. + depthStencil: { + depthWriteEnabled: true, + depthCompare: "less", + format: "depth24plus", + }, + }); + + const depthTexture = device.createTexture({ + size: { width, height }, + format: "depth24plus", + usage: GPUTextureUsage.RENDER_ATTACHMENT, + }); + + const uniformBufferSize = 4 * 16; // 4x4 matrix + const uniformBuffer = device.createBuffer({ + size: uniformBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + }); + + const uniformBindGroup = device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [ + { + binding: 0, + resource: { + buffer: uniformBuffer, + }, + }, + ], + }); + + const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ + { + view: undefined, // Assigned later + + clearValue: [0.5, 0.5, 0.5, 1.0], + loadOp: "clear", + storeOp: "store", + }, + ], + depthStencilAttachment: { + view: depthTexture.createView(), + + depthClearValue: 1.0, + depthLoadOp: "clear", + depthStoreOp: "store", + }, + }; + + const projectionMatrix = mat4.perspective( + (2 * Math.PI) / 5, + aspect, + 1, + 100.0 + ); + const modelViewProjectionMatrix = mat4.create(); + + function getTransformationMatrix() { + const viewMatrix = mat4.identity(); + mat4.translate(viewMatrix, vec3.fromValues(0, 0, -4), viewMatrix); + const now = Date.now() / 1000; + mat4.rotate( + viewMatrix, + vec3.fromValues(Math.sin(now), Math.cos(now), 0), + 1, + viewMatrix + ); + + mat4.multiply(projectionMatrix, viewMatrix, modelViewProjectionMatrix); + + return modelViewProjectionMatrix as Float32Array; + } + + function frame() { + const transformationMatrix = getTransformationMatrix(); + device.queue.writeBuffer( + uniformBuffer, + 0, + transformationMatrix.buffer, + transformationMatrix.byteOffset, + transformationMatrix.byteLength + ); + renderPassDescriptor.colorAttachments[0].view = context + .getCurrentTexture() + .createView(); + + const commandEncoder = device.createCommandEncoder(); + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + passEncoder.setPipeline(pipeline); + passEncoder.setBindGroup(0, uniformBindGroup); + passEncoder.setVertexBuffer(0, verticesBuffer); + passEncoder.draw(cubeVertexCount); + passEncoder.end(); + device.queue.submit([commandEncoder.finish()]); + context.present(); + requestAnimationFrame(frame); + } + requestAnimationFrame(frame); +}; diff --git a/example/src/Examples/Breathe/demo1/demo5.ts b/example/src/Examples/Breathe/demo1/demo5.ts new file mode 100644 index 0000000000..36d66bc2bc --- /dev/null +++ b/example/src/Examples/Breathe/demo1/demo5.ts @@ -0,0 +1,222 @@ +import { mat4, vec3 } from "wgpu-matrix"; +import { Dimensions } from "react-native"; + +import { + cubeVertexArray, + cubeVertexSize, + cubeUVOffset, + cubePositionOffset, + cubeVertexCount, +} from "./cube"; +import { instancedVertWGSL, vertexPositionColorWGSL } from "./shaders"; + +const { width, height } = Dimensions.get("window"); + +export const demo5 = async (device: GPUDevice, context: GPUCanvasContext) => { + // Create a vertex buffer from the cube data. + const verticesBuffer = device.createBuffer({ + size: cubeVertexArray.byteLength, + usage: GPUBufferUsage.VERTEX, + mappedAtCreation: true, + }); + new Float32Array(verticesBuffer.getMappedRange()).set(cubeVertexArray); + verticesBuffer.unmap(); + + const pipeline = device.createRenderPipeline({ + layout: "auto", + vertex: { + module: device.createShaderModule({ + code: instancedVertWGSL, + }), + entryPoint: "main", + buffers: [ + { + arrayStride: cubeVertexSize, + attributes: [ + { + // position + shaderLocation: 0, + offset: cubePositionOffset, + format: "float32x4", + }, + { + // uv + shaderLocation: 1, + offset: cubeUVOffset, + format: "float32x2", + }, + ], + }, + ], + }, + fragment: { + module: device.createShaderModule({ + code: vertexPositionColorWGSL, + }), + entryPoint: "main", + targets: [ + { + format: "rgba8unorm", + }, + ], + }, + primitive: { + topology: "triangle-list", + + // Backface culling since the cube is solid piece of geometry. + // Faces pointing away from the camera will be occluded by faces + // pointing toward the camera. + cullMode: "back", + }, + + // Enable depth testing so that the fragment closest to the camera + // is rendered in front. + // depthStencil: { + // depthWriteEnabled: true, + // depthCompare: 'less', + // format: 'depth24plus', + // }, + }); + + // const depthTexture = device.createTexture({ + // size: { width, height }, + // format: 'depth24plus', + // usage: GPUTextureUsage.RENDER_ATTACHMENT, + // }); + + const xCount = 4; + const yCount = 4; + const numInstances = xCount * yCount; + const matrixFloatCount = 16; // 4x4 matrix + const matrixSize = 4 * matrixFloatCount; + const uniformBufferSize = numInstances * matrixSize; + + // Allocate a buffer large enough to hold transforms for every + // instance. + const uniformBuffer = device.createBuffer({ + size: uniformBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + }); + + const uniformBindGroup = device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [ + { + binding: 0, + resource: { + buffer: uniformBuffer, + }, + }, + ], + }); + + const aspect = width / height; + const projectionMatrix = mat4.perspective( + (2 * Math.PI) / 5, + aspect, + 1, + 100.0 + ); + + type Mat4 = mat4.default; + const modelMatrices = new Array(numInstances); + const mvpMatricesData = new Float32Array(matrixFloatCount * numInstances); + + const step = 4.0; + + // Initialize the matrix data for every instance. + let m = 0; + for (let x = 0; x < xCount; x++) { + for (let y = 0; y < yCount; y++) { + modelMatrices[m] = mat4.translation( + vec3.fromValues( + step * (x - xCount / 2 + 0.5), + step * (y - yCount / 2 + 0.5), + 0 + ) + ); + m++; + } + } + + const viewMatrix = mat4.translation(vec3.fromValues(0, 0, -12)); + + const tmpMat4 = mat4.create(); + + // Update the transformation matrix data for each instance. + function updateTransformationMatrix() { + const now = Date.now() / 1000; + + let m = 0, + i = 0; + for (let x = 0; x < xCount; x++) { + for (let y = 0; y < yCount; y++) { + mat4.rotate( + modelMatrices[i], + vec3.fromValues( + Math.sin((x + 0.5) * now), + Math.cos((y + 0.5) * now), + 0 + ), + 1, + tmpMat4 + ); + + mat4.multiply(viewMatrix, tmpMat4, tmpMat4); + mat4.multiply(projectionMatrix, tmpMat4, tmpMat4); + + mvpMatricesData.set(tmpMat4, m); + + i++; + m += matrixFloatCount; + } + } + } + + const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ + { + view: undefined, // Assigned later + + clearValue: [0.5, 0.5, 0.5, 1.0], + loadOp: "clear", + storeOp: "store", + }, + ], + // depthStencilAttachment: { + // view: depthTexture.createView(), + + // depthClearValue: 1.0, + // depthLoadOp: 'clear', + // depthStoreOp: 'store', + // }, + }; + + function frame() { + // Update the matrix data. + updateTransformationMatrix(); + device.queue.writeBuffer( + uniformBuffer, + 0, + mvpMatricesData.buffer, + mvpMatricesData.byteOffset, + mvpMatricesData.byteLength + ); + + renderPassDescriptor.colorAttachments[0].view = context + .getCurrentTexture() + .createView(); + + const commandEncoder = device.createCommandEncoder(); + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + passEncoder.setPipeline(pipeline); + passEncoder.setBindGroup(0, uniformBindGroup); + passEncoder.setVertexBuffer(0, verticesBuffer); + passEncoder.draw(cubeVertexCount, numInstances, 0, 0); + passEncoder.end(); + device.queue.submit([commandEncoder.finish()]); + context.present(); + requestAnimationFrame(frame); + } + requestAnimationFrame(frame); +}; diff --git a/example/src/Examples/Breathe/demo1/demo7.ts b/example/src/Examples/Breathe/demo1/demo7.ts new file mode 100644 index 0000000000..b782cc0ce7 --- /dev/null +++ b/example/src/Examples/Breathe/demo1/demo7.ts @@ -0,0 +1,194 @@ +import { Dimensions } from "react-native"; + +const { width, height } = Dimensions.get("window"); + +export class Bitmap { + constructor( + public data: Uint8Array, + public width: number, + public height: number + ) { + this.flipYAxis(); + } + flipYAxis(): void { + const rowLength = this.width * 4; // 4 bytes per pixel (RGBA8) + const tempRow = new Uint8Array(rowLength); + + for (let y = 0; y < this.height / 2; y++) { + const topRowIndex = y * rowLength; + const bottomRowIndex = (this.height - y - 1) * rowLength; + + // Swap rows + tempRow.set(this.data.subarray(topRowIndex, topRowIndex + rowLength)); + this.data.copyWithin( + topRowIndex, + bottomRowIndex, + bottomRowIndex + rowLength + ); + this.data.set(tempRow, bottomRowIndex); + } + } +} + +export const demo7 = async ( + device: GPUDevice, + context: GPUCanvasContext, + img: Bitmap +) => { + const presentationFormat = "rgba8unorm"; + + // First Matrix + + const rows1 = 512; + const columns1 = 512; + const firstMatrix = new Float32Array(rows1 * columns1 + 2); + firstMatrix[0] = rows1; + firstMatrix[1] = columns1; + for (let i = 2; i < firstMatrix.length; i++) { + firstMatrix[i] = Math.random(); + } + + const gpuBufferFirstMatrix = device.createBuffer({ + mappedAtCreation: true, + size: firstMatrix.byteLength, + usage: GPUBufferUsage.STORAGE, + }); + const arrayBufferFirstMatrix = gpuBufferFirstMatrix.getMappedRange(); + new Float32Array(arrayBufferFirstMatrix).set(firstMatrix); + gpuBufferFirstMatrix.unmap(); + + // Second Matrix + + const secondMatrix = new Float32Array(rows1 * columns1 + 2); + secondMatrix[0] = rows1; + secondMatrix[1] = columns1; + for (let i = 2; i < secondMatrix.length; i++) { + secondMatrix[i] = Math.random(); + } + + const gpuBufferSecondMatrix = device.createBuffer({ + mappedAtCreation: true, + size: secondMatrix.byteLength, + usage: GPUBufferUsage.STORAGE, + }); + const arrayBufferSecondMatrix = gpuBufferSecondMatrix.getMappedRange(); + new Float32Array(arrayBufferSecondMatrix).set(secondMatrix); + gpuBufferSecondMatrix.unmap(); + + // Result Matrix + + const resultMatrixBufferSize = + Float32Array.BYTES_PER_ELEMENT * (2 + firstMatrix[0] * secondMatrix[1]); + const resultMatrixBuffer = device.createBuffer({ + size: resultMatrixBufferSize, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC, + }); + + // Compute shader code + + const shaderModule = device.createShaderModule({ + code: ` + struct Matrix { + size : vec2, + numbers: array, + } + + @group(0) @binding(0) var firstMatrix : Matrix; + @group(0) @binding(1) var secondMatrix : Matrix; + @group(0) @binding(2) var resultMatrix : Matrix; + + @compute @workgroup_size(8, 8) + fn main(@builtin(global_invocation_id) global_id : vec3) { + // Guard against out-of-bounds work group sizes + if (global_id.x >= u32(firstMatrix.size.x) || global_id.y >= u32(secondMatrix.size.y)) { + return; + } + + resultMatrix.size = vec2(firstMatrix.size.x, secondMatrix.size.y); + + let resultCell = vec2(global_id.x, global_id.y); + var result = 0.0; + for (var i = 0u; i < u32(firstMatrix.size.y); i = i + 1u) { + let a = i + resultCell.x * u32(firstMatrix.size.y); + let b = resultCell.y + i * u32(secondMatrix.size.y); + result = result + firstMatrix.numbers[a] * secondMatrix.numbers[b]; + } + + let index = resultCell.y + resultCell.x * u32(secondMatrix.size.y); + resultMatrix.numbers[index] = result; + } + `, + }); + + // Pipeline setup + + const computePipeline = device.createComputePipeline({ + layout: "auto", + compute: { + module: shaderModule, + entryPoint: "main", + }, + }); + + // Bind group + + const bindGroup = device.createBindGroup({ + layout: computePipeline.getBindGroupLayout(0 /* index */), + entries: [ + { + binding: 0, + resource: { + buffer: gpuBufferFirstMatrix, + }, + }, + { + binding: 1, + resource: { + buffer: gpuBufferSecondMatrix, + }, + }, + { + binding: 2, + resource: { + buffer: resultMatrixBuffer, + }, + }, + ], + }); + + // Commands submission + + const commandEncoder = device.createCommandEncoder(); + + const passEncoder = commandEncoder.beginComputePass(); + passEncoder.setPipeline(computePipeline); + passEncoder.setBindGroup(0, bindGroup); + const workgroupCountX = Math.ceil(rows1 / 8); + const workgroupCountY = Math.ceil(columns2 / 8); + passEncoder.dispatchWorkgroups(workgroupCountX, workgroupCountY); + passEncoder.end(); + + // Get a GPU buffer for reading in an unmapped state. + const gpuReadBuffer = device.createBuffer({ + size: resultMatrixBufferSize, + usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ, + }); + + // Encode commands for copying buffer to buffer. + commandEncoder.copyBufferToBuffer( + resultMatrixBuffer /* source buffer */, + 0 /* source offset */, + gpuReadBuffer /* destination buffer */, + 0 /* destination offset */, + resultMatrixBufferSize /* size */ + ); + + // Submit GPU commands. + const gpuCommands = commandEncoder.finish(); + device.queue.submit([gpuCommands]); + + // Read buffer. + await gpuReadBuffer.mapAsync(GPUMapMode.READ); + const arrayBuffer = gpuReadBuffer.getMappedRange(); + console.log(new Float32Array(arrayBuffer)); +}; diff --git a/example/src/Examples/Breathe/demo1/main.ts b/example/src/Examples/Breathe/demo1/main.ts index e53d1ee12f..1bbae5a160 100644 --- a/example/src/Examples/Breathe/demo1/main.ts +++ b/example/src/Examples/Breathe/demo1/main.ts @@ -1,4 +1,5 @@ -import { mat4, vec3 } from 'wgpu-matrix'; +import { mat4, vec3 } from "wgpu-matrix"; +import { Dimensions } from "react-native"; import { cubeVertexArray, @@ -6,205 +7,173 @@ import { cubeUVOffset, cubePositionOffset, cubeVertexCount, -} from './cube'; - -import {basicVertWGSL, vertexPositionColorWGSL} from './shaders'; -import { gpu } from '@shopify/react-native-skia'; -import { Dimensions } from 'react-native'; - -const GPUBufferUsage = { - None: 0x00000000, - MapRead: 0x00000001, - MapWrite: 0x00000002, - CopyStr: 0x00000004, - COPY_DST: 0x00000008, - Index: 0x00000010, - VERTEX: 0x00000020, - UNIFORM: 0x00000040, - Storage: 0x00000080, - Indirect: 0x00000100, - QueryResolve: 0x00000200, - Force32: 0x7FFFFFFF -}; - -const GPUTextureUsage = { - RENDER_ATTACHMENT: 0x00000010, -} - -const {width, height} = Dimensions.get("window"); - -export const demo1 = async (context: GPUCanvasContext) => { - const adapter = await gpu.requestAdapter(); - const device = await adapter!.requestDevice(); - const presentationFormat = 'rgba8unorm'; -context.configure({ - device, - format: presentationFormat, - alphaMode: 'premultiplied', -}); - -// Create a vertex buffer from the cube data. -const verticesBuffer = device.createBuffer({ - size: cubeVertexArray.byteLength, - usage: GPUBufferUsage.VERTEX, - mappedAtCreation: true, -}); - -const mappedRange = verticesBuffer.getMappedRange(0, cubeVertexArray.byteLength); -new Float32Array(mappedRange).set(cubeVertexArray); -verticesBuffer.unmap(); - -const pipeline = device.createRenderPipeline({ - layout: 'auto', - vertex: { - module: device.createShaderModule({ - code: basicVertWGSL, - }), - entryPoint: "main", - buffers: [ +} from "./cube"; +import { basicVertWGSL, vertexPositionColorWGSL } from "./shaders"; + +const { width, height } = Dimensions.get("window"); + +export const demo1 = async (device: GPUDevice, context: GPUCanvasContext) => { + // Create a vertex buffer from the cube data. + const verticesBuffer = device.createBuffer({ + size: cubeVertexArray.byteLength, + usage: GPUBufferUsage.VERTEX, + mappedAtCreation: true, + }); + + new Float32Array( + verticesBuffer.getMappedRange(0, cubeVertexArray.byteLength) + ).set(cubeVertexArray); + verticesBuffer.unmap(); + const pipeline = device.createRenderPipeline({ + layout: "auto", + vertex: { + module: device.createShaderModule({ + code: basicVertWGSL, + }), + entryPoint: "main", + buffers: [ + { + arrayStride: cubeVertexSize, + attributes: [ + { + // position + shaderLocation: 0, + offset: cubePositionOffset, + format: "float32x4", + }, + { + // uv + shaderLocation: 1, + offset: cubeUVOffset, + format: "float32x2", + }, + ], + }, + ], + }, + fragment: { + module: device.createShaderModule({ + code: vertexPositionColorWGSL, + }), + entryPoint: "main", + targets: [ + { + format: "rgba8unorm", + }, + ], + }, + // depthStencil: { + // depthWriteEnabled: true, + // depthCompare: "less", + // format: "depth24plus", + // }, + primitive: { + topology: "triangle-list", + cullMode: "back", + }, + }); + + // const depthTexture = device.createTexture({ + // size: { width, height }, + // format: "depth24plus", + // usage: GPUTextureUsage.RENDER_ATTACHMENT, + // }); + + const uniformBufferSize = 4 * 16; // 4x4 matrix + const uniformBuffer = device.createBuffer({ + size: uniformBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + mappedAtCreation: false, + }); + const uniformBindGroup = device.createBindGroup({ + layout: pipeline.getBindGroupLayout(0), + entries: [ { - arrayStride: cubeVertexSize, - attributes: [ - { - // position - shaderLocation: 0, - offset: cubePositionOffset, - format: 'float32x4', - }, - { - // uv - shaderLocation: 1, - offset: cubeUVOffset, - format: 'float32x2', - }, - ], + binding: 0, + buffer: uniformBuffer, + offset: 0, + size: uniformBufferSize, }, ], - }, - fragment: { - module: device.createShaderModule({ - code: vertexPositionColorWGSL, - }), - entryPoint: "main", - targets: [ + }); + + const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ { - format: presentationFormat, + view: undefined, // Assigned later + + clearValue: [0.5, 0.5, 0.5, 1.0], + loadOp: "clear", + storeOp: "store", }, ], - }, - primitive: { - topology: 'triangle-list', - - // Backface culling since the cube is solid piece of geometry. - // Faces pointing away from the camera will be occluded by faces - // pointing toward the camera. - cullMode: 'back', - }, - - // Enable depth testing so that the fragment closest to the camera - // is rendered in front. - depthStencil: { - depthWriteEnabled: true, - depthCompare: 'less', - format: 'depth24plus', - }, -}); - -const depthTexture = device.createTexture({ - size: { width, height }, - format: 'depth24plus', - usage: GPUTextureUsage.RENDER_ATTACHMENT, -}); - - -const uniformBufferSize = 4 * 16; // 4x4 matrix -const uniformBuffer = device.createBuffer({ - size: uniformBufferSize, - usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, - mappedAtCreation: false -}); - -console.log(pipeline.getBindGroupLayout(0)) - -const uniformBindGroup = device.createBindGroup({ - layout: pipeline.getBindGroupLayout(0), - entries: [ - { - binding: 0, - buffer: uniformBuffer, - }, - ], -}); - - - -const renderPassDescriptor: GPURenderPassDescriptor = { - colorAttachments: [ - { - view: context - .getCurrentTexture() - .createView(), // Assigned later - - clearValue: [0.5, 0.5, 0.5, 1.0], - loadOp: 'clear', - storeOp: 'store', - }, - ], - depthStencilAttachment: { - view: depthTexture.createView(), - - depthClearValue: 1.0, - depthLoadOp: 'clear', - depthStoreOp: 'store', - }, -}; - -console.log(renderPassDescriptor) - -const aspect = width / height; -const projectionMatrix = mat4.perspective((2 * Math.PI) / 5, aspect, 1, 100.0); -const modelViewProjectionMatrix = mat4.create(); - -function getTransformationMatrix() { - const viewMatrix = mat4.identity(); - mat4.translate(viewMatrix, vec3.fromValues(0, 0, -4), viewMatrix); - const now = Date.now() / 1000; - mat4.rotate( - viewMatrix, - vec3.fromValues(Math.sin(now), Math.cos(now), 0), + // depthStencilAttachment: { + // view: depthTexture.createView(), + + // depthClearValue: 1.0, + // depthLoadOp: 'clear', + // depthStoreOp: 'store', + // }, + }; + + const aspect = width / height; + const projectionMatrix = mat4.perspective( + (2 * Math.PI) / 5, + aspect, 1, - viewMatrix - ); - - mat4.multiply(projectionMatrix, viewMatrix, modelViewProjectionMatrix); - - return modelViewProjectionMatrix as Float32Array; -} - -function frame() { - const transformationMatrix = getTransformationMatrix(); - device.queue.writeBuffer( - uniformBuffer, - 0, - transformationMatrix.buffer, - transformationMatrix.byteOffset, - transformationMatrix.byteLength + 100.0 ); - // renderPassDescriptor.colorAttachments[0].view = context - // .getCurrentTexture() - // .createView(); - - const commandEncoder = device.createCommandEncoder(); - const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); - passEncoder.setPipeline(pipeline); - passEncoder.setBindGroup(0, uniformBindGroup); - passEncoder.setVertexBuffer(0, verticesBuffer); - passEncoder.draw(cubeVertexCount); - passEncoder.end(); - device.queue.submit([commandEncoder.finish()]); - + const modelViewProjectionMatrix = mat4.create(); + + function getTransformationMatrix() { + const viewMatrix = mat4.identity(); + mat4.translate(viewMatrix, vec3.fromValues(0, 0, -4), viewMatrix); + const now = Date.now() / 1000; + mat4.rotate( + viewMatrix, + vec3.fromValues(Math.sin(now), Math.cos(now), 0), + 1, + viewMatrix + ); + + mat4.multiply(projectionMatrix, viewMatrix, modelViewProjectionMatrix); + + return modelViewProjectionMatrix as Float32Array; + } + + function frame() { + const transformationMatrix = getTransformationMatrix(); + device.queue.writeBuffer( + uniformBuffer, + 0, + transformationMatrix.buffer, + 0, + transformationMatrix.byteLength + ); + + renderPassDescriptor.colorAttachments[0].view = context + .getCurrentTexture() + .createView(); + + const commandEncoder = device.createCommandEncoder(); + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + //passEncoder.pushDebugGroup("mygroupmarker"); + passEncoder.setPipeline(pipeline); + passEncoder.setBindGroup(0, uniformBindGroup); + passEncoder.setVertexBuffer( + 0, + verticesBuffer, + 0, + cubeVertexArray.byteLength + ); + passEncoder.draw(cubeVertexCount); + //passEncoder.popDebugGroup(); + passEncoder.end(); + device.queue.submit([commandEncoder.finish()]); + //await device.queue.onSubmittedWorkDone(); + context.present(); + console.log("DONE!"); + requestAnimationFrame(frame); + } requestAnimationFrame(frame); -} -requestAnimationFrame(frame); - -}; \ No newline at end of file +}; diff --git a/example/src/Examples/Breathe/demo1/shaders.ts b/example/src/Examples/Breathe/demo1/shaders.ts index ee8ad26a64..fb456d2698 100644 --- a/example/src/Examples/Breathe/demo1/shaders.ts +++ b/example/src/Examples/Breathe/demo1/shaders.ts @@ -27,4 +27,32 @@ fn main( output.fragUV = uv; output.fragPosition = 0.5 * (position + vec4(1.0, 1.0, 1.0, 1.0)); return output; -}`; \ No newline at end of file +} +`; + +export const instancedVertWGSL = ` +struct Uniforms { + modelViewProjectionMatrix : array, +} + +@binding(0) @group(0) var uniforms : Uniforms; + +struct VertexOutput { + @builtin(position) Position : vec4f, + @location(0) fragUV : vec2f, + @location(1) fragPosition: vec4f, +} + +@vertex +fn main( + @builtin(instance_index) instanceIdx : u32, + @location(0) position : vec4f, + @location(1) uv : vec2f +) -> VertexOutput { + var output : VertexOutput; + output.Position = uniforms.modelViewProjectionMatrix[instanceIdx] * position; + output.fragUV = uv; + output.fragPosition = 0.5 * (position + vec4(1.0)); + return output; +} +`; diff --git a/example/src/Examples/Breathe/demo2.ts b/example/src/Examples/Breathe/demo2.ts new file mode 100644 index 0000000000..6b5b0d6eb5 --- /dev/null +++ b/example/src/Examples/Breathe/demo2.ts @@ -0,0 +1,69 @@ +import { gpu } from "@shopify/react-native-skia"; + +const triangleVertWGSL = `@vertex +fn main( + @builtin(vertex_index) VertexIndex : u32 +) -> @builtin(position) vec4f { + var pos = array( + vec2(0.0, 0.5), + vec2(-0.5, -0.5), + vec2(0.5, -0.5) + ); + + return vec4f(pos[VertexIndex], 0.0, 1.0); +} +`; + +const redFragWGSL = `@fragment +fn main() -> @location(0) vec4f { + return vec4(0.3, 0.6, 1.0, 1.0); +}`; + +export const demo2 = async (device, context: GPUCanvasContext) => { + const presentationFormat = "rgba8unorm"; + + const pipeline = device.createRenderPipeline({ + layout: "auto", + vertex: { + module: device.createShaderModule({ + code: triangleVertWGSL, + }), + entryPoint: "main", + }, + fragment: { + module: device.createShaderModule({ + code: redFragWGSL, + }), + entryPoint: "main", + targets: [ + { + format: presentationFormat, + }, + ], + }, + primitive: { + topology: "triangle-list", + }, + }); + + const commandEncoder = device.createCommandEncoder(); + const textureView = context.getCurrentTexture().createView(); + + const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ + { + view: textureView, + clearValue: [1.0, 0.0, 1.0, 1], + loadOp: "clear", + storeOp: "store", + }, + ], + }; + + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + passEncoder.setPipeline(pipeline); + passEncoder.draw(3); + passEncoder.end(); + + device.queue.submit([commandEncoder.finish()]); +}; diff --git a/example/src/Examples/Breathe/demo3.tsx b/example/src/Examples/Breathe/demo3.tsx new file mode 100644 index 0000000000..4fc9a392cf --- /dev/null +++ b/example/src/Examples/Breathe/demo3.tsx @@ -0,0 +1,24 @@ +export const demo3 = async(device: GPUDevice, context: GPUCanvasContext) => { + // Create an array of data + const data = new Uint32Array([1.0, 2.0, 3.0, 4.0]); + + // Create a GPU buffer and store data + const gpuBuffer = device.createBuffer({ + size: data.byteLength, + usage: 9, //GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST + mappedAtCreation: false + }); + + + // Copy data to the GPU buffer + device.queue.writeBuffer(gpuBuffer, 0, data.buffer, 0, data.byteLength); + + await gpuBuffer.mapAsync(1, 0, data.byteLength); // GPUMapMode.READ + console.log("mapAsync done"); + const arrayBuffer = gpuBuffer.getMappedRange(0, data.byteLength); + const readData = new Float32Array(arrayBuffer); + + // // Output the read data + console.log('Data read from the buffer:', readData); + gpuBuffer.unmap(); + }; \ No newline at end of file diff --git a/example/src/Examples/Breathe/demo6/main.ts b/example/src/Examples/Breathe/demo6/main.ts new file mode 100644 index 0000000000..568ffd1b5b --- /dev/null +++ b/example/src/Examples/Breathe/demo6/main.ts @@ -0,0 +1,448 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable camelcase */ +import { mat4, vec3 } from "wgpu-matrix"; +import { Dimensions } from "react-native"; +import type { SharedValue } from "react-native-reanimated"; + +import type { Bitmap } from "../demo1/demo7"; + +import { probabilityMapWGSL } from "./probabilityMap"; +import { particleWGSL } from "./particle"; + +const { width, height } = Dimensions.get("window"); +const canvas = { width, height }; +const presentationFormat = "rgba8unorm"; + +export const demo6 = ( + device: GPUDevice, + context: GPUCanvasContext, + imageBitmap: Bitmap, + rotateX: SharedValue, + rotateY: SharedValue +) => { + const numParticles = 10000; + const particlePositionOffset = 0; + const particleColorOffset = 4 * 4; + const particleInstanceByteSize = + 3 * 4 + // position + 1 * 4 + // lifetime + 4 * 4 + // color + 3 * 4 + // velocity + 1 * 4 + // padding + 0; + + context.configure({ + device, + format: presentationFormat, + alphaMode: "premultiplied", + }); + + const particlesBuffer = device.createBuffer({ + size: numParticles * particleInstanceByteSize, + usage: GPUBufferUsage.VERTEX | GPUBufferUsage.STORAGE, + }); + + const renderPipeline = device.createRenderPipeline({ + layout: "auto", + vertex: { + module: device.createShaderModule({ + code: particleWGSL, + }), + entryPoint: "vs_main", + buffers: [ + { + // instanced particles buffer + arrayStride: particleInstanceByteSize, + stepMode: "instance", + attributes: [ + { + // position + shaderLocation: 0, + offset: particlePositionOffset, + format: "float32x3", + }, + { + // color + shaderLocation: 1, + offset: particleColorOffset, + format: "float32x4", + }, + ], + }, + { + // quad vertex buffer + arrayStride: 2 * 4, // vec2f + stepMode: "vertex", + attributes: [ + { + // vertex positions + shaderLocation: 2, + offset: 0, + format: "float32x2", + }, + ], + }, + ], + }, + fragment: { + module: device.createShaderModule({ + code: particleWGSL, + }), + entryPoint: "fs_main", + targets: [ + { + format: presentationFormat, + blend: { + color: { + srcFactor: "src-alpha", + dstFactor: "one", + operation: "add", + }, + alpha: { + srcFactor: "zero", + dstFactor: "one", + operation: "add", + }, + }, + }, + ], + }, + primitive: { + topology: "triangle-list", + }, + + // depthStencil: { + // depthWriteEnabled: false, + // depthCompare: 'less', + // format: 'depth24plus', + // }, + }); + + // const depthTexture = device.createTexture({ + // size: [canvas.width, canvas.height], + // format: 'depth24plus', + // usage: GPUTextureUsage.RENDER_ATTACHMENT, + // }); + + const uniformBufferSize = + 4 * 4 * 4 + // modelViewProjectionMatrix : mat4x4f + 3 * 4 + // right : vec3f + 4 + // padding + 3 * 4 + // up : vec3f + 4 + // padding + 0; + const uniformBuffer = device.createBuffer({ + size: uniformBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + }); + + const uniformBindGroup = device.createBindGroup({ + layout: renderPipeline.getBindGroupLayout(0), + entries: [ + { + binding: 0, + resource: { + buffer: uniformBuffer, + }, + }, + ], + }); + + const renderPassDescriptor: GPURenderPassDescriptor = { + colorAttachments: [ + { + view: undefined, // Assigned later + clearValue: [0, 0, 0, 1], + loadOp: "clear", + storeOp: "store", + }, + ], + // depthStencilAttachment: { + // view: depthTexture.createView(), + + // depthClearValue: 1.0, + // depthLoadOp: 'clear', + // depthStoreOp: 'store', + // }, + }; + + ////////////////////////////////////////////////////////////////////////////// + // Quad vertex buffer + ////////////////////////////////////////////////////////////////////////////// + const quadVertexBuffer = device.createBuffer({ + size: 6 * 2 * 4, // 6x vec2f + usage: GPUBufferUsage.VERTEX, + mappedAtCreation: true, + }); + // prettier-ignore + const vertexData = [ + -1.0, -1.0, +1.0, -1.0, -1.0, +1.0, -1.0, +1.0, +1.0, -1.0, +1.0, +1.0, +]; + new Float32Array(quadVertexBuffer.getMappedRange()).set(vertexData); + quadVertexBuffer.unmap(); + + ////////////////////////////////////////////////////////////////////////////// + // Texture + ////////////////////////////////////////////////////////////////////////////// + let texture: GPUTexture; + let textureWidth = 1; + let textureHeight = 1; + let numMipLevels = 1; + { + // Calculate number of mip levels required to generate the probability map + while ( + textureWidth < imageBitmap.width || + textureHeight < imageBitmap.height + ) { + textureWidth *= 2; + textureHeight *= 2; + numMipLevels++; + } + texture = device.createTexture({ + size: { width: imageBitmap.width, height: imageBitmap.height }, + mipLevelCount: numMipLevels, + format: "rgba8unorm", + usage: + GPUTextureUsage.TEXTURE_BINDING | + GPUTextureUsage.STORAGE_BINDING | + GPUTextureUsage.COPY_DST | + GPUTextureUsage.RENDER_ATTACHMENT, + }); + device.queue.writeTexture( + { texture: texture, mipLevel: 0, origin: { x: 0, y: 0, z: 0 } }, + imageBitmap.data.buffer, + { + offset: 0, + bytesPerRow: 4 * imageBitmap.width, + rowsPerImage: imageBitmap.height, + }, + { width: imageBitmap.width, height: imageBitmap.height } + ); + } + + ////////////////////////////////////////////////////////////////////////////// + // Probability map generation + // The 0'th mip level of texture holds the color data and spawn-probability in + // the alpha channel. The mip levels 1..N are generated to hold spawn + // probabilities up to the top 1x1 mip level. + ////////////////////////////////////////////////////////////////////////////// + { + const probabilityMapImportLevelPipeline = device.createComputePipeline({ + layout: "auto", + compute: { + module: device.createShaderModule({ code: probabilityMapWGSL }), + entryPoint: "import_level", + }, + }); + const probabilityMapExportLevelPipeline = device.createComputePipeline({ + layout: "auto", + compute: { + module: device.createShaderModule({ code: probabilityMapWGSL }), + entryPoint: "export_level", + }, + }); + + const probabilityMapUBOBufferSize = + 1 * 4 + // stride + 3 * 4 + // padding + 0; + const probabilityMapUBOBuffer = device.createBuffer({ + size: probabilityMapUBOBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + }); + const buffer_a = device.createBuffer({ + size: textureWidth * textureHeight * 4, + usage: GPUBufferUsage.STORAGE, + }); + const buffer_b = device.createBuffer({ + size: textureWidth * textureHeight * 4, + usage: GPUBufferUsage.STORAGE, + }); + device.queue.writeBuffer( + probabilityMapUBOBuffer, + 0, + new Int32Array([textureWidth]).buffer + ); + const commandEncoder = device.createCommandEncoder(); + for (let level = 0; level < numMipLevels; level++) { + const levelWidth = textureWidth >> level; + const levelHeight = textureHeight >> level; + const pipeline = + level == 0 + ? probabilityMapImportLevelPipeline.getBindGroupLayout(0) + : probabilityMapExportLevelPipeline.getBindGroupLayout(0); + const probabilityMapBindGroup = device.createBindGroup({ + layout: pipeline, + entries: [ + { + // ubo + binding: 0, + resource: { buffer: probabilityMapUBOBuffer }, + }, + { + // buf_in + binding: 1, + resource: { buffer: level & 1 ? buffer_a : buffer_b }, + }, + { + // buf_out + binding: 2, + resource: { buffer: level & 1 ? buffer_b : buffer_a }, + }, + { + // tex_in / tex_out + binding: 3, + resource: texture.createView({ + format: "rgba8unorm", + dimension: "2d", + baseMipLevel: level, + mipLevelCount: 1, + }), + }, + ], + }); + if (level == 0) { + const passEncoder = commandEncoder.beginComputePass(); + passEncoder.setPipeline(probabilityMapImportLevelPipeline); + passEncoder.setBindGroup(0, probabilityMapBindGroup); + passEncoder.dispatchWorkgroups(Math.ceil(levelWidth / 64), levelHeight); + passEncoder.end(); + } else { + const passEncoder = commandEncoder.beginComputePass(); + passEncoder.setPipeline(probabilityMapExportLevelPipeline); + passEncoder.setBindGroup(0, probabilityMapBindGroup); + passEncoder.dispatchWorkgroups(Math.ceil(levelWidth / 64), levelHeight); + passEncoder.end(); + } + } + device.queue.submit([commandEncoder.finish()]); + } + + ////////////////////////////////////////////////////////////////////////////// + // Simulation compute pipeline + ////////////////////////////////////////////////////////////////////////////// + const simulationParams = { + simulate: true, + deltaTime: 0.04, + }; + + const simulationUBOBufferSize = + 1 * 4 + // deltaTime + 3 * 4 + // padding + 4 * 4 + // seed + 0; + const simulationUBOBuffer = device.createBuffer({ + size: simulationUBOBufferSize, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, + }); + + const computePipeline = device.createComputePipeline({ + layout: "auto", + compute: { + module: device.createShaderModule({ + code: particleWGSL, + }), + entryPoint: "simulate", + }, + }); + const computeBindGroup = device.createBindGroup({ + layout: computePipeline.getBindGroupLayout(0), + entries: [ + { + binding: 0, + resource: { + buffer: simulationUBOBuffer, + }, + }, + { + binding: 1, + resource: { + buffer: particlesBuffer, + offset: 0, + size: numParticles * particleInstanceByteSize, + }, + }, + { + binding: 2, + resource: texture.createView(), + }, + ], + }); + + const aspect = canvas.width / canvas.height; + const projection = mat4.perspective((2 * Math.PI) / 5, aspect, 1, 100.0); + const view = mat4.create(); + const mvp = mat4.create(); + + function frame() { + device.queue.writeBuffer( + simulationUBOBuffer, + 0, + new Float32Array([ + simulationParams.simulate ? simulationParams.deltaTime : 0.0, + 0.0, + 0.0, + 0.0, // padding + Math.random() * 100, + Math.random() * 100, // seed.xy + 1 + Math.random(), + 1 + Math.random(), // seed.zw + ]).buffer + ); + + mat4.identity(view); + mat4.translate(view, vec3.fromValues(0, 0, -3), view); + mat4.rotateX(view, Math.PI + rotateX.value, view); + mat4.rotateY(view, rotateY.value, view); + mat4.multiply(projection, view, mvp); + + // prettier-ignore + device.queue.writeBuffer( + uniformBuffer, + 0, + new Float32Array([ + // modelViewProjectionMatrix + mvp[0], mvp[1], mvp[2], mvp[3], + mvp[4], mvp[5], mvp[6], mvp[7], + mvp[8], mvp[9], mvp[10], mvp[11], + mvp[12], mvp[13], mvp[14], mvp[15], + + view[0], view[4], view[8], // right + + 0, // padding + + view[1], view[5], view[9], // up + + 0, // padding + ]).buffer + ); + const swapChainTexture = context.getCurrentTexture(); + // @ts-expect-error + renderPassDescriptor.colorAttachments[0].view = + swapChainTexture.createView(); + + const commandEncoder = device.createCommandEncoder(); + { + const passEncoder = commandEncoder.beginComputePass(); + passEncoder.setPipeline(computePipeline); + passEncoder.setBindGroup(0, computeBindGroup); + passEncoder.dispatchWorkgroups(Math.ceil(numParticles / 64)); + passEncoder.end(); + } + { + const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); + passEncoder.setPipeline(renderPipeline); + passEncoder.setBindGroup(0, uniformBindGroup); + passEncoder.setVertexBuffer(0, particlesBuffer); + passEncoder.setVertexBuffer(1, quadVertexBuffer); + passEncoder.draw(6, numParticles, 0, 0); + passEncoder.end(); + } + + device.queue.submit([commandEncoder.finish()]); + // @ts-expect-error + context.present(); + requestAnimationFrame(frame); + } + requestAnimationFrame(frame); +}; diff --git a/example/src/Examples/Breathe/demo6/particle.ts b/example/src/Examples/Breathe/demo6/particle.ts new file mode 100644 index 0000000000..7ea7c888dd --- /dev/null +++ b/example/src/Examples/Breathe/demo6/particle.ts @@ -0,0 +1,137 @@ +export const particleWGSL = `//////////////////////////////////////////////////////////////////////////////// +// Utilities +//////////////////////////////////////////////////////////////////////////////// +var rand_seed : vec2f; + +fn init_rand(invocation_id : u32, seed : vec4f) { + rand_seed = seed.xz; + rand_seed = fract(rand_seed * cos(35.456+f32(invocation_id) * seed.yw)); + rand_seed = fract(rand_seed * cos(41.235+f32(invocation_id) * seed.xw)); +} + +fn rand() -> f32 { + rand_seed.x = fract(cos(dot(rand_seed, vec2f(23.14077926, 232.61690225))) * 136.8168); + rand_seed.y = fract(cos(dot(rand_seed, vec2f(54.47856553, 345.84153136))) * 534.7645); + return rand_seed.y; +} + +//////////////////////////////////////////////////////////////////////////////// +// Vertex shader +//////////////////////////////////////////////////////////////////////////////// +struct RenderParams { + modelViewProjectionMatrix : mat4x4f, + right : vec3f, + up : vec3f +} +@binding(0) @group(0) var render_params : RenderParams; + +struct VertexInput { + @location(0) position : vec3f, + @location(1) color : vec4f, + @location(2) quad_pos : vec2f, // -1..+1 +} + +struct VertexOutput { + @builtin(position) position : vec4f, + @location(0) color : vec4f, + @location(1) quad_pos : vec2f, // -1..+1 +} + +@vertex +fn vs_main(in : VertexInput) -> VertexOutput { + var quad_pos = mat2x3f(render_params.right, render_params.up) * in.quad_pos; + var position = in.position + quad_pos * 0.01; + var out : VertexOutput; + out.position = render_params.modelViewProjectionMatrix * vec4f(position, 1.0); + out.color = in.color; + out.quad_pos = in.quad_pos; + return out; +} + +//////////////////////////////////////////////////////////////////////////////// +// Fragment shader +//////////////////////////////////////////////////////////////////////////////// +@fragment +fn fs_main(in : VertexOutput) -> @location(0) vec4f { + var color = in.color; + // Apply a circular particle alpha mask + color.a = color.a * max(1.0 - length(in.quad_pos), 0.0); + return color; +} + +//////////////////////////////////////////////////////////////////////////////// +// Simulation Compute shader +//////////////////////////////////////////////////////////////////////////////// +struct SimulationParams { + deltaTime : f32, + seed : vec4f, +} + +struct Particle { + position : vec3f, + lifetime : f32, + color : vec4f, + velocity : vec3f, +} + +struct Particles { + particles : array, +} + +@binding(0) @group(0) var sim_params : SimulationParams; +@binding(1) @group(0) var data : Particles; +@binding(2) @group(0) var texture : texture_2d; + +@compute @workgroup_size(64) +fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3u) { + let idx = global_invocation_id.x; + + init_rand(idx, sim_params.seed); + + var particle = data.particles[idx]; + + // Apply gravity + particle.velocity.z = particle.velocity.z - sim_params.deltaTime * 0.5; + + // Basic velocity integration + particle.position = particle.position + sim_params.deltaTime * particle.velocity; + + // Age each particle. Fade out before vanishing. + particle.lifetime = particle.lifetime - sim_params.deltaTime; + particle.color.a = smoothstep(0.0, 0.5, particle.lifetime); + + // If the lifetime has gone negative, then the particle is dead and should be + // respawned. + if (particle.lifetime < 0.0) { + // Use the probability map to find where the particle should be spawned. + // Starting with the 1x1 mip level. + var coord : vec2i; + for (var level = u32(textureNumLevels(texture) - 1); level > 0; level--) { + // Load the probability value from the mip-level + // Generate a random number and using the probabilty values, pick the + // next texel in the next largest mip level: + // + // 0.0 probabilites.r probabilites.g probabilites.b 1.0 + // | | | | | + // | TOP-LEFT | TOP-RIGHT | BOTTOM-LEFT | BOTTOM_RIGHT | + // + let probabilites = textureLoad(texture, coord, level); + let value = vec4f(rand()); + let mask = (value >= vec4f(0.0, probabilites.xyz)) & (value < probabilites); + coord = coord * 2; + coord.x = coord.x + select(0, 1, any(mask.yw)); // x y + coord.y = coord.y + select(0, 1, any(mask.zw)); // z w + } + let uv = vec2f(coord) / vec2f(textureDimensions(texture)); + particle.position = vec3f((uv - 0.5) * 3.0 * vec2f(1.0, -1.0), 0.0); + particle.color = textureLoad(texture, coord, 0); + particle.velocity.x = (rand() - 0.5) * 0.1; + particle.velocity.y = (rand() - 0.5) * 0.1; + particle.velocity.z = rand() * 0.3; + particle.lifetime = 0.5 + rand() * 3.0; + } + + // Store the new particle value + data.particles[idx] = particle; +} +`; \ No newline at end of file diff --git a/example/src/Examples/Breathe/demo6/probabilityMap.ts b/example/src/Examples/Breathe/demo6/probabilityMap.ts new file mode 100644 index 0000000000..14493e5b17 --- /dev/null +++ b/example/src/Examples/Breathe/demo6/probabilityMap.ts @@ -0,0 +1,55 @@ +export const probabilityMapWGSL = `struct UBO { + width : u32, +} + +struct Buffer { + weights : array, +} + +@binding(0) @group(0) var ubo : UBO; +@binding(1) @group(0) var buf_in : Buffer; +@binding(2) @group(0) var buf_out : Buffer; +@binding(3) @group(0) var tex_in : texture_2d; +@binding(3) @group(0) var tex_out : texture_storage_2d; + + +//////////////////////////////////////////////////////////////////////////////// +// import_level +// +// Loads the alpha channel from a texel of the source image, and writes it to +// the buf_out.weights. +//////////////////////////////////////////////////////////////////////////////// +@compute @workgroup_size(64) +fn import_level(@builtin(global_invocation_id) coord : vec3u) { + _ = &buf_in; + let offset = coord.x + coord.y * ubo.width; + buf_out.weights[offset] = textureLoad(tex_in, vec2i(coord.xy), 0).w; +} + +//////////////////////////////////////////////////////////////////////////////// +// export_level +// +// Loads 4 f32 weight values from buf_in.weights, and stores summed value into +// buf_out.weights, along with the calculated 'probabilty' vec4 values into the +// mip level of tex_out. See simulate() in particle.wgsl to understand the +// probability logic. +//////////////////////////////////////////////////////////////////////////////// +@compute @workgroup_size(64) +fn export_level(@builtin(global_invocation_id) coord : vec3u) { + if (all(coord.xy < vec2u(textureDimensions(tex_out)))) { + let dst_offset = coord.x + coord.y * ubo.width; + let src_offset = coord.x*2u + coord.y*2u * ubo.width; + + let a = buf_in.weights[src_offset + 0u]; + let b = buf_in.weights[src_offset + 1u]; + let c = buf_in.weights[src_offset + 0u + ubo.width]; + let d = buf_in.weights[src_offset + 1u + ubo.width]; + let sum = dot(vec4f(a, b, c, d), vec4f(1.0)); + + buf_out.weights[dst_offset] = sum / 4.0; + + let probabilities = vec4f(a, a+b, a+b+c, sum) / max(sum, 0.0001); + textureStore(tex_out, vec2i(coord.xy), probabilities); + } +} +`; \ No newline at end of file diff --git a/example/src/Examples/Breathe/demo6/react.png b/example/src/Examples/Breathe/demo6/react.png new file mode 100644 index 0000000000..06568a5233 Binary files /dev/null and b/example/src/Examples/Breathe/demo6/react.png differ diff --git a/example/src/Examples/Breathe/demo6/test.png b/example/src/Examples/Breathe/demo6/test.png new file mode 100644 index 0000000000..d19ce0a785 Binary files /dev/null and b/example/src/Examples/Breathe/demo6/test.png differ diff --git a/example/src/Examples/Breathe/demo6/webgpu.png b/example/src/Examples/Breathe/demo6/webgpu.png new file mode 100644 index 0000000000..a44b73ead9 Binary files /dev/null and b/example/src/Examples/Breathe/demo6/webgpu.png differ diff --git a/package/.vscode/settings.json b/package/.vscode/settings.json new file mode 100644 index 0000000000..9bc61e6971 --- /dev/null +++ b/package/.vscode/settings.json @@ -0,0 +1,69 @@ +{ + "files.associations": { + "utility": "cpp", + "__bit_reference": "cpp", + "__config": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__node_handle": "cpp", + "__split_buffer": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__verbose_abort": "cpp", + "array": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "execution": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "queue": "cpp", + "ratio": "cpp", + "regex": "cpp", + "set": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "tuple": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "variant": "cpp", + "vector": "cpp", + "algorithm": "cpp" + } +} \ No newline at end of file diff --git a/package/android/CMakeLists.txt b/package/android/CMakeLists.txt index 1c4b87ca6e..d475c79fd6 100644 --- a/package/android/CMakeLists.txt +++ b/package/android/CMakeLists.txt @@ -48,6 +48,7 @@ add_library( "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp" "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/GrAHardwareBufferUtils.cpp" "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/WebGPUTriangle.cpp" + "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/dawn/webgpu_cpp.cpp" "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiHostObject.cpp" "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiValue.cpp" @@ -91,6 +92,8 @@ target_include_directories( ../cpp/wgpu ../cpp/jsi ../cpp/rnskia + ../cpp/rnskia/webgpu + ../cpp/rnskia/dawn ../cpp/rnskia/values ../cpp/rnskia/dom ../cpp/rnskia/dom/base diff --git a/package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h b/package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h index f0e505284d..4f30973cbb 100644 --- a/package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +++ b/package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h @@ -27,6 +27,10 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { : RNSkPlatformContext(runtime, jsCallInvoker, jniPlatformContext->getPixelDensity()), _jniPlatformContext(jniPlatformContext) { + wgpu::InstanceDescriptor instanceDesc; + instanceDesc.features.timedWaitAnyEnable = true; + instanceDesc.features.timedWaitAnyMaxCount = 64; + _instance = wgpu::CreateInstance(&instanceDesc); // Hook onto the notify draw loop callback in the platform context jniPlatformContext->setOnNotifyDrawLoop( [this]() { notifyDrawLoop(false); }); @@ -66,22 +70,20 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { void registerSurfaceDescriptor(int nativeId, void *window, int width, int height) override { - WGPUSurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc = {}; - androidSurfaceDesc.chain.sType = - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow; - androidSurfaceDesc.window = window; - WGPUSurfaceDescriptor surfaceDesc = {}; - surfaceDesc.nextInChain = - reinterpret_cast(&androidSurfaceDesc); + wgpu::SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc = {}; + androidSurfaceDesc.window = window; - wgpu::Instance instance = wgpuCreateInstance(nullptr); - wgpu::Surface surface = wgpuInstanceCreateSurface(instance, &surfaceDesc); + wgpu::SurfaceDescriptor surfaceDesc = {}; + surfaceDesc.nextInChain = &androidSurfaceDesc; + auto surface = _instance.CreateSurface(&surfaceDesc); _descriptors[nativeId] = std::make_tuple( std::make_shared(surface), width, height); } + wgpu::Instance getInstance() { return _instance; } + virtual std::tuple, int, int> getSurfaceDescriptor(int nativeId) override { auto it = _descriptors.find(nativeId); @@ -96,6 +98,7 @@ class RNSkAndroidPlatformContext : public RNSkPlatformContext { JniPlatformContext *_jniPlatformContext; std::map, int, int>> _descriptors; + wgpu::Instance _instance = nullptr; }; } // namespace RNSkia diff --git a/package/android/cpp/rnskia-android/RNSkAndroidView.h b/package/android/cpp/rnskia-android/RNSkAndroidView.h index 398138adf7..6926e83459 100644 --- a/package/android/cpp/rnskia-android/RNSkAndroidView.h +++ b/package/android/cpp/rnskia-android/RNSkAndroidView.h @@ -66,8 +66,9 @@ class RNSkAndroidView : public T, public RNSkBaseAndroidView { auto nativeId = getSkiaView()->getNativeId(); T::getPlatformContext()->registerSurfaceDescriptor(nativeId, _window, width, height); - - // runTriangleDemo(_window, width, height); + // RNSkLogger::logToConsole("Surface size changed: %d, %d", + // isVulkanSupported()); + // runTriangleDemo(_window, width, height); } float getPixelDensity() override { diff --git a/package/android/cpp/rnskia-android/WebGPUTriangle.cpp b/package/android/cpp/rnskia-android/WebGPUTriangle.cpp index 6730384215..1f83d29a91 100644 --- a/package/android/cpp/rnskia-android/WebGPUTriangle.cpp +++ b/package/android/cpp/rnskia-android/WebGPUTriangle.cpp @@ -5,62 +5,84 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" using namespace wgpu; +namespace RNSkia { + void runTriangleDemo(void *window, int width, int height) { RNSkia::RNSkLogger::logToConsole("width: %d, height: %d", width, height); - Instance instance = wgpuCreateInstance(nullptr); + auto instance = CreateInstance(nullptr); if (!instance) { RNSkia::RNSkLogger::logToConsole("Failed to create WebGPU instance"); return; } - WGPUSurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc = {}; - androidSurfaceDesc.chain.sType = - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow; + SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc = {}; androidSurfaceDesc.window = window; // Set up the generic surface descriptor to use the platform-specific one - WGPUSurfaceDescriptor surfaceDesc = {}; + SurfaceDescriptor surfaceDesc = {}; surfaceDesc.nextInChain = - reinterpret_cast(&androidSurfaceDesc); - Surface surface = wgpuInstanceCreateSurface(instance, &surfaceDesc); + reinterpret_cast(&androidSurfaceDesc); + Surface surface = instance.CreateSurface(&surfaceDesc); RNSkia::RNSkLogger::logToConsole("Requesting adapter..."); RequestAdapterOptions adapterOpts; - // adapterOpts.compatibleSurface = surface; - Adapter adapter = instance.requestAdapter(adapterOpts); - std::cout << "Got adapter: " << adapter << std::endl; - std::cout << "Requesting device..." << std::endl; + wgpu::Adapter adapter = nullptr; + instance.RequestAdapter( + nullptr, + [](WGPURequestAdapterStatus, WGPUAdapter cAdapter, const char *message, + void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = + wgpu::Adapter::Acquire(cAdapter); + }, + &adapter); + + wgpu::Device device = nullptr; + adapter.RequestDevice( + nullptr, + [](WGPURequestDeviceStatus, WGPUDevice cDevice, const char *message, + void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = wgpu::Device::Acquire(cDevice); + }, + &device); + DeviceDescriptor deviceDesc; deviceDesc.label = "My Device"; // deviceDesc.requiredFeaturesCount = 0; deviceDesc.requiredLimits = nullptr; deviceDesc.defaultQueue.label = "The default queue"; - Device device = adapter.requestDevice(deviceDesc); - RNSkia::RNSkLogger::logToConsole("GOT DEVICE"); // Add an error callback for more debug info - auto h = device.setUncapturedErrorCallback( - [](ErrorType type, char const *message) { - RNSkia::RNSkLogger::logToConsole("error: %s", message); - }); - - Queue queue = device.getQueue(); + // auto h = device.SetUncapturedErrorCallback( + // [=](ErrorType type, char const *message, void *userData) { + // RNSkia::RNSkLogger::logToConsole("error: %s", message); + // RNSkia::RNSkLogger::logToConsole("GOT DEVICE"); + // }, + // nullptr); + Queue queue = device.GetQueue(); RNSkia::RNSkLogger::logToConsole("Creating swap chain..."); - TextureFormat swapChainFormat = - surface.getPreferredFormat(adapter); // TextureFormat swapChainFormat = - // TextureFormat::BGRA8Unorm; + // TextureFormat swapChainFormat = surface.GetPreferredFormat( + // adapter); // TextureFormat swapChainFormat = + // TextureFormat::BGRA8Unorm; SwapChainDescriptor swapChainDesc; swapChainDesc.width = width; swapChainDesc.height = height; swapChainDesc.usage = TextureUsage::RenderAttachment; - swapChainDesc.format = swapChainFormat; + swapChainDesc.format = TextureFormat::RGBA8Unorm; swapChainDesc.presentMode = PresentMode::Fifo; - SwapChain swapChain = device.createSwapChain(surface, swapChainDesc); + SwapChain swapChain = device.CreateSwapChain(surface, &swapChainDesc); RNSkia::RNSkLogger::logToConsole("Creating shader module."); const char *shaderSource = R"( @@ -89,15 +111,13 @@ fn fs_main() -> @location(0) vec4f { // Use the extension mechanism to load a WGSL shader source code ShaderModuleWGSLDescriptor shaderCodeDesc; // Set the chained struct's header - shaderCodeDesc.chain.next = nullptr; - shaderCodeDesc.chain.sType = SType::ShaderModuleWGSLDescriptor; // Connect the chain - shaderDesc.nextInChain = &shaderCodeDesc.chain; + shaderDesc.nextInChain = &shaderCodeDesc; // Setup the actual payload of the shader code descriptor shaderCodeDesc.code = shaderSource; - ShaderModule shaderModule = device.createShaderModule(shaderDesc); + auto shaderModule = device.CreateShaderModule(&shaderDesc); RNSkia::RNSkLogger::logToConsole("Creating rendering pipeline."); RenderPipelineDescriptor pipelineDesc; @@ -115,8 +135,9 @@ fn fs_main() -> @location(0) vec4f { // Primitive assembly and rasterization // Each sequence of 3 vertices is considered as a triangle pipelineDesc.primitive.topology = PrimitiveTopology::TriangleList; - // We'll see later how to specify the order in which vertices should be - // connected. When not specified, vertices are considered sequentially. + // We'll see later how to specify the order in which vertices should + // be connected. When not specified, vertices are considered + // sequentially. pipelineDesc.primitive.stripIndexFormat = IndexFormat::Undefined; // The face orientation is defined by assuming that when looking // from the front of the face, its corner vertices are enumerated @@ -147,13 +168,13 @@ fn fs_main() -> @location(0) vec4f { blendState.alpha.operation = BlendOperation::Add; ColorTargetState colorTarget; - colorTarget.format = swapChainFormat; + colorTarget.format = TextureFormat::RGBA8Unorm; colorTarget.blend = &blendState; - colorTarget.writeMask = - ColorWriteMask::All; // We could write to only some of the color channels. + colorTarget.writeMask = ColorWriteMask::All; // We could write to only some + // of the color channels. - // We have only one target because our render pass has only one output color - // attachment. + // We have only one target because our render pass has only one output + // color attachment. fragmentState.targetCount = 1; fragmentState.targets = &colorTarget; @@ -171,21 +192,20 @@ fn fs_main() -> @location(0) vec4f { // Pipeline layout pipelineDesc.layout = nullptr; - RenderPipeline pipeline = device.createRenderPipeline(pipelineDesc); - std::cout << "Render pipeline: " << pipeline << std::endl; + RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); // while (true) { // wgpuInstanceProcessEvents(instance); - TextureView nextTexture = swapChain.getCurrentTextureView(); + TextureView nextTexture = swapChain.GetCurrentTextureView(); if (!nextTexture) { RNSkia::RNSkLogger::logToConsole("Cannot acquire next swap chain texture"); - return; + // return; } CommandEncoderDescriptor commandEncoderDesc; commandEncoderDesc.label = "Command Encoder"; - CommandEncoder encoder = device.createCommandEncoder(commandEncoderDesc); + CommandEncoder encoder = device.CreateCommandEncoder(&commandEncoderDesc); RenderPassDescriptor renderPassDesc; @@ -202,38 +222,40 @@ fn fs_main() -> @location(0) vec4f { renderPassDesc.depthStencilAttachment = nullptr; // renderPassDesc.timestampWriteCount = 0; renderPassDesc.timestampWrites = nullptr; - RenderPassEncoder renderPass = encoder.beginRenderPass(renderPassDesc); + RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDesc); // In its overall outline, drawing a triangle is as simple as this: // Select which render pipeline to use - renderPass.setPipeline(pipeline); + renderPass.SetPipeline(pipeline); // Draw 1 instance of a 3-vertices shape - renderPass.draw(3, 1, 0, 0); - - renderPass.end(); - renderPass.release(); + renderPass.Draw(3, 1, 0, 0); - nextTexture.release(); + renderPass.End(); CommandBufferDescriptor cmdBufferDescriptor; cmdBufferDescriptor.label = "Command buffer"; - CommandBuffer command = encoder.finish(cmdBufferDescriptor); - encoder.release(); - std::vector commands; + CommandBuffer command = encoder.Finish(&cmdBufferDescriptor); + std::vector commands; commands.push_back(command); - queue.submit(command); - command.release(); - - swapChain.present(); - // } - - pipeline.release(); - shaderModule.release(); - swapChain.release(); - device.release(); - adapter.release(); - instance.release(); + queue.Submit(commands.size(), commands.data()); + bool done = false; + queue.OnSubmittedWorkDone( + [](WGPUQueueWorkDoneStatus status, void *userdata) { + RNSkia::RNSkLogger::logToConsole("Queue work done"); + auto done = static_cast(userdata); + *done = true; + }, + &done); + RNSkia::RNSkLogger::logToConsole("Preprocess events"); + while (!done) { + instance.ProcessEvents(); + } + RNSkia::RNSkLogger::logToConsole("Present"); + swapChain.Present(); + // surface.release(); // glfwDestroyWindow(window); // glfwTerminate(); -} \ No newline at end of file +} + +} // namespace RNSkia \ No newline at end of file diff --git a/package/android/cpp/rnskia-android/WebGPUTriangle.h b/package/android/cpp/rnskia-android/WebGPUTriangle.h index a29cc10965..0248532910 100644 --- a/package/android/cpp/rnskia-android/WebGPUTriangle.h +++ b/package/android/cpp/rnskia-android/WebGPUTriangle.h @@ -1,8 +1,14 @@ +#pragma once + #include #include #include #define WEBGPU_CPP_IMPLEMENTATION -void runTriangleDemo(void *surface, int width, int height); \ No newline at end of file +namespace RNSkia { + +void runTriangleDemo(void *surface, int width, int height); + +} // namespace RNSkia \ No newline at end of file diff --git a/package/android/cpp/rnskia-android/dawn/webgpu_cpp.cpp b/package/android/cpp/rnskia-android/dawn/webgpu_cpp.cpp new file mode 100644 index 0000000000..b8784a52b5 --- /dev/null +++ b/package/android/cpp/rnskia-android/dawn/webgpu_cpp.cpp @@ -0,0 +1,6893 @@ + +#include + +#include "dawn/webgpu_cpp.h" + +#if defined(__GNUC__) || defined(__clang__) +// error: 'offsetof' within non-standard-layout type 'wgpu::XXX' is +// conditionally-supported +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif + +namespace wgpu { + +// WGSLFeatureName + +static_assert(sizeof(WGSLFeatureName) == sizeof(WGPUWGSLFeatureName), + "sizeof mismatch for WGSLFeatureName"); +static_assert(alignof(WGSLFeatureName) == alignof(WGPUWGSLFeatureName), + "alignof mismatch for WGSLFeatureName"); + +static_assert(static_cast(WGSLFeatureName::Undefined) == + WGPUWGSLFeatureName_Undefined, + "value mismatch for WGSLFeatureName::Undefined"); +static_assert( + static_cast( + WGSLFeatureName::ReadonlyAndReadwriteStorageTextures) == + WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures, + "value mismatch for WGSLFeatureName::ReadonlyAndReadwriteStorageTextures"); +static_assert( + static_cast(WGSLFeatureName::Packed4x8IntegerDotProduct) == + WGPUWGSLFeatureName_Packed4x8IntegerDotProduct, + "value mismatch for WGSLFeatureName::Packed4x8IntegerDotProduct"); +static_assert( + static_cast(WGSLFeatureName::UnrestrictedPointerParameters) == + WGPUWGSLFeatureName_UnrestrictedPointerParameters, + "value mismatch for WGSLFeatureName::UnrestrictedPointerParameters"); +static_assert(static_cast(WGSLFeatureName::PointerCompositeAccess) == + WGPUWGSLFeatureName_PointerCompositeAccess, + "value mismatch for WGSLFeatureName::PointerCompositeAccess"); +static_assert( + static_cast(WGSLFeatureName::ChromiumTestingUnimplemented) == + WGPUWGSLFeatureName_ChromiumTestingUnimplemented, + "value mismatch for WGSLFeatureName::ChromiumTestingUnimplemented"); +static_assert( + static_cast(WGSLFeatureName::ChromiumTestingUnsafeExperimental) == + WGPUWGSLFeatureName_ChromiumTestingUnsafeExperimental, + "value mismatch for WGSLFeatureName::ChromiumTestingUnsafeExperimental"); +static_assert( + static_cast(WGSLFeatureName::ChromiumTestingExperimental) == + WGPUWGSLFeatureName_ChromiumTestingExperimental, + "value mismatch for WGSLFeatureName::ChromiumTestingExperimental"); +static_assert( + static_cast( + WGSLFeatureName::ChromiumTestingShippedWithKillswitch) == + WGPUWGSLFeatureName_ChromiumTestingShippedWithKillswitch, + "value mismatch for WGSLFeatureName::ChromiumTestingShippedWithKillswitch"); +static_assert(static_cast(WGSLFeatureName::ChromiumTestingShipped) == + WGPUWGSLFeatureName_ChromiumTestingShipped, + "value mismatch for WGSLFeatureName::ChromiumTestingShipped"); + +// AdapterType + +static_assert(sizeof(AdapterType) == sizeof(WGPUAdapterType), + "sizeof mismatch for AdapterType"); +static_assert(alignof(AdapterType) == alignof(WGPUAdapterType), + "alignof mismatch for AdapterType"); + +static_assert(static_cast(AdapterType::DiscreteGPU) == + WGPUAdapterType_DiscreteGPU, + "value mismatch for AdapterType::DiscreteGPU"); +static_assert(static_cast(AdapterType::IntegratedGPU) == + WGPUAdapterType_IntegratedGPU, + "value mismatch for AdapterType::IntegratedGPU"); +static_assert(static_cast(AdapterType::CPU) == WGPUAdapterType_CPU, + "value mismatch for AdapterType::CPU"); +static_assert(static_cast(AdapterType::Unknown) == + WGPUAdapterType_Unknown, + "value mismatch for AdapterType::Unknown"); + +// AddressMode + +static_assert(sizeof(AddressMode) == sizeof(WGPUAddressMode), + "sizeof mismatch for AddressMode"); +static_assert(alignof(AddressMode) == alignof(WGPUAddressMode), + "alignof mismatch for AddressMode"); + +static_assert(static_cast(AddressMode::Undefined) == + WGPUAddressMode_Undefined, + "value mismatch for AddressMode::Undefined"); +static_assert(static_cast(AddressMode::ClampToEdge) == + WGPUAddressMode_ClampToEdge, + "value mismatch for AddressMode::ClampToEdge"); +static_assert(static_cast(AddressMode::Repeat) == + WGPUAddressMode_Repeat, + "value mismatch for AddressMode::Repeat"); +static_assert(static_cast(AddressMode::MirrorRepeat) == + WGPUAddressMode_MirrorRepeat, + "value mismatch for AddressMode::MirrorRepeat"); + +// AlphaMode + +static_assert(sizeof(AlphaMode) == sizeof(WGPUAlphaMode), + "sizeof mismatch for AlphaMode"); +static_assert(alignof(AlphaMode) == alignof(WGPUAlphaMode), + "alignof mismatch for AlphaMode"); + +static_assert(static_cast(AlphaMode::Opaque) == WGPUAlphaMode_Opaque, + "value mismatch for AlphaMode::Opaque"); +static_assert(static_cast(AlphaMode::Premultiplied) == + WGPUAlphaMode_Premultiplied, + "value mismatch for AlphaMode::Premultiplied"); +static_assert(static_cast(AlphaMode::Unpremultiplied) == + WGPUAlphaMode_Unpremultiplied, + "value mismatch for AlphaMode::Unpremultiplied"); + +// BackendType + +static_assert(sizeof(BackendType) == sizeof(WGPUBackendType), + "sizeof mismatch for BackendType"); +static_assert(alignof(BackendType) == alignof(WGPUBackendType), + "alignof mismatch for BackendType"); + +static_assert(static_cast(BackendType::Undefined) == + WGPUBackendType_Undefined, + "value mismatch for BackendType::Undefined"); +static_assert(static_cast(BackendType::Null) == WGPUBackendType_Null, + "value mismatch for BackendType::Null"); +static_assert(static_cast(BackendType::WebGPU) == + WGPUBackendType_WebGPU, + "value mismatch for BackendType::WebGPU"); +static_assert(static_cast(BackendType::D3D11) == + WGPUBackendType_D3D11, + "value mismatch for BackendType::D3D11"); +static_assert(static_cast(BackendType::D3D12) == + WGPUBackendType_D3D12, + "value mismatch for BackendType::D3D12"); +static_assert(static_cast(BackendType::Metal) == + WGPUBackendType_Metal, + "value mismatch for BackendType::Metal"); +static_assert(static_cast(BackendType::Vulkan) == + WGPUBackendType_Vulkan, + "value mismatch for BackendType::Vulkan"); +static_assert(static_cast(BackendType::OpenGL) == + WGPUBackendType_OpenGL, + "value mismatch for BackendType::OpenGL"); +static_assert(static_cast(BackendType::OpenGLES) == + WGPUBackendType_OpenGLES, + "value mismatch for BackendType::OpenGLES"); + +// BlendFactor + +static_assert(sizeof(BlendFactor) == sizeof(WGPUBlendFactor), + "sizeof mismatch for BlendFactor"); +static_assert(alignof(BlendFactor) == alignof(WGPUBlendFactor), + "alignof mismatch for BlendFactor"); + +static_assert(static_cast(BlendFactor::Undefined) == + WGPUBlendFactor_Undefined, + "value mismatch for BlendFactor::Undefined"); +static_assert(static_cast(BlendFactor::Zero) == WGPUBlendFactor_Zero, + "value mismatch for BlendFactor::Zero"); +static_assert(static_cast(BlendFactor::One) == WGPUBlendFactor_One, + "value mismatch for BlendFactor::One"); +static_assert(static_cast(BlendFactor::Src) == WGPUBlendFactor_Src, + "value mismatch for BlendFactor::Src"); +static_assert(static_cast(BlendFactor::OneMinusSrc) == + WGPUBlendFactor_OneMinusSrc, + "value mismatch for BlendFactor::OneMinusSrc"); +static_assert(static_cast(BlendFactor::SrcAlpha) == + WGPUBlendFactor_SrcAlpha, + "value mismatch for BlendFactor::SrcAlpha"); +static_assert(static_cast(BlendFactor::OneMinusSrcAlpha) == + WGPUBlendFactor_OneMinusSrcAlpha, + "value mismatch for BlendFactor::OneMinusSrcAlpha"); +static_assert(static_cast(BlendFactor::Dst) == WGPUBlendFactor_Dst, + "value mismatch for BlendFactor::Dst"); +static_assert(static_cast(BlendFactor::OneMinusDst) == + WGPUBlendFactor_OneMinusDst, + "value mismatch for BlendFactor::OneMinusDst"); +static_assert(static_cast(BlendFactor::DstAlpha) == + WGPUBlendFactor_DstAlpha, + "value mismatch for BlendFactor::DstAlpha"); +static_assert(static_cast(BlendFactor::OneMinusDstAlpha) == + WGPUBlendFactor_OneMinusDstAlpha, + "value mismatch for BlendFactor::OneMinusDstAlpha"); +static_assert(static_cast(BlendFactor::SrcAlphaSaturated) == + WGPUBlendFactor_SrcAlphaSaturated, + "value mismatch for BlendFactor::SrcAlphaSaturated"); +static_assert(static_cast(BlendFactor::Constant) == + WGPUBlendFactor_Constant, + "value mismatch for BlendFactor::Constant"); +static_assert(static_cast(BlendFactor::OneMinusConstant) == + WGPUBlendFactor_OneMinusConstant, + "value mismatch for BlendFactor::OneMinusConstant"); +static_assert(static_cast(BlendFactor::Src1) == WGPUBlendFactor_Src1, + "value mismatch for BlendFactor::Src1"); +static_assert(static_cast(BlendFactor::OneMinusSrc1) == + WGPUBlendFactor_OneMinusSrc1, + "value mismatch for BlendFactor::OneMinusSrc1"); +static_assert(static_cast(BlendFactor::Src1Alpha) == + WGPUBlendFactor_Src1Alpha, + "value mismatch for BlendFactor::Src1Alpha"); +static_assert(static_cast(BlendFactor::OneMinusSrc1Alpha) == + WGPUBlendFactor_OneMinusSrc1Alpha, + "value mismatch for BlendFactor::OneMinusSrc1Alpha"); + +// BlendOperation + +static_assert(sizeof(BlendOperation) == sizeof(WGPUBlendOperation), + "sizeof mismatch for BlendOperation"); +static_assert(alignof(BlendOperation) == alignof(WGPUBlendOperation), + "alignof mismatch for BlendOperation"); + +static_assert(static_cast(BlendOperation::Undefined) == + WGPUBlendOperation_Undefined, + "value mismatch for BlendOperation::Undefined"); +static_assert(static_cast(BlendOperation::Add) == + WGPUBlendOperation_Add, + "value mismatch for BlendOperation::Add"); +static_assert(static_cast(BlendOperation::Subtract) == + WGPUBlendOperation_Subtract, + "value mismatch for BlendOperation::Subtract"); +static_assert(static_cast(BlendOperation::ReverseSubtract) == + WGPUBlendOperation_ReverseSubtract, + "value mismatch for BlendOperation::ReverseSubtract"); +static_assert(static_cast(BlendOperation::Min) == + WGPUBlendOperation_Min, + "value mismatch for BlendOperation::Min"); +static_assert(static_cast(BlendOperation::Max) == + WGPUBlendOperation_Max, + "value mismatch for BlendOperation::Max"); + +// BufferBindingType + +static_assert(sizeof(BufferBindingType) == sizeof(WGPUBufferBindingType), + "sizeof mismatch for BufferBindingType"); +static_assert(alignof(BufferBindingType) == alignof(WGPUBufferBindingType), + "alignof mismatch for BufferBindingType"); + +static_assert(static_cast(BufferBindingType::Undefined) == + WGPUBufferBindingType_Undefined, + "value mismatch for BufferBindingType::Undefined"); +static_assert(static_cast(BufferBindingType::Uniform) == + WGPUBufferBindingType_Uniform, + "value mismatch for BufferBindingType::Uniform"); +static_assert(static_cast(BufferBindingType::Storage) == + WGPUBufferBindingType_Storage, + "value mismatch for BufferBindingType::Storage"); +static_assert(static_cast(BufferBindingType::ReadOnlyStorage) == + WGPUBufferBindingType_ReadOnlyStorage, + "value mismatch for BufferBindingType::ReadOnlyStorage"); + +// BufferMapAsyncStatus + +static_assert(sizeof(BufferMapAsyncStatus) == sizeof(WGPUBufferMapAsyncStatus), + "sizeof mismatch for BufferMapAsyncStatus"); +static_assert(alignof(BufferMapAsyncStatus) == + alignof(WGPUBufferMapAsyncStatus), + "alignof mismatch for BufferMapAsyncStatus"); + +static_assert(static_cast(BufferMapAsyncStatus::Success) == + WGPUBufferMapAsyncStatus_Success, + "value mismatch for BufferMapAsyncStatus::Success"); +static_assert(static_cast(BufferMapAsyncStatus::InstanceDropped) == + WGPUBufferMapAsyncStatus_InstanceDropped, + "value mismatch for BufferMapAsyncStatus::InstanceDropped"); +static_assert(static_cast(BufferMapAsyncStatus::ValidationError) == + WGPUBufferMapAsyncStatus_ValidationError, + "value mismatch for BufferMapAsyncStatus::ValidationError"); +static_assert(static_cast(BufferMapAsyncStatus::Unknown) == + WGPUBufferMapAsyncStatus_Unknown, + "value mismatch for BufferMapAsyncStatus::Unknown"); +static_assert(static_cast(BufferMapAsyncStatus::DeviceLost) == + WGPUBufferMapAsyncStatus_DeviceLost, + "value mismatch for BufferMapAsyncStatus::DeviceLost"); +static_assert( + static_cast(BufferMapAsyncStatus::DestroyedBeforeCallback) == + WGPUBufferMapAsyncStatus_DestroyedBeforeCallback, + "value mismatch for BufferMapAsyncStatus::DestroyedBeforeCallback"); +static_assert( + static_cast(BufferMapAsyncStatus::UnmappedBeforeCallback) == + WGPUBufferMapAsyncStatus_UnmappedBeforeCallback, + "value mismatch for BufferMapAsyncStatus::UnmappedBeforeCallback"); +static_assert( + static_cast(BufferMapAsyncStatus::MappingAlreadyPending) == + WGPUBufferMapAsyncStatus_MappingAlreadyPending, + "value mismatch for BufferMapAsyncStatus::MappingAlreadyPending"); +static_assert(static_cast(BufferMapAsyncStatus::OffsetOutOfRange) == + WGPUBufferMapAsyncStatus_OffsetOutOfRange, + "value mismatch for BufferMapAsyncStatus::OffsetOutOfRange"); +static_assert(static_cast(BufferMapAsyncStatus::SizeOutOfRange) == + WGPUBufferMapAsyncStatus_SizeOutOfRange, + "value mismatch for BufferMapAsyncStatus::SizeOutOfRange"); + +// BufferMapState + +static_assert(sizeof(BufferMapState) == sizeof(WGPUBufferMapState), + "sizeof mismatch for BufferMapState"); +static_assert(alignof(BufferMapState) == alignof(WGPUBufferMapState), + "alignof mismatch for BufferMapState"); + +static_assert(static_cast(BufferMapState::Unmapped) == + WGPUBufferMapState_Unmapped, + "value mismatch for BufferMapState::Unmapped"); +static_assert(static_cast(BufferMapState::Pending) == + WGPUBufferMapState_Pending, + "value mismatch for BufferMapState::Pending"); +static_assert(static_cast(BufferMapState::Mapped) == + WGPUBufferMapState_Mapped, + "value mismatch for BufferMapState::Mapped"); + +// CallbackMode + +static_assert(sizeof(CallbackMode) == sizeof(WGPUCallbackMode), + "sizeof mismatch for CallbackMode"); +static_assert(alignof(CallbackMode) == alignof(WGPUCallbackMode), + "alignof mismatch for CallbackMode"); + +static_assert(static_cast(CallbackMode::WaitAnyOnly) == + WGPUCallbackMode_WaitAnyOnly, + "value mismatch for CallbackMode::WaitAnyOnly"); +static_assert(static_cast(CallbackMode::AllowProcessEvents) == + WGPUCallbackMode_AllowProcessEvents, + "value mismatch for CallbackMode::AllowProcessEvents"); +static_assert(static_cast(CallbackMode::AllowSpontaneous) == + WGPUCallbackMode_AllowSpontaneous, + "value mismatch for CallbackMode::AllowSpontaneous"); + +// CompareFunction + +static_assert(sizeof(CompareFunction) == sizeof(WGPUCompareFunction), + "sizeof mismatch for CompareFunction"); +static_assert(alignof(CompareFunction) == alignof(WGPUCompareFunction), + "alignof mismatch for CompareFunction"); + +static_assert(static_cast(CompareFunction::Undefined) == + WGPUCompareFunction_Undefined, + "value mismatch for CompareFunction::Undefined"); +static_assert(static_cast(CompareFunction::Never) == + WGPUCompareFunction_Never, + "value mismatch for CompareFunction::Never"); +static_assert(static_cast(CompareFunction::Less) == + WGPUCompareFunction_Less, + "value mismatch for CompareFunction::Less"); +static_assert(static_cast(CompareFunction::Equal) == + WGPUCompareFunction_Equal, + "value mismatch for CompareFunction::Equal"); +static_assert(static_cast(CompareFunction::LessEqual) == + WGPUCompareFunction_LessEqual, + "value mismatch for CompareFunction::LessEqual"); +static_assert(static_cast(CompareFunction::Greater) == + WGPUCompareFunction_Greater, + "value mismatch for CompareFunction::Greater"); +static_assert(static_cast(CompareFunction::NotEqual) == + WGPUCompareFunction_NotEqual, + "value mismatch for CompareFunction::NotEqual"); +static_assert(static_cast(CompareFunction::GreaterEqual) == + WGPUCompareFunction_GreaterEqual, + "value mismatch for CompareFunction::GreaterEqual"); +static_assert(static_cast(CompareFunction::Always) == + WGPUCompareFunction_Always, + "value mismatch for CompareFunction::Always"); + +// CompilationInfoRequestStatus + +static_assert(sizeof(CompilationInfoRequestStatus) == + sizeof(WGPUCompilationInfoRequestStatus), + "sizeof mismatch for CompilationInfoRequestStatus"); +static_assert(alignof(CompilationInfoRequestStatus) == + alignof(WGPUCompilationInfoRequestStatus), + "alignof mismatch for CompilationInfoRequestStatus"); + +static_assert(static_cast(CompilationInfoRequestStatus::Success) == + WGPUCompilationInfoRequestStatus_Success, + "value mismatch for CompilationInfoRequestStatus::Success"); +static_assert( + static_cast(CompilationInfoRequestStatus::InstanceDropped) == + WGPUCompilationInfoRequestStatus_InstanceDropped, + "value mismatch for CompilationInfoRequestStatus::InstanceDropped"); +static_assert(static_cast(CompilationInfoRequestStatus::Error) == + WGPUCompilationInfoRequestStatus_Error, + "value mismatch for CompilationInfoRequestStatus::Error"); +static_assert(static_cast(CompilationInfoRequestStatus::DeviceLost) == + WGPUCompilationInfoRequestStatus_DeviceLost, + "value mismatch for CompilationInfoRequestStatus::DeviceLost"); +static_assert(static_cast(CompilationInfoRequestStatus::Unknown) == + WGPUCompilationInfoRequestStatus_Unknown, + "value mismatch for CompilationInfoRequestStatus::Unknown"); + +// CompilationMessageType + +static_assert(sizeof(CompilationMessageType) == + sizeof(WGPUCompilationMessageType), + "sizeof mismatch for CompilationMessageType"); +static_assert(alignof(CompilationMessageType) == + alignof(WGPUCompilationMessageType), + "alignof mismatch for CompilationMessageType"); + +static_assert(static_cast(CompilationMessageType::Error) == + WGPUCompilationMessageType_Error, + "value mismatch for CompilationMessageType::Error"); +static_assert(static_cast(CompilationMessageType::Warning) == + WGPUCompilationMessageType_Warning, + "value mismatch for CompilationMessageType::Warning"); +static_assert(static_cast(CompilationMessageType::Info) == + WGPUCompilationMessageType_Info, + "value mismatch for CompilationMessageType::Info"); + +// CreatePipelineAsyncStatus + +static_assert(sizeof(CreatePipelineAsyncStatus) == + sizeof(WGPUCreatePipelineAsyncStatus), + "sizeof mismatch for CreatePipelineAsyncStatus"); +static_assert(alignof(CreatePipelineAsyncStatus) == + alignof(WGPUCreatePipelineAsyncStatus), + "alignof mismatch for CreatePipelineAsyncStatus"); + +static_assert(static_cast(CreatePipelineAsyncStatus::Success) == + WGPUCreatePipelineAsyncStatus_Success, + "value mismatch for CreatePipelineAsyncStatus::Success"); +static_assert( + static_cast(CreatePipelineAsyncStatus::InstanceDropped) == + WGPUCreatePipelineAsyncStatus_InstanceDropped, + "value mismatch for CreatePipelineAsyncStatus::InstanceDropped"); +static_assert( + static_cast(CreatePipelineAsyncStatus::ValidationError) == + WGPUCreatePipelineAsyncStatus_ValidationError, + "value mismatch for CreatePipelineAsyncStatus::ValidationError"); +static_assert(static_cast(CreatePipelineAsyncStatus::InternalError) == + WGPUCreatePipelineAsyncStatus_InternalError, + "value mismatch for CreatePipelineAsyncStatus::InternalError"); +static_assert(static_cast(CreatePipelineAsyncStatus::DeviceLost) == + WGPUCreatePipelineAsyncStatus_DeviceLost, + "value mismatch for CreatePipelineAsyncStatus::DeviceLost"); +static_assert( + static_cast(CreatePipelineAsyncStatus::DeviceDestroyed) == + WGPUCreatePipelineAsyncStatus_DeviceDestroyed, + "value mismatch for CreatePipelineAsyncStatus::DeviceDestroyed"); +static_assert(static_cast(CreatePipelineAsyncStatus::Unknown) == + WGPUCreatePipelineAsyncStatus_Unknown, + "value mismatch for CreatePipelineAsyncStatus::Unknown"); + +// CullMode + +static_assert(sizeof(CullMode) == sizeof(WGPUCullMode), + "sizeof mismatch for CullMode"); +static_assert(alignof(CullMode) == alignof(WGPUCullMode), + "alignof mismatch for CullMode"); + +static_assert(static_cast(CullMode::Undefined) == + WGPUCullMode_Undefined, + "value mismatch for CullMode::Undefined"); +static_assert(static_cast(CullMode::None) == WGPUCullMode_None, + "value mismatch for CullMode::None"); +static_assert(static_cast(CullMode::Front) == WGPUCullMode_Front, + "value mismatch for CullMode::Front"); +static_assert(static_cast(CullMode::Back) == WGPUCullMode_Back, + "value mismatch for CullMode::Back"); + +// DeviceLostReason + +static_assert(sizeof(DeviceLostReason) == sizeof(WGPUDeviceLostReason), + "sizeof mismatch for DeviceLostReason"); +static_assert(alignof(DeviceLostReason) == alignof(WGPUDeviceLostReason), + "alignof mismatch for DeviceLostReason"); + +static_assert(static_cast(DeviceLostReason::Undefined) == + WGPUDeviceLostReason_Undefined, + "value mismatch for DeviceLostReason::Undefined"); +static_assert(static_cast(DeviceLostReason::Destroyed) == + WGPUDeviceLostReason_Destroyed, + "value mismatch for DeviceLostReason::Destroyed"); + +// ErrorFilter + +static_assert(sizeof(ErrorFilter) == sizeof(WGPUErrorFilter), + "sizeof mismatch for ErrorFilter"); +static_assert(alignof(ErrorFilter) == alignof(WGPUErrorFilter), + "alignof mismatch for ErrorFilter"); + +static_assert(static_cast(ErrorFilter::Validation) == + WGPUErrorFilter_Validation, + "value mismatch for ErrorFilter::Validation"); +static_assert(static_cast(ErrorFilter::OutOfMemory) == + WGPUErrorFilter_OutOfMemory, + "value mismatch for ErrorFilter::OutOfMemory"); +static_assert(static_cast(ErrorFilter::Internal) == + WGPUErrorFilter_Internal, + "value mismatch for ErrorFilter::Internal"); + +// ErrorType + +static_assert(sizeof(ErrorType) == sizeof(WGPUErrorType), + "sizeof mismatch for ErrorType"); +static_assert(alignof(ErrorType) == alignof(WGPUErrorType), + "alignof mismatch for ErrorType"); + +static_assert(static_cast(ErrorType::NoError) == + WGPUErrorType_NoError, + "value mismatch for ErrorType::NoError"); +static_assert(static_cast(ErrorType::Validation) == + WGPUErrorType_Validation, + "value mismatch for ErrorType::Validation"); +static_assert(static_cast(ErrorType::OutOfMemory) == + WGPUErrorType_OutOfMemory, + "value mismatch for ErrorType::OutOfMemory"); +static_assert(static_cast(ErrorType::Internal) == + WGPUErrorType_Internal, + "value mismatch for ErrorType::Internal"); +static_assert(static_cast(ErrorType::Unknown) == + WGPUErrorType_Unknown, + "value mismatch for ErrorType::Unknown"); +static_assert(static_cast(ErrorType::DeviceLost) == + WGPUErrorType_DeviceLost, + "value mismatch for ErrorType::DeviceLost"); + +// ExternalTextureRotation + +static_assert(sizeof(ExternalTextureRotation) == + sizeof(WGPUExternalTextureRotation), + "sizeof mismatch for ExternalTextureRotation"); +static_assert(alignof(ExternalTextureRotation) == + alignof(WGPUExternalTextureRotation), + "alignof mismatch for ExternalTextureRotation"); + +static_assert(static_cast(ExternalTextureRotation::Rotate0Degrees) == + WGPUExternalTextureRotation_Rotate0Degrees, + "value mismatch for ExternalTextureRotation::Rotate0Degrees"); +static_assert(static_cast(ExternalTextureRotation::Rotate90Degrees) == + WGPUExternalTextureRotation_Rotate90Degrees, + "value mismatch for ExternalTextureRotation::Rotate90Degrees"); +static_assert( + static_cast(ExternalTextureRotation::Rotate180Degrees) == + WGPUExternalTextureRotation_Rotate180Degrees, + "value mismatch for ExternalTextureRotation::Rotate180Degrees"); +static_assert( + static_cast(ExternalTextureRotation::Rotate270Degrees) == + WGPUExternalTextureRotation_Rotate270Degrees, + "value mismatch for ExternalTextureRotation::Rotate270Degrees"); + +// FeatureName + +static_assert(sizeof(FeatureName) == sizeof(WGPUFeatureName), + "sizeof mismatch for FeatureName"); +static_assert(alignof(FeatureName) == alignof(WGPUFeatureName), + "alignof mismatch for FeatureName"); + +static_assert(static_cast(FeatureName::Undefined) == + WGPUFeatureName_Undefined, + "value mismatch for FeatureName::Undefined"); +static_assert(static_cast(FeatureName::DepthClipControl) == + WGPUFeatureName_DepthClipControl, + "value mismatch for FeatureName::DepthClipControl"); +static_assert(static_cast(FeatureName::Depth32FloatStencil8) == + WGPUFeatureName_Depth32FloatStencil8, + "value mismatch for FeatureName::Depth32FloatStencil8"); +static_assert(static_cast(FeatureName::TimestampQuery) == + WGPUFeatureName_TimestampQuery, + "value mismatch for FeatureName::TimestampQuery"); +static_assert(static_cast(FeatureName::TextureCompressionBC) == + WGPUFeatureName_TextureCompressionBC, + "value mismatch for FeatureName::TextureCompressionBC"); +static_assert(static_cast(FeatureName::TextureCompressionETC2) == + WGPUFeatureName_TextureCompressionETC2, + "value mismatch for FeatureName::TextureCompressionETC2"); +static_assert(static_cast(FeatureName::TextureCompressionASTC) == + WGPUFeatureName_TextureCompressionASTC, + "value mismatch for FeatureName::TextureCompressionASTC"); +static_assert(static_cast(FeatureName::IndirectFirstInstance) == + WGPUFeatureName_IndirectFirstInstance, + "value mismatch for FeatureName::IndirectFirstInstance"); +static_assert(static_cast(FeatureName::ShaderF16) == + WGPUFeatureName_ShaderF16, + "value mismatch for FeatureName::ShaderF16"); +static_assert(static_cast(FeatureName::RG11B10UfloatRenderable) == + WGPUFeatureName_RG11B10UfloatRenderable, + "value mismatch for FeatureName::RG11B10UfloatRenderable"); +static_assert(static_cast(FeatureName::BGRA8UnormStorage) == + WGPUFeatureName_BGRA8UnormStorage, + "value mismatch for FeatureName::BGRA8UnormStorage"); +static_assert(static_cast(FeatureName::Float32Filterable) == + WGPUFeatureName_Float32Filterable, + "value mismatch for FeatureName::Float32Filterable"); +static_assert(static_cast(FeatureName::DawnInternalUsages) == + WGPUFeatureName_DawnInternalUsages, + "value mismatch for FeatureName::DawnInternalUsages"); +static_assert(static_cast(FeatureName::DawnMultiPlanarFormats) == + WGPUFeatureName_DawnMultiPlanarFormats, + "value mismatch for FeatureName::DawnMultiPlanarFormats"); +static_assert(static_cast(FeatureName::DawnNative) == + WGPUFeatureName_DawnNative, + "value mismatch for FeatureName::DawnNative"); +static_assert( + static_cast( + FeatureName::ChromiumExperimentalTimestampQueryInsidePasses) == + WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses, + "value mismatch for " + "FeatureName::ChromiumExperimentalTimestampQueryInsidePasses"); +static_assert( + static_cast(FeatureName::ImplicitDeviceSynchronization) == + WGPUFeatureName_ImplicitDeviceSynchronization, + "value mismatch for FeatureName::ImplicitDeviceSynchronization"); +static_assert(static_cast(FeatureName::SurfaceCapabilities) == + WGPUFeatureName_SurfaceCapabilities, + "value mismatch for FeatureName::SurfaceCapabilities"); +static_assert(static_cast(FeatureName::TransientAttachments) == + WGPUFeatureName_TransientAttachments, + "value mismatch for FeatureName::TransientAttachments"); +static_assert(static_cast(FeatureName::MSAARenderToSingleSampled) == + WGPUFeatureName_MSAARenderToSingleSampled, + "value mismatch for FeatureName::MSAARenderToSingleSampled"); +static_assert(static_cast(FeatureName::DualSourceBlending) == + WGPUFeatureName_DualSourceBlending, + "value mismatch for FeatureName::DualSourceBlending"); +static_assert(static_cast(FeatureName::D3D11MultithreadProtected) == + WGPUFeatureName_D3D11MultithreadProtected, + "value mismatch for FeatureName::D3D11MultithreadProtected"); +static_assert(static_cast(FeatureName::ANGLETextureSharing) == + WGPUFeatureName_ANGLETextureSharing, + "value mismatch for FeatureName::ANGLETextureSharing"); +static_assert( + static_cast(FeatureName::ChromiumExperimentalSubgroups) == + WGPUFeatureName_ChromiumExperimentalSubgroups, + "value mismatch for FeatureName::ChromiumExperimentalSubgroups"); +static_assert( + static_cast( + FeatureName::ChromiumExperimentalSubgroupUniformControlFlow) == + WGPUFeatureName_ChromiumExperimentalSubgroupUniformControlFlow, + "value mismatch for " + "FeatureName::ChromiumExperimentalSubgroupUniformControlFlow"); +static_assert(static_cast(FeatureName::PixelLocalStorageCoherent) == + WGPUFeatureName_PixelLocalStorageCoherent, + "value mismatch for FeatureName::PixelLocalStorageCoherent"); +static_assert( + static_cast(FeatureName::PixelLocalStorageNonCoherent) == + WGPUFeatureName_PixelLocalStorageNonCoherent, + "value mismatch for FeatureName::PixelLocalStorageNonCoherent"); +static_assert(static_cast(FeatureName::Unorm16TextureFormats) == + WGPUFeatureName_Unorm16TextureFormats, + "value mismatch for FeatureName::Unorm16TextureFormats"); +static_assert(static_cast(FeatureName::Snorm16TextureFormats) == + WGPUFeatureName_Snorm16TextureFormats, + "value mismatch for FeatureName::Snorm16TextureFormats"); +static_assert( + static_cast(FeatureName::MultiPlanarFormatExtendedUsages) == + WGPUFeatureName_MultiPlanarFormatExtendedUsages, + "value mismatch for FeatureName::MultiPlanarFormatExtendedUsages"); +static_assert(static_cast(FeatureName::MultiPlanarFormatP010) == + WGPUFeatureName_MultiPlanarFormatP010, + "value mismatch for FeatureName::MultiPlanarFormatP010"); +static_assert(static_cast(FeatureName::HostMappedPointer) == + WGPUFeatureName_HostMappedPointer, + "value mismatch for FeatureName::HostMappedPointer"); +static_assert(static_cast(FeatureName::MultiPlanarRenderTargets) == + WGPUFeatureName_MultiPlanarRenderTargets, + "value mismatch for FeatureName::MultiPlanarRenderTargets"); +static_assert(static_cast(FeatureName::MultiPlanarFormatNv12a) == + WGPUFeatureName_MultiPlanarFormatNv12a, + "value mismatch for FeatureName::MultiPlanarFormatNv12a"); +static_assert(static_cast(FeatureName::FramebufferFetch) == + WGPUFeatureName_FramebufferFetch, + "value mismatch for FeatureName::FramebufferFetch"); +static_assert(static_cast(FeatureName::BufferMapExtendedUsages) == + WGPUFeatureName_BufferMapExtendedUsages, + "value mismatch for FeatureName::BufferMapExtendedUsages"); +static_assert( + static_cast(FeatureName::AdapterPropertiesMemoryHeaps) == + WGPUFeatureName_AdapterPropertiesMemoryHeaps, + "value mismatch for FeatureName::AdapterPropertiesMemoryHeaps"); +static_assert(static_cast(FeatureName::AdapterPropertiesD3D) == + WGPUFeatureName_AdapterPropertiesD3D, + "value mismatch for FeatureName::AdapterPropertiesD3D"); +static_assert(static_cast(FeatureName::AdapterPropertiesVk) == + WGPUFeatureName_AdapterPropertiesVk, + "value mismatch for FeatureName::AdapterPropertiesVk"); +static_assert(static_cast(FeatureName::R8UnormStorage) == + WGPUFeatureName_R8UnormStorage, + "value mismatch for FeatureName::R8UnormStorage"); +static_assert(static_cast(FeatureName::FormatCapabilities) == + WGPUFeatureName_FormatCapabilities, + "value mismatch for FeatureName::FormatCapabilities"); +static_assert(static_cast(FeatureName::DrmFormatCapabilities) == + WGPUFeatureName_DrmFormatCapabilities, + "value mismatch for FeatureName::DrmFormatCapabilities"); +static_assert(static_cast(FeatureName::Norm16TextureFormats) == + WGPUFeatureName_Norm16TextureFormats, + "value mismatch for FeatureName::Norm16TextureFormats"); +static_assert( + static_cast( + FeatureName::SharedTextureMemoryVkDedicatedAllocation) == + WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation, + "value mismatch for FeatureName::SharedTextureMemoryVkDedicatedAllocation"); +static_assert( + static_cast(FeatureName::SharedTextureMemoryAHardwareBuffer) == + WGPUFeatureName_SharedTextureMemoryAHardwareBuffer, + "value mismatch for FeatureName::SharedTextureMemoryAHardwareBuffer"); +static_assert(static_cast(FeatureName::SharedTextureMemoryDmaBuf) == + WGPUFeatureName_SharedTextureMemoryDmaBuf, + "value mismatch for FeatureName::SharedTextureMemoryDmaBuf"); +static_assert(static_cast(FeatureName::SharedTextureMemoryOpaqueFD) == + WGPUFeatureName_SharedTextureMemoryOpaqueFD, + "value mismatch for FeatureName::SharedTextureMemoryOpaqueFD"); +static_assert( + static_cast(FeatureName::SharedTextureMemoryZirconHandle) == + WGPUFeatureName_SharedTextureMemoryZirconHandle, + "value mismatch for FeatureName::SharedTextureMemoryZirconHandle"); +static_assert( + static_cast(FeatureName::SharedTextureMemoryDXGISharedHandle) == + WGPUFeatureName_SharedTextureMemoryDXGISharedHandle, + "value mismatch for FeatureName::SharedTextureMemoryDXGISharedHandle"); +static_assert( + static_cast(FeatureName::SharedTextureMemoryD3D11Texture2D) == + WGPUFeatureName_SharedTextureMemoryD3D11Texture2D, + "value mismatch for FeatureName::SharedTextureMemoryD3D11Texture2D"); +static_assert( + static_cast(FeatureName::SharedTextureMemoryIOSurface) == + WGPUFeatureName_SharedTextureMemoryIOSurface, + "value mismatch for FeatureName::SharedTextureMemoryIOSurface"); +static_assert(static_cast(FeatureName::SharedTextureMemoryEGLImage) == + WGPUFeatureName_SharedTextureMemoryEGLImage, + "value mismatch for FeatureName::SharedTextureMemoryEGLImage"); +static_assert( + static_cast(FeatureName::SharedFenceVkSemaphoreOpaqueFD) == + WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD, + "value mismatch for FeatureName::SharedFenceVkSemaphoreOpaqueFD"); +static_assert( + static_cast(FeatureName::SharedFenceVkSemaphoreSyncFD) == + WGPUFeatureName_SharedFenceVkSemaphoreSyncFD, + "value mismatch for FeatureName::SharedFenceVkSemaphoreSyncFD"); +static_assert( + static_cast(FeatureName::SharedFenceVkSemaphoreZirconHandle) == + WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle, + "value mismatch for FeatureName::SharedFenceVkSemaphoreZirconHandle"); +static_assert(static_cast(FeatureName::SharedFenceDXGISharedHandle) == + WGPUFeatureName_SharedFenceDXGISharedHandle, + "value mismatch for FeatureName::SharedFenceDXGISharedHandle"); +static_assert(static_cast(FeatureName::SharedFenceMTLSharedEvent) == + WGPUFeatureName_SharedFenceMTLSharedEvent, + "value mismatch for FeatureName::SharedFenceMTLSharedEvent"); +static_assert( + static_cast(FeatureName::SharedBufferMemoryD3D12Resource) == + WGPUFeatureName_SharedBufferMemoryD3D12Resource, + "value mismatch for FeatureName::SharedBufferMemoryD3D12Resource"); +static_assert(static_cast(FeatureName::StaticSamplers) == + WGPUFeatureName_StaticSamplers, + "value mismatch for FeatureName::StaticSamplers"); + +// FilterMode + +static_assert(sizeof(FilterMode) == sizeof(WGPUFilterMode), + "sizeof mismatch for FilterMode"); +static_assert(alignof(FilterMode) == alignof(WGPUFilterMode), + "alignof mismatch for FilterMode"); + +static_assert(static_cast(FilterMode::Undefined) == + WGPUFilterMode_Undefined, + "value mismatch for FilterMode::Undefined"); +static_assert(static_cast(FilterMode::Nearest) == + WGPUFilterMode_Nearest, + "value mismatch for FilterMode::Nearest"); +static_assert(static_cast(FilterMode::Linear) == + WGPUFilterMode_Linear, + "value mismatch for FilterMode::Linear"); + +// FrontFace + +static_assert(sizeof(FrontFace) == sizeof(WGPUFrontFace), + "sizeof mismatch for FrontFace"); +static_assert(alignof(FrontFace) == alignof(WGPUFrontFace), + "alignof mismatch for FrontFace"); + +static_assert(static_cast(FrontFace::Undefined) == + WGPUFrontFace_Undefined, + "value mismatch for FrontFace::Undefined"); +static_assert(static_cast(FrontFace::CCW) == WGPUFrontFace_CCW, + "value mismatch for FrontFace::CCW"); +static_assert(static_cast(FrontFace::CW) == WGPUFrontFace_CW, + "value mismatch for FrontFace::CW"); + +// IndexFormat + +static_assert(sizeof(IndexFormat) == sizeof(WGPUIndexFormat), + "sizeof mismatch for IndexFormat"); +static_assert(alignof(IndexFormat) == alignof(WGPUIndexFormat), + "alignof mismatch for IndexFormat"); + +static_assert(static_cast(IndexFormat::Undefined) == + WGPUIndexFormat_Undefined, + "value mismatch for IndexFormat::Undefined"); +static_assert(static_cast(IndexFormat::Uint16) == + WGPUIndexFormat_Uint16, + "value mismatch for IndexFormat::Uint16"); +static_assert(static_cast(IndexFormat::Uint32) == + WGPUIndexFormat_Uint32, + "value mismatch for IndexFormat::Uint32"); + +// LoadOp + +static_assert(sizeof(LoadOp) == sizeof(WGPULoadOp), + "sizeof mismatch for LoadOp"); +static_assert(alignof(LoadOp) == alignof(WGPULoadOp), + "alignof mismatch for LoadOp"); + +static_assert(static_cast(LoadOp::Undefined) == WGPULoadOp_Undefined, + "value mismatch for LoadOp::Undefined"); +static_assert(static_cast(LoadOp::Clear) == WGPULoadOp_Clear, + "value mismatch for LoadOp::Clear"); +static_assert(static_cast(LoadOp::Load) == WGPULoadOp_Load, + "value mismatch for LoadOp::Load"); + +// LoggingType + +static_assert(sizeof(LoggingType) == sizeof(WGPULoggingType), + "sizeof mismatch for LoggingType"); +static_assert(alignof(LoggingType) == alignof(WGPULoggingType), + "alignof mismatch for LoggingType"); + +static_assert(static_cast(LoggingType::Verbose) == + WGPULoggingType_Verbose, + "value mismatch for LoggingType::Verbose"); +static_assert(static_cast(LoggingType::Info) == WGPULoggingType_Info, + "value mismatch for LoggingType::Info"); +static_assert(static_cast(LoggingType::Warning) == + WGPULoggingType_Warning, + "value mismatch for LoggingType::Warning"); +static_assert(static_cast(LoggingType::Error) == + WGPULoggingType_Error, + "value mismatch for LoggingType::Error"); + +// MipmapFilterMode + +static_assert(sizeof(MipmapFilterMode) == sizeof(WGPUMipmapFilterMode), + "sizeof mismatch for MipmapFilterMode"); +static_assert(alignof(MipmapFilterMode) == alignof(WGPUMipmapFilterMode), + "alignof mismatch for MipmapFilterMode"); + +static_assert(static_cast(MipmapFilterMode::Undefined) == + WGPUMipmapFilterMode_Undefined, + "value mismatch for MipmapFilterMode::Undefined"); +static_assert(static_cast(MipmapFilterMode::Nearest) == + WGPUMipmapFilterMode_Nearest, + "value mismatch for MipmapFilterMode::Nearest"); +static_assert(static_cast(MipmapFilterMode::Linear) == + WGPUMipmapFilterMode_Linear, + "value mismatch for MipmapFilterMode::Linear"); + +// PopErrorScopeStatus + +static_assert(sizeof(PopErrorScopeStatus) == sizeof(WGPUPopErrorScopeStatus), + "sizeof mismatch for PopErrorScopeStatus"); +static_assert(alignof(PopErrorScopeStatus) == alignof(WGPUPopErrorScopeStatus), + "alignof mismatch for PopErrorScopeStatus"); + +static_assert(static_cast(PopErrorScopeStatus::Success) == + WGPUPopErrorScopeStatus_Success, + "value mismatch for PopErrorScopeStatus::Success"); +static_assert(static_cast(PopErrorScopeStatus::InstanceDropped) == + WGPUPopErrorScopeStatus_InstanceDropped, + "value mismatch for PopErrorScopeStatus::InstanceDropped"); + +// PowerPreference + +static_assert(sizeof(PowerPreference) == sizeof(WGPUPowerPreference), + "sizeof mismatch for PowerPreference"); +static_assert(alignof(PowerPreference) == alignof(WGPUPowerPreference), + "alignof mismatch for PowerPreference"); + +static_assert(static_cast(PowerPreference::Undefined) == + WGPUPowerPreference_Undefined, + "value mismatch for PowerPreference::Undefined"); +static_assert(static_cast(PowerPreference::LowPower) == + WGPUPowerPreference_LowPower, + "value mismatch for PowerPreference::LowPower"); +static_assert(static_cast(PowerPreference::HighPerformance) == + WGPUPowerPreference_HighPerformance, + "value mismatch for PowerPreference::HighPerformance"); + +// PresentMode + +static_assert(sizeof(PresentMode) == sizeof(WGPUPresentMode), + "sizeof mismatch for PresentMode"); +static_assert(alignof(PresentMode) == alignof(WGPUPresentMode), + "alignof mismatch for PresentMode"); + +static_assert(static_cast(PresentMode::Fifo) == WGPUPresentMode_Fifo, + "value mismatch for PresentMode::Fifo"); +static_assert(static_cast(PresentMode::Immediate) == + WGPUPresentMode_Immediate, + "value mismatch for PresentMode::Immediate"); +static_assert(static_cast(PresentMode::Mailbox) == + WGPUPresentMode_Mailbox, + "value mismatch for PresentMode::Mailbox"); + +// PrimitiveTopology + +static_assert(sizeof(PrimitiveTopology) == sizeof(WGPUPrimitiveTopology), + "sizeof mismatch for PrimitiveTopology"); +static_assert(alignof(PrimitiveTopology) == alignof(WGPUPrimitiveTopology), + "alignof mismatch for PrimitiveTopology"); + +static_assert(static_cast(PrimitiveTopology::Undefined) == + WGPUPrimitiveTopology_Undefined, + "value mismatch for PrimitiveTopology::Undefined"); +static_assert(static_cast(PrimitiveTopology::PointList) == + WGPUPrimitiveTopology_PointList, + "value mismatch for PrimitiveTopology::PointList"); +static_assert(static_cast(PrimitiveTopology::LineList) == + WGPUPrimitiveTopology_LineList, + "value mismatch for PrimitiveTopology::LineList"); +static_assert(static_cast(PrimitiveTopology::LineStrip) == + WGPUPrimitiveTopology_LineStrip, + "value mismatch for PrimitiveTopology::LineStrip"); +static_assert(static_cast(PrimitiveTopology::TriangleList) == + WGPUPrimitiveTopology_TriangleList, + "value mismatch for PrimitiveTopology::TriangleList"); +static_assert(static_cast(PrimitiveTopology::TriangleStrip) == + WGPUPrimitiveTopology_TriangleStrip, + "value mismatch for PrimitiveTopology::TriangleStrip"); + +// QueryType + +static_assert(sizeof(QueryType) == sizeof(WGPUQueryType), + "sizeof mismatch for QueryType"); +static_assert(alignof(QueryType) == alignof(WGPUQueryType), + "alignof mismatch for QueryType"); + +static_assert(static_cast(QueryType::Occlusion) == + WGPUQueryType_Occlusion, + "value mismatch for QueryType::Occlusion"); +static_assert(static_cast(QueryType::Timestamp) == + WGPUQueryType_Timestamp, + "value mismatch for QueryType::Timestamp"); + +// QueueWorkDoneStatus + +static_assert(sizeof(QueueWorkDoneStatus) == sizeof(WGPUQueueWorkDoneStatus), + "sizeof mismatch for QueueWorkDoneStatus"); +static_assert(alignof(QueueWorkDoneStatus) == alignof(WGPUQueueWorkDoneStatus), + "alignof mismatch for QueueWorkDoneStatus"); + +static_assert(static_cast(QueueWorkDoneStatus::Success) == + WGPUQueueWorkDoneStatus_Success, + "value mismatch for QueueWorkDoneStatus::Success"); +static_assert(static_cast(QueueWorkDoneStatus::InstanceDropped) == + WGPUQueueWorkDoneStatus_InstanceDropped, + "value mismatch for QueueWorkDoneStatus::InstanceDropped"); +static_assert(static_cast(QueueWorkDoneStatus::Error) == + WGPUQueueWorkDoneStatus_Error, + "value mismatch for QueueWorkDoneStatus::Error"); +static_assert(static_cast(QueueWorkDoneStatus::Unknown) == + WGPUQueueWorkDoneStatus_Unknown, + "value mismatch for QueueWorkDoneStatus::Unknown"); +static_assert(static_cast(QueueWorkDoneStatus::DeviceLost) == + WGPUQueueWorkDoneStatus_DeviceLost, + "value mismatch for QueueWorkDoneStatus::DeviceLost"); + +// RequestAdapterStatus + +static_assert(sizeof(RequestAdapterStatus) == sizeof(WGPURequestAdapterStatus), + "sizeof mismatch for RequestAdapterStatus"); +static_assert(alignof(RequestAdapterStatus) == + alignof(WGPURequestAdapterStatus), + "alignof mismatch for RequestAdapterStatus"); + +static_assert(static_cast(RequestAdapterStatus::Success) == + WGPURequestAdapterStatus_Success, + "value mismatch for RequestAdapterStatus::Success"); +static_assert(static_cast(RequestAdapterStatus::InstanceDropped) == + WGPURequestAdapterStatus_InstanceDropped, + "value mismatch for RequestAdapterStatus::InstanceDropped"); +static_assert(static_cast(RequestAdapterStatus::Unavailable) == + WGPURequestAdapterStatus_Unavailable, + "value mismatch for RequestAdapterStatus::Unavailable"); +static_assert(static_cast(RequestAdapterStatus::Error) == + WGPURequestAdapterStatus_Error, + "value mismatch for RequestAdapterStatus::Error"); +static_assert(static_cast(RequestAdapterStatus::Unknown) == + WGPURequestAdapterStatus_Unknown, + "value mismatch for RequestAdapterStatus::Unknown"); + +// RequestDeviceStatus + +static_assert(sizeof(RequestDeviceStatus) == sizeof(WGPURequestDeviceStatus), + "sizeof mismatch for RequestDeviceStatus"); +static_assert(alignof(RequestDeviceStatus) == alignof(WGPURequestDeviceStatus), + "alignof mismatch for RequestDeviceStatus"); + +static_assert(static_cast(RequestDeviceStatus::Success) == + WGPURequestDeviceStatus_Success, + "value mismatch for RequestDeviceStatus::Success"); +static_assert(static_cast(RequestDeviceStatus::InstanceDropped) == + WGPURequestDeviceStatus_InstanceDropped, + "value mismatch for RequestDeviceStatus::InstanceDropped"); +static_assert(static_cast(RequestDeviceStatus::Error) == + WGPURequestDeviceStatus_Error, + "value mismatch for RequestDeviceStatus::Error"); +static_assert(static_cast(RequestDeviceStatus::Unknown) == + WGPURequestDeviceStatus_Unknown, + "value mismatch for RequestDeviceStatus::Unknown"); + +// SType + +static_assert(sizeof(SType) == sizeof(WGPUSType), "sizeof mismatch for SType"); +static_assert(alignof(SType) == alignof(WGPUSType), + "alignof mismatch for SType"); + +static_assert(static_cast(SType::Invalid) == WGPUSType_Invalid, + "value mismatch for SType::Invalid"); +static_assert(static_cast(SType::SurfaceDescriptorFromMetalLayer) == + WGPUSType_SurfaceDescriptorFromMetalLayer, + "value mismatch for SType::SurfaceDescriptorFromMetalLayer"); +static_assert(static_cast(SType::SurfaceDescriptorFromWindowsHWND) == + WGPUSType_SurfaceDescriptorFromWindowsHWND, + "value mismatch for SType::SurfaceDescriptorFromWindowsHWND"); +static_assert(static_cast(SType::SurfaceDescriptorFromXlibWindow) == + WGPUSType_SurfaceDescriptorFromXlibWindow, + "value mismatch for SType::SurfaceDescriptorFromXlibWindow"); +static_assert( + static_cast(SType::SurfaceDescriptorFromCanvasHTMLSelector) == + WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector, + "value mismatch for SType::SurfaceDescriptorFromCanvasHTMLSelector"); +static_assert(static_cast(SType::ShaderModuleSPIRVDescriptor) == + WGPUSType_ShaderModuleSPIRVDescriptor, + "value mismatch for SType::ShaderModuleSPIRVDescriptor"); +static_assert(static_cast(SType::ShaderModuleWGSLDescriptor) == + WGPUSType_ShaderModuleWGSLDescriptor, + "value mismatch for SType::ShaderModuleWGSLDescriptor"); +static_assert(static_cast(SType::PrimitiveDepthClipControl) == + WGPUSType_PrimitiveDepthClipControl, + "value mismatch for SType::PrimitiveDepthClipControl"); +static_assert( + static_cast(SType::SurfaceDescriptorFromWaylandSurface) == + WGPUSType_SurfaceDescriptorFromWaylandSurface, + "value mismatch for SType::SurfaceDescriptorFromWaylandSurface"); +static_assert( + static_cast(SType::SurfaceDescriptorFromAndroidNativeWindow) == + WGPUSType_SurfaceDescriptorFromAndroidNativeWindow, + "value mismatch for SType::SurfaceDescriptorFromAndroidNativeWindow"); +static_assert( + static_cast(SType::SurfaceDescriptorFromWindowsCoreWindow) == + WGPUSType_SurfaceDescriptorFromWindowsCoreWindow, + "value mismatch for SType::SurfaceDescriptorFromWindowsCoreWindow"); +static_assert(static_cast(SType::ExternalTextureBindingEntry) == + WGPUSType_ExternalTextureBindingEntry, + "value mismatch for SType::ExternalTextureBindingEntry"); +static_assert(static_cast(SType::ExternalTextureBindingLayout) == + WGPUSType_ExternalTextureBindingLayout, + "value mismatch for SType::ExternalTextureBindingLayout"); +static_assert( + static_cast(SType::SurfaceDescriptorFromWindowsSwapChainPanel) == + WGPUSType_SurfaceDescriptorFromWindowsSwapChainPanel, + "value mismatch for SType::SurfaceDescriptorFromWindowsSwapChainPanel"); +static_assert(static_cast(SType::RenderPassDescriptorMaxDrawCount) == + WGPUSType_RenderPassDescriptorMaxDrawCount, + "value mismatch for SType::RenderPassDescriptorMaxDrawCount"); +static_assert( + static_cast(SType::DepthStencilStateDepthWriteDefinedDawn) == + WGPUSType_DepthStencilStateDepthWriteDefinedDawn, + "value mismatch for SType::DepthStencilStateDepthWriteDefinedDawn"); +static_assert( + static_cast(SType::TextureBindingViewDimensionDescriptor) == + WGPUSType_TextureBindingViewDimensionDescriptor, + "value mismatch for SType::TextureBindingViewDimensionDescriptor"); +static_assert( + static_cast(SType::DawnTextureInternalUsageDescriptor) == + WGPUSType_DawnTextureInternalUsageDescriptor, + "value mismatch for SType::DawnTextureInternalUsageDescriptor"); +static_assert( + static_cast(SType::DawnEncoderInternalUsageDescriptor) == + WGPUSType_DawnEncoderInternalUsageDescriptor, + "value mismatch for SType::DawnEncoderInternalUsageDescriptor"); +static_assert(static_cast(SType::DawnInstanceDescriptor) == + WGPUSType_DawnInstanceDescriptor, + "value mismatch for SType::DawnInstanceDescriptor"); +static_assert(static_cast(SType::DawnCacheDeviceDescriptor) == + WGPUSType_DawnCacheDeviceDescriptor, + "value mismatch for SType::DawnCacheDeviceDescriptor"); +static_assert( + static_cast(SType::DawnAdapterPropertiesPowerPreference) == + WGPUSType_DawnAdapterPropertiesPowerPreference, + "value mismatch for SType::DawnAdapterPropertiesPowerPreference"); +static_assert( + static_cast(SType::DawnBufferDescriptorErrorInfoFromWireClient) == + WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient, + "value mismatch for SType::DawnBufferDescriptorErrorInfoFromWireClient"); +static_assert(static_cast(SType::DawnTogglesDescriptor) == + WGPUSType_DawnTogglesDescriptor, + "value mismatch for SType::DawnTogglesDescriptor"); +static_assert( + static_cast(SType::DawnShaderModuleSPIRVOptionsDescriptor) == + WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor, + "value mismatch for SType::DawnShaderModuleSPIRVOptionsDescriptor"); +static_assert(static_cast(SType::RequestAdapterOptionsLUID) == + WGPUSType_RequestAdapterOptionsLUID, + "value mismatch for SType::RequestAdapterOptionsLUID"); +static_assert(static_cast(SType::RequestAdapterOptionsGetGLProc) == + WGPUSType_RequestAdapterOptionsGetGLProc, + "value mismatch for SType::RequestAdapterOptionsGetGLProc"); +static_assert(static_cast(SType::RequestAdapterOptionsD3D11Device) == + WGPUSType_RequestAdapterOptionsD3D11Device, + "value mismatch for SType::RequestAdapterOptionsD3D11Device"); +static_assert( + static_cast(SType::DawnMultisampleStateRenderToSingleSampled) == + WGPUSType_DawnMultisampleStateRenderToSingleSampled, + "value mismatch for SType::DawnMultisampleStateRenderToSingleSampled"); +static_assert(static_cast( + SType::DawnRenderPassColorAttachmentRenderToSingleSampled) == + WGPUSType_DawnRenderPassColorAttachmentRenderToSingleSampled, + "value mismatch for " + "SType::DawnRenderPassColorAttachmentRenderToSingleSampled"); +static_assert(static_cast(SType::RenderPassPixelLocalStorage) == + WGPUSType_RenderPassPixelLocalStorage, + "value mismatch for SType::RenderPassPixelLocalStorage"); +static_assert(static_cast(SType::PipelineLayoutPixelLocalStorage) == + WGPUSType_PipelineLayoutPixelLocalStorage, + "value mismatch for SType::PipelineLayoutPixelLocalStorage"); +static_assert(static_cast(SType::BufferHostMappedPointer) == + WGPUSType_BufferHostMappedPointer, + "value mismatch for SType::BufferHostMappedPointer"); +static_assert(static_cast(SType::DawnExperimentalSubgroupLimits) == + WGPUSType_DawnExperimentalSubgroupLimits, + "value mismatch for SType::DawnExperimentalSubgroupLimits"); +static_assert(static_cast(SType::AdapterPropertiesMemoryHeaps) == + WGPUSType_AdapterPropertiesMemoryHeaps, + "value mismatch for SType::AdapterPropertiesMemoryHeaps"); +static_assert(static_cast(SType::AdapterPropertiesD3D) == + WGPUSType_AdapterPropertiesD3D, + "value mismatch for SType::AdapterPropertiesD3D"); +static_assert(static_cast(SType::AdapterPropertiesVk) == + WGPUSType_AdapterPropertiesVk, + "value mismatch for SType::AdapterPropertiesVk"); +static_assert(static_cast(SType::DawnComputePipelineFullSubgroups) == + WGPUSType_DawnComputePipelineFullSubgroups, + "value mismatch for SType::DawnComputePipelineFullSubgroups"); +static_assert(static_cast(SType::DawnWireWGSLControl) == + WGPUSType_DawnWireWGSLControl, + "value mismatch for SType::DawnWireWGSLControl"); +static_assert(static_cast(SType::DawnWGSLBlocklist) == + WGPUSType_DawnWGSLBlocklist, + "value mismatch for SType::DawnWGSLBlocklist"); +static_assert(static_cast(SType::DrmFormatCapabilities) == + WGPUSType_DrmFormatCapabilities, + "value mismatch for SType::DrmFormatCapabilities"); +static_assert( + static_cast(SType::SharedTextureMemoryVkImageDescriptor) == + WGPUSType_SharedTextureMemoryVkImageDescriptor, + "value mismatch for SType::SharedTextureMemoryVkImageDescriptor"); +static_assert(static_cast( + SType::SharedTextureMemoryVkDedicatedAllocationDescriptor) == + WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor, + "value mismatch for " + "SType::SharedTextureMemoryVkDedicatedAllocationDescriptor"); +static_assert( + static_cast( + SType::SharedTextureMemoryAHardwareBufferDescriptor) == + WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor, + "value mismatch for SType::SharedTextureMemoryAHardwareBufferDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryDmaBufDescriptor) == + WGPUSType_SharedTextureMemoryDmaBufDescriptor, + "value mismatch for SType::SharedTextureMemoryDmaBufDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryOpaqueFDDescriptor) == + WGPUSType_SharedTextureMemoryOpaqueFDDescriptor, + "value mismatch for SType::SharedTextureMemoryOpaqueFDDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryZirconHandleDescriptor) == + WGPUSType_SharedTextureMemoryZirconHandleDescriptor, + "value mismatch for SType::SharedTextureMemoryZirconHandleDescriptor"); +static_assert( + static_cast( + SType::SharedTextureMemoryDXGISharedHandleDescriptor) == + WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor, + "value mismatch for SType::SharedTextureMemoryDXGISharedHandleDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryD3D11Texture2DDescriptor) == + WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor, + "value mismatch for SType::SharedTextureMemoryD3D11Texture2DDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryIOSurfaceDescriptor) == + WGPUSType_SharedTextureMemoryIOSurfaceDescriptor, + "value mismatch for SType::SharedTextureMemoryIOSurfaceDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryEGLImageDescriptor) == + WGPUSType_SharedTextureMemoryEGLImageDescriptor, + "value mismatch for SType::SharedTextureMemoryEGLImageDescriptor"); +static_assert( + static_cast(SType::SharedTextureMemoryInitializedBeginState) == + WGPUSType_SharedTextureMemoryInitializedBeginState, + "value mismatch for SType::SharedTextureMemoryInitializedBeginState"); +static_assert( + static_cast(SType::SharedTextureMemoryInitializedEndState) == + WGPUSType_SharedTextureMemoryInitializedEndState, + "value mismatch for SType::SharedTextureMemoryInitializedEndState"); +static_assert( + static_cast(SType::SharedTextureMemoryVkImageLayoutBeginState) == + WGPUSType_SharedTextureMemoryVkImageLayoutBeginState, + "value mismatch for SType::SharedTextureMemoryVkImageLayoutBeginState"); +static_assert( + static_cast(SType::SharedTextureMemoryVkImageLayoutEndState) == + WGPUSType_SharedTextureMemoryVkImageLayoutEndState, + "value mismatch for SType::SharedTextureMemoryVkImageLayoutEndState"); +static_assert( + static_cast(SType::SharedFenceVkSemaphoreOpaqueFDDescriptor) == + WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor, + "value mismatch for SType::SharedFenceVkSemaphoreOpaqueFDDescriptor"); +static_assert( + static_cast(SType::SharedFenceVkSemaphoreOpaqueFDExportInfo) == + WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo, + "value mismatch for SType::SharedFenceVkSemaphoreOpaqueFDExportInfo"); +static_assert( + static_cast(SType::SharedFenceVkSemaphoreSyncFDDescriptor) == + WGPUSType_SharedFenceVkSemaphoreSyncFDDescriptor, + "value mismatch for SType::SharedFenceVkSemaphoreSyncFDDescriptor"); +static_assert( + static_cast(SType::SharedFenceVkSemaphoreSyncFDExportInfo) == + WGPUSType_SharedFenceVkSemaphoreSyncFDExportInfo, + "value mismatch for SType::SharedFenceVkSemaphoreSyncFDExportInfo"); +static_assert( + static_cast( + SType::SharedFenceVkSemaphoreZirconHandleDescriptor) == + WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor, + "value mismatch for SType::SharedFenceVkSemaphoreZirconHandleDescriptor"); +static_assert( + static_cast( + SType::SharedFenceVkSemaphoreZirconHandleExportInfo) == + WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo, + "value mismatch for SType::SharedFenceVkSemaphoreZirconHandleExportInfo"); +static_assert( + static_cast(SType::SharedFenceDXGISharedHandleDescriptor) == + WGPUSType_SharedFenceDXGISharedHandleDescriptor, + "value mismatch for SType::SharedFenceDXGISharedHandleDescriptor"); +static_assert( + static_cast(SType::SharedFenceDXGISharedHandleExportInfo) == + WGPUSType_SharedFenceDXGISharedHandleExportInfo, + "value mismatch for SType::SharedFenceDXGISharedHandleExportInfo"); +static_assert( + static_cast(SType::SharedFenceMTLSharedEventDescriptor) == + WGPUSType_SharedFenceMTLSharedEventDescriptor, + "value mismatch for SType::SharedFenceMTLSharedEventDescriptor"); +static_assert( + static_cast(SType::SharedFenceMTLSharedEventExportInfo) == + WGPUSType_SharedFenceMTLSharedEventExportInfo, + "value mismatch for SType::SharedFenceMTLSharedEventExportInfo"); +static_assert( + static_cast(SType::SharedBufferMemoryD3D12ResourceDescriptor) == + WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor, + "value mismatch for SType::SharedBufferMemoryD3D12ResourceDescriptor"); +static_assert(static_cast(SType::StaticSamplerBindingLayout) == + WGPUSType_StaticSamplerBindingLayout, + "value mismatch for SType::StaticSamplerBindingLayout"); + +// SamplerBindingType + +static_assert(sizeof(SamplerBindingType) == sizeof(WGPUSamplerBindingType), + "sizeof mismatch for SamplerBindingType"); +static_assert(alignof(SamplerBindingType) == alignof(WGPUSamplerBindingType), + "alignof mismatch for SamplerBindingType"); + +static_assert(static_cast(SamplerBindingType::Undefined) == + WGPUSamplerBindingType_Undefined, + "value mismatch for SamplerBindingType::Undefined"); +static_assert(static_cast(SamplerBindingType::Filtering) == + WGPUSamplerBindingType_Filtering, + "value mismatch for SamplerBindingType::Filtering"); +static_assert(static_cast(SamplerBindingType::NonFiltering) == + WGPUSamplerBindingType_NonFiltering, + "value mismatch for SamplerBindingType::NonFiltering"); +static_assert(static_cast(SamplerBindingType::Comparison) == + WGPUSamplerBindingType_Comparison, + "value mismatch for SamplerBindingType::Comparison"); + +// SharedFenceType + +static_assert(sizeof(SharedFenceType) == sizeof(WGPUSharedFenceType), + "sizeof mismatch for SharedFenceType"); +static_assert(alignof(SharedFenceType) == alignof(WGPUSharedFenceType), + "alignof mismatch for SharedFenceType"); + +static_assert(static_cast(SharedFenceType::Undefined) == + WGPUSharedFenceType_Undefined, + "value mismatch for SharedFenceType::Undefined"); +static_assert(static_cast(SharedFenceType::VkSemaphoreOpaqueFD) == + WGPUSharedFenceType_VkSemaphoreOpaqueFD, + "value mismatch for SharedFenceType::VkSemaphoreOpaqueFD"); +static_assert(static_cast(SharedFenceType::VkSemaphoreSyncFD) == + WGPUSharedFenceType_VkSemaphoreSyncFD, + "value mismatch for SharedFenceType::VkSemaphoreSyncFD"); +static_assert(static_cast(SharedFenceType::VkSemaphoreZirconHandle) == + WGPUSharedFenceType_VkSemaphoreZirconHandle, + "value mismatch for SharedFenceType::VkSemaphoreZirconHandle"); +static_assert(static_cast(SharedFenceType::DXGISharedHandle) == + WGPUSharedFenceType_DXGISharedHandle, + "value mismatch for SharedFenceType::DXGISharedHandle"); +static_assert(static_cast(SharedFenceType::MTLSharedEvent) == + WGPUSharedFenceType_MTLSharedEvent, + "value mismatch for SharedFenceType::MTLSharedEvent"); + +// StencilOperation + +static_assert(sizeof(StencilOperation) == sizeof(WGPUStencilOperation), + "sizeof mismatch for StencilOperation"); +static_assert(alignof(StencilOperation) == alignof(WGPUStencilOperation), + "alignof mismatch for StencilOperation"); + +static_assert(static_cast(StencilOperation::Undefined) == + WGPUStencilOperation_Undefined, + "value mismatch for StencilOperation::Undefined"); +static_assert(static_cast(StencilOperation::Keep) == + WGPUStencilOperation_Keep, + "value mismatch for StencilOperation::Keep"); +static_assert(static_cast(StencilOperation::Zero) == + WGPUStencilOperation_Zero, + "value mismatch for StencilOperation::Zero"); +static_assert(static_cast(StencilOperation::Replace) == + WGPUStencilOperation_Replace, + "value mismatch for StencilOperation::Replace"); +static_assert(static_cast(StencilOperation::Invert) == + WGPUStencilOperation_Invert, + "value mismatch for StencilOperation::Invert"); +static_assert(static_cast(StencilOperation::IncrementClamp) == + WGPUStencilOperation_IncrementClamp, + "value mismatch for StencilOperation::IncrementClamp"); +static_assert(static_cast(StencilOperation::DecrementClamp) == + WGPUStencilOperation_DecrementClamp, + "value mismatch for StencilOperation::DecrementClamp"); +static_assert(static_cast(StencilOperation::IncrementWrap) == + WGPUStencilOperation_IncrementWrap, + "value mismatch for StencilOperation::IncrementWrap"); +static_assert(static_cast(StencilOperation::DecrementWrap) == + WGPUStencilOperation_DecrementWrap, + "value mismatch for StencilOperation::DecrementWrap"); + +// StorageTextureAccess + +static_assert(sizeof(StorageTextureAccess) == sizeof(WGPUStorageTextureAccess), + "sizeof mismatch for StorageTextureAccess"); +static_assert(alignof(StorageTextureAccess) == + alignof(WGPUStorageTextureAccess), + "alignof mismatch for StorageTextureAccess"); + +static_assert(static_cast(StorageTextureAccess::Undefined) == + WGPUStorageTextureAccess_Undefined, + "value mismatch for StorageTextureAccess::Undefined"); +static_assert(static_cast(StorageTextureAccess::WriteOnly) == + WGPUStorageTextureAccess_WriteOnly, + "value mismatch for StorageTextureAccess::WriteOnly"); +static_assert(static_cast(StorageTextureAccess::ReadOnly) == + WGPUStorageTextureAccess_ReadOnly, + "value mismatch for StorageTextureAccess::ReadOnly"); +static_assert(static_cast(StorageTextureAccess::ReadWrite) == + WGPUStorageTextureAccess_ReadWrite, + "value mismatch for StorageTextureAccess::ReadWrite"); + +// StoreOp + +static_assert(sizeof(StoreOp) == sizeof(WGPUStoreOp), + "sizeof mismatch for StoreOp"); +static_assert(alignof(StoreOp) == alignof(WGPUStoreOp), + "alignof mismatch for StoreOp"); + +static_assert(static_cast(StoreOp::Undefined) == + WGPUStoreOp_Undefined, + "value mismatch for StoreOp::Undefined"); +static_assert(static_cast(StoreOp::Store) == WGPUStoreOp_Store, + "value mismatch for StoreOp::Store"); +static_assert(static_cast(StoreOp::Discard) == WGPUStoreOp_Discard, + "value mismatch for StoreOp::Discard"); + +// TextureAspect + +static_assert(sizeof(TextureAspect) == sizeof(WGPUTextureAspect), + "sizeof mismatch for TextureAspect"); +static_assert(alignof(TextureAspect) == alignof(WGPUTextureAspect), + "alignof mismatch for TextureAspect"); + +static_assert(static_cast(TextureAspect::Undefined) == + WGPUTextureAspect_Undefined, + "value mismatch for TextureAspect::Undefined"); +static_assert(static_cast(TextureAspect::All) == + WGPUTextureAspect_All, + "value mismatch for TextureAspect::All"); +static_assert(static_cast(TextureAspect::StencilOnly) == + WGPUTextureAspect_StencilOnly, + "value mismatch for TextureAspect::StencilOnly"); +static_assert(static_cast(TextureAspect::DepthOnly) == + WGPUTextureAspect_DepthOnly, + "value mismatch for TextureAspect::DepthOnly"); +static_assert(static_cast(TextureAspect::Plane0Only) == + WGPUTextureAspect_Plane0Only, + "value mismatch for TextureAspect::Plane0Only"); +static_assert(static_cast(TextureAspect::Plane1Only) == + WGPUTextureAspect_Plane1Only, + "value mismatch for TextureAspect::Plane1Only"); +static_assert(static_cast(TextureAspect::Plane2Only) == + WGPUTextureAspect_Plane2Only, + "value mismatch for TextureAspect::Plane2Only"); + +// TextureDimension + +static_assert(sizeof(TextureDimension) == sizeof(WGPUTextureDimension), + "sizeof mismatch for TextureDimension"); +static_assert(alignof(TextureDimension) == alignof(WGPUTextureDimension), + "alignof mismatch for TextureDimension"); + +static_assert(static_cast(TextureDimension::Undefined) == + WGPUTextureDimension_Undefined, + "value mismatch for TextureDimension::Undefined"); +static_assert(static_cast(TextureDimension::e1D) == + WGPUTextureDimension_1D, + "value mismatch for TextureDimension::e1D"); +static_assert(static_cast(TextureDimension::e2D) == + WGPUTextureDimension_2D, + "value mismatch for TextureDimension::e2D"); +static_assert(static_cast(TextureDimension::e3D) == + WGPUTextureDimension_3D, + "value mismatch for TextureDimension::e3D"); + +// TextureFormat + +static_assert(sizeof(TextureFormat) == sizeof(WGPUTextureFormat), + "sizeof mismatch for TextureFormat"); +static_assert(alignof(TextureFormat) == alignof(WGPUTextureFormat), + "alignof mismatch for TextureFormat"); + +static_assert(static_cast(TextureFormat::Undefined) == + WGPUTextureFormat_Undefined, + "value mismatch for TextureFormat::Undefined"); +static_assert(static_cast(TextureFormat::R8Unorm) == + WGPUTextureFormat_R8Unorm, + "value mismatch for TextureFormat::R8Unorm"); +static_assert(static_cast(TextureFormat::R8Snorm) == + WGPUTextureFormat_R8Snorm, + "value mismatch for TextureFormat::R8Snorm"); +static_assert(static_cast(TextureFormat::R8Uint) == + WGPUTextureFormat_R8Uint, + "value mismatch for TextureFormat::R8Uint"); +static_assert(static_cast(TextureFormat::R8Sint) == + WGPUTextureFormat_R8Sint, + "value mismatch for TextureFormat::R8Sint"); +static_assert(static_cast(TextureFormat::R16Uint) == + WGPUTextureFormat_R16Uint, + "value mismatch for TextureFormat::R16Uint"); +static_assert(static_cast(TextureFormat::R16Sint) == + WGPUTextureFormat_R16Sint, + "value mismatch for TextureFormat::R16Sint"); +static_assert(static_cast(TextureFormat::R16Float) == + WGPUTextureFormat_R16Float, + "value mismatch for TextureFormat::R16Float"); +static_assert(static_cast(TextureFormat::RG8Unorm) == + WGPUTextureFormat_RG8Unorm, + "value mismatch for TextureFormat::RG8Unorm"); +static_assert(static_cast(TextureFormat::RG8Snorm) == + WGPUTextureFormat_RG8Snorm, + "value mismatch for TextureFormat::RG8Snorm"); +static_assert(static_cast(TextureFormat::RG8Uint) == + WGPUTextureFormat_RG8Uint, + "value mismatch for TextureFormat::RG8Uint"); +static_assert(static_cast(TextureFormat::RG8Sint) == + WGPUTextureFormat_RG8Sint, + "value mismatch for TextureFormat::RG8Sint"); +static_assert(static_cast(TextureFormat::R32Float) == + WGPUTextureFormat_R32Float, + "value mismatch for TextureFormat::R32Float"); +static_assert(static_cast(TextureFormat::R32Uint) == + WGPUTextureFormat_R32Uint, + "value mismatch for TextureFormat::R32Uint"); +static_assert(static_cast(TextureFormat::R32Sint) == + WGPUTextureFormat_R32Sint, + "value mismatch for TextureFormat::R32Sint"); +static_assert(static_cast(TextureFormat::RG16Uint) == + WGPUTextureFormat_RG16Uint, + "value mismatch for TextureFormat::RG16Uint"); +static_assert(static_cast(TextureFormat::RG16Sint) == + WGPUTextureFormat_RG16Sint, + "value mismatch for TextureFormat::RG16Sint"); +static_assert(static_cast(TextureFormat::RG16Float) == + WGPUTextureFormat_RG16Float, + "value mismatch for TextureFormat::RG16Float"); +static_assert(static_cast(TextureFormat::RGBA8Unorm) == + WGPUTextureFormat_RGBA8Unorm, + "value mismatch for TextureFormat::RGBA8Unorm"); +static_assert(static_cast(TextureFormat::RGBA8UnormSrgb) == + WGPUTextureFormat_RGBA8UnormSrgb, + "value mismatch for TextureFormat::RGBA8UnormSrgb"); +static_assert(static_cast(TextureFormat::RGBA8Snorm) == + WGPUTextureFormat_RGBA8Snorm, + "value mismatch for TextureFormat::RGBA8Snorm"); +static_assert(static_cast(TextureFormat::RGBA8Uint) == + WGPUTextureFormat_RGBA8Uint, + "value mismatch for TextureFormat::RGBA8Uint"); +static_assert(static_cast(TextureFormat::RGBA8Sint) == + WGPUTextureFormat_RGBA8Sint, + "value mismatch for TextureFormat::RGBA8Sint"); +static_assert(static_cast(TextureFormat::BGRA8Unorm) == + WGPUTextureFormat_BGRA8Unorm, + "value mismatch for TextureFormat::BGRA8Unorm"); +static_assert(static_cast(TextureFormat::BGRA8UnormSrgb) == + WGPUTextureFormat_BGRA8UnormSrgb, + "value mismatch for TextureFormat::BGRA8UnormSrgb"); +static_assert(static_cast(TextureFormat::RGB10A2Uint) == + WGPUTextureFormat_RGB10A2Uint, + "value mismatch for TextureFormat::RGB10A2Uint"); +static_assert(static_cast(TextureFormat::RGB10A2Unorm) == + WGPUTextureFormat_RGB10A2Unorm, + "value mismatch for TextureFormat::RGB10A2Unorm"); +static_assert(static_cast(TextureFormat::RG11B10Ufloat) == + WGPUTextureFormat_RG11B10Ufloat, + "value mismatch for TextureFormat::RG11B10Ufloat"); +static_assert(static_cast(TextureFormat::RGB9E5Ufloat) == + WGPUTextureFormat_RGB9E5Ufloat, + "value mismatch for TextureFormat::RGB9E5Ufloat"); +static_assert(static_cast(TextureFormat::RG32Float) == + WGPUTextureFormat_RG32Float, + "value mismatch for TextureFormat::RG32Float"); +static_assert(static_cast(TextureFormat::RG32Uint) == + WGPUTextureFormat_RG32Uint, + "value mismatch for TextureFormat::RG32Uint"); +static_assert(static_cast(TextureFormat::RG32Sint) == + WGPUTextureFormat_RG32Sint, + "value mismatch for TextureFormat::RG32Sint"); +static_assert(static_cast(TextureFormat::RGBA16Uint) == + WGPUTextureFormat_RGBA16Uint, + "value mismatch for TextureFormat::RGBA16Uint"); +static_assert(static_cast(TextureFormat::RGBA16Sint) == + WGPUTextureFormat_RGBA16Sint, + "value mismatch for TextureFormat::RGBA16Sint"); +static_assert(static_cast(TextureFormat::RGBA16Float) == + WGPUTextureFormat_RGBA16Float, + "value mismatch for TextureFormat::RGBA16Float"); +static_assert(static_cast(TextureFormat::RGBA32Float) == + WGPUTextureFormat_RGBA32Float, + "value mismatch for TextureFormat::RGBA32Float"); +static_assert(static_cast(TextureFormat::RGBA32Uint) == + WGPUTextureFormat_RGBA32Uint, + "value mismatch for TextureFormat::RGBA32Uint"); +static_assert(static_cast(TextureFormat::RGBA32Sint) == + WGPUTextureFormat_RGBA32Sint, + "value mismatch for TextureFormat::RGBA32Sint"); +static_assert(static_cast(TextureFormat::Stencil8) == + WGPUTextureFormat_Stencil8, + "value mismatch for TextureFormat::Stencil8"); +static_assert(static_cast(TextureFormat::Depth16Unorm) == + WGPUTextureFormat_Depth16Unorm, + "value mismatch for TextureFormat::Depth16Unorm"); +static_assert(static_cast(TextureFormat::Depth24Plus) == + WGPUTextureFormat_Depth24Plus, + "value mismatch for TextureFormat::Depth24Plus"); +static_assert(static_cast(TextureFormat::Depth24PlusStencil8) == + WGPUTextureFormat_Depth24PlusStencil8, + "value mismatch for TextureFormat::Depth24PlusStencil8"); +static_assert(static_cast(TextureFormat::Depth32Float) == + WGPUTextureFormat_Depth32Float, + "value mismatch for TextureFormat::Depth32Float"); +static_assert(static_cast(TextureFormat::Depth32FloatStencil8) == + WGPUTextureFormat_Depth32FloatStencil8, + "value mismatch for TextureFormat::Depth32FloatStencil8"); +static_assert(static_cast(TextureFormat::BC1RGBAUnorm) == + WGPUTextureFormat_BC1RGBAUnorm, + "value mismatch for TextureFormat::BC1RGBAUnorm"); +static_assert(static_cast(TextureFormat::BC1RGBAUnormSrgb) == + WGPUTextureFormat_BC1RGBAUnormSrgb, + "value mismatch for TextureFormat::BC1RGBAUnormSrgb"); +static_assert(static_cast(TextureFormat::BC2RGBAUnorm) == + WGPUTextureFormat_BC2RGBAUnorm, + "value mismatch for TextureFormat::BC2RGBAUnorm"); +static_assert(static_cast(TextureFormat::BC2RGBAUnormSrgb) == + WGPUTextureFormat_BC2RGBAUnormSrgb, + "value mismatch for TextureFormat::BC2RGBAUnormSrgb"); +static_assert(static_cast(TextureFormat::BC3RGBAUnorm) == + WGPUTextureFormat_BC3RGBAUnorm, + "value mismatch for TextureFormat::BC3RGBAUnorm"); +static_assert(static_cast(TextureFormat::BC3RGBAUnormSrgb) == + WGPUTextureFormat_BC3RGBAUnormSrgb, + "value mismatch for TextureFormat::BC3RGBAUnormSrgb"); +static_assert(static_cast(TextureFormat::BC4RUnorm) == + WGPUTextureFormat_BC4RUnorm, + "value mismatch for TextureFormat::BC4RUnorm"); +static_assert(static_cast(TextureFormat::BC4RSnorm) == + WGPUTextureFormat_BC4RSnorm, + "value mismatch for TextureFormat::BC4RSnorm"); +static_assert(static_cast(TextureFormat::BC5RGUnorm) == + WGPUTextureFormat_BC5RGUnorm, + "value mismatch for TextureFormat::BC5RGUnorm"); +static_assert(static_cast(TextureFormat::BC5RGSnorm) == + WGPUTextureFormat_BC5RGSnorm, + "value mismatch for TextureFormat::BC5RGSnorm"); +static_assert(static_cast(TextureFormat::BC6HRGBUfloat) == + WGPUTextureFormat_BC6HRGBUfloat, + "value mismatch for TextureFormat::BC6HRGBUfloat"); +static_assert(static_cast(TextureFormat::BC6HRGBFloat) == + WGPUTextureFormat_BC6HRGBFloat, + "value mismatch for TextureFormat::BC6HRGBFloat"); +static_assert(static_cast(TextureFormat::BC7RGBAUnorm) == + WGPUTextureFormat_BC7RGBAUnorm, + "value mismatch for TextureFormat::BC7RGBAUnorm"); +static_assert(static_cast(TextureFormat::BC7RGBAUnormSrgb) == + WGPUTextureFormat_BC7RGBAUnormSrgb, + "value mismatch for TextureFormat::BC7RGBAUnormSrgb"); +static_assert(static_cast(TextureFormat::ETC2RGB8Unorm) == + WGPUTextureFormat_ETC2RGB8Unorm, + "value mismatch for TextureFormat::ETC2RGB8Unorm"); +static_assert(static_cast(TextureFormat::ETC2RGB8UnormSrgb) == + WGPUTextureFormat_ETC2RGB8UnormSrgb, + "value mismatch for TextureFormat::ETC2RGB8UnormSrgb"); +static_assert(static_cast(TextureFormat::ETC2RGB8A1Unorm) == + WGPUTextureFormat_ETC2RGB8A1Unorm, + "value mismatch for TextureFormat::ETC2RGB8A1Unorm"); +static_assert(static_cast(TextureFormat::ETC2RGB8A1UnormSrgb) == + WGPUTextureFormat_ETC2RGB8A1UnormSrgb, + "value mismatch for TextureFormat::ETC2RGB8A1UnormSrgb"); +static_assert(static_cast(TextureFormat::ETC2RGBA8Unorm) == + WGPUTextureFormat_ETC2RGBA8Unorm, + "value mismatch for TextureFormat::ETC2RGBA8Unorm"); +static_assert(static_cast(TextureFormat::ETC2RGBA8UnormSrgb) == + WGPUTextureFormat_ETC2RGBA8UnormSrgb, + "value mismatch for TextureFormat::ETC2RGBA8UnormSrgb"); +static_assert(static_cast(TextureFormat::EACR11Unorm) == + WGPUTextureFormat_EACR11Unorm, + "value mismatch for TextureFormat::EACR11Unorm"); +static_assert(static_cast(TextureFormat::EACR11Snorm) == + WGPUTextureFormat_EACR11Snorm, + "value mismatch for TextureFormat::EACR11Snorm"); +static_assert(static_cast(TextureFormat::EACRG11Unorm) == + WGPUTextureFormat_EACRG11Unorm, + "value mismatch for TextureFormat::EACRG11Unorm"); +static_assert(static_cast(TextureFormat::EACRG11Snorm) == + WGPUTextureFormat_EACRG11Snorm, + "value mismatch for TextureFormat::EACRG11Snorm"); +static_assert(static_cast(TextureFormat::ASTC4x4Unorm) == + WGPUTextureFormat_ASTC4x4Unorm, + "value mismatch for TextureFormat::ASTC4x4Unorm"); +static_assert(static_cast(TextureFormat::ASTC4x4UnormSrgb) == + WGPUTextureFormat_ASTC4x4UnormSrgb, + "value mismatch for TextureFormat::ASTC4x4UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC5x4Unorm) == + WGPUTextureFormat_ASTC5x4Unorm, + "value mismatch for TextureFormat::ASTC5x4Unorm"); +static_assert(static_cast(TextureFormat::ASTC5x4UnormSrgb) == + WGPUTextureFormat_ASTC5x4UnormSrgb, + "value mismatch for TextureFormat::ASTC5x4UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC5x5Unorm) == + WGPUTextureFormat_ASTC5x5Unorm, + "value mismatch for TextureFormat::ASTC5x5Unorm"); +static_assert(static_cast(TextureFormat::ASTC5x5UnormSrgb) == + WGPUTextureFormat_ASTC5x5UnormSrgb, + "value mismatch for TextureFormat::ASTC5x5UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC6x5Unorm) == + WGPUTextureFormat_ASTC6x5Unorm, + "value mismatch for TextureFormat::ASTC6x5Unorm"); +static_assert(static_cast(TextureFormat::ASTC6x5UnormSrgb) == + WGPUTextureFormat_ASTC6x5UnormSrgb, + "value mismatch for TextureFormat::ASTC6x5UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC6x6Unorm) == + WGPUTextureFormat_ASTC6x6Unorm, + "value mismatch for TextureFormat::ASTC6x6Unorm"); +static_assert(static_cast(TextureFormat::ASTC6x6UnormSrgb) == + WGPUTextureFormat_ASTC6x6UnormSrgb, + "value mismatch for TextureFormat::ASTC6x6UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC8x5Unorm) == + WGPUTextureFormat_ASTC8x5Unorm, + "value mismatch for TextureFormat::ASTC8x5Unorm"); +static_assert(static_cast(TextureFormat::ASTC8x5UnormSrgb) == + WGPUTextureFormat_ASTC8x5UnormSrgb, + "value mismatch for TextureFormat::ASTC8x5UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC8x6Unorm) == + WGPUTextureFormat_ASTC8x6Unorm, + "value mismatch for TextureFormat::ASTC8x6Unorm"); +static_assert(static_cast(TextureFormat::ASTC8x6UnormSrgb) == + WGPUTextureFormat_ASTC8x6UnormSrgb, + "value mismatch for TextureFormat::ASTC8x6UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC8x8Unorm) == + WGPUTextureFormat_ASTC8x8Unorm, + "value mismatch for TextureFormat::ASTC8x8Unorm"); +static_assert(static_cast(TextureFormat::ASTC8x8UnormSrgb) == + WGPUTextureFormat_ASTC8x8UnormSrgb, + "value mismatch for TextureFormat::ASTC8x8UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC10x5Unorm) == + WGPUTextureFormat_ASTC10x5Unorm, + "value mismatch for TextureFormat::ASTC10x5Unorm"); +static_assert(static_cast(TextureFormat::ASTC10x5UnormSrgb) == + WGPUTextureFormat_ASTC10x5UnormSrgb, + "value mismatch for TextureFormat::ASTC10x5UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC10x6Unorm) == + WGPUTextureFormat_ASTC10x6Unorm, + "value mismatch for TextureFormat::ASTC10x6Unorm"); +static_assert(static_cast(TextureFormat::ASTC10x6UnormSrgb) == + WGPUTextureFormat_ASTC10x6UnormSrgb, + "value mismatch for TextureFormat::ASTC10x6UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC10x8Unorm) == + WGPUTextureFormat_ASTC10x8Unorm, + "value mismatch for TextureFormat::ASTC10x8Unorm"); +static_assert(static_cast(TextureFormat::ASTC10x8UnormSrgb) == + WGPUTextureFormat_ASTC10x8UnormSrgb, + "value mismatch for TextureFormat::ASTC10x8UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC10x10Unorm) == + WGPUTextureFormat_ASTC10x10Unorm, + "value mismatch for TextureFormat::ASTC10x10Unorm"); +static_assert(static_cast(TextureFormat::ASTC10x10UnormSrgb) == + WGPUTextureFormat_ASTC10x10UnormSrgb, + "value mismatch for TextureFormat::ASTC10x10UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC12x10Unorm) == + WGPUTextureFormat_ASTC12x10Unorm, + "value mismatch for TextureFormat::ASTC12x10Unorm"); +static_assert(static_cast(TextureFormat::ASTC12x10UnormSrgb) == + WGPUTextureFormat_ASTC12x10UnormSrgb, + "value mismatch for TextureFormat::ASTC12x10UnormSrgb"); +static_assert(static_cast(TextureFormat::ASTC12x12Unorm) == + WGPUTextureFormat_ASTC12x12Unorm, + "value mismatch for TextureFormat::ASTC12x12Unorm"); +static_assert(static_cast(TextureFormat::ASTC12x12UnormSrgb) == + WGPUTextureFormat_ASTC12x12UnormSrgb, + "value mismatch for TextureFormat::ASTC12x12UnormSrgb"); +static_assert(static_cast(TextureFormat::R16Unorm) == + WGPUTextureFormat_R16Unorm, + "value mismatch for TextureFormat::R16Unorm"); +static_assert(static_cast(TextureFormat::RG16Unorm) == + WGPUTextureFormat_RG16Unorm, + "value mismatch for TextureFormat::RG16Unorm"); +static_assert(static_cast(TextureFormat::RGBA16Unorm) == + WGPUTextureFormat_RGBA16Unorm, + "value mismatch for TextureFormat::RGBA16Unorm"); +static_assert(static_cast(TextureFormat::R16Snorm) == + WGPUTextureFormat_R16Snorm, + "value mismatch for TextureFormat::R16Snorm"); +static_assert(static_cast(TextureFormat::RG16Snorm) == + WGPUTextureFormat_RG16Snorm, + "value mismatch for TextureFormat::RG16Snorm"); +static_assert(static_cast(TextureFormat::RGBA16Snorm) == + WGPUTextureFormat_RGBA16Snorm, + "value mismatch for TextureFormat::RGBA16Snorm"); +static_assert(static_cast(TextureFormat::R8BG8Biplanar420Unorm) == + WGPUTextureFormat_R8BG8Biplanar420Unorm, + "value mismatch for TextureFormat::R8BG8Biplanar420Unorm"); +static_assert( + static_cast(TextureFormat::R10X6BG10X6Biplanar420Unorm) == + WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm, + "value mismatch for TextureFormat::R10X6BG10X6Biplanar420Unorm"); +static_assert(static_cast(TextureFormat::R8BG8A8Triplanar420Unorm) == + WGPUTextureFormat_R8BG8A8Triplanar420Unorm, + "value mismatch for TextureFormat::R8BG8A8Triplanar420Unorm"); + +// TextureSampleType + +static_assert(sizeof(TextureSampleType) == sizeof(WGPUTextureSampleType), + "sizeof mismatch for TextureSampleType"); +static_assert(alignof(TextureSampleType) == alignof(WGPUTextureSampleType), + "alignof mismatch for TextureSampleType"); + +static_assert(static_cast(TextureSampleType::Undefined) == + WGPUTextureSampleType_Undefined, + "value mismatch for TextureSampleType::Undefined"); +static_assert(static_cast(TextureSampleType::Float) == + WGPUTextureSampleType_Float, + "value mismatch for TextureSampleType::Float"); +static_assert(static_cast(TextureSampleType::UnfilterableFloat) == + WGPUTextureSampleType_UnfilterableFloat, + "value mismatch for TextureSampleType::UnfilterableFloat"); +static_assert(static_cast(TextureSampleType::Depth) == + WGPUTextureSampleType_Depth, + "value mismatch for TextureSampleType::Depth"); +static_assert(static_cast(TextureSampleType::Sint) == + WGPUTextureSampleType_Sint, + "value mismatch for TextureSampleType::Sint"); +static_assert(static_cast(TextureSampleType::Uint) == + WGPUTextureSampleType_Uint, + "value mismatch for TextureSampleType::Uint"); + +// TextureViewDimension + +static_assert(sizeof(TextureViewDimension) == sizeof(WGPUTextureViewDimension), + "sizeof mismatch for TextureViewDimension"); +static_assert(alignof(TextureViewDimension) == + alignof(WGPUTextureViewDimension), + "alignof mismatch for TextureViewDimension"); + +static_assert(static_cast(TextureViewDimension::Undefined) == + WGPUTextureViewDimension_Undefined, + "value mismatch for TextureViewDimension::Undefined"); +static_assert(static_cast(TextureViewDimension::e1D) == + WGPUTextureViewDimension_1D, + "value mismatch for TextureViewDimension::e1D"); +static_assert(static_cast(TextureViewDimension::e2D) == + WGPUTextureViewDimension_2D, + "value mismatch for TextureViewDimension::e2D"); +static_assert(static_cast(TextureViewDimension::e2DArray) == + WGPUTextureViewDimension_2DArray, + "value mismatch for TextureViewDimension::e2DArray"); +static_assert(static_cast(TextureViewDimension::Cube) == + WGPUTextureViewDimension_Cube, + "value mismatch for TextureViewDimension::Cube"); +static_assert(static_cast(TextureViewDimension::CubeArray) == + WGPUTextureViewDimension_CubeArray, + "value mismatch for TextureViewDimension::CubeArray"); +static_assert(static_cast(TextureViewDimension::e3D) == + WGPUTextureViewDimension_3D, + "value mismatch for TextureViewDimension::e3D"); + +// VertexFormat + +static_assert(sizeof(VertexFormat) == sizeof(WGPUVertexFormat), + "sizeof mismatch for VertexFormat"); +static_assert(alignof(VertexFormat) == alignof(WGPUVertexFormat), + "alignof mismatch for VertexFormat"); + +static_assert(static_cast(VertexFormat::Undefined) == + WGPUVertexFormat_Undefined, + "value mismatch for VertexFormat::Undefined"); +static_assert(static_cast(VertexFormat::Uint8x2) == + WGPUVertexFormat_Uint8x2, + "value mismatch for VertexFormat::Uint8x2"); +static_assert(static_cast(VertexFormat::Uint8x4) == + WGPUVertexFormat_Uint8x4, + "value mismatch for VertexFormat::Uint8x4"); +static_assert(static_cast(VertexFormat::Sint8x2) == + WGPUVertexFormat_Sint8x2, + "value mismatch for VertexFormat::Sint8x2"); +static_assert(static_cast(VertexFormat::Sint8x4) == + WGPUVertexFormat_Sint8x4, + "value mismatch for VertexFormat::Sint8x4"); +static_assert(static_cast(VertexFormat::Unorm8x2) == + WGPUVertexFormat_Unorm8x2, + "value mismatch for VertexFormat::Unorm8x2"); +static_assert(static_cast(VertexFormat::Unorm8x4) == + WGPUVertexFormat_Unorm8x4, + "value mismatch for VertexFormat::Unorm8x4"); +static_assert(static_cast(VertexFormat::Snorm8x2) == + WGPUVertexFormat_Snorm8x2, + "value mismatch for VertexFormat::Snorm8x2"); +static_assert(static_cast(VertexFormat::Snorm8x4) == + WGPUVertexFormat_Snorm8x4, + "value mismatch for VertexFormat::Snorm8x4"); +static_assert(static_cast(VertexFormat::Uint16x2) == + WGPUVertexFormat_Uint16x2, + "value mismatch for VertexFormat::Uint16x2"); +static_assert(static_cast(VertexFormat::Uint16x4) == + WGPUVertexFormat_Uint16x4, + "value mismatch for VertexFormat::Uint16x4"); +static_assert(static_cast(VertexFormat::Sint16x2) == + WGPUVertexFormat_Sint16x2, + "value mismatch for VertexFormat::Sint16x2"); +static_assert(static_cast(VertexFormat::Sint16x4) == + WGPUVertexFormat_Sint16x4, + "value mismatch for VertexFormat::Sint16x4"); +static_assert(static_cast(VertexFormat::Unorm16x2) == + WGPUVertexFormat_Unorm16x2, + "value mismatch for VertexFormat::Unorm16x2"); +static_assert(static_cast(VertexFormat::Unorm16x4) == + WGPUVertexFormat_Unorm16x4, + "value mismatch for VertexFormat::Unorm16x4"); +static_assert(static_cast(VertexFormat::Snorm16x2) == + WGPUVertexFormat_Snorm16x2, + "value mismatch for VertexFormat::Snorm16x2"); +static_assert(static_cast(VertexFormat::Snorm16x4) == + WGPUVertexFormat_Snorm16x4, + "value mismatch for VertexFormat::Snorm16x4"); +static_assert(static_cast(VertexFormat::Float16x2) == + WGPUVertexFormat_Float16x2, + "value mismatch for VertexFormat::Float16x2"); +static_assert(static_cast(VertexFormat::Float16x4) == + WGPUVertexFormat_Float16x4, + "value mismatch for VertexFormat::Float16x4"); +static_assert(static_cast(VertexFormat::Float32) == + WGPUVertexFormat_Float32, + "value mismatch for VertexFormat::Float32"); +static_assert(static_cast(VertexFormat::Float32x2) == + WGPUVertexFormat_Float32x2, + "value mismatch for VertexFormat::Float32x2"); +static_assert(static_cast(VertexFormat::Float32x3) == + WGPUVertexFormat_Float32x3, + "value mismatch for VertexFormat::Float32x3"); +static_assert(static_cast(VertexFormat::Float32x4) == + WGPUVertexFormat_Float32x4, + "value mismatch for VertexFormat::Float32x4"); +static_assert(static_cast(VertexFormat::Uint32) == + WGPUVertexFormat_Uint32, + "value mismatch for VertexFormat::Uint32"); +static_assert(static_cast(VertexFormat::Uint32x2) == + WGPUVertexFormat_Uint32x2, + "value mismatch for VertexFormat::Uint32x2"); +static_assert(static_cast(VertexFormat::Uint32x3) == + WGPUVertexFormat_Uint32x3, + "value mismatch for VertexFormat::Uint32x3"); +static_assert(static_cast(VertexFormat::Uint32x4) == + WGPUVertexFormat_Uint32x4, + "value mismatch for VertexFormat::Uint32x4"); +static_assert(static_cast(VertexFormat::Sint32) == + WGPUVertexFormat_Sint32, + "value mismatch for VertexFormat::Sint32"); +static_assert(static_cast(VertexFormat::Sint32x2) == + WGPUVertexFormat_Sint32x2, + "value mismatch for VertexFormat::Sint32x2"); +static_assert(static_cast(VertexFormat::Sint32x3) == + WGPUVertexFormat_Sint32x3, + "value mismatch for VertexFormat::Sint32x3"); +static_assert(static_cast(VertexFormat::Sint32x4) == + WGPUVertexFormat_Sint32x4, + "value mismatch for VertexFormat::Sint32x4"); +static_assert(static_cast(VertexFormat::Unorm10_10_10_2) == + WGPUVertexFormat_Unorm10_10_10_2, + "value mismatch for VertexFormat::Unorm10_10_10_2"); + +// VertexStepMode + +static_assert(sizeof(VertexStepMode) == sizeof(WGPUVertexStepMode), + "sizeof mismatch for VertexStepMode"); +static_assert(alignof(VertexStepMode) == alignof(WGPUVertexStepMode), + "alignof mismatch for VertexStepMode"); + +static_assert(static_cast(VertexStepMode::Undefined) == + WGPUVertexStepMode_Undefined, + "value mismatch for VertexStepMode::Undefined"); +static_assert(static_cast(VertexStepMode::VertexBufferNotUsed) == + WGPUVertexStepMode_VertexBufferNotUsed, + "value mismatch for VertexStepMode::VertexBufferNotUsed"); +static_assert(static_cast(VertexStepMode::Vertex) == + WGPUVertexStepMode_Vertex, + "value mismatch for VertexStepMode::Vertex"); +static_assert(static_cast(VertexStepMode::Instance) == + WGPUVertexStepMode_Instance, + "value mismatch for VertexStepMode::Instance"); + +// WaitStatus + +static_assert(sizeof(WaitStatus) == sizeof(WGPUWaitStatus), + "sizeof mismatch for WaitStatus"); +static_assert(alignof(WaitStatus) == alignof(WGPUWaitStatus), + "alignof mismatch for WaitStatus"); + +static_assert(static_cast(WaitStatus::Success) == + WGPUWaitStatus_Success, + "value mismatch for WaitStatus::Success"); +static_assert(static_cast(WaitStatus::TimedOut) == + WGPUWaitStatus_TimedOut, + "value mismatch for WaitStatus::TimedOut"); +static_assert(static_cast(WaitStatus::UnsupportedTimeout) == + WGPUWaitStatus_UnsupportedTimeout, + "value mismatch for WaitStatus::UnsupportedTimeout"); +static_assert(static_cast(WaitStatus::UnsupportedCount) == + WGPUWaitStatus_UnsupportedCount, + "value mismatch for WaitStatus::UnsupportedCount"); +static_assert(static_cast(WaitStatus::UnsupportedMixedSources) == + WGPUWaitStatus_UnsupportedMixedSources, + "value mismatch for WaitStatus::UnsupportedMixedSources"); +static_assert(static_cast(WaitStatus::Unknown) == + WGPUWaitStatus_Unknown, + "value mismatch for WaitStatus::Unknown"); + +// BufferUsage + +static_assert(sizeof(BufferUsage) == sizeof(WGPUBufferUsageFlags), + "sizeof mismatch for BufferUsage"); +static_assert(alignof(BufferUsage) == alignof(WGPUBufferUsageFlags), + "alignof mismatch for BufferUsage"); + +static_assert(static_cast(BufferUsage::None) == WGPUBufferUsage_None, + "value mismatch for BufferUsage::None"); +static_assert(static_cast(BufferUsage::MapRead) == + WGPUBufferUsage_MapRead, + "value mismatch for BufferUsage::MapRead"); +static_assert(static_cast(BufferUsage::MapWrite) == + WGPUBufferUsage_MapWrite, + "value mismatch for BufferUsage::MapWrite"); +static_assert(static_cast(BufferUsage::CopySrc) == + WGPUBufferUsage_CopySrc, + "value mismatch for BufferUsage::CopySrc"); +static_assert(static_cast(BufferUsage::CopyDst) == + WGPUBufferUsage_CopyDst, + "value mismatch for BufferUsage::CopyDst"); +static_assert(static_cast(BufferUsage::Index) == + WGPUBufferUsage_Index, + "value mismatch for BufferUsage::Index"); +static_assert(static_cast(BufferUsage::Vertex) == + WGPUBufferUsage_Vertex, + "value mismatch for BufferUsage::Vertex"); +static_assert(static_cast(BufferUsage::Uniform) == + WGPUBufferUsage_Uniform, + "value mismatch for BufferUsage::Uniform"); +static_assert(static_cast(BufferUsage::Storage) == + WGPUBufferUsage_Storage, + "value mismatch for BufferUsage::Storage"); +static_assert(static_cast(BufferUsage::Indirect) == + WGPUBufferUsage_Indirect, + "value mismatch for BufferUsage::Indirect"); +static_assert(static_cast(BufferUsage::QueryResolve) == + WGPUBufferUsage_QueryResolve, + "value mismatch for BufferUsage::QueryResolve"); + +// ColorWriteMask + +static_assert(sizeof(ColorWriteMask) == sizeof(WGPUColorWriteMaskFlags), + "sizeof mismatch for ColorWriteMask"); +static_assert(alignof(ColorWriteMask) == alignof(WGPUColorWriteMaskFlags), + "alignof mismatch for ColorWriteMask"); + +static_assert(static_cast(ColorWriteMask::None) == + WGPUColorWriteMask_None, + "value mismatch for ColorWriteMask::None"); +static_assert(static_cast(ColorWriteMask::Red) == + WGPUColorWriteMask_Red, + "value mismatch for ColorWriteMask::Red"); +static_assert(static_cast(ColorWriteMask::Green) == + WGPUColorWriteMask_Green, + "value mismatch for ColorWriteMask::Green"); +static_assert(static_cast(ColorWriteMask::Blue) == + WGPUColorWriteMask_Blue, + "value mismatch for ColorWriteMask::Blue"); +static_assert(static_cast(ColorWriteMask::Alpha) == + WGPUColorWriteMask_Alpha, + "value mismatch for ColorWriteMask::Alpha"); +static_assert(static_cast(ColorWriteMask::All) == + WGPUColorWriteMask_All, + "value mismatch for ColorWriteMask::All"); + +// HeapProperty + +static_assert(sizeof(HeapProperty) == sizeof(WGPUHeapPropertyFlags), + "sizeof mismatch for HeapProperty"); +static_assert(alignof(HeapProperty) == alignof(WGPUHeapPropertyFlags), + "alignof mismatch for HeapProperty"); + +static_assert(static_cast(HeapProperty::Undefined) == + WGPUHeapProperty_Undefined, + "value mismatch for HeapProperty::Undefined"); +static_assert(static_cast(HeapProperty::DeviceLocal) == + WGPUHeapProperty_DeviceLocal, + "value mismatch for HeapProperty::DeviceLocal"); +static_assert(static_cast(HeapProperty::HostVisible) == + WGPUHeapProperty_HostVisible, + "value mismatch for HeapProperty::HostVisible"); +static_assert(static_cast(HeapProperty::HostCoherent) == + WGPUHeapProperty_HostCoherent, + "value mismatch for HeapProperty::HostCoherent"); +static_assert(static_cast(HeapProperty::HostUncached) == + WGPUHeapProperty_HostUncached, + "value mismatch for HeapProperty::HostUncached"); +static_assert(static_cast(HeapProperty::HostCached) == + WGPUHeapProperty_HostCached, + "value mismatch for HeapProperty::HostCached"); + +// MapMode + +static_assert(sizeof(MapMode) == sizeof(WGPUMapModeFlags), + "sizeof mismatch for MapMode"); +static_assert(alignof(MapMode) == alignof(WGPUMapModeFlags), + "alignof mismatch for MapMode"); + +static_assert(static_cast(MapMode::None) == WGPUMapMode_None, + "value mismatch for MapMode::None"); +static_assert(static_cast(MapMode::Read) == WGPUMapMode_Read, + "value mismatch for MapMode::Read"); +static_assert(static_cast(MapMode::Write) == WGPUMapMode_Write, + "value mismatch for MapMode::Write"); + +// ShaderStage + +static_assert(sizeof(ShaderStage) == sizeof(WGPUShaderStageFlags), + "sizeof mismatch for ShaderStage"); +static_assert(alignof(ShaderStage) == alignof(WGPUShaderStageFlags), + "alignof mismatch for ShaderStage"); + +static_assert(static_cast(ShaderStage::None) == WGPUShaderStage_None, + "value mismatch for ShaderStage::None"); +static_assert(static_cast(ShaderStage::Vertex) == + WGPUShaderStage_Vertex, + "value mismatch for ShaderStage::Vertex"); +static_assert(static_cast(ShaderStage::Fragment) == + WGPUShaderStage_Fragment, + "value mismatch for ShaderStage::Fragment"); +static_assert(static_cast(ShaderStage::Compute) == + WGPUShaderStage_Compute, + "value mismatch for ShaderStage::Compute"); + +// TextureUsage + +static_assert(sizeof(TextureUsage) == sizeof(WGPUTextureUsageFlags), + "sizeof mismatch for TextureUsage"); +static_assert(alignof(TextureUsage) == alignof(WGPUTextureUsageFlags), + "alignof mismatch for TextureUsage"); + +static_assert(static_cast(TextureUsage::None) == + WGPUTextureUsage_None, + "value mismatch for TextureUsage::None"); +static_assert(static_cast(TextureUsage::CopySrc) == + WGPUTextureUsage_CopySrc, + "value mismatch for TextureUsage::CopySrc"); +static_assert(static_cast(TextureUsage::CopyDst) == + WGPUTextureUsage_CopyDst, + "value mismatch for TextureUsage::CopyDst"); +static_assert(static_cast(TextureUsage::TextureBinding) == + WGPUTextureUsage_TextureBinding, + "value mismatch for TextureUsage::TextureBinding"); +static_assert(static_cast(TextureUsage::StorageBinding) == + WGPUTextureUsage_StorageBinding, + "value mismatch for TextureUsage::StorageBinding"); +static_assert(static_cast(TextureUsage::RenderAttachment) == + WGPUTextureUsage_RenderAttachment, + "value mismatch for TextureUsage::RenderAttachment"); +static_assert(static_cast(TextureUsage::TransientAttachment) == + WGPUTextureUsage_TransientAttachment, + "value mismatch for TextureUsage::TransientAttachment"); +static_assert(static_cast(TextureUsage::StorageAttachment) == + WGPUTextureUsage_StorageAttachment, + "value mismatch for TextureUsage::StorageAttachment"); + +// ChainedStruct + +static_assert(sizeof(ChainedStruct) == sizeof(WGPUChainedStruct), + "sizeof mismatch for ChainedStruct"); +static_assert(alignof(ChainedStruct) == alignof(WGPUChainedStruct), + "alignof mismatch for ChainedStruct"); +static_assert(offsetof(ChainedStruct, nextInChain) == + offsetof(WGPUChainedStruct, next), + "offsetof mismatch for ChainedStruct::nextInChain"); +static_assert(offsetof(ChainedStruct, sType) == + offsetof(WGPUChainedStruct, sType), + "offsetof mismatch for ChainedStruct::sType"); + +// AdapterProperties + +static_assert(sizeof(AdapterProperties) == sizeof(WGPUAdapterProperties), + "sizeof mismatch for AdapterProperties"); +static_assert(alignof(AdapterProperties) == alignof(WGPUAdapterProperties), + "alignof mismatch for AdapterProperties"); + +static_assert(offsetof(AdapterProperties, nextInChain) == + offsetof(WGPUAdapterProperties, nextInChain), + "offsetof mismatch for AdapterProperties::nextInChain"); +static_assert(offsetof(AdapterProperties, vendorID) == + offsetof(WGPUAdapterProperties, vendorID), + "offsetof mismatch for AdapterProperties::vendorID"); +static_assert(offsetof(AdapterProperties, vendorName) == + offsetof(WGPUAdapterProperties, vendorName), + "offsetof mismatch for AdapterProperties::vendorName"); +static_assert(offsetof(AdapterProperties, architecture) == + offsetof(WGPUAdapterProperties, architecture), + "offsetof mismatch for AdapterProperties::architecture"); +static_assert(offsetof(AdapterProperties, deviceID) == + offsetof(WGPUAdapterProperties, deviceID), + "offsetof mismatch for AdapterProperties::deviceID"); +static_assert(offsetof(AdapterProperties, name) == + offsetof(WGPUAdapterProperties, name), + "offsetof mismatch for AdapterProperties::name"); +static_assert(offsetof(AdapterProperties, driverDescription) == + offsetof(WGPUAdapterProperties, driverDescription), + "offsetof mismatch for AdapterProperties::driverDescription"); +static_assert(offsetof(AdapterProperties, adapterType) == + offsetof(WGPUAdapterProperties, adapterType), + "offsetof mismatch for AdapterProperties::adapterType"); +static_assert(offsetof(AdapterProperties, backendType) == + offsetof(WGPUAdapterProperties, backendType), + "offsetof mismatch for AdapterProperties::backendType"); +static_assert(offsetof(AdapterProperties, compatibilityMode) == + offsetof(WGPUAdapterProperties, compatibilityMode), + "offsetof mismatch for AdapterProperties::compatibilityMode"); + +// AdapterPropertiesD3D + +static_assert(sizeof(AdapterPropertiesD3D) == sizeof(WGPUAdapterPropertiesD3D), + "sizeof mismatch for AdapterPropertiesD3D"); +static_assert(alignof(AdapterPropertiesD3D) == + alignof(WGPUAdapterPropertiesD3D), + "alignof mismatch for AdapterPropertiesD3D"); + +static_assert(offsetof(AdapterPropertiesD3D, shaderModel) == + offsetof(WGPUAdapterPropertiesD3D, shaderModel), + "offsetof mismatch for AdapterPropertiesD3D::shaderModel"); + +// AdapterPropertiesVk + +static_assert(sizeof(AdapterPropertiesVk) == sizeof(WGPUAdapterPropertiesVk), + "sizeof mismatch for AdapterPropertiesVk"); +static_assert(alignof(AdapterPropertiesVk) == alignof(WGPUAdapterPropertiesVk), + "alignof mismatch for AdapterPropertiesVk"); + +static_assert(offsetof(AdapterPropertiesVk, driverVersion) == + offsetof(WGPUAdapterPropertiesVk, driverVersion), + "offsetof mismatch for AdapterPropertiesVk::driverVersion"); + +// BindGroupEntry + +static_assert(sizeof(BindGroupEntry) == sizeof(WGPUBindGroupEntry), + "sizeof mismatch for BindGroupEntry"); +static_assert(alignof(BindGroupEntry) == alignof(WGPUBindGroupEntry), + "alignof mismatch for BindGroupEntry"); + +static_assert(offsetof(BindGroupEntry, nextInChain) == + offsetof(WGPUBindGroupEntry, nextInChain), + "offsetof mismatch for BindGroupEntry::nextInChain"); +static_assert(offsetof(BindGroupEntry, binding) == + offsetof(WGPUBindGroupEntry, binding), + "offsetof mismatch for BindGroupEntry::binding"); +static_assert(offsetof(BindGroupEntry, buffer) == + offsetof(WGPUBindGroupEntry, buffer), + "offsetof mismatch for BindGroupEntry::buffer"); +static_assert(offsetof(BindGroupEntry, offset) == + offsetof(WGPUBindGroupEntry, offset), + "offsetof mismatch for BindGroupEntry::offset"); +static_assert(offsetof(BindGroupEntry, size) == + offsetof(WGPUBindGroupEntry, size), + "offsetof mismatch for BindGroupEntry::size"); +static_assert(offsetof(BindGroupEntry, sampler) == + offsetof(WGPUBindGroupEntry, sampler), + "offsetof mismatch for BindGroupEntry::sampler"); +static_assert(offsetof(BindGroupEntry, textureView) == + offsetof(WGPUBindGroupEntry, textureView), + "offsetof mismatch for BindGroupEntry::textureView"); + +// BlendComponent + +static_assert(sizeof(BlendComponent) == sizeof(WGPUBlendComponent), + "sizeof mismatch for BlendComponent"); +static_assert(alignof(BlendComponent) == alignof(WGPUBlendComponent), + "alignof mismatch for BlendComponent"); + +static_assert(offsetof(BlendComponent, operation) == + offsetof(WGPUBlendComponent, operation), + "offsetof mismatch for BlendComponent::operation"); +static_assert(offsetof(BlendComponent, srcFactor) == + offsetof(WGPUBlendComponent, srcFactor), + "offsetof mismatch for BlendComponent::srcFactor"); +static_assert(offsetof(BlendComponent, dstFactor) == + offsetof(WGPUBlendComponent, dstFactor), + "offsetof mismatch for BlendComponent::dstFactor"); + +// BufferBindingLayout + +static_assert(sizeof(BufferBindingLayout) == sizeof(WGPUBufferBindingLayout), + "sizeof mismatch for BufferBindingLayout"); +static_assert(alignof(BufferBindingLayout) == alignof(WGPUBufferBindingLayout), + "alignof mismatch for BufferBindingLayout"); + +static_assert(offsetof(BufferBindingLayout, nextInChain) == + offsetof(WGPUBufferBindingLayout, nextInChain), + "offsetof mismatch for BufferBindingLayout::nextInChain"); +static_assert(offsetof(BufferBindingLayout, type) == + offsetof(WGPUBufferBindingLayout, type), + "offsetof mismatch for BufferBindingLayout::type"); +static_assert(offsetof(BufferBindingLayout, hasDynamicOffset) == + offsetof(WGPUBufferBindingLayout, hasDynamicOffset), + "offsetof mismatch for BufferBindingLayout::hasDynamicOffset"); +static_assert(offsetof(BufferBindingLayout, minBindingSize) == + offsetof(WGPUBufferBindingLayout, minBindingSize), + "offsetof mismatch for BufferBindingLayout::minBindingSize"); + +// BufferDescriptor + +static_assert(sizeof(BufferDescriptor) == sizeof(WGPUBufferDescriptor), + "sizeof mismatch for BufferDescriptor"); +static_assert(alignof(BufferDescriptor) == alignof(WGPUBufferDescriptor), + "alignof mismatch for BufferDescriptor"); + +static_assert(offsetof(BufferDescriptor, nextInChain) == + offsetof(WGPUBufferDescriptor, nextInChain), + "offsetof mismatch for BufferDescriptor::nextInChain"); +static_assert(offsetof(BufferDescriptor, label) == + offsetof(WGPUBufferDescriptor, label), + "offsetof mismatch for BufferDescriptor::label"); +static_assert(offsetof(BufferDescriptor, usage) == + offsetof(WGPUBufferDescriptor, usage), + "offsetof mismatch for BufferDescriptor::usage"); +static_assert(offsetof(BufferDescriptor, size) == + offsetof(WGPUBufferDescriptor, size), + "offsetof mismatch for BufferDescriptor::size"); +static_assert(offsetof(BufferDescriptor, mappedAtCreation) == + offsetof(WGPUBufferDescriptor, mappedAtCreation), + "offsetof mismatch for BufferDescriptor::mappedAtCreation"); + +// BufferHostMappedPointer + +static_assert(sizeof(BufferHostMappedPointer) == + sizeof(WGPUBufferHostMappedPointer), + "sizeof mismatch for BufferHostMappedPointer"); +static_assert(alignof(BufferHostMappedPointer) == + alignof(WGPUBufferHostMappedPointer), + "alignof mismatch for BufferHostMappedPointer"); + +static_assert(offsetof(BufferHostMappedPointer, pointer) == + offsetof(WGPUBufferHostMappedPointer, pointer), + "offsetof mismatch for BufferHostMappedPointer::pointer"); +static_assert(offsetof(BufferHostMappedPointer, disposeCallback) == + offsetof(WGPUBufferHostMappedPointer, disposeCallback), + "offsetof mismatch for BufferHostMappedPointer::disposeCallback"); +static_assert(offsetof(BufferHostMappedPointer, userdata) == + offsetof(WGPUBufferHostMappedPointer, userdata), + "offsetof mismatch for BufferHostMappedPointer::userdata"); + +// BufferMapCallbackInfo + +static_assert(sizeof(BufferMapCallbackInfo) == + sizeof(WGPUBufferMapCallbackInfo), + "sizeof mismatch for BufferMapCallbackInfo"); +static_assert(alignof(BufferMapCallbackInfo) == + alignof(WGPUBufferMapCallbackInfo), + "alignof mismatch for BufferMapCallbackInfo"); + +static_assert(offsetof(BufferMapCallbackInfo, nextInChain) == + offsetof(WGPUBufferMapCallbackInfo, nextInChain), + "offsetof mismatch for BufferMapCallbackInfo::nextInChain"); +static_assert(offsetof(BufferMapCallbackInfo, mode) == + offsetof(WGPUBufferMapCallbackInfo, mode), + "offsetof mismatch for BufferMapCallbackInfo::mode"); +static_assert(offsetof(BufferMapCallbackInfo, callback) == + offsetof(WGPUBufferMapCallbackInfo, callback), + "offsetof mismatch for BufferMapCallbackInfo::callback"); +static_assert(offsetof(BufferMapCallbackInfo, userdata) == + offsetof(WGPUBufferMapCallbackInfo, userdata), + "offsetof mismatch for BufferMapCallbackInfo::userdata"); + +// Color + +static_assert(sizeof(Color) == sizeof(WGPUColor), "sizeof mismatch for Color"); +static_assert(alignof(Color) == alignof(WGPUColor), + "alignof mismatch for Color"); + +static_assert(offsetof(Color, r) == offsetof(WGPUColor, r), + "offsetof mismatch for Color::r"); +static_assert(offsetof(Color, g) == offsetof(WGPUColor, g), + "offsetof mismatch for Color::g"); +static_assert(offsetof(Color, b) == offsetof(WGPUColor, b), + "offsetof mismatch for Color::b"); +static_assert(offsetof(Color, a) == offsetof(WGPUColor, a), + "offsetof mismatch for Color::a"); + +// CommandBufferDescriptor + +static_assert(sizeof(CommandBufferDescriptor) == + sizeof(WGPUCommandBufferDescriptor), + "sizeof mismatch for CommandBufferDescriptor"); +static_assert(alignof(CommandBufferDescriptor) == + alignof(WGPUCommandBufferDescriptor), + "alignof mismatch for CommandBufferDescriptor"); + +static_assert(offsetof(CommandBufferDescriptor, nextInChain) == + offsetof(WGPUCommandBufferDescriptor, nextInChain), + "offsetof mismatch for CommandBufferDescriptor::nextInChain"); +static_assert(offsetof(CommandBufferDescriptor, label) == + offsetof(WGPUCommandBufferDescriptor, label), + "offsetof mismatch for CommandBufferDescriptor::label"); + +// CommandEncoderDescriptor + +static_assert(sizeof(CommandEncoderDescriptor) == + sizeof(WGPUCommandEncoderDescriptor), + "sizeof mismatch for CommandEncoderDescriptor"); +static_assert(alignof(CommandEncoderDescriptor) == + alignof(WGPUCommandEncoderDescriptor), + "alignof mismatch for CommandEncoderDescriptor"); + +static_assert(offsetof(CommandEncoderDescriptor, nextInChain) == + offsetof(WGPUCommandEncoderDescriptor, nextInChain), + "offsetof mismatch for CommandEncoderDescriptor::nextInChain"); +static_assert(offsetof(CommandEncoderDescriptor, label) == + offsetof(WGPUCommandEncoderDescriptor, label), + "offsetof mismatch for CommandEncoderDescriptor::label"); + +// CompilationInfoCallbackInfo + +static_assert(sizeof(CompilationInfoCallbackInfo) == + sizeof(WGPUCompilationInfoCallbackInfo), + "sizeof mismatch for CompilationInfoCallbackInfo"); +static_assert(alignof(CompilationInfoCallbackInfo) == + alignof(WGPUCompilationInfoCallbackInfo), + "alignof mismatch for CompilationInfoCallbackInfo"); + +static_assert(offsetof(CompilationInfoCallbackInfo, nextInChain) == + offsetof(WGPUCompilationInfoCallbackInfo, nextInChain), + "offsetof mismatch for CompilationInfoCallbackInfo::nextInChain"); +static_assert(offsetof(CompilationInfoCallbackInfo, mode) == + offsetof(WGPUCompilationInfoCallbackInfo, mode), + "offsetof mismatch for CompilationInfoCallbackInfo::mode"); +static_assert(offsetof(CompilationInfoCallbackInfo, callback) == + offsetof(WGPUCompilationInfoCallbackInfo, callback), + "offsetof mismatch for CompilationInfoCallbackInfo::callback"); +static_assert(offsetof(CompilationInfoCallbackInfo, userdata) == + offsetof(WGPUCompilationInfoCallbackInfo, userdata), + "offsetof mismatch for CompilationInfoCallbackInfo::userdata"); + +// CompilationMessage + +static_assert(sizeof(CompilationMessage) == sizeof(WGPUCompilationMessage), + "sizeof mismatch for CompilationMessage"); +static_assert(alignof(CompilationMessage) == alignof(WGPUCompilationMessage), + "alignof mismatch for CompilationMessage"); + +static_assert(offsetof(CompilationMessage, nextInChain) == + offsetof(WGPUCompilationMessage, nextInChain), + "offsetof mismatch for CompilationMessage::nextInChain"); +static_assert(offsetof(CompilationMessage, message) == + offsetof(WGPUCompilationMessage, message), + "offsetof mismatch for CompilationMessage::message"); +static_assert(offsetof(CompilationMessage, type) == + offsetof(WGPUCompilationMessage, type), + "offsetof mismatch for CompilationMessage::type"); +static_assert(offsetof(CompilationMessage, lineNum) == + offsetof(WGPUCompilationMessage, lineNum), + "offsetof mismatch for CompilationMessage::lineNum"); +static_assert(offsetof(CompilationMessage, linePos) == + offsetof(WGPUCompilationMessage, linePos), + "offsetof mismatch for CompilationMessage::linePos"); +static_assert(offsetof(CompilationMessage, offset) == + offsetof(WGPUCompilationMessage, offset), + "offsetof mismatch for CompilationMessage::offset"); +static_assert(offsetof(CompilationMessage, length) == + offsetof(WGPUCompilationMessage, length), + "offsetof mismatch for CompilationMessage::length"); +static_assert(offsetof(CompilationMessage, utf16LinePos) == + offsetof(WGPUCompilationMessage, utf16LinePos), + "offsetof mismatch for CompilationMessage::utf16LinePos"); +static_assert(offsetof(CompilationMessage, utf16Offset) == + offsetof(WGPUCompilationMessage, utf16Offset), + "offsetof mismatch for CompilationMessage::utf16Offset"); +static_assert(offsetof(CompilationMessage, utf16Length) == + offsetof(WGPUCompilationMessage, utf16Length), + "offsetof mismatch for CompilationMessage::utf16Length"); + +// ComputePassTimestampWrites + +static_assert(sizeof(ComputePassTimestampWrites) == + sizeof(WGPUComputePassTimestampWrites), + "sizeof mismatch for ComputePassTimestampWrites"); +static_assert(alignof(ComputePassTimestampWrites) == + alignof(WGPUComputePassTimestampWrites), + "alignof mismatch for ComputePassTimestampWrites"); + +static_assert(offsetof(ComputePassTimestampWrites, querySet) == + offsetof(WGPUComputePassTimestampWrites, querySet), + "offsetof mismatch for ComputePassTimestampWrites::querySet"); +static_assert(offsetof(ComputePassTimestampWrites, beginningOfPassWriteIndex) == + offsetof(WGPUComputePassTimestampWrites, + beginningOfPassWriteIndex), + "offsetof mismatch for " + "ComputePassTimestampWrites::beginningOfPassWriteIndex"); +static_assert( + offsetof(ComputePassTimestampWrites, endOfPassWriteIndex) == + offsetof(WGPUComputePassTimestampWrites, endOfPassWriteIndex), + "offsetof mismatch for ComputePassTimestampWrites::endOfPassWriteIndex"); + +// ConstantEntry + +static_assert(sizeof(ConstantEntry) == sizeof(WGPUConstantEntry), + "sizeof mismatch for ConstantEntry"); +static_assert(alignof(ConstantEntry) == alignof(WGPUConstantEntry), + "alignof mismatch for ConstantEntry"); + +static_assert(offsetof(ConstantEntry, nextInChain) == + offsetof(WGPUConstantEntry, nextInChain), + "offsetof mismatch for ConstantEntry::nextInChain"); +static_assert(offsetof(ConstantEntry, key) == offsetof(WGPUConstantEntry, key), + "offsetof mismatch for ConstantEntry::key"); +static_assert(offsetof(ConstantEntry, value) == + offsetof(WGPUConstantEntry, value), + "offsetof mismatch for ConstantEntry::value"); + +// CopyTextureForBrowserOptions + +static_assert(sizeof(CopyTextureForBrowserOptions) == + sizeof(WGPUCopyTextureForBrowserOptions), + "sizeof mismatch for CopyTextureForBrowserOptions"); +static_assert(alignof(CopyTextureForBrowserOptions) == + alignof(WGPUCopyTextureForBrowserOptions), + "alignof mismatch for CopyTextureForBrowserOptions"); + +static_assert( + offsetof(CopyTextureForBrowserOptions, nextInChain) == + offsetof(WGPUCopyTextureForBrowserOptions, nextInChain), + "offsetof mismatch for CopyTextureForBrowserOptions::nextInChain"); +static_assert(offsetof(CopyTextureForBrowserOptions, flipY) == + offsetof(WGPUCopyTextureForBrowserOptions, flipY), + "offsetof mismatch for CopyTextureForBrowserOptions::flipY"); +static_assert(offsetof(CopyTextureForBrowserOptions, + needsColorSpaceConversion) == + offsetof(WGPUCopyTextureForBrowserOptions, + needsColorSpaceConversion), + "offsetof mismatch for " + "CopyTextureForBrowserOptions::needsColorSpaceConversion"); +static_assert( + offsetof(CopyTextureForBrowserOptions, srcAlphaMode) == + offsetof(WGPUCopyTextureForBrowserOptions, srcAlphaMode), + "offsetof mismatch for CopyTextureForBrowserOptions::srcAlphaMode"); +static_assert(offsetof(CopyTextureForBrowserOptions, + srcTransferFunctionParameters) == + offsetof(WGPUCopyTextureForBrowserOptions, + srcTransferFunctionParameters), + "offsetof mismatch for " + "CopyTextureForBrowserOptions::srcTransferFunctionParameters"); +static_assert( + offsetof(CopyTextureForBrowserOptions, conversionMatrix) == + offsetof(WGPUCopyTextureForBrowserOptions, conversionMatrix), + "offsetof mismatch for CopyTextureForBrowserOptions::conversionMatrix"); +static_assert(offsetof(CopyTextureForBrowserOptions, + dstTransferFunctionParameters) == + offsetof(WGPUCopyTextureForBrowserOptions, + dstTransferFunctionParameters), + "offsetof mismatch for " + "CopyTextureForBrowserOptions::dstTransferFunctionParameters"); +static_assert( + offsetof(CopyTextureForBrowserOptions, dstAlphaMode) == + offsetof(WGPUCopyTextureForBrowserOptions, dstAlphaMode), + "offsetof mismatch for CopyTextureForBrowserOptions::dstAlphaMode"); +static_assert( + offsetof(CopyTextureForBrowserOptions, internalUsage) == + offsetof(WGPUCopyTextureForBrowserOptions, internalUsage), + "offsetof mismatch for CopyTextureForBrowserOptions::internalUsage"); + +// CreateComputePipelineAsyncCallbackInfo + +static_assert(sizeof(CreateComputePipelineAsyncCallbackInfo) == + sizeof(WGPUCreateComputePipelineAsyncCallbackInfo), + "sizeof mismatch for CreateComputePipelineAsyncCallbackInfo"); +static_assert(alignof(CreateComputePipelineAsyncCallbackInfo) == + alignof(WGPUCreateComputePipelineAsyncCallbackInfo), + "alignof mismatch for CreateComputePipelineAsyncCallbackInfo"); + +static_assert(offsetof(CreateComputePipelineAsyncCallbackInfo, nextInChain) == + offsetof(WGPUCreateComputePipelineAsyncCallbackInfo, + nextInChain), + "offsetof mismatch for " + "CreateComputePipelineAsyncCallbackInfo::nextInChain"); +static_assert( + offsetof(CreateComputePipelineAsyncCallbackInfo, mode) == + offsetof(WGPUCreateComputePipelineAsyncCallbackInfo, mode), + "offsetof mismatch for CreateComputePipelineAsyncCallbackInfo::mode"); +static_assert( + offsetof(CreateComputePipelineAsyncCallbackInfo, callback) == + offsetof(WGPUCreateComputePipelineAsyncCallbackInfo, callback), + "offsetof mismatch for CreateComputePipelineAsyncCallbackInfo::callback"); +static_assert( + offsetof(CreateComputePipelineAsyncCallbackInfo, userdata) == + offsetof(WGPUCreateComputePipelineAsyncCallbackInfo, userdata), + "offsetof mismatch for CreateComputePipelineAsyncCallbackInfo::userdata"); + +// CreateRenderPipelineAsyncCallbackInfo + +static_assert(sizeof(CreateRenderPipelineAsyncCallbackInfo) == + sizeof(WGPUCreateRenderPipelineAsyncCallbackInfo), + "sizeof mismatch for CreateRenderPipelineAsyncCallbackInfo"); +static_assert(alignof(CreateRenderPipelineAsyncCallbackInfo) == + alignof(WGPUCreateRenderPipelineAsyncCallbackInfo), + "alignof mismatch for CreateRenderPipelineAsyncCallbackInfo"); + +static_assert( + offsetof(CreateRenderPipelineAsyncCallbackInfo, nextInChain) == + offsetof(WGPUCreateRenderPipelineAsyncCallbackInfo, nextInChain), + "offsetof mismatch for CreateRenderPipelineAsyncCallbackInfo::nextInChain"); +static_assert( + offsetof(CreateRenderPipelineAsyncCallbackInfo, mode) == + offsetof(WGPUCreateRenderPipelineAsyncCallbackInfo, mode), + "offsetof mismatch for CreateRenderPipelineAsyncCallbackInfo::mode"); +static_assert( + offsetof(CreateRenderPipelineAsyncCallbackInfo, callback) == + offsetof(WGPUCreateRenderPipelineAsyncCallbackInfo, callback), + "offsetof mismatch for CreateRenderPipelineAsyncCallbackInfo::callback"); +static_assert( + offsetof(CreateRenderPipelineAsyncCallbackInfo, userdata) == + offsetof(WGPUCreateRenderPipelineAsyncCallbackInfo, userdata), + "offsetof mismatch for CreateRenderPipelineAsyncCallbackInfo::userdata"); + +// DawnWGSLBlocklist + +static_assert(sizeof(DawnWGSLBlocklist) == sizeof(WGPUDawnWGSLBlocklist), + "sizeof mismatch for DawnWGSLBlocklist"); +static_assert(alignof(DawnWGSLBlocklist) == alignof(WGPUDawnWGSLBlocklist), + "alignof mismatch for DawnWGSLBlocklist"); + +static_assert( + offsetof(DawnWGSLBlocklist, blocklistedFeatureCount) == + offsetof(WGPUDawnWGSLBlocklist, blocklistedFeatureCount), + "offsetof mismatch for DawnWGSLBlocklist::blocklistedFeatureCount"); +static_assert(offsetof(DawnWGSLBlocklist, blocklistedFeatures) == + offsetof(WGPUDawnWGSLBlocklist, blocklistedFeatures), + "offsetof mismatch for DawnWGSLBlocklist::blocklistedFeatures"); + +// DawnAdapterPropertiesPowerPreference + +static_assert(sizeof(DawnAdapterPropertiesPowerPreference) == + sizeof(WGPUDawnAdapterPropertiesPowerPreference), + "sizeof mismatch for DawnAdapterPropertiesPowerPreference"); +static_assert(alignof(DawnAdapterPropertiesPowerPreference) == + alignof(WGPUDawnAdapterPropertiesPowerPreference), + "alignof mismatch for DawnAdapterPropertiesPowerPreference"); + +static_assert(offsetof(DawnAdapterPropertiesPowerPreference, powerPreference) == + offsetof(WGPUDawnAdapterPropertiesPowerPreference, + powerPreference), + "offsetof mismatch for " + "DawnAdapterPropertiesPowerPreference::powerPreference"); + +// DawnBufferDescriptorErrorInfoFromWireClient + +static_assert( + sizeof(DawnBufferDescriptorErrorInfoFromWireClient) == + sizeof(WGPUDawnBufferDescriptorErrorInfoFromWireClient), + "sizeof mismatch for DawnBufferDescriptorErrorInfoFromWireClient"); +static_assert( + alignof(DawnBufferDescriptorErrorInfoFromWireClient) == + alignof(WGPUDawnBufferDescriptorErrorInfoFromWireClient), + "alignof mismatch for DawnBufferDescriptorErrorInfoFromWireClient"); + +static_assert(offsetof(DawnBufferDescriptorErrorInfoFromWireClient, + outOfMemory) == + offsetof(WGPUDawnBufferDescriptorErrorInfoFromWireClient, + outOfMemory), + "offsetof mismatch for " + "DawnBufferDescriptorErrorInfoFromWireClient::outOfMemory"); + +// DawnCacheDeviceDescriptor + +static_assert(sizeof(DawnCacheDeviceDescriptor) == + sizeof(WGPUDawnCacheDeviceDescriptor), + "sizeof mismatch for DawnCacheDeviceDescriptor"); +static_assert(alignof(DawnCacheDeviceDescriptor) == + alignof(WGPUDawnCacheDeviceDescriptor), + "alignof mismatch for DawnCacheDeviceDescriptor"); + +static_assert(offsetof(DawnCacheDeviceDescriptor, isolationKey) == + offsetof(WGPUDawnCacheDeviceDescriptor, isolationKey), + "offsetof mismatch for DawnCacheDeviceDescriptor::isolationKey"); +static_assert( + offsetof(DawnCacheDeviceDescriptor, loadDataFunction) == + offsetof(WGPUDawnCacheDeviceDescriptor, loadDataFunction), + "offsetof mismatch for DawnCacheDeviceDescriptor::loadDataFunction"); +static_assert( + offsetof(DawnCacheDeviceDescriptor, storeDataFunction) == + offsetof(WGPUDawnCacheDeviceDescriptor, storeDataFunction), + "offsetof mismatch for DawnCacheDeviceDescriptor::storeDataFunction"); +static_assert( + offsetof(DawnCacheDeviceDescriptor, functionUserdata) == + offsetof(WGPUDawnCacheDeviceDescriptor, functionUserdata), + "offsetof mismatch for DawnCacheDeviceDescriptor::functionUserdata"); + +// DawnComputePipelineFullSubgroups + +static_assert(sizeof(DawnComputePipelineFullSubgroups) == + sizeof(WGPUDawnComputePipelineFullSubgroups), + "sizeof mismatch for DawnComputePipelineFullSubgroups"); +static_assert(alignof(DawnComputePipelineFullSubgroups) == + alignof(WGPUDawnComputePipelineFullSubgroups), + "alignof mismatch for DawnComputePipelineFullSubgroups"); + +static_assert(offsetof(DawnComputePipelineFullSubgroups, + requiresFullSubgroups) == + offsetof(WGPUDawnComputePipelineFullSubgroups, + requiresFullSubgroups), + "offsetof mismatch for " + "DawnComputePipelineFullSubgroups::requiresFullSubgroups"); + +// DawnEncoderInternalUsageDescriptor + +static_assert(sizeof(DawnEncoderInternalUsageDescriptor) == + sizeof(WGPUDawnEncoderInternalUsageDescriptor), + "sizeof mismatch for DawnEncoderInternalUsageDescriptor"); +static_assert(alignof(DawnEncoderInternalUsageDescriptor) == + alignof(WGPUDawnEncoderInternalUsageDescriptor), + "alignof mismatch for DawnEncoderInternalUsageDescriptor"); + +static_assert(offsetof(DawnEncoderInternalUsageDescriptor, useInternalUsages) == + offsetof(WGPUDawnEncoderInternalUsageDescriptor, + useInternalUsages), + "offsetof mismatch for " + "DawnEncoderInternalUsageDescriptor::useInternalUsages"); + +// DawnExperimentalSubgroupLimits + +static_assert(sizeof(DawnExperimentalSubgroupLimits) == + sizeof(WGPUDawnExperimentalSubgroupLimits), + "sizeof mismatch for DawnExperimentalSubgroupLimits"); +static_assert(alignof(DawnExperimentalSubgroupLimits) == + alignof(WGPUDawnExperimentalSubgroupLimits), + "alignof mismatch for DawnExperimentalSubgroupLimits"); + +static_assert( + offsetof(DawnExperimentalSubgroupLimits, minSubgroupSize) == + offsetof(WGPUDawnExperimentalSubgroupLimits, minSubgroupSize), + "offsetof mismatch for DawnExperimentalSubgroupLimits::minSubgroupSize"); +static_assert( + offsetof(DawnExperimentalSubgroupLimits, maxSubgroupSize) == + offsetof(WGPUDawnExperimentalSubgroupLimits, maxSubgroupSize), + "offsetof mismatch for DawnExperimentalSubgroupLimits::maxSubgroupSize"); + +// DawnMultisampleStateRenderToSingleSampled + +static_assert(sizeof(DawnMultisampleStateRenderToSingleSampled) == + sizeof(WGPUDawnMultisampleStateRenderToSingleSampled), + "sizeof mismatch for DawnMultisampleStateRenderToSingleSampled"); +static_assert(alignof(DawnMultisampleStateRenderToSingleSampled) == + alignof(WGPUDawnMultisampleStateRenderToSingleSampled), + "alignof mismatch for DawnMultisampleStateRenderToSingleSampled"); + +static_assert( + offsetof(DawnMultisampleStateRenderToSingleSampled, enabled) == + offsetof(WGPUDawnMultisampleStateRenderToSingleSampled, enabled), + "offsetof mismatch for DawnMultisampleStateRenderToSingleSampled::enabled"); + +// DawnRenderPassColorAttachmentRenderToSingleSampled + +static_assert( + sizeof(DawnRenderPassColorAttachmentRenderToSingleSampled) == + sizeof(WGPUDawnRenderPassColorAttachmentRenderToSingleSampled), + "sizeof mismatch for DawnRenderPassColorAttachmentRenderToSingleSampled"); +static_assert( + alignof(DawnRenderPassColorAttachmentRenderToSingleSampled) == + alignof(WGPUDawnRenderPassColorAttachmentRenderToSingleSampled), + "alignof mismatch for DawnRenderPassColorAttachmentRenderToSingleSampled"); + +static_assert( + offsetof(DawnRenderPassColorAttachmentRenderToSingleSampled, + implicitSampleCount) == + offsetof(WGPUDawnRenderPassColorAttachmentRenderToSingleSampled, + implicitSampleCount), + "offsetof mismatch for " + "DawnRenderPassColorAttachmentRenderToSingleSampled::implicitSampleCount"); + +// DawnShaderModuleSPIRVOptionsDescriptor + +static_assert(sizeof(DawnShaderModuleSPIRVOptionsDescriptor) == + sizeof(WGPUDawnShaderModuleSPIRVOptionsDescriptor), + "sizeof mismatch for DawnShaderModuleSPIRVOptionsDescriptor"); +static_assert(alignof(DawnShaderModuleSPIRVOptionsDescriptor) == + alignof(WGPUDawnShaderModuleSPIRVOptionsDescriptor), + "alignof mismatch for DawnShaderModuleSPIRVOptionsDescriptor"); + +static_assert( + offsetof(DawnShaderModuleSPIRVOptionsDescriptor, + allowNonUniformDerivatives) == + offsetof(WGPUDawnShaderModuleSPIRVOptionsDescriptor, + allowNonUniformDerivatives), + "offsetof mismatch for " + "DawnShaderModuleSPIRVOptionsDescriptor::allowNonUniformDerivatives"); + +// DawnTextureInternalUsageDescriptor + +static_assert(sizeof(DawnTextureInternalUsageDescriptor) == + sizeof(WGPUDawnTextureInternalUsageDescriptor), + "sizeof mismatch for DawnTextureInternalUsageDescriptor"); +static_assert(alignof(DawnTextureInternalUsageDescriptor) == + alignof(WGPUDawnTextureInternalUsageDescriptor), + "alignof mismatch for DawnTextureInternalUsageDescriptor"); + +static_assert( + offsetof(DawnTextureInternalUsageDescriptor, internalUsage) == + offsetof(WGPUDawnTextureInternalUsageDescriptor, internalUsage), + "offsetof mismatch for DawnTextureInternalUsageDescriptor::internalUsage"); + +// DawnTogglesDescriptor + +static_assert(sizeof(DawnTogglesDescriptor) == + sizeof(WGPUDawnTogglesDescriptor), + "sizeof mismatch for DawnTogglesDescriptor"); +static_assert(alignof(DawnTogglesDescriptor) == + alignof(WGPUDawnTogglesDescriptor), + "alignof mismatch for DawnTogglesDescriptor"); + +static_assert( + offsetof(DawnTogglesDescriptor, enabledToggleCount) == + offsetof(WGPUDawnTogglesDescriptor, enabledToggleCount), + "offsetof mismatch for DawnTogglesDescriptor::enabledToggleCount"); +static_assert(offsetof(DawnTogglesDescriptor, enabledToggles) == + offsetof(WGPUDawnTogglesDescriptor, enabledToggles), + "offsetof mismatch for DawnTogglesDescriptor::enabledToggles"); +static_assert( + offsetof(DawnTogglesDescriptor, disabledToggleCount) == + offsetof(WGPUDawnTogglesDescriptor, disabledToggleCount), + "offsetof mismatch for DawnTogglesDescriptor::disabledToggleCount"); +static_assert(offsetof(DawnTogglesDescriptor, disabledToggles) == + offsetof(WGPUDawnTogglesDescriptor, disabledToggles), + "offsetof mismatch for DawnTogglesDescriptor::disabledToggles"); + +// DawnWireWGSLControl + +static_assert(sizeof(DawnWireWGSLControl) == sizeof(WGPUDawnWireWGSLControl), + "sizeof mismatch for DawnWireWGSLControl"); +static_assert(alignof(DawnWireWGSLControl) == alignof(WGPUDawnWireWGSLControl), + "alignof mismatch for DawnWireWGSLControl"); + +static_assert(offsetof(DawnWireWGSLControl, enableExperimental) == + offsetof(WGPUDawnWireWGSLControl, enableExperimental), + "offsetof mismatch for DawnWireWGSLControl::enableExperimental"); +static_assert(offsetof(DawnWireWGSLControl, enableUnsafe) == + offsetof(WGPUDawnWireWGSLControl, enableUnsafe), + "offsetof mismatch for DawnWireWGSLControl::enableUnsafe"); +static_assert(offsetof(DawnWireWGSLControl, enableTesting) == + offsetof(WGPUDawnWireWGSLControl, enableTesting), + "offsetof mismatch for DawnWireWGSLControl::enableTesting"); + +// DepthStencilStateDepthWriteDefinedDawn + +static_assert(sizeof(DepthStencilStateDepthWriteDefinedDawn) == + sizeof(WGPUDepthStencilStateDepthWriteDefinedDawn), + "sizeof mismatch for DepthStencilStateDepthWriteDefinedDawn"); +static_assert(alignof(DepthStencilStateDepthWriteDefinedDawn) == + alignof(WGPUDepthStencilStateDepthWriteDefinedDawn), + "alignof mismatch for DepthStencilStateDepthWriteDefinedDawn"); + +static_assert(offsetof(DepthStencilStateDepthWriteDefinedDawn, + depthWriteDefined) == + offsetof(WGPUDepthStencilStateDepthWriteDefinedDawn, + depthWriteDefined), + "offsetof mismatch for " + "DepthStencilStateDepthWriteDefinedDawn::depthWriteDefined"); + +// DrmFormatProperties + +static_assert(sizeof(DrmFormatProperties) == sizeof(WGPUDrmFormatProperties), + "sizeof mismatch for DrmFormatProperties"); +static_assert(alignof(DrmFormatProperties) == alignof(WGPUDrmFormatProperties), + "alignof mismatch for DrmFormatProperties"); + +static_assert(offsetof(DrmFormatProperties, modifier) == + offsetof(WGPUDrmFormatProperties, modifier), + "offsetof mismatch for DrmFormatProperties::modifier"); +static_assert(offsetof(DrmFormatProperties, modifierPlaneCount) == + offsetof(WGPUDrmFormatProperties, modifierPlaneCount), + "offsetof mismatch for DrmFormatProperties::modifierPlaneCount"); + +// Extent2D + +static_assert(sizeof(Extent2D) == sizeof(WGPUExtent2D), + "sizeof mismatch for Extent2D"); +static_assert(alignof(Extent2D) == alignof(WGPUExtent2D), + "alignof mismatch for Extent2D"); + +static_assert(offsetof(Extent2D, width) == offsetof(WGPUExtent2D, width), + "offsetof mismatch for Extent2D::width"); +static_assert(offsetof(Extent2D, height) == offsetof(WGPUExtent2D, height), + "offsetof mismatch for Extent2D::height"); + +// Extent3D + +static_assert(sizeof(Extent3D) == sizeof(WGPUExtent3D), + "sizeof mismatch for Extent3D"); +static_assert(alignof(Extent3D) == alignof(WGPUExtent3D), + "alignof mismatch for Extent3D"); + +static_assert(offsetof(Extent3D, width) == offsetof(WGPUExtent3D, width), + "offsetof mismatch for Extent3D::width"); +static_assert(offsetof(Extent3D, height) == offsetof(WGPUExtent3D, height), + "offsetof mismatch for Extent3D::height"); +static_assert(offsetof(Extent3D, depthOrArrayLayers) == + offsetof(WGPUExtent3D, depthOrArrayLayers), + "offsetof mismatch for Extent3D::depthOrArrayLayers"); + +// ExternalTextureBindingEntry + +static_assert(sizeof(ExternalTextureBindingEntry) == + sizeof(WGPUExternalTextureBindingEntry), + "sizeof mismatch for ExternalTextureBindingEntry"); +static_assert(alignof(ExternalTextureBindingEntry) == + alignof(WGPUExternalTextureBindingEntry), + "alignof mismatch for ExternalTextureBindingEntry"); + +static_assert( + offsetof(ExternalTextureBindingEntry, externalTexture) == + offsetof(WGPUExternalTextureBindingEntry, externalTexture), + "offsetof mismatch for ExternalTextureBindingEntry::externalTexture"); + +// ExternalTextureBindingLayout + +static_assert(sizeof(ExternalTextureBindingLayout) == + sizeof(WGPUExternalTextureBindingLayout), + "sizeof mismatch for ExternalTextureBindingLayout"); +static_assert(alignof(ExternalTextureBindingLayout) == + alignof(WGPUExternalTextureBindingLayout), + "alignof mismatch for ExternalTextureBindingLayout"); + +// FormatCapabilities + +static_assert(sizeof(FormatCapabilities) == sizeof(WGPUFormatCapabilities), + "sizeof mismatch for FormatCapabilities"); +static_assert(alignof(FormatCapabilities) == alignof(WGPUFormatCapabilities), + "alignof mismatch for FormatCapabilities"); + +static_assert(offsetof(FormatCapabilities, nextInChain) == + offsetof(WGPUFormatCapabilities, nextInChain), + "offsetof mismatch for FormatCapabilities::nextInChain"); + +// Future + +static_assert(sizeof(Future) == sizeof(WGPUFuture), + "sizeof mismatch for Future"); +static_assert(alignof(Future) == alignof(WGPUFuture), + "alignof mismatch for Future"); + +static_assert(offsetof(Future, id) == offsetof(WGPUFuture, id), + "offsetof mismatch for Future::id"); + +// InstanceFeatures + +static_assert(sizeof(InstanceFeatures) == sizeof(WGPUInstanceFeatures), + "sizeof mismatch for InstanceFeatures"); +static_assert(alignof(InstanceFeatures) == alignof(WGPUInstanceFeatures), + "alignof mismatch for InstanceFeatures"); + +static_assert(offsetof(InstanceFeatures, nextInChain) == + offsetof(WGPUInstanceFeatures, nextInChain), + "offsetof mismatch for InstanceFeatures::nextInChain"); +static_assert(offsetof(InstanceFeatures, timedWaitAnyEnable) == + offsetof(WGPUInstanceFeatures, timedWaitAnyEnable), + "offsetof mismatch for InstanceFeatures::timedWaitAnyEnable"); +static_assert(offsetof(InstanceFeatures, timedWaitAnyMaxCount) == + offsetof(WGPUInstanceFeatures, timedWaitAnyMaxCount), + "offsetof mismatch for InstanceFeatures::timedWaitAnyMaxCount"); + +// Limits + +static_assert(sizeof(Limits) == sizeof(WGPULimits), + "sizeof mismatch for Limits"); +static_assert(alignof(Limits) == alignof(WGPULimits), + "alignof mismatch for Limits"); + +static_assert(offsetof(Limits, maxTextureDimension1D) == + offsetof(WGPULimits, maxTextureDimension1D), + "offsetof mismatch for Limits::maxTextureDimension1D"); +static_assert(offsetof(Limits, maxTextureDimension2D) == + offsetof(WGPULimits, maxTextureDimension2D), + "offsetof mismatch for Limits::maxTextureDimension2D"); +static_assert(offsetof(Limits, maxTextureDimension3D) == + offsetof(WGPULimits, maxTextureDimension3D), + "offsetof mismatch for Limits::maxTextureDimension3D"); +static_assert(offsetof(Limits, maxTextureArrayLayers) == + offsetof(WGPULimits, maxTextureArrayLayers), + "offsetof mismatch for Limits::maxTextureArrayLayers"); +static_assert(offsetof(Limits, maxBindGroups) == + offsetof(WGPULimits, maxBindGroups), + "offsetof mismatch for Limits::maxBindGroups"); +static_assert(offsetof(Limits, maxBindGroupsPlusVertexBuffers) == + offsetof(WGPULimits, maxBindGroupsPlusVertexBuffers), + "offsetof mismatch for Limits::maxBindGroupsPlusVertexBuffers"); +static_assert(offsetof(Limits, maxBindingsPerBindGroup) == + offsetof(WGPULimits, maxBindingsPerBindGroup), + "offsetof mismatch for Limits::maxBindingsPerBindGroup"); +static_assert( + offsetof(Limits, maxDynamicUniformBuffersPerPipelineLayout) == + offsetof(WGPULimits, maxDynamicUniformBuffersPerPipelineLayout), + "offsetof mismatch for Limits::maxDynamicUniformBuffersPerPipelineLayout"); +static_assert( + offsetof(Limits, maxDynamicStorageBuffersPerPipelineLayout) == + offsetof(WGPULimits, maxDynamicStorageBuffersPerPipelineLayout), + "offsetof mismatch for Limits::maxDynamicStorageBuffersPerPipelineLayout"); +static_assert(offsetof(Limits, maxSampledTexturesPerShaderStage) == + offsetof(WGPULimits, maxSampledTexturesPerShaderStage), + "offsetof mismatch for Limits::maxSampledTexturesPerShaderStage"); +static_assert(offsetof(Limits, maxSamplersPerShaderStage) == + offsetof(WGPULimits, maxSamplersPerShaderStage), + "offsetof mismatch for Limits::maxSamplersPerShaderStage"); +static_assert(offsetof(Limits, maxStorageBuffersPerShaderStage) == + offsetof(WGPULimits, maxStorageBuffersPerShaderStage), + "offsetof mismatch for Limits::maxStorageBuffersPerShaderStage"); +static_assert(offsetof(Limits, maxStorageTexturesPerShaderStage) == + offsetof(WGPULimits, maxStorageTexturesPerShaderStage), + "offsetof mismatch for Limits::maxStorageTexturesPerShaderStage"); +static_assert(offsetof(Limits, maxUniformBuffersPerShaderStage) == + offsetof(WGPULimits, maxUniformBuffersPerShaderStage), + "offsetof mismatch for Limits::maxUniformBuffersPerShaderStage"); +static_assert(offsetof(Limits, maxUniformBufferBindingSize) == + offsetof(WGPULimits, maxUniformBufferBindingSize), + "offsetof mismatch for Limits::maxUniformBufferBindingSize"); +static_assert(offsetof(Limits, maxStorageBufferBindingSize) == + offsetof(WGPULimits, maxStorageBufferBindingSize), + "offsetof mismatch for Limits::maxStorageBufferBindingSize"); +static_assert(offsetof(Limits, minUniformBufferOffsetAlignment) == + offsetof(WGPULimits, minUniformBufferOffsetAlignment), + "offsetof mismatch for Limits::minUniformBufferOffsetAlignment"); +static_assert(offsetof(Limits, minStorageBufferOffsetAlignment) == + offsetof(WGPULimits, minStorageBufferOffsetAlignment), + "offsetof mismatch for Limits::minStorageBufferOffsetAlignment"); +static_assert(offsetof(Limits, maxVertexBuffers) == + offsetof(WGPULimits, maxVertexBuffers), + "offsetof mismatch for Limits::maxVertexBuffers"); +static_assert(offsetof(Limits, maxBufferSize) == + offsetof(WGPULimits, maxBufferSize), + "offsetof mismatch for Limits::maxBufferSize"); +static_assert(offsetof(Limits, maxVertexAttributes) == + offsetof(WGPULimits, maxVertexAttributes), + "offsetof mismatch for Limits::maxVertexAttributes"); +static_assert(offsetof(Limits, maxVertexBufferArrayStride) == + offsetof(WGPULimits, maxVertexBufferArrayStride), + "offsetof mismatch for Limits::maxVertexBufferArrayStride"); +static_assert(offsetof(Limits, maxInterStageShaderComponents) == + offsetof(WGPULimits, maxInterStageShaderComponents), + "offsetof mismatch for Limits::maxInterStageShaderComponents"); +static_assert(offsetof(Limits, maxInterStageShaderVariables) == + offsetof(WGPULimits, maxInterStageShaderVariables), + "offsetof mismatch for Limits::maxInterStageShaderVariables"); +static_assert(offsetof(Limits, maxColorAttachments) == + offsetof(WGPULimits, maxColorAttachments), + "offsetof mismatch for Limits::maxColorAttachments"); +static_assert(offsetof(Limits, maxColorAttachmentBytesPerSample) == + offsetof(WGPULimits, maxColorAttachmentBytesPerSample), + "offsetof mismatch for Limits::maxColorAttachmentBytesPerSample"); +static_assert(offsetof(Limits, maxComputeWorkgroupStorageSize) == + offsetof(WGPULimits, maxComputeWorkgroupStorageSize), + "offsetof mismatch for Limits::maxComputeWorkgroupStorageSize"); +static_assert( + offsetof(Limits, maxComputeInvocationsPerWorkgroup) == + offsetof(WGPULimits, maxComputeInvocationsPerWorkgroup), + "offsetof mismatch for Limits::maxComputeInvocationsPerWorkgroup"); +static_assert(offsetof(Limits, maxComputeWorkgroupSizeX) == + offsetof(WGPULimits, maxComputeWorkgroupSizeX), + "offsetof mismatch for Limits::maxComputeWorkgroupSizeX"); +static_assert(offsetof(Limits, maxComputeWorkgroupSizeY) == + offsetof(WGPULimits, maxComputeWorkgroupSizeY), + "offsetof mismatch for Limits::maxComputeWorkgroupSizeY"); +static_assert(offsetof(Limits, maxComputeWorkgroupSizeZ) == + offsetof(WGPULimits, maxComputeWorkgroupSizeZ), + "offsetof mismatch for Limits::maxComputeWorkgroupSizeZ"); +static_assert(offsetof(Limits, maxComputeWorkgroupsPerDimension) == + offsetof(WGPULimits, maxComputeWorkgroupsPerDimension), + "offsetof mismatch for Limits::maxComputeWorkgroupsPerDimension"); + +// MemoryHeapInfo + +static_assert(sizeof(MemoryHeapInfo) == sizeof(WGPUMemoryHeapInfo), + "sizeof mismatch for MemoryHeapInfo"); +static_assert(alignof(MemoryHeapInfo) == alignof(WGPUMemoryHeapInfo), + "alignof mismatch for MemoryHeapInfo"); + +static_assert(offsetof(MemoryHeapInfo, properties) == + offsetof(WGPUMemoryHeapInfo, properties), + "offsetof mismatch for MemoryHeapInfo::properties"); +static_assert(offsetof(MemoryHeapInfo, size) == + offsetof(WGPUMemoryHeapInfo, size), + "offsetof mismatch for MemoryHeapInfo::size"); + +// MultisampleState + +static_assert(sizeof(MultisampleState) == sizeof(WGPUMultisampleState), + "sizeof mismatch for MultisampleState"); +static_assert(alignof(MultisampleState) == alignof(WGPUMultisampleState), + "alignof mismatch for MultisampleState"); + +static_assert(offsetof(MultisampleState, nextInChain) == + offsetof(WGPUMultisampleState, nextInChain), + "offsetof mismatch for MultisampleState::nextInChain"); +static_assert(offsetof(MultisampleState, count) == + offsetof(WGPUMultisampleState, count), + "offsetof mismatch for MultisampleState::count"); +static_assert(offsetof(MultisampleState, mask) == + offsetof(WGPUMultisampleState, mask), + "offsetof mismatch for MultisampleState::mask"); +static_assert(offsetof(MultisampleState, alphaToCoverageEnabled) == + offsetof(WGPUMultisampleState, alphaToCoverageEnabled), + "offsetof mismatch for MultisampleState::alphaToCoverageEnabled"); + +// Origin2D + +static_assert(sizeof(Origin2D) == sizeof(WGPUOrigin2D), + "sizeof mismatch for Origin2D"); +static_assert(alignof(Origin2D) == alignof(WGPUOrigin2D), + "alignof mismatch for Origin2D"); + +static_assert(offsetof(Origin2D, x) == offsetof(WGPUOrigin2D, x), + "offsetof mismatch for Origin2D::x"); +static_assert(offsetof(Origin2D, y) == offsetof(WGPUOrigin2D, y), + "offsetof mismatch for Origin2D::y"); + +// Origin3D + +static_assert(sizeof(Origin3D) == sizeof(WGPUOrigin3D), + "sizeof mismatch for Origin3D"); +static_assert(alignof(Origin3D) == alignof(WGPUOrigin3D), + "alignof mismatch for Origin3D"); + +static_assert(offsetof(Origin3D, x) == offsetof(WGPUOrigin3D, x), + "offsetof mismatch for Origin3D::x"); +static_assert(offsetof(Origin3D, y) == offsetof(WGPUOrigin3D, y), + "offsetof mismatch for Origin3D::y"); +static_assert(offsetof(Origin3D, z) == offsetof(WGPUOrigin3D, z), + "offsetof mismatch for Origin3D::z"); + +// PipelineLayoutDescriptor + +static_assert(sizeof(PipelineLayoutDescriptor) == + sizeof(WGPUPipelineLayoutDescriptor), + "sizeof mismatch for PipelineLayoutDescriptor"); +static_assert(alignof(PipelineLayoutDescriptor) == + alignof(WGPUPipelineLayoutDescriptor), + "alignof mismatch for PipelineLayoutDescriptor"); + +static_assert(offsetof(PipelineLayoutDescriptor, nextInChain) == + offsetof(WGPUPipelineLayoutDescriptor, nextInChain), + "offsetof mismatch for PipelineLayoutDescriptor::nextInChain"); +static_assert(offsetof(PipelineLayoutDescriptor, label) == + offsetof(WGPUPipelineLayoutDescriptor, label), + "offsetof mismatch for PipelineLayoutDescriptor::label"); +static_assert( + offsetof(PipelineLayoutDescriptor, bindGroupLayoutCount) == + offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayoutCount), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayoutCount"); +static_assert( + offsetof(PipelineLayoutDescriptor, bindGroupLayouts) == + offsetof(WGPUPipelineLayoutDescriptor, bindGroupLayouts), + "offsetof mismatch for PipelineLayoutDescriptor::bindGroupLayouts"); + +// PipelineLayoutStorageAttachment + +static_assert(sizeof(PipelineLayoutStorageAttachment) == + sizeof(WGPUPipelineLayoutStorageAttachment), + "sizeof mismatch for PipelineLayoutStorageAttachment"); +static_assert(alignof(PipelineLayoutStorageAttachment) == + alignof(WGPUPipelineLayoutStorageAttachment), + "alignof mismatch for PipelineLayoutStorageAttachment"); + +static_assert( + offsetof(PipelineLayoutStorageAttachment, nextInChain) == + offsetof(WGPUPipelineLayoutStorageAttachment, nextInChain), + "offsetof mismatch for PipelineLayoutStorageAttachment::nextInChain"); +static_assert(offsetof(PipelineLayoutStorageAttachment, offset) == + offsetof(WGPUPipelineLayoutStorageAttachment, offset), + "offsetof mismatch for PipelineLayoutStorageAttachment::offset"); +static_assert(offsetof(PipelineLayoutStorageAttachment, format) == + offsetof(WGPUPipelineLayoutStorageAttachment, format), + "offsetof mismatch for PipelineLayoutStorageAttachment::format"); + +// PopErrorScopeCallbackInfo + +static_assert(sizeof(PopErrorScopeCallbackInfo) == + sizeof(WGPUPopErrorScopeCallbackInfo), + "sizeof mismatch for PopErrorScopeCallbackInfo"); +static_assert(alignof(PopErrorScopeCallbackInfo) == + alignof(WGPUPopErrorScopeCallbackInfo), + "alignof mismatch for PopErrorScopeCallbackInfo"); + +static_assert(offsetof(PopErrorScopeCallbackInfo, nextInChain) == + offsetof(WGPUPopErrorScopeCallbackInfo, nextInChain), + "offsetof mismatch for PopErrorScopeCallbackInfo::nextInChain"); +static_assert(offsetof(PopErrorScopeCallbackInfo, mode) == + offsetof(WGPUPopErrorScopeCallbackInfo, mode), + "offsetof mismatch for PopErrorScopeCallbackInfo::mode"); +static_assert(offsetof(PopErrorScopeCallbackInfo, callback) == + offsetof(WGPUPopErrorScopeCallbackInfo, callback), + "offsetof mismatch for PopErrorScopeCallbackInfo::callback"); +static_assert(offsetof(PopErrorScopeCallbackInfo, oldCallback) == + offsetof(WGPUPopErrorScopeCallbackInfo, oldCallback), + "offsetof mismatch for PopErrorScopeCallbackInfo::oldCallback"); +static_assert(offsetof(PopErrorScopeCallbackInfo, userdata) == + offsetof(WGPUPopErrorScopeCallbackInfo, userdata), + "offsetof mismatch for PopErrorScopeCallbackInfo::userdata"); + +// PrimitiveDepthClipControl + +static_assert(sizeof(PrimitiveDepthClipControl) == + sizeof(WGPUPrimitiveDepthClipControl), + "sizeof mismatch for PrimitiveDepthClipControl"); +static_assert(alignof(PrimitiveDepthClipControl) == + alignof(WGPUPrimitiveDepthClipControl), + "alignof mismatch for PrimitiveDepthClipControl"); + +static_assert( + offsetof(PrimitiveDepthClipControl, unclippedDepth) == + offsetof(WGPUPrimitiveDepthClipControl, unclippedDepth), + "offsetof mismatch for PrimitiveDepthClipControl::unclippedDepth"); + +// PrimitiveState + +static_assert(sizeof(PrimitiveState) == sizeof(WGPUPrimitiveState), + "sizeof mismatch for PrimitiveState"); +static_assert(alignof(PrimitiveState) == alignof(WGPUPrimitiveState), + "alignof mismatch for PrimitiveState"); + +static_assert(offsetof(PrimitiveState, nextInChain) == + offsetof(WGPUPrimitiveState, nextInChain), + "offsetof mismatch for PrimitiveState::nextInChain"); +static_assert(offsetof(PrimitiveState, topology) == + offsetof(WGPUPrimitiveState, topology), + "offsetof mismatch for PrimitiveState::topology"); +static_assert(offsetof(PrimitiveState, stripIndexFormat) == + offsetof(WGPUPrimitiveState, stripIndexFormat), + "offsetof mismatch for PrimitiveState::stripIndexFormat"); +static_assert(offsetof(PrimitiveState, frontFace) == + offsetof(WGPUPrimitiveState, frontFace), + "offsetof mismatch for PrimitiveState::frontFace"); +static_assert(offsetof(PrimitiveState, cullMode) == + offsetof(WGPUPrimitiveState, cullMode), + "offsetof mismatch for PrimitiveState::cullMode"); + +// QuerySetDescriptor + +static_assert(sizeof(QuerySetDescriptor) == sizeof(WGPUQuerySetDescriptor), + "sizeof mismatch for QuerySetDescriptor"); +static_assert(alignof(QuerySetDescriptor) == alignof(WGPUQuerySetDescriptor), + "alignof mismatch for QuerySetDescriptor"); + +static_assert(offsetof(QuerySetDescriptor, nextInChain) == + offsetof(WGPUQuerySetDescriptor, nextInChain), + "offsetof mismatch for QuerySetDescriptor::nextInChain"); +static_assert(offsetof(QuerySetDescriptor, label) == + offsetof(WGPUQuerySetDescriptor, label), + "offsetof mismatch for QuerySetDescriptor::label"); +static_assert(offsetof(QuerySetDescriptor, type) == + offsetof(WGPUQuerySetDescriptor, type), + "offsetof mismatch for QuerySetDescriptor::type"); +static_assert(offsetof(QuerySetDescriptor, count) == + offsetof(WGPUQuerySetDescriptor, count), + "offsetof mismatch for QuerySetDescriptor::count"); + +// QueueDescriptor + +static_assert(sizeof(QueueDescriptor) == sizeof(WGPUQueueDescriptor), + "sizeof mismatch for QueueDescriptor"); +static_assert(alignof(QueueDescriptor) == alignof(WGPUQueueDescriptor), + "alignof mismatch for QueueDescriptor"); + +static_assert(offsetof(QueueDescriptor, nextInChain) == + offsetof(WGPUQueueDescriptor, nextInChain), + "offsetof mismatch for QueueDescriptor::nextInChain"); +static_assert(offsetof(QueueDescriptor, label) == + offsetof(WGPUQueueDescriptor, label), + "offsetof mismatch for QueueDescriptor::label"); + +// QueueWorkDoneCallbackInfo + +static_assert(sizeof(QueueWorkDoneCallbackInfo) == + sizeof(WGPUQueueWorkDoneCallbackInfo), + "sizeof mismatch for QueueWorkDoneCallbackInfo"); +static_assert(alignof(QueueWorkDoneCallbackInfo) == + alignof(WGPUQueueWorkDoneCallbackInfo), + "alignof mismatch for QueueWorkDoneCallbackInfo"); + +static_assert(offsetof(QueueWorkDoneCallbackInfo, nextInChain) == + offsetof(WGPUQueueWorkDoneCallbackInfo, nextInChain), + "offsetof mismatch for QueueWorkDoneCallbackInfo::nextInChain"); +static_assert(offsetof(QueueWorkDoneCallbackInfo, mode) == + offsetof(WGPUQueueWorkDoneCallbackInfo, mode), + "offsetof mismatch for QueueWorkDoneCallbackInfo::mode"); +static_assert(offsetof(QueueWorkDoneCallbackInfo, callback) == + offsetof(WGPUQueueWorkDoneCallbackInfo, callback), + "offsetof mismatch for QueueWorkDoneCallbackInfo::callback"); +static_assert(offsetof(QueueWorkDoneCallbackInfo, userdata) == + offsetof(WGPUQueueWorkDoneCallbackInfo, userdata), + "offsetof mismatch for QueueWorkDoneCallbackInfo::userdata"); + +// RenderBundleDescriptor + +static_assert(sizeof(RenderBundleDescriptor) == + sizeof(WGPURenderBundleDescriptor), + "sizeof mismatch for RenderBundleDescriptor"); +static_assert(alignof(RenderBundleDescriptor) == + alignof(WGPURenderBundleDescriptor), + "alignof mismatch for RenderBundleDescriptor"); + +static_assert(offsetof(RenderBundleDescriptor, nextInChain) == + offsetof(WGPURenderBundleDescriptor, nextInChain), + "offsetof mismatch for RenderBundleDescriptor::nextInChain"); +static_assert(offsetof(RenderBundleDescriptor, label) == + offsetof(WGPURenderBundleDescriptor, label), + "offsetof mismatch for RenderBundleDescriptor::label"); + +// RenderBundleEncoderDescriptor + +static_assert(sizeof(RenderBundleEncoderDescriptor) == + sizeof(WGPURenderBundleEncoderDescriptor), + "sizeof mismatch for RenderBundleEncoderDescriptor"); +static_assert(alignof(RenderBundleEncoderDescriptor) == + alignof(WGPURenderBundleEncoderDescriptor), + "alignof mismatch for RenderBundleEncoderDescriptor"); + +static_assert( + offsetof(RenderBundleEncoderDescriptor, nextInChain) == + offsetof(WGPURenderBundleEncoderDescriptor, nextInChain), + "offsetof mismatch for RenderBundleEncoderDescriptor::nextInChain"); +static_assert(offsetof(RenderBundleEncoderDescriptor, label) == + offsetof(WGPURenderBundleEncoderDescriptor, label), + "offsetof mismatch for RenderBundleEncoderDescriptor::label"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, colorFormatCount) == + offsetof(WGPURenderBundleEncoderDescriptor, colorFormatCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormatCount"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, colorFormats) == + offsetof(WGPURenderBundleEncoderDescriptor, colorFormats), + "offsetof mismatch for RenderBundleEncoderDescriptor::colorFormats"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, depthStencilFormat) == + offsetof(WGPURenderBundleEncoderDescriptor, depthStencilFormat), + "offsetof mismatch for RenderBundleEncoderDescriptor::depthStencilFormat"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, sampleCount) == + offsetof(WGPURenderBundleEncoderDescriptor, sampleCount), + "offsetof mismatch for RenderBundleEncoderDescriptor::sampleCount"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, depthReadOnly) == + offsetof(WGPURenderBundleEncoderDescriptor, depthReadOnly), + "offsetof mismatch for RenderBundleEncoderDescriptor::depthReadOnly"); +static_assert( + offsetof(RenderBundleEncoderDescriptor, stencilReadOnly) == + offsetof(WGPURenderBundleEncoderDescriptor, stencilReadOnly), + "offsetof mismatch for RenderBundleEncoderDescriptor::stencilReadOnly"); + +// RenderPassDepthStencilAttachment + +static_assert(sizeof(RenderPassDepthStencilAttachment) == + sizeof(WGPURenderPassDepthStencilAttachment), + "sizeof mismatch for RenderPassDepthStencilAttachment"); +static_assert(alignof(RenderPassDepthStencilAttachment) == + alignof(WGPURenderPassDepthStencilAttachment), + "alignof mismatch for RenderPassDepthStencilAttachment"); + +static_assert(offsetof(RenderPassDepthStencilAttachment, view) == + offsetof(WGPURenderPassDepthStencilAttachment, view), + "offsetof mismatch for RenderPassDepthStencilAttachment::view"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, depthLoadOp) == + offsetof(WGPURenderPassDepthStencilAttachment, depthLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachment::depthLoadOp"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, depthStoreOp) == + offsetof(WGPURenderPassDepthStencilAttachment, depthStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachment::depthStoreOp"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, depthClearValue) == + offsetof(WGPURenderPassDepthStencilAttachment, depthClearValue), + "offsetof mismatch for RenderPassDepthStencilAttachment::depthClearValue"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, depthReadOnly) == + offsetof(WGPURenderPassDepthStencilAttachment, depthReadOnly), + "offsetof mismatch for RenderPassDepthStencilAttachment::depthReadOnly"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, stencilLoadOp) == + offsetof(WGPURenderPassDepthStencilAttachment, stencilLoadOp), + "offsetof mismatch for RenderPassDepthStencilAttachment::stencilLoadOp"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, stencilStoreOp) == + offsetof(WGPURenderPassDepthStencilAttachment, stencilStoreOp), + "offsetof mismatch for RenderPassDepthStencilAttachment::stencilStoreOp"); +static_assert(offsetof(RenderPassDepthStencilAttachment, stencilClearValue) == + offsetof(WGPURenderPassDepthStencilAttachment, + stencilClearValue), + "offsetof mismatch for " + "RenderPassDepthStencilAttachment::stencilClearValue"); +static_assert( + offsetof(RenderPassDepthStencilAttachment, stencilReadOnly) == + offsetof(WGPURenderPassDepthStencilAttachment, stencilReadOnly), + "offsetof mismatch for RenderPassDepthStencilAttachment::stencilReadOnly"); + +// RenderPassDescriptorMaxDrawCount + +static_assert(sizeof(RenderPassDescriptorMaxDrawCount) == + sizeof(WGPURenderPassDescriptorMaxDrawCount), + "sizeof mismatch for RenderPassDescriptorMaxDrawCount"); +static_assert(alignof(RenderPassDescriptorMaxDrawCount) == + alignof(WGPURenderPassDescriptorMaxDrawCount), + "alignof mismatch for RenderPassDescriptorMaxDrawCount"); + +static_assert( + offsetof(RenderPassDescriptorMaxDrawCount, maxDrawCount) == + offsetof(WGPURenderPassDescriptorMaxDrawCount, maxDrawCount), + "offsetof mismatch for RenderPassDescriptorMaxDrawCount::maxDrawCount"); + +// RenderPassTimestampWrites + +static_assert(sizeof(RenderPassTimestampWrites) == + sizeof(WGPURenderPassTimestampWrites), + "sizeof mismatch for RenderPassTimestampWrites"); +static_assert(alignof(RenderPassTimestampWrites) == + alignof(WGPURenderPassTimestampWrites), + "alignof mismatch for RenderPassTimestampWrites"); + +static_assert(offsetof(RenderPassTimestampWrites, querySet) == + offsetof(WGPURenderPassTimestampWrites, querySet), + "offsetof mismatch for RenderPassTimestampWrites::querySet"); +static_assert(offsetof(RenderPassTimestampWrites, beginningOfPassWriteIndex) == + offsetof(WGPURenderPassTimestampWrites, + beginningOfPassWriteIndex), + "offsetof mismatch for " + "RenderPassTimestampWrites::beginningOfPassWriteIndex"); +static_assert( + offsetof(RenderPassTimestampWrites, endOfPassWriteIndex) == + offsetof(WGPURenderPassTimestampWrites, endOfPassWriteIndex), + "offsetof mismatch for RenderPassTimestampWrites::endOfPassWriteIndex"); + +// RequestAdapterCallbackInfo + +static_assert(sizeof(RequestAdapterCallbackInfo) == + sizeof(WGPURequestAdapterCallbackInfo), + "sizeof mismatch for RequestAdapterCallbackInfo"); +static_assert(alignof(RequestAdapterCallbackInfo) == + alignof(WGPURequestAdapterCallbackInfo), + "alignof mismatch for RequestAdapterCallbackInfo"); + +static_assert(offsetof(RequestAdapterCallbackInfo, nextInChain) == + offsetof(WGPURequestAdapterCallbackInfo, nextInChain), + "offsetof mismatch for RequestAdapterCallbackInfo::nextInChain"); +static_assert(offsetof(RequestAdapterCallbackInfo, mode) == + offsetof(WGPURequestAdapterCallbackInfo, mode), + "offsetof mismatch for RequestAdapterCallbackInfo::mode"); +static_assert(offsetof(RequestAdapterCallbackInfo, callback) == + offsetof(WGPURequestAdapterCallbackInfo, callback), + "offsetof mismatch for RequestAdapterCallbackInfo::callback"); +static_assert(offsetof(RequestAdapterCallbackInfo, userdata) == + offsetof(WGPURequestAdapterCallbackInfo, userdata), + "offsetof mismatch for RequestAdapterCallbackInfo::userdata"); + +// RequestAdapterOptions + +static_assert(sizeof(RequestAdapterOptions) == + sizeof(WGPURequestAdapterOptions), + "sizeof mismatch for RequestAdapterOptions"); +static_assert(alignof(RequestAdapterOptions) == + alignof(WGPURequestAdapterOptions), + "alignof mismatch for RequestAdapterOptions"); + +static_assert(offsetof(RequestAdapterOptions, nextInChain) == + offsetof(WGPURequestAdapterOptions, nextInChain), + "offsetof mismatch for RequestAdapterOptions::nextInChain"); +static_assert(offsetof(RequestAdapterOptions, compatibleSurface) == + offsetof(WGPURequestAdapterOptions, compatibleSurface), + "offsetof mismatch for RequestAdapterOptions::compatibleSurface"); +static_assert(offsetof(RequestAdapterOptions, powerPreference) == + offsetof(WGPURequestAdapterOptions, powerPreference), + "offsetof mismatch for RequestAdapterOptions::powerPreference"); +static_assert(offsetof(RequestAdapterOptions, backendType) == + offsetof(WGPURequestAdapterOptions, backendType), + "offsetof mismatch for RequestAdapterOptions::backendType"); +static_assert( + offsetof(RequestAdapterOptions, forceFallbackAdapter) == + offsetof(WGPURequestAdapterOptions, forceFallbackAdapter), + "offsetof mismatch for RequestAdapterOptions::forceFallbackAdapter"); +static_assert(offsetof(RequestAdapterOptions, compatibilityMode) == + offsetof(WGPURequestAdapterOptions, compatibilityMode), + "offsetof mismatch for RequestAdapterOptions::compatibilityMode"); + +// RequestDeviceCallbackInfo + +static_assert(sizeof(RequestDeviceCallbackInfo) == + sizeof(WGPURequestDeviceCallbackInfo), + "sizeof mismatch for RequestDeviceCallbackInfo"); +static_assert(alignof(RequestDeviceCallbackInfo) == + alignof(WGPURequestDeviceCallbackInfo), + "alignof mismatch for RequestDeviceCallbackInfo"); + +static_assert(offsetof(RequestDeviceCallbackInfo, nextInChain) == + offsetof(WGPURequestDeviceCallbackInfo, nextInChain), + "offsetof mismatch for RequestDeviceCallbackInfo::nextInChain"); +static_assert(offsetof(RequestDeviceCallbackInfo, mode) == + offsetof(WGPURequestDeviceCallbackInfo, mode), + "offsetof mismatch for RequestDeviceCallbackInfo::mode"); +static_assert(offsetof(RequestDeviceCallbackInfo, callback) == + offsetof(WGPURequestDeviceCallbackInfo, callback), + "offsetof mismatch for RequestDeviceCallbackInfo::callback"); +static_assert(offsetof(RequestDeviceCallbackInfo, userdata) == + offsetof(WGPURequestDeviceCallbackInfo, userdata), + "offsetof mismatch for RequestDeviceCallbackInfo::userdata"); + +// SamplerBindingLayout + +static_assert(sizeof(SamplerBindingLayout) == sizeof(WGPUSamplerBindingLayout), + "sizeof mismatch for SamplerBindingLayout"); +static_assert(alignof(SamplerBindingLayout) == + alignof(WGPUSamplerBindingLayout), + "alignof mismatch for SamplerBindingLayout"); + +static_assert(offsetof(SamplerBindingLayout, nextInChain) == + offsetof(WGPUSamplerBindingLayout, nextInChain), + "offsetof mismatch for SamplerBindingLayout::nextInChain"); +static_assert(offsetof(SamplerBindingLayout, type) == + offsetof(WGPUSamplerBindingLayout, type), + "offsetof mismatch for SamplerBindingLayout::type"); + +// SamplerDescriptor + +static_assert(sizeof(SamplerDescriptor) == sizeof(WGPUSamplerDescriptor), + "sizeof mismatch for SamplerDescriptor"); +static_assert(alignof(SamplerDescriptor) == alignof(WGPUSamplerDescriptor), + "alignof mismatch for SamplerDescriptor"); + +static_assert(offsetof(SamplerDescriptor, nextInChain) == + offsetof(WGPUSamplerDescriptor, nextInChain), + "offsetof mismatch for SamplerDescriptor::nextInChain"); +static_assert(offsetof(SamplerDescriptor, label) == + offsetof(WGPUSamplerDescriptor, label), + "offsetof mismatch for SamplerDescriptor::label"); +static_assert(offsetof(SamplerDescriptor, addressModeU) == + offsetof(WGPUSamplerDescriptor, addressModeU), + "offsetof mismatch for SamplerDescriptor::addressModeU"); +static_assert(offsetof(SamplerDescriptor, addressModeV) == + offsetof(WGPUSamplerDescriptor, addressModeV), + "offsetof mismatch for SamplerDescriptor::addressModeV"); +static_assert(offsetof(SamplerDescriptor, addressModeW) == + offsetof(WGPUSamplerDescriptor, addressModeW), + "offsetof mismatch for SamplerDescriptor::addressModeW"); +static_assert(offsetof(SamplerDescriptor, magFilter) == + offsetof(WGPUSamplerDescriptor, magFilter), + "offsetof mismatch for SamplerDescriptor::magFilter"); +static_assert(offsetof(SamplerDescriptor, minFilter) == + offsetof(WGPUSamplerDescriptor, minFilter), + "offsetof mismatch for SamplerDescriptor::minFilter"); +static_assert(offsetof(SamplerDescriptor, mipmapFilter) == + offsetof(WGPUSamplerDescriptor, mipmapFilter), + "offsetof mismatch for SamplerDescriptor::mipmapFilter"); +static_assert(offsetof(SamplerDescriptor, lodMinClamp) == + offsetof(WGPUSamplerDescriptor, lodMinClamp), + "offsetof mismatch for SamplerDescriptor::lodMinClamp"); +static_assert(offsetof(SamplerDescriptor, lodMaxClamp) == + offsetof(WGPUSamplerDescriptor, lodMaxClamp), + "offsetof mismatch for SamplerDescriptor::lodMaxClamp"); +static_assert(offsetof(SamplerDescriptor, compare) == + offsetof(WGPUSamplerDescriptor, compare), + "offsetof mismatch for SamplerDescriptor::compare"); +static_assert(offsetof(SamplerDescriptor, maxAnisotropy) == + offsetof(WGPUSamplerDescriptor, maxAnisotropy), + "offsetof mismatch for SamplerDescriptor::maxAnisotropy"); + +// ShaderModuleSPIRVDescriptor + +static_assert(sizeof(ShaderModuleSPIRVDescriptor) == + sizeof(WGPUShaderModuleSPIRVDescriptor), + "sizeof mismatch for ShaderModuleSPIRVDescriptor"); +static_assert(alignof(ShaderModuleSPIRVDescriptor) == + alignof(WGPUShaderModuleSPIRVDescriptor), + "alignof mismatch for ShaderModuleSPIRVDescriptor"); + +static_assert(offsetof(ShaderModuleSPIRVDescriptor, codeSize) == + offsetof(WGPUShaderModuleSPIRVDescriptor, codeSize), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::codeSize"); +static_assert(offsetof(ShaderModuleSPIRVDescriptor, code) == + offsetof(WGPUShaderModuleSPIRVDescriptor, code), + "offsetof mismatch for ShaderModuleSPIRVDescriptor::code"); + +// ShaderModuleWGSLDescriptor + +static_assert(sizeof(ShaderModuleWGSLDescriptor) == + sizeof(WGPUShaderModuleWGSLDescriptor), + "sizeof mismatch for ShaderModuleWGSLDescriptor"); +static_assert(alignof(ShaderModuleWGSLDescriptor) == + alignof(WGPUShaderModuleWGSLDescriptor), + "alignof mismatch for ShaderModuleWGSLDescriptor"); + +static_assert(offsetof(ShaderModuleWGSLDescriptor, code) == + offsetof(WGPUShaderModuleWGSLDescriptor, code), + "offsetof mismatch for ShaderModuleWGSLDescriptor::code"); + +// ShaderModuleDescriptor + +static_assert(sizeof(ShaderModuleDescriptor) == + sizeof(WGPUShaderModuleDescriptor), + "sizeof mismatch for ShaderModuleDescriptor"); +static_assert(alignof(ShaderModuleDescriptor) == + alignof(WGPUShaderModuleDescriptor), + "alignof mismatch for ShaderModuleDescriptor"); + +static_assert(offsetof(ShaderModuleDescriptor, nextInChain) == + offsetof(WGPUShaderModuleDescriptor, nextInChain), + "offsetof mismatch for ShaderModuleDescriptor::nextInChain"); +static_assert(offsetof(ShaderModuleDescriptor, label) == + offsetof(WGPUShaderModuleDescriptor, label), + "offsetof mismatch for ShaderModuleDescriptor::label"); + +// SharedBufferMemoryBeginAccessDescriptor + +static_assert(sizeof(SharedBufferMemoryBeginAccessDescriptor) == + sizeof(WGPUSharedBufferMemoryBeginAccessDescriptor), + "sizeof mismatch for SharedBufferMemoryBeginAccessDescriptor"); +static_assert(alignof(SharedBufferMemoryBeginAccessDescriptor) == + alignof(WGPUSharedBufferMemoryBeginAccessDescriptor), + "alignof mismatch for SharedBufferMemoryBeginAccessDescriptor"); + +static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, nextInChain) == + offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, + nextInChain), + "offsetof mismatch for " + "SharedBufferMemoryBeginAccessDescriptor::nextInChain"); +static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, initialized) == + offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, + initialized), + "offsetof mismatch for " + "SharedBufferMemoryBeginAccessDescriptor::initialized"); +static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, fenceCount) == + offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, + fenceCount), + "offsetof mismatch for " + "SharedBufferMemoryBeginAccessDescriptor::fenceCount"); +static_assert( + offsetof(SharedBufferMemoryBeginAccessDescriptor, fences) == + offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, fences), + "offsetof mismatch for SharedBufferMemoryBeginAccessDescriptor::fences"); +static_assert(offsetof(SharedBufferMemoryBeginAccessDescriptor, + signaledValues) == + offsetof(WGPUSharedBufferMemoryBeginAccessDescriptor, + signaledValues), + "offsetof mismatch for " + "SharedBufferMemoryBeginAccessDescriptor::signaledValues"); + +// SharedBufferMemoryDescriptor + +static_assert(sizeof(SharedBufferMemoryDescriptor) == + sizeof(WGPUSharedBufferMemoryDescriptor), + "sizeof mismatch for SharedBufferMemoryDescriptor"); +static_assert(alignof(SharedBufferMemoryDescriptor) == + alignof(WGPUSharedBufferMemoryDescriptor), + "alignof mismatch for SharedBufferMemoryDescriptor"); + +static_assert( + offsetof(SharedBufferMemoryDescriptor, nextInChain) == + offsetof(WGPUSharedBufferMemoryDescriptor, nextInChain), + "offsetof mismatch for SharedBufferMemoryDescriptor::nextInChain"); +static_assert(offsetof(SharedBufferMemoryDescriptor, label) == + offsetof(WGPUSharedBufferMemoryDescriptor, label), + "offsetof mismatch for SharedBufferMemoryDescriptor::label"); + +// SharedBufferMemoryEndAccessState + +static_assert(sizeof(SharedBufferMemoryEndAccessState) == + sizeof(WGPUSharedBufferMemoryEndAccessState), + "sizeof mismatch for SharedBufferMemoryEndAccessState"); +static_assert(alignof(SharedBufferMemoryEndAccessState) == + alignof(WGPUSharedBufferMemoryEndAccessState), + "alignof mismatch for SharedBufferMemoryEndAccessState"); + +static_assert( + offsetof(SharedBufferMemoryEndAccessState, nextInChain) == + offsetof(WGPUSharedBufferMemoryEndAccessState, nextInChain), + "offsetof mismatch for SharedBufferMemoryEndAccessState::nextInChain"); +static_assert( + offsetof(SharedBufferMemoryEndAccessState, initialized) == + offsetof(WGPUSharedBufferMemoryEndAccessState, initialized), + "offsetof mismatch for SharedBufferMemoryEndAccessState::initialized"); +static_assert( + offsetof(SharedBufferMemoryEndAccessState, fenceCount) == + offsetof(WGPUSharedBufferMemoryEndAccessState, fenceCount), + "offsetof mismatch for SharedBufferMemoryEndAccessState::fenceCount"); +static_assert(offsetof(SharedBufferMemoryEndAccessState, fences) == + offsetof(WGPUSharedBufferMemoryEndAccessState, fences), + "offsetof mismatch for SharedBufferMemoryEndAccessState::fences"); +static_assert( + offsetof(SharedBufferMemoryEndAccessState, signaledValues) == + offsetof(WGPUSharedBufferMemoryEndAccessState, signaledValues), + "offsetof mismatch for SharedBufferMemoryEndAccessState::signaledValues"); + +// SharedBufferMemoryProperties + +static_assert(sizeof(SharedBufferMemoryProperties) == + sizeof(WGPUSharedBufferMemoryProperties), + "sizeof mismatch for SharedBufferMemoryProperties"); +static_assert(alignof(SharedBufferMemoryProperties) == + alignof(WGPUSharedBufferMemoryProperties), + "alignof mismatch for SharedBufferMemoryProperties"); + +static_assert( + offsetof(SharedBufferMemoryProperties, nextInChain) == + offsetof(WGPUSharedBufferMemoryProperties, nextInChain), + "offsetof mismatch for SharedBufferMemoryProperties::nextInChain"); +static_assert(offsetof(SharedBufferMemoryProperties, usage) == + offsetof(WGPUSharedBufferMemoryProperties, usage), + "offsetof mismatch for SharedBufferMemoryProperties::usage"); +static_assert(offsetof(SharedBufferMemoryProperties, size) == + offsetof(WGPUSharedBufferMemoryProperties, size), + "offsetof mismatch for SharedBufferMemoryProperties::size"); + +// SharedFenceDXGISharedHandleDescriptor + +static_assert(sizeof(SharedFenceDXGISharedHandleDescriptor) == + sizeof(WGPUSharedFenceDXGISharedHandleDescriptor), + "sizeof mismatch for SharedFenceDXGISharedHandleDescriptor"); +static_assert(alignof(SharedFenceDXGISharedHandleDescriptor) == + alignof(WGPUSharedFenceDXGISharedHandleDescriptor), + "alignof mismatch for SharedFenceDXGISharedHandleDescriptor"); + +static_assert( + offsetof(SharedFenceDXGISharedHandleDescriptor, handle) == + offsetof(WGPUSharedFenceDXGISharedHandleDescriptor, handle), + "offsetof mismatch for SharedFenceDXGISharedHandleDescriptor::handle"); + +// SharedFenceDXGISharedHandleExportInfo + +static_assert(sizeof(SharedFenceDXGISharedHandleExportInfo) == + sizeof(WGPUSharedFenceDXGISharedHandleExportInfo), + "sizeof mismatch for SharedFenceDXGISharedHandleExportInfo"); +static_assert(alignof(SharedFenceDXGISharedHandleExportInfo) == + alignof(WGPUSharedFenceDXGISharedHandleExportInfo), + "alignof mismatch for SharedFenceDXGISharedHandleExportInfo"); + +static_assert( + offsetof(SharedFenceDXGISharedHandleExportInfo, handle) == + offsetof(WGPUSharedFenceDXGISharedHandleExportInfo, handle), + "offsetof mismatch for SharedFenceDXGISharedHandleExportInfo::handle"); + +// SharedFenceMTLSharedEventDescriptor + +static_assert(sizeof(SharedFenceMTLSharedEventDescriptor) == + sizeof(WGPUSharedFenceMTLSharedEventDescriptor), + "sizeof mismatch for SharedFenceMTLSharedEventDescriptor"); +static_assert(alignof(SharedFenceMTLSharedEventDescriptor) == + alignof(WGPUSharedFenceMTLSharedEventDescriptor), + "alignof mismatch for SharedFenceMTLSharedEventDescriptor"); + +static_assert( + offsetof(SharedFenceMTLSharedEventDescriptor, sharedEvent) == + offsetof(WGPUSharedFenceMTLSharedEventDescriptor, sharedEvent), + "offsetof mismatch for SharedFenceMTLSharedEventDescriptor::sharedEvent"); + +// SharedFenceMTLSharedEventExportInfo + +static_assert(sizeof(SharedFenceMTLSharedEventExportInfo) == + sizeof(WGPUSharedFenceMTLSharedEventExportInfo), + "sizeof mismatch for SharedFenceMTLSharedEventExportInfo"); +static_assert(alignof(SharedFenceMTLSharedEventExportInfo) == + alignof(WGPUSharedFenceMTLSharedEventExportInfo), + "alignof mismatch for SharedFenceMTLSharedEventExportInfo"); + +static_assert( + offsetof(SharedFenceMTLSharedEventExportInfo, sharedEvent) == + offsetof(WGPUSharedFenceMTLSharedEventExportInfo, sharedEvent), + "offsetof mismatch for SharedFenceMTLSharedEventExportInfo::sharedEvent"); + +// SharedFenceDescriptor + +static_assert(sizeof(SharedFenceDescriptor) == + sizeof(WGPUSharedFenceDescriptor), + "sizeof mismatch for SharedFenceDescriptor"); +static_assert(alignof(SharedFenceDescriptor) == + alignof(WGPUSharedFenceDescriptor), + "alignof mismatch for SharedFenceDescriptor"); + +static_assert(offsetof(SharedFenceDescriptor, nextInChain) == + offsetof(WGPUSharedFenceDescriptor, nextInChain), + "offsetof mismatch for SharedFenceDescriptor::nextInChain"); +static_assert(offsetof(SharedFenceDescriptor, label) == + offsetof(WGPUSharedFenceDescriptor, label), + "offsetof mismatch for SharedFenceDescriptor::label"); + +// SharedFenceExportInfo + +static_assert(sizeof(SharedFenceExportInfo) == + sizeof(WGPUSharedFenceExportInfo), + "sizeof mismatch for SharedFenceExportInfo"); +static_assert(alignof(SharedFenceExportInfo) == + alignof(WGPUSharedFenceExportInfo), + "alignof mismatch for SharedFenceExportInfo"); + +static_assert(offsetof(SharedFenceExportInfo, nextInChain) == + offsetof(WGPUSharedFenceExportInfo, nextInChain), + "offsetof mismatch for SharedFenceExportInfo::nextInChain"); +static_assert(offsetof(SharedFenceExportInfo, type) == + offsetof(WGPUSharedFenceExportInfo, type), + "offsetof mismatch for SharedFenceExportInfo::type"); + +// SharedFenceVkSemaphoreOpaqueFDDescriptor + +static_assert(sizeof(SharedFenceVkSemaphoreOpaqueFDDescriptor) == + sizeof(WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor), + "sizeof mismatch for SharedFenceVkSemaphoreOpaqueFDDescriptor"); +static_assert(alignof(SharedFenceVkSemaphoreOpaqueFDDescriptor) == + alignof(WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor), + "alignof mismatch for SharedFenceVkSemaphoreOpaqueFDDescriptor"); + +static_assert( + offsetof(SharedFenceVkSemaphoreOpaqueFDDescriptor, handle) == + offsetof(WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor, handle), + "offsetof mismatch for SharedFenceVkSemaphoreOpaqueFDDescriptor::handle"); + +// SharedFenceVkSemaphoreOpaqueFDExportInfo + +static_assert(sizeof(SharedFenceVkSemaphoreOpaqueFDExportInfo) == + sizeof(WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo), + "sizeof mismatch for SharedFenceVkSemaphoreOpaqueFDExportInfo"); +static_assert(alignof(SharedFenceVkSemaphoreOpaqueFDExportInfo) == + alignof(WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo), + "alignof mismatch for SharedFenceVkSemaphoreOpaqueFDExportInfo"); + +static_assert( + offsetof(SharedFenceVkSemaphoreOpaqueFDExportInfo, handle) == + offsetof(WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo, handle), + "offsetof mismatch for SharedFenceVkSemaphoreOpaqueFDExportInfo::handle"); + +// SharedFenceVkSemaphoreSyncFDDescriptor + +static_assert(sizeof(SharedFenceVkSemaphoreSyncFDDescriptor) == + sizeof(WGPUSharedFenceVkSemaphoreSyncFDDescriptor), + "sizeof mismatch for SharedFenceVkSemaphoreSyncFDDescriptor"); +static_assert(alignof(SharedFenceVkSemaphoreSyncFDDescriptor) == + alignof(WGPUSharedFenceVkSemaphoreSyncFDDescriptor), + "alignof mismatch for SharedFenceVkSemaphoreSyncFDDescriptor"); + +static_assert( + offsetof(SharedFenceVkSemaphoreSyncFDDescriptor, handle) == + offsetof(WGPUSharedFenceVkSemaphoreSyncFDDescriptor, handle), + "offsetof mismatch for SharedFenceVkSemaphoreSyncFDDescriptor::handle"); + +// SharedFenceVkSemaphoreSyncFDExportInfo + +static_assert(sizeof(SharedFenceVkSemaphoreSyncFDExportInfo) == + sizeof(WGPUSharedFenceVkSemaphoreSyncFDExportInfo), + "sizeof mismatch for SharedFenceVkSemaphoreSyncFDExportInfo"); +static_assert(alignof(SharedFenceVkSemaphoreSyncFDExportInfo) == + alignof(WGPUSharedFenceVkSemaphoreSyncFDExportInfo), + "alignof mismatch for SharedFenceVkSemaphoreSyncFDExportInfo"); + +static_assert( + offsetof(SharedFenceVkSemaphoreSyncFDExportInfo, handle) == + offsetof(WGPUSharedFenceVkSemaphoreSyncFDExportInfo, handle), + "offsetof mismatch for SharedFenceVkSemaphoreSyncFDExportInfo::handle"); + +// SharedFenceVkSemaphoreZirconHandleDescriptor + +static_assert( + sizeof(SharedFenceVkSemaphoreZirconHandleDescriptor) == + sizeof(WGPUSharedFenceVkSemaphoreZirconHandleDescriptor), + "sizeof mismatch for SharedFenceVkSemaphoreZirconHandleDescriptor"); +static_assert( + alignof(SharedFenceVkSemaphoreZirconHandleDescriptor) == + alignof(WGPUSharedFenceVkSemaphoreZirconHandleDescriptor), + "alignof mismatch for SharedFenceVkSemaphoreZirconHandleDescriptor"); + +static_assert(offsetof(SharedFenceVkSemaphoreZirconHandleDescriptor, handle) == + offsetof(WGPUSharedFenceVkSemaphoreZirconHandleDescriptor, + handle), + "offsetof mismatch for " + "SharedFenceVkSemaphoreZirconHandleDescriptor::handle"); + +// SharedFenceVkSemaphoreZirconHandleExportInfo + +static_assert( + sizeof(SharedFenceVkSemaphoreZirconHandleExportInfo) == + sizeof(WGPUSharedFenceVkSemaphoreZirconHandleExportInfo), + "sizeof mismatch for SharedFenceVkSemaphoreZirconHandleExportInfo"); +static_assert( + alignof(SharedFenceVkSemaphoreZirconHandleExportInfo) == + alignof(WGPUSharedFenceVkSemaphoreZirconHandleExportInfo), + "alignof mismatch for SharedFenceVkSemaphoreZirconHandleExportInfo"); + +static_assert(offsetof(SharedFenceVkSemaphoreZirconHandleExportInfo, handle) == + offsetof(WGPUSharedFenceVkSemaphoreZirconHandleExportInfo, + handle), + "offsetof mismatch for " + "SharedFenceVkSemaphoreZirconHandleExportInfo::handle"); + +// SharedTextureMemoryDXGISharedHandleDescriptor + +static_assert( + sizeof(SharedTextureMemoryDXGISharedHandleDescriptor) == + sizeof(WGPUSharedTextureMemoryDXGISharedHandleDescriptor), + "sizeof mismatch for SharedTextureMemoryDXGISharedHandleDescriptor"); +static_assert( + alignof(SharedTextureMemoryDXGISharedHandleDescriptor) == + alignof(WGPUSharedTextureMemoryDXGISharedHandleDescriptor), + "alignof mismatch for SharedTextureMemoryDXGISharedHandleDescriptor"); + +static_assert(offsetof(SharedTextureMemoryDXGISharedHandleDescriptor, handle) == + offsetof(WGPUSharedTextureMemoryDXGISharedHandleDescriptor, + handle), + "offsetof mismatch for " + "SharedTextureMemoryDXGISharedHandleDescriptor::handle"); +static_assert(offsetof(SharedTextureMemoryDXGISharedHandleDescriptor, + useKeyedMutex) == + offsetof(WGPUSharedTextureMemoryDXGISharedHandleDescriptor, + useKeyedMutex), + "offsetof mismatch for " + "SharedTextureMemoryDXGISharedHandleDescriptor::useKeyedMutex"); + +// SharedTextureMemoryEGLImageDescriptor + +static_assert(sizeof(SharedTextureMemoryEGLImageDescriptor) == + sizeof(WGPUSharedTextureMemoryEGLImageDescriptor), + "sizeof mismatch for SharedTextureMemoryEGLImageDescriptor"); +static_assert(alignof(SharedTextureMemoryEGLImageDescriptor) == + alignof(WGPUSharedTextureMemoryEGLImageDescriptor), + "alignof mismatch for SharedTextureMemoryEGLImageDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryEGLImageDescriptor, image) == + offsetof(WGPUSharedTextureMemoryEGLImageDescriptor, image), + "offsetof mismatch for SharedTextureMemoryEGLImageDescriptor::image"); + +// SharedTextureMemoryIOSurfaceDescriptor + +static_assert(sizeof(SharedTextureMemoryIOSurfaceDescriptor) == + sizeof(WGPUSharedTextureMemoryIOSurfaceDescriptor), + "sizeof mismatch for SharedTextureMemoryIOSurfaceDescriptor"); +static_assert(alignof(SharedTextureMemoryIOSurfaceDescriptor) == + alignof(WGPUSharedTextureMemoryIOSurfaceDescriptor), + "alignof mismatch for SharedTextureMemoryIOSurfaceDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryIOSurfaceDescriptor, ioSurface) == + offsetof(WGPUSharedTextureMemoryIOSurfaceDescriptor, ioSurface), + "offsetof mismatch for SharedTextureMemoryIOSurfaceDescriptor::ioSurface"); + +// SharedTextureMemoryAHardwareBufferDescriptor + +static_assert( + sizeof(SharedTextureMemoryAHardwareBufferDescriptor) == + sizeof(WGPUSharedTextureMemoryAHardwareBufferDescriptor), + "sizeof mismatch for SharedTextureMemoryAHardwareBufferDescriptor"); +static_assert( + alignof(SharedTextureMemoryAHardwareBufferDescriptor) == + alignof(WGPUSharedTextureMemoryAHardwareBufferDescriptor), + "alignof mismatch for SharedTextureMemoryAHardwareBufferDescriptor"); + +static_assert(offsetof(SharedTextureMemoryAHardwareBufferDescriptor, handle) == + offsetof(WGPUSharedTextureMemoryAHardwareBufferDescriptor, + handle), + "offsetof mismatch for " + "SharedTextureMemoryAHardwareBufferDescriptor::handle"); + +// SharedTextureMemoryBeginAccessDescriptor + +static_assert(sizeof(SharedTextureMemoryBeginAccessDescriptor) == + sizeof(WGPUSharedTextureMemoryBeginAccessDescriptor), + "sizeof mismatch for SharedTextureMemoryBeginAccessDescriptor"); +static_assert(alignof(SharedTextureMemoryBeginAccessDescriptor) == + alignof(WGPUSharedTextureMemoryBeginAccessDescriptor), + "alignof mismatch for SharedTextureMemoryBeginAccessDescriptor"); + +static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, nextInChain) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, + nextInChain), + "offsetof mismatch for " + "SharedTextureMemoryBeginAccessDescriptor::nextInChain"); +static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, + concurrentRead) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, + concurrentRead), + "offsetof mismatch for " + "SharedTextureMemoryBeginAccessDescriptor::concurrentRead"); +static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, initialized) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, + initialized), + "offsetof mismatch for " + "SharedTextureMemoryBeginAccessDescriptor::initialized"); +static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, fenceCount) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, + fenceCount), + "offsetof mismatch for " + "SharedTextureMemoryBeginAccessDescriptor::fenceCount"); +static_assert( + offsetof(SharedTextureMemoryBeginAccessDescriptor, fences) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, fences), + "offsetof mismatch for SharedTextureMemoryBeginAccessDescriptor::fences"); +static_assert(offsetof(SharedTextureMemoryBeginAccessDescriptor, + signaledValues) == + offsetof(WGPUSharedTextureMemoryBeginAccessDescriptor, + signaledValues), + "offsetof mismatch for " + "SharedTextureMemoryBeginAccessDescriptor::signaledValues"); + +// SharedTextureMemoryDescriptor + +static_assert(sizeof(SharedTextureMemoryDescriptor) == + sizeof(WGPUSharedTextureMemoryDescriptor), + "sizeof mismatch for SharedTextureMemoryDescriptor"); +static_assert(alignof(SharedTextureMemoryDescriptor) == + alignof(WGPUSharedTextureMemoryDescriptor), + "alignof mismatch for SharedTextureMemoryDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryDescriptor, nextInChain) == + offsetof(WGPUSharedTextureMemoryDescriptor, nextInChain), + "offsetof mismatch for SharedTextureMemoryDescriptor::nextInChain"); +static_assert(offsetof(SharedTextureMemoryDescriptor, label) == + offsetof(WGPUSharedTextureMemoryDescriptor, label), + "offsetof mismatch for SharedTextureMemoryDescriptor::label"); + +// SharedTextureMemoryDmaBufPlane + +static_assert(sizeof(SharedTextureMemoryDmaBufPlane) == + sizeof(WGPUSharedTextureMemoryDmaBufPlane), + "sizeof mismatch for SharedTextureMemoryDmaBufPlane"); +static_assert(alignof(SharedTextureMemoryDmaBufPlane) == + alignof(WGPUSharedTextureMemoryDmaBufPlane), + "alignof mismatch for SharedTextureMemoryDmaBufPlane"); + +static_assert(offsetof(SharedTextureMemoryDmaBufPlane, fd) == + offsetof(WGPUSharedTextureMemoryDmaBufPlane, fd), + "offsetof mismatch for SharedTextureMemoryDmaBufPlane::fd"); +static_assert(offsetof(SharedTextureMemoryDmaBufPlane, offset) == + offsetof(WGPUSharedTextureMemoryDmaBufPlane, offset), + "offsetof mismatch for SharedTextureMemoryDmaBufPlane::offset"); +static_assert(offsetof(SharedTextureMemoryDmaBufPlane, stride) == + offsetof(WGPUSharedTextureMemoryDmaBufPlane, stride), + "offsetof mismatch for SharedTextureMemoryDmaBufPlane::stride"); + +// SharedTextureMemoryEndAccessState + +static_assert(sizeof(SharedTextureMemoryEndAccessState) == + sizeof(WGPUSharedTextureMemoryEndAccessState), + "sizeof mismatch for SharedTextureMemoryEndAccessState"); +static_assert(alignof(SharedTextureMemoryEndAccessState) == + alignof(WGPUSharedTextureMemoryEndAccessState), + "alignof mismatch for SharedTextureMemoryEndAccessState"); + +static_assert( + offsetof(SharedTextureMemoryEndAccessState, nextInChain) == + offsetof(WGPUSharedTextureMemoryEndAccessState, nextInChain), + "offsetof mismatch for SharedTextureMemoryEndAccessState::nextInChain"); +static_assert( + offsetof(SharedTextureMemoryEndAccessState, initialized) == + offsetof(WGPUSharedTextureMemoryEndAccessState, initialized), + "offsetof mismatch for SharedTextureMemoryEndAccessState::initialized"); +static_assert( + offsetof(SharedTextureMemoryEndAccessState, fenceCount) == + offsetof(WGPUSharedTextureMemoryEndAccessState, fenceCount), + "offsetof mismatch for SharedTextureMemoryEndAccessState::fenceCount"); +static_assert( + offsetof(SharedTextureMemoryEndAccessState, fences) == + offsetof(WGPUSharedTextureMemoryEndAccessState, fences), + "offsetof mismatch for SharedTextureMemoryEndAccessState::fences"); +static_assert( + offsetof(SharedTextureMemoryEndAccessState, signaledValues) == + offsetof(WGPUSharedTextureMemoryEndAccessState, signaledValues), + "offsetof mismatch for SharedTextureMemoryEndAccessState::signaledValues"); + +// SharedTextureMemoryOpaqueFDDescriptor + +static_assert(sizeof(SharedTextureMemoryOpaqueFDDescriptor) == + sizeof(WGPUSharedTextureMemoryOpaqueFDDescriptor), + "sizeof mismatch for SharedTextureMemoryOpaqueFDDescriptor"); +static_assert(alignof(SharedTextureMemoryOpaqueFDDescriptor) == + alignof(WGPUSharedTextureMemoryOpaqueFDDescriptor), + "alignof mismatch for SharedTextureMemoryOpaqueFDDescriptor"); + +static_assert(offsetof(SharedTextureMemoryOpaqueFDDescriptor, + vkImageCreateInfo) == + offsetof(WGPUSharedTextureMemoryOpaqueFDDescriptor, + vkImageCreateInfo), + "offsetof mismatch for " + "SharedTextureMemoryOpaqueFDDescriptor::vkImageCreateInfo"); +static_assert( + offsetof(SharedTextureMemoryOpaqueFDDescriptor, memoryFD) == + offsetof(WGPUSharedTextureMemoryOpaqueFDDescriptor, memoryFD), + "offsetof mismatch for SharedTextureMemoryOpaqueFDDescriptor::memoryFD"); +static_assert(offsetof(SharedTextureMemoryOpaqueFDDescriptor, + memoryTypeIndex) == + offsetof(WGPUSharedTextureMemoryOpaqueFDDescriptor, + memoryTypeIndex), + "offsetof mismatch for " + "SharedTextureMemoryOpaqueFDDescriptor::memoryTypeIndex"); +static_assert(offsetof(SharedTextureMemoryOpaqueFDDescriptor, allocationSize) == + offsetof(WGPUSharedTextureMemoryOpaqueFDDescriptor, + allocationSize), + "offsetof mismatch for " + "SharedTextureMemoryOpaqueFDDescriptor::allocationSize"); +static_assert(offsetof(SharedTextureMemoryOpaqueFDDescriptor, + dedicatedAllocation) == + offsetof(WGPUSharedTextureMemoryOpaqueFDDescriptor, + dedicatedAllocation), + "offsetof mismatch for " + "SharedTextureMemoryOpaqueFDDescriptor::dedicatedAllocation"); + +// SharedTextureMemoryVkDedicatedAllocationDescriptor + +static_assert( + sizeof(SharedTextureMemoryVkDedicatedAllocationDescriptor) == + sizeof(WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor), + "sizeof mismatch for SharedTextureMemoryVkDedicatedAllocationDescriptor"); +static_assert( + alignof(SharedTextureMemoryVkDedicatedAllocationDescriptor) == + alignof(WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor), + "alignof mismatch for SharedTextureMemoryVkDedicatedAllocationDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryVkDedicatedAllocationDescriptor, + dedicatedAllocation) == + offsetof(WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor, + dedicatedAllocation), + "offsetof mismatch for " + "SharedTextureMemoryVkDedicatedAllocationDescriptor::dedicatedAllocation"); + +// SharedTextureMemoryVkImageLayoutBeginState + +static_assert(sizeof(SharedTextureMemoryVkImageLayoutBeginState) == + sizeof(WGPUSharedTextureMemoryVkImageLayoutBeginState), + "sizeof mismatch for SharedTextureMemoryVkImageLayoutBeginState"); +static_assert( + alignof(SharedTextureMemoryVkImageLayoutBeginState) == + alignof(WGPUSharedTextureMemoryVkImageLayoutBeginState), + "alignof mismatch for SharedTextureMemoryVkImageLayoutBeginState"); + +static_assert(offsetof(SharedTextureMemoryVkImageLayoutBeginState, oldLayout) == + offsetof(WGPUSharedTextureMemoryVkImageLayoutBeginState, + oldLayout), + "offsetof mismatch for " + "SharedTextureMemoryVkImageLayoutBeginState::oldLayout"); +static_assert(offsetof(SharedTextureMemoryVkImageLayoutBeginState, newLayout) == + offsetof(WGPUSharedTextureMemoryVkImageLayoutBeginState, + newLayout), + "offsetof mismatch for " + "SharedTextureMemoryVkImageLayoutBeginState::newLayout"); + +// SharedTextureMemoryVkImageLayoutEndState + +static_assert(sizeof(SharedTextureMemoryVkImageLayoutEndState) == + sizeof(WGPUSharedTextureMemoryVkImageLayoutEndState), + "sizeof mismatch for SharedTextureMemoryVkImageLayoutEndState"); +static_assert(alignof(SharedTextureMemoryVkImageLayoutEndState) == + alignof(WGPUSharedTextureMemoryVkImageLayoutEndState), + "alignof mismatch for SharedTextureMemoryVkImageLayoutEndState"); + +static_assert(offsetof(SharedTextureMemoryVkImageLayoutEndState, oldLayout) == + offsetof(WGPUSharedTextureMemoryVkImageLayoutEndState, + oldLayout), + "offsetof mismatch for " + "SharedTextureMemoryVkImageLayoutEndState::oldLayout"); +static_assert(offsetof(SharedTextureMemoryVkImageLayoutEndState, newLayout) == + offsetof(WGPUSharedTextureMemoryVkImageLayoutEndState, + newLayout), + "offsetof mismatch for " + "SharedTextureMemoryVkImageLayoutEndState::newLayout"); + +// SharedTextureMemoryZirconHandleDescriptor + +static_assert(sizeof(SharedTextureMemoryZirconHandleDescriptor) == + sizeof(WGPUSharedTextureMemoryZirconHandleDescriptor), + "sizeof mismatch for SharedTextureMemoryZirconHandleDescriptor"); +static_assert(alignof(SharedTextureMemoryZirconHandleDescriptor) == + alignof(WGPUSharedTextureMemoryZirconHandleDescriptor), + "alignof mismatch for SharedTextureMemoryZirconHandleDescriptor"); + +static_assert(offsetof(SharedTextureMemoryZirconHandleDescriptor, memoryFD) == + offsetof(WGPUSharedTextureMemoryZirconHandleDescriptor, + memoryFD), + "offsetof mismatch for " + "SharedTextureMemoryZirconHandleDescriptor::memoryFD"); +static_assert(offsetof(SharedTextureMemoryZirconHandleDescriptor, + allocationSize) == + offsetof(WGPUSharedTextureMemoryZirconHandleDescriptor, + allocationSize), + "offsetof mismatch for " + "SharedTextureMemoryZirconHandleDescriptor::allocationSize"); + +// StaticSamplerBindingLayout + +static_assert(sizeof(StaticSamplerBindingLayout) == + sizeof(WGPUStaticSamplerBindingLayout), + "sizeof mismatch for StaticSamplerBindingLayout"); +static_assert(alignof(StaticSamplerBindingLayout) == + alignof(WGPUStaticSamplerBindingLayout), + "alignof mismatch for StaticSamplerBindingLayout"); + +static_assert(offsetof(StaticSamplerBindingLayout, sampler) == + offsetof(WGPUStaticSamplerBindingLayout, sampler), + "offsetof mismatch for StaticSamplerBindingLayout::sampler"); + +// StencilFaceState + +static_assert(sizeof(StencilFaceState) == sizeof(WGPUStencilFaceState), + "sizeof mismatch for StencilFaceState"); +static_assert(alignof(StencilFaceState) == alignof(WGPUStencilFaceState), + "alignof mismatch for StencilFaceState"); + +static_assert(offsetof(StencilFaceState, compare) == + offsetof(WGPUStencilFaceState, compare), + "offsetof mismatch for StencilFaceState::compare"); +static_assert(offsetof(StencilFaceState, failOp) == + offsetof(WGPUStencilFaceState, failOp), + "offsetof mismatch for StencilFaceState::failOp"); +static_assert(offsetof(StencilFaceState, depthFailOp) == + offsetof(WGPUStencilFaceState, depthFailOp), + "offsetof mismatch for StencilFaceState::depthFailOp"); +static_assert(offsetof(StencilFaceState, passOp) == + offsetof(WGPUStencilFaceState, passOp), + "offsetof mismatch for StencilFaceState::passOp"); + +// StorageTextureBindingLayout + +static_assert(sizeof(StorageTextureBindingLayout) == + sizeof(WGPUStorageTextureBindingLayout), + "sizeof mismatch for StorageTextureBindingLayout"); +static_assert(alignof(StorageTextureBindingLayout) == + alignof(WGPUStorageTextureBindingLayout), + "alignof mismatch for StorageTextureBindingLayout"); + +static_assert(offsetof(StorageTextureBindingLayout, nextInChain) == + offsetof(WGPUStorageTextureBindingLayout, nextInChain), + "offsetof mismatch for StorageTextureBindingLayout::nextInChain"); +static_assert(offsetof(StorageTextureBindingLayout, access) == + offsetof(WGPUStorageTextureBindingLayout, access), + "offsetof mismatch for StorageTextureBindingLayout::access"); +static_assert(offsetof(StorageTextureBindingLayout, format) == + offsetof(WGPUStorageTextureBindingLayout, format), + "offsetof mismatch for StorageTextureBindingLayout::format"); +static_assert( + offsetof(StorageTextureBindingLayout, viewDimension) == + offsetof(WGPUStorageTextureBindingLayout, viewDimension), + "offsetof mismatch for StorageTextureBindingLayout::viewDimension"); + +// SurfaceDescriptor + +static_assert(sizeof(SurfaceDescriptor) == sizeof(WGPUSurfaceDescriptor), + "sizeof mismatch for SurfaceDescriptor"); +static_assert(alignof(SurfaceDescriptor) == alignof(WGPUSurfaceDescriptor), + "alignof mismatch for SurfaceDescriptor"); + +static_assert(offsetof(SurfaceDescriptor, nextInChain) == + offsetof(WGPUSurfaceDescriptor, nextInChain), + "offsetof mismatch for SurfaceDescriptor::nextInChain"); +static_assert(offsetof(SurfaceDescriptor, label) == + offsetof(WGPUSurfaceDescriptor, label), + "offsetof mismatch for SurfaceDescriptor::label"); + +// SurfaceDescriptorFromAndroidNativeWindow + +static_assert(sizeof(SurfaceDescriptorFromAndroidNativeWindow) == + sizeof(WGPUSurfaceDescriptorFromAndroidNativeWindow), + "sizeof mismatch for SurfaceDescriptorFromAndroidNativeWindow"); +static_assert(alignof(SurfaceDescriptorFromAndroidNativeWindow) == + alignof(WGPUSurfaceDescriptorFromAndroidNativeWindow), + "alignof mismatch for SurfaceDescriptorFromAndroidNativeWindow"); + +static_assert( + offsetof(SurfaceDescriptorFromAndroidNativeWindow, window) == + offsetof(WGPUSurfaceDescriptorFromAndroidNativeWindow, window), + "offsetof mismatch for SurfaceDescriptorFromAndroidNativeWindow::window"); + +// SurfaceDescriptorFromCanvasHTMLSelector + +static_assert(sizeof(SurfaceDescriptorFromCanvasHTMLSelector) == + sizeof(WGPUSurfaceDescriptorFromCanvasHTMLSelector), + "sizeof mismatch for SurfaceDescriptorFromCanvasHTMLSelector"); +static_assert(alignof(SurfaceDescriptorFromCanvasHTMLSelector) == + alignof(WGPUSurfaceDescriptorFromCanvasHTMLSelector), + "alignof mismatch for SurfaceDescriptorFromCanvasHTMLSelector"); + +static_assert( + offsetof(SurfaceDescriptorFromCanvasHTMLSelector, selector) == + offsetof(WGPUSurfaceDescriptorFromCanvasHTMLSelector, selector), + "offsetof mismatch for SurfaceDescriptorFromCanvasHTMLSelector::selector"); + +// SurfaceDescriptorFromMetalLayer + +static_assert(sizeof(SurfaceDescriptorFromMetalLayer) == + sizeof(WGPUSurfaceDescriptorFromMetalLayer), + "sizeof mismatch for SurfaceDescriptorFromMetalLayer"); +static_assert(alignof(SurfaceDescriptorFromMetalLayer) == + alignof(WGPUSurfaceDescriptorFromMetalLayer), + "alignof mismatch for SurfaceDescriptorFromMetalLayer"); + +static_assert(offsetof(SurfaceDescriptorFromMetalLayer, layer) == + offsetof(WGPUSurfaceDescriptorFromMetalLayer, layer), + "offsetof mismatch for SurfaceDescriptorFromMetalLayer::layer"); + +// SurfaceDescriptorFromWaylandSurface + +static_assert(sizeof(SurfaceDescriptorFromWaylandSurface) == + sizeof(WGPUSurfaceDescriptorFromWaylandSurface), + "sizeof mismatch for SurfaceDescriptorFromWaylandSurface"); +static_assert(alignof(SurfaceDescriptorFromWaylandSurface) == + alignof(WGPUSurfaceDescriptorFromWaylandSurface), + "alignof mismatch for SurfaceDescriptorFromWaylandSurface"); + +static_assert( + offsetof(SurfaceDescriptorFromWaylandSurface, display) == + offsetof(WGPUSurfaceDescriptorFromWaylandSurface, display), + "offsetof mismatch for SurfaceDescriptorFromWaylandSurface::display"); +static_assert( + offsetof(SurfaceDescriptorFromWaylandSurface, surface) == + offsetof(WGPUSurfaceDescriptorFromWaylandSurface, surface), + "offsetof mismatch for SurfaceDescriptorFromWaylandSurface::surface"); + +// SurfaceDescriptorFromWindowsHWND + +static_assert(sizeof(SurfaceDescriptorFromWindowsHWND) == + sizeof(WGPUSurfaceDescriptorFromWindowsHWND), + "sizeof mismatch for SurfaceDescriptorFromWindowsHWND"); +static_assert(alignof(SurfaceDescriptorFromWindowsHWND) == + alignof(WGPUSurfaceDescriptorFromWindowsHWND), + "alignof mismatch for SurfaceDescriptorFromWindowsHWND"); + +static_assert( + offsetof(SurfaceDescriptorFromWindowsHWND, hinstance) == + offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hinstance), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hinstance"); +static_assert(offsetof(SurfaceDescriptorFromWindowsHWND, hwnd) == + offsetof(WGPUSurfaceDescriptorFromWindowsHWND, hwnd), + "offsetof mismatch for SurfaceDescriptorFromWindowsHWND::hwnd"); + +// SurfaceDescriptorFromWindowsCoreWindow + +static_assert(sizeof(SurfaceDescriptorFromWindowsCoreWindow) == + sizeof(WGPUSurfaceDescriptorFromWindowsCoreWindow), + "sizeof mismatch for SurfaceDescriptorFromWindowsCoreWindow"); +static_assert(alignof(SurfaceDescriptorFromWindowsCoreWindow) == + alignof(WGPUSurfaceDescriptorFromWindowsCoreWindow), + "alignof mismatch for SurfaceDescriptorFromWindowsCoreWindow"); + +static_assert( + offsetof(SurfaceDescriptorFromWindowsCoreWindow, coreWindow) == + offsetof(WGPUSurfaceDescriptorFromWindowsCoreWindow, coreWindow), + "offsetof mismatch for SurfaceDescriptorFromWindowsCoreWindow::coreWindow"); + +// SurfaceDescriptorFromWindowsSwapChainPanel + +static_assert(sizeof(SurfaceDescriptorFromWindowsSwapChainPanel) == + sizeof(WGPUSurfaceDescriptorFromWindowsSwapChainPanel), + "sizeof mismatch for SurfaceDescriptorFromWindowsSwapChainPanel"); +static_assert( + alignof(SurfaceDescriptorFromWindowsSwapChainPanel) == + alignof(WGPUSurfaceDescriptorFromWindowsSwapChainPanel), + "alignof mismatch for SurfaceDescriptorFromWindowsSwapChainPanel"); + +static_assert(offsetof(SurfaceDescriptorFromWindowsSwapChainPanel, + swapChainPanel) == + offsetof(WGPUSurfaceDescriptorFromWindowsSwapChainPanel, + swapChainPanel), + "offsetof mismatch for " + "SurfaceDescriptorFromWindowsSwapChainPanel::swapChainPanel"); + +// SurfaceDescriptorFromXlibWindow + +static_assert(sizeof(SurfaceDescriptorFromXlibWindow) == + sizeof(WGPUSurfaceDescriptorFromXlibWindow), + "sizeof mismatch for SurfaceDescriptorFromXlibWindow"); +static_assert(alignof(SurfaceDescriptorFromXlibWindow) == + alignof(WGPUSurfaceDescriptorFromXlibWindow), + "alignof mismatch for SurfaceDescriptorFromXlibWindow"); + +static_assert(offsetof(SurfaceDescriptorFromXlibWindow, display) == + offsetof(WGPUSurfaceDescriptorFromXlibWindow, display), + "offsetof mismatch for SurfaceDescriptorFromXlibWindow::display"); +static_assert(offsetof(SurfaceDescriptorFromXlibWindow, window) == + offsetof(WGPUSurfaceDescriptorFromXlibWindow, window), + "offsetof mismatch for SurfaceDescriptorFromXlibWindow::window"); + +// SwapChainDescriptor + +static_assert(sizeof(SwapChainDescriptor) == sizeof(WGPUSwapChainDescriptor), + "sizeof mismatch for SwapChainDescriptor"); +static_assert(alignof(SwapChainDescriptor) == alignof(WGPUSwapChainDescriptor), + "alignof mismatch for SwapChainDescriptor"); + +static_assert(offsetof(SwapChainDescriptor, nextInChain) == + offsetof(WGPUSwapChainDescriptor, nextInChain), + "offsetof mismatch for SwapChainDescriptor::nextInChain"); +static_assert(offsetof(SwapChainDescriptor, label) == + offsetof(WGPUSwapChainDescriptor, label), + "offsetof mismatch for SwapChainDescriptor::label"); +static_assert(offsetof(SwapChainDescriptor, usage) == + offsetof(WGPUSwapChainDescriptor, usage), + "offsetof mismatch for SwapChainDescriptor::usage"); +static_assert(offsetof(SwapChainDescriptor, format) == + offsetof(WGPUSwapChainDescriptor, format), + "offsetof mismatch for SwapChainDescriptor::format"); +static_assert(offsetof(SwapChainDescriptor, width) == + offsetof(WGPUSwapChainDescriptor, width), + "offsetof mismatch for SwapChainDescriptor::width"); +static_assert(offsetof(SwapChainDescriptor, height) == + offsetof(WGPUSwapChainDescriptor, height), + "offsetof mismatch for SwapChainDescriptor::height"); +static_assert(offsetof(SwapChainDescriptor, presentMode) == + offsetof(WGPUSwapChainDescriptor, presentMode), + "offsetof mismatch for SwapChainDescriptor::presentMode"); + +// TextureBindingLayout + +static_assert(sizeof(TextureBindingLayout) == sizeof(WGPUTextureBindingLayout), + "sizeof mismatch for TextureBindingLayout"); +static_assert(alignof(TextureBindingLayout) == + alignof(WGPUTextureBindingLayout), + "alignof mismatch for TextureBindingLayout"); + +static_assert(offsetof(TextureBindingLayout, nextInChain) == + offsetof(WGPUTextureBindingLayout, nextInChain), + "offsetof mismatch for TextureBindingLayout::nextInChain"); +static_assert(offsetof(TextureBindingLayout, sampleType) == + offsetof(WGPUTextureBindingLayout, sampleType), + "offsetof mismatch for TextureBindingLayout::sampleType"); +static_assert(offsetof(TextureBindingLayout, viewDimension) == + offsetof(WGPUTextureBindingLayout, viewDimension), + "offsetof mismatch for TextureBindingLayout::viewDimension"); +static_assert(offsetof(TextureBindingLayout, multisampled) == + offsetof(WGPUTextureBindingLayout, multisampled), + "offsetof mismatch for TextureBindingLayout::multisampled"); + +// TextureBindingViewDimensionDescriptor + +static_assert(sizeof(TextureBindingViewDimensionDescriptor) == + sizeof(WGPUTextureBindingViewDimensionDescriptor), + "sizeof mismatch for TextureBindingViewDimensionDescriptor"); +static_assert(alignof(TextureBindingViewDimensionDescriptor) == + alignof(WGPUTextureBindingViewDimensionDescriptor), + "alignof mismatch for TextureBindingViewDimensionDescriptor"); + +static_assert( + offsetof(TextureBindingViewDimensionDescriptor, + textureBindingViewDimension) == + offsetof(WGPUTextureBindingViewDimensionDescriptor, + textureBindingViewDimension), + "offsetof mismatch for " + "TextureBindingViewDimensionDescriptor::textureBindingViewDimension"); + +// TextureDataLayout + +static_assert(sizeof(TextureDataLayout) == sizeof(WGPUTextureDataLayout), + "sizeof mismatch for TextureDataLayout"); +static_assert(alignof(TextureDataLayout) == alignof(WGPUTextureDataLayout), + "alignof mismatch for TextureDataLayout"); + +static_assert(offsetof(TextureDataLayout, nextInChain) == + offsetof(WGPUTextureDataLayout, nextInChain), + "offsetof mismatch for TextureDataLayout::nextInChain"); +static_assert(offsetof(TextureDataLayout, offset) == + offsetof(WGPUTextureDataLayout, offset), + "offsetof mismatch for TextureDataLayout::offset"); +static_assert(offsetof(TextureDataLayout, bytesPerRow) == + offsetof(WGPUTextureDataLayout, bytesPerRow), + "offsetof mismatch for TextureDataLayout::bytesPerRow"); +static_assert(offsetof(TextureDataLayout, rowsPerImage) == + offsetof(WGPUTextureDataLayout, rowsPerImage), + "offsetof mismatch for TextureDataLayout::rowsPerImage"); + +// TextureViewDescriptor + +static_assert(sizeof(TextureViewDescriptor) == + sizeof(WGPUTextureViewDescriptor), + "sizeof mismatch for TextureViewDescriptor"); +static_assert(alignof(TextureViewDescriptor) == + alignof(WGPUTextureViewDescriptor), + "alignof mismatch for TextureViewDescriptor"); + +static_assert(offsetof(TextureViewDescriptor, nextInChain) == + offsetof(WGPUTextureViewDescriptor, nextInChain), + "offsetof mismatch for TextureViewDescriptor::nextInChain"); +static_assert(offsetof(TextureViewDescriptor, label) == + offsetof(WGPUTextureViewDescriptor, label), + "offsetof mismatch for TextureViewDescriptor::label"); +static_assert(offsetof(TextureViewDescriptor, format) == + offsetof(WGPUTextureViewDescriptor, format), + "offsetof mismatch for TextureViewDescriptor::format"); +static_assert(offsetof(TextureViewDescriptor, dimension) == + offsetof(WGPUTextureViewDescriptor, dimension), + "offsetof mismatch for TextureViewDescriptor::dimension"); +static_assert(offsetof(TextureViewDescriptor, baseMipLevel) == + offsetof(WGPUTextureViewDescriptor, baseMipLevel), + "offsetof mismatch for TextureViewDescriptor::baseMipLevel"); +static_assert(offsetof(TextureViewDescriptor, mipLevelCount) == + offsetof(WGPUTextureViewDescriptor, mipLevelCount), + "offsetof mismatch for TextureViewDescriptor::mipLevelCount"); +static_assert(offsetof(TextureViewDescriptor, baseArrayLayer) == + offsetof(WGPUTextureViewDescriptor, baseArrayLayer), + "offsetof mismatch for TextureViewDescriptor::baseArrayLayer"); +static_assert(offsetof(TextureViewDescriptor, arrayLayerCount) == + offsetof(WGPUTextureViewDescriptor, arrayLayerCount), + "offsetof mismatch for TextureViewDescriptor::arrayLayerCount"); +static_assert(offsetof(TextureViewDescriptor, aspect) == + offsetof(WGPUTextureViewDescriptor, aspect), + "offsetof mismatch for TextureViewDescriptor::aspect"); + +// VertexAttribute + +static_assert(sizeof(VertexAttribute) == sizeof(WGPUVertexAttribute), + "sizeof mismatch for VertexAttribute"); +static_assert(alignof(VertexAttribute) == alignof(WGPUVertexAttribute), + "alignof mismatch for VertexAttribute"); + +static_assert(offsetof(VertexAttribute, format) == + offsetof(WGPUVertexAttribute, format), + "offsetof mismatch for VertexAttribute::format"); +static_assert(offsetof(VertexAttribute, offset) == + offsetof(WGPUVertexAttribute, offset), + "offsetof mismatch for VertexAttribute::offset"); +static_assert(offsetof(VertexAttribute, shaderLocation) == + offsetof(WGPUVertexAttribute, shaderLocation), + "offsetof mismatch for VertexAttribute::shaderLocation"); + +// AdapterPropertiesMemoryHeaps + +static_assert(sizeof(AdapterPropertiesMemoryHeaps) == + sizeof(WGPUAdapterPropertiesMemoryHeaps), + "sizeof mismatch for AdapterPropertiesMemoryHeaps"); +static_assert(alignof(AdapterPropertiesMemoryHeaps) == + alignof(WGPUAdapterPropertiesMemoryHeaps), + "alignof mismatch for AdapterPropertiesMemoryHeaps"); + +static_assert(offsetof(AdapterPropertiesMemoryHeaps, heapCount) == + offsetof(WGPUAdapterPropertiesMemoryHeaps, heapCount), + "offsetof mismatch for AdapterPropertiesMemoryHeaps::heapCount"); +static_assert(offsetof(AdapterPropertiesMemoryHeaps, heapInfo) == + offsetof(WGPUAdapterPropertiesMemoryHeaps, heapInfo), + "offsetof mismatch for AdapterPropertiesMemoryHeaps::heapInfo"); + +// BindGroupDescriptor + +static_assert(sizeof(BindGroupDescriptor) == sizeof(WGPUBindGroupDescriptor), + "sizeof mismatch for BindGroupDescriptor"); +static_assert(alignof(BindGroupDescriptor) == alignof(WGPUBindGroupDescriptor), + "alignof mismatch for BindGroupDescriptor"); + +static_assert(offsetof(BindGroupDescriptor, nextInChain) == + offsetof(WGPUBindGroupDescriptor, nextInChain), + "offsetof mismatch for BindGroupDescriptor::nextInChain"); +static_assert(offsetof(BindGroupDescriptor, label) == + offsetof(WGPUBindGroupDescriptor, label), + "offsetof mismatch for BindGroupDescriptor::label"); +static_assert(offsetof(BindGroupDescriptor, layout) == + offsetof(WGPUBindGroupDescriptor, layout), + "offsetof mismatch for BindGroupDescriptor::layout"); +static_assert(offsetof(BindGroupDescriptor, entryCount) == + offsetof(WGPUBindGroupDescriptor, entryCount), + "offsetof mismatch for BindGroupDescriptor::entryCount"); +static_assert(offsetof(BindGroupDescriptor, entries) == + offsetof(WGPUBindGroupDescriptor, entries), + "offsetof mismatch for BindGroupDescriptor::entries"); + +// BindGroupLayoutEntry + +static_assert(sizeof(BindGroupLayoutEntry) == sizeof(WGPUBindGroupLayoutEntry), + "sizeof mismatch for BindGroupLayoutEntry"); +static_assert(alignof(BindGroupLayoutEntry) == + alignof(WGPUBindGroupLayoutEntry), + "alignof mismatch for BindGroupLayoutEntry"); + +static_assert(offsetof(BindGroupLayoutEntry, nextInChain) == + offsetof(WGPUBindGroupLayoutEntry, nextInChain), + "offsetof mismatch for BindGroupLayoutEntry::nextInChain"); +static_assert(offsetof(BindGroupLayoutEntry, binding) == + offsetof(WGPUBindGroupLayoutEntry, binding), + "offsetof mismatch for BindGroupLayoutEntry::binding"); +static_assert(offsetof(BindGroupLayoutEntry, visibility) == + offsetof(WGPUBindGroupLayoutEntry, visibility), + "offsetof mismatch for BindGroupLayoutEntry::visibility"); +static_assert(offsetof(BindGroupLayoutEntry, buffer) == + offsetof(WGPUBindGroupLayoutEntry, buffer), + "offsetof mismatch for BindGroupLayoutEntry::buffer"); +static_assert(offsetof(BindGroupLayoutEntry, sampler) == + offsetof(WGPUBindGroupLayoutEntry, sampler), + "offsetof mismatch for BindGroupLayoutEntry::sampler"); +static_assert(offsetof(BindGroupLayoutEntry, texture) == + offsetof(WGPUBindGroupLayoutEntry, texture), + "offsetof mismatch for BindGroupLayoutEntry::texture"); +static_assert(offsetof(BindGroupLayoutEntry, storageTexture) == + offsetof(WGPUBindGroupLayoutEntry, storageTexture), + "offsetof mismatch for BindGroupLayoutEntry::storageTexture"); + +// BlendState + +static_assert(sizeof(BlendState) == sizeof(WGPUBlendState), + "sizeof mismatch for BlendState"); +static_assert(alignof(BlendState) == alignof(WGPUBlendState), + "alignof mismatch for BlendState"); + +static_assert(offsetof(BlendState, color) == offsetof(WGPUBlendState, color), + "offsetof mismatch for BlendState::color"); +static_assert(offsetof(BlendState, alpha) == offsetof(WGPUBlendState, alpha), + "offsetof mismatch for BlendState::alpha"); + +// CompilationInfo + +static_assert(sizeof(CompilationInfo) == sizeof(WGPUCompilationInfo), + "sizeof mismatch for CompilationInfo"); +static_assert(alignof(CompilationInfo) == alignof(WGPUCompilationInfo), + "alignof mismatch for CompilationInfo"); + +static_assert(offsetof(CompilationInfo, nextInChain) == + offsetof(WGPUCompilationInfo, nextInChain), + "offsetof mismatch for CompilationInfo::nextInChain"); +static_assert(offsetof(CompilationInfo, messageCount) == + offsetof(WGPUCompilationInfo, messageCount), + "offsetof mismatch for CompilationInfo::messageCount"); +static_assert(offsetof(CompilationInfo, messages) == + offsetof(WGPUCompilationInfo, messages), + "offsetof mismatch for CompilationInfo::messages"); + +// ComputePassDescriptor + +static_assert(sizeof(ComputePassDescriptor) == + sizeof(WGPUComputePassDescriptor), + "sizeof mismatch for ComputePassDescriptor"); +static_assert(alignof(ComputePassDescriptor) == + alignof(WGPUComputePassDescriptor), + "alignof mismatch for ComputePassDescriptor"); + +static_assert(offsetof(ComputePassDescriptor, nextInChain) == + offsetof(WGPUComputePassDescriptor, nextInChain), + "offsetof mismatch for ComputePassDescriptor::nextInChain"); +static_assert(offsetof(ComputePassDescriptor, label) == + offsetof(WGPUComputePassDescriptor, label), + "offsetof mismatch for ComputePassDescriptor::label"); +static_assert(offsetof(ComputePassDescriptor, timestampWrites) == + offsetof(WGPUComputePassDescriptor, timestampWrites), + "offsetof mismatch for ComputePassDescriptor::timestampWrites"); + +// DepthStencilState + +static_assert(sizeof(DepthStencilState) == sizeof(WGPUDepthStencilState), + "sizeof mismatch for DepthStencilState"); +static_assert(alignof(DepthStencilState) == alignof(WGPUDepthStencilState), + "alignof mismatch for DepthStencilState"); + +static_assert(offsetof(DepthStencilState, nextInChain) == + offsetof(WGPUDepthStencilState, nextInChain), + "offsetof mismatch for DepthStencilState::nextInChain"); +static_assert(offsetof(DepthStencilState, format) == + offsetof(WGPUDepthStencilState, format), + "offsetof mismatch for DepthStencilState::format"); +static_assert(offsetof(DepthStencilState, depthWriteEnabled) == + offsetof(WGPUDepthStencilState, depthWriteEnabled), + "offsetof mismatch for DepthStencilState::depthWriteEnabled"); +static_assert(offsetof(DepthStencilState, depthCompare) == + offsetof(WGPUDepthStencilState, depthCompare), + "offsetof mismatch for DepthStencilState::depthCompare"); +static_assert(offsetof(DepthStencilState, stencilFront) == + offsetof(WGPUDepthStencilState, stencilFront), + "offsetof mismatch for DepthStencilState::stencilFront"); +static_assert(offsetof(DepthStencilState, stencilBack) == + offsetof(WGPUDepthStencilState, stencilBack), + "offsetof mismatch for DepthStencilState::stencilBack"); +static_assert(offsetof(DepthStencilState, stencilReadMask) == + offsetof(WGPUDepthStencilState, stencilReadMask), + "offsetof mismatch for DepthStencilState::stencilReadMask"); +static_assert(offsetof(DepthStencilState, stencilWriteMask) == + offsetof(WGPUDepthStencilState, stencilWriteMask), + "offsetof mismatch for DepthStencilState::stencilWriteMask"); +static_assert(offsetof(DepthStencilState, depthBias) == + offsetof(WGPUDepthStencilState, depthBias), + "offsetof mismatch for DepthStencilState::depthBias"); +static_assert(offsetof(DepthStencilState, depthBiasSlopeScale) == + offsetof(WGPUDepthStencilState, depthBiasSlopeScale), + "offsetof mismatch for DepthStencilState::depthBiasSlopeScale"); +static_assert(offsetof(DepthStencilState, depthBiasClamp) == + offsetof(WGPUDepthStencilState, depthBiasClamp), + "offsetof mismatch for DepthStencilState::depthBiasClamp"); + +// DrmFormatCapabilities + +static_assert(sizeof(DrmFormatCapabilities) == + sizeof(WGPUDrmFormatCapabilities), + "sizeof mismatch for DrmFormatCapabilities"); +static_assert(alignof(DrmFormatCapabilities) == + alignof(WGPUDrmFormatCapabilities), + "alignof mismatch for DrmFormatCapabilities"); + +static_assert(offsetof(DrmFormatCapabilities, propertiesCount) == + offsetof(WGPUDrmFormatCapabilities, propertiesCount), + "offsetof mismatch for DrmFormatCapabilities::propertiesCount"); +static_assert(offsetof(DrmFormatCapabilities, properties) == + offsetof(WGPUDrmFormatCapabilities, properties), + "offsetof mismatch for DrmFormatCapabilities::properties"); + +// ExternalTextureDescriptor + +static_assert(sizeof(ExternalTextureDescriptor) == + sizeof(WGPUExternalTextureDescriptor), + "sizeof mismatch for ExternalTextureDescriptor"); +static_assert(alignof(ExternalTextureDescriptor) == + alignof(WGPUExternalTextureDescriptor), + "alignof mismatch for ExternalTextureDescriptor"); + +static_assert(offsetof(ExternalTextureDescriptor, nextInChain) == + offsetof(WGPUExternalTextureDescriptor, nextInChain), + "offsetof mismatch for ExternalTextureDescriptor::nextInChain"); +static_assert(offsetof(ExternalTextureDescriptor, label) == + offsetof(WGPUExternalTextureDescriptor, label), + "offsetof mismatch for ExternalTextureDescriptor::label"); +static_assert(offsetof(ExternalTextureDescriptor, plane0) == + offsetof(WGPUExternalTextureDescriptor, plane0), + "offsetof mismatch for ExternalTextureDescriptor::plane0"); +static_assert(offsetof(ExternalTextureDescriptor, plane1) == + offsetof(WGPUExternalTextureDescriptor, plane1), + "offsetof mismatch for ExternalTextureDescriptor::plane1"); +static_assert(offsetof(ExternalTextureDescriptor, visibleOrigin) == + offsetof(WGPUExternalTextureDescriptor, visibleOrigin), + "offsetof mismatch for ExternalTextureDescriptor::visibleOrigin"); +static_assert(offsetof(ExternalTextureDescriptor, visibleSize) == + offsetof(WGPUExternalTextureDescriptor, visibleSize), + "offsetof mismatch for ExternalTextureDescriptor::visibleSize"); +static_assert(offsetof(ExternalTextureDescriptor, doYuvToRgbConversionOnly) == + offsetof(WGPUExternalTextureDescriptor, + doYuvToRgbConversionOnly), + "offsetof mismatch for " + "ExternalTextureDescriptor::doYuvToRgbConversionOnly"); +static_assert(offsetof(ExternalTextureDescriptor, yuvToRgbConversionMatrix) == + offsetof(WGPUExternalTextureDescriptor, + yuvToRgbConversionMatrix), + "offsetof mismatch for " + "ExternalTextureDescriptor::yuvToRgbConversionMatrix"); +static_assert(offsetof(ExternalTextureDescriptor, + srcTransferFunctionParameters) == + offsetof(WGPUExternalTextureDescriptor, + srcTransferFunctionParameters), + "offsetof mismatch for " + "ExternalTextureDescriptor::srcTransferFunctionParameters"); +static_assert(offsetof(ExternalTextureDescriptor, + dstTransferFunctionParameters) == + offsetof(WGPUExternalTextureDescriptor, + dstTransferFunctionParameters), + "offsetof mismatch for " + "ExternalTextureDescriptor::dstTransferFunctionParameters"); +static_assert( + offsetof(ExternalTextureDescriptor, gamutConversionMatrix) == + offsetof(WGPUExternalTextureDescriptor, gamutConversionMatrix), + "offsetof mismatch for ExternalTextureDescriptor::gamutConversionMatrix"); +static_assert(offsetof(ExternalTextureDescriptor, flipY) == + offsetof(WGPUExternalTextureDescriptor, flipY), + "offsetof mismatch for ExternalTextureDescriptor::flipY"); +static_assert(offsetof(ExternalTextureDescriptor, mirrored) == + offsetof(WGPUExternalTextureDescriptor, mirrored), + "offsetof mismatch for ExternalTextureDescriptor::mirrored"); +static_assert(offsetof(ExternalTextureDescriptor, rotation) == + offsetof(WGPUExternalTextureDescriptor, rotation), + "offsetof mismatch for ExternalTextureDescriptor::rotation"); + +// FutureWaitInfo + +static_assert(sizeof(FutureWaitInfo) == sizeof(WGPUFutureWaitInfo), + "sizeof mismatch for FutureWaitInfo"); +static_assert(alignof(FutureWaitInfo) == alignof(WGPUFutureWaitInfo), + "alignof mismatch for FutureWaitInfo"); + +static_assert(offsetof(FutureWaitInfo, future) == + offsetof(WGPUFutureWaitInfo, future), + "offsetof mismatch for FutureWaitInfo::future"); +static_assert(offsetof(FutureWaitInfo, completed) == + offsetof(WGPUFutureWaitInfo, completed), + "offsetof mismatch for FutureWaitInfo::completed"); + +// ImageCopyBuffer + +static_assert(sizeof(ImageCopyBuffer) == sizeof(WGPUImageCopyBuffer), + "sizeof mismatch for ImageCopyBuffer"); +static_assert(alignof(ImageCopyBuffer) == alignof(WGPUImageCopyBuffer), + "alignof mismatch for ImageCopyBuffer"); + +static_assert(offsetof(ImageCopyBuffer, nextInChain) == + offsetof(WGPUImageCopyBuffer, nextInChain), + "offsetof mismatch for ImageCopyBuffer::nextInChain"); +static_assert(offsetof(ImageCopyBuffer, layout) == + offsetof(WGPUImageCopyBuffer, layout), + "offsetof mismatch for ImageCopyBuffer::layout"); +static_assert(offsetof(ImageCopyBuffer, buffer) == + offsetof(WGPUImageCopyBuffer, buffer), + "offsetof mismatch for ImageCopyBuffer::buffer"); + +// ImageCopyExternalTexture + +static_assert(sizeof(ImageCopyExternalTexture) == + sizeof(WGPUImageCopyExternalTexture), + "sizeof mismatch for ImageCopyExternalTexture"); +static_assert(alignof(ImageCopyExternalTexture) == + alignof(WGPUImageCopyExternalTexture), + "alignof mismatch for ImageCopyExternalTexture"); + +static_assert(offsetof(ImageCopyExternalTexture, nextInChain) == + offsetof(WGPUImageCopyExternalTexture, nextInChain), + "offsetof mismatch for ImageCopyExternalTexture::nextInChain"); +static_assert( + offsetof(ImageCopyExternalTexture, externalTexture) == + offsetof(WGPUImageCopyExternalTexture, externalTexture), + "offsetof mismatch for ImageCopyExternalTexture::externalTexture"); +static_assert(offsetof(ImageCopyExternalTexture, origin) == + offsetof(WGPUImageCopyExternalTexture, origin), + "offsetof mismatch for ImageCopyExternalTexture::origin"); +static_assert(offsetof(ImageCopyExternalTexture, naturalSize) == + offsetof(WGPUImageCopyExternalTexture, naturalSize), + "offsetof mismatch for ImageCopyExternalTexture::naturalSize"); + +// ImageCopyTexture + +static_assert(sizeof(ImageCopyTexture) == sizeof(WGPUImageCopyTexture), + "sizeof mismatch for ImageCopyTexture"); +static_assert(alignof(ImageCopyTexture) == alignof(WGPUImageCopyTexture), + "alignof mismatch for ImageCopyTexture"); + +static_assert(offsetof(ImageCopyTexture, nextInChain) == + offsetof(WGPUImageCopyTexture, nextInChain), + "offsetof mismatch for ImageCopyTexture::nextInChain"); +static_assert(offsetof(ImageCopyTexture, texture) == + offsetof(WGPUImageCopyTexture, texture), + "offsetof mismatch for ImageCopyTexture::texture"); +static_assert(offsetof(ImageCopyTexture, mipLevel) == + offsetof(WGPUImageCopyTexture, mipLevel), + "offsetof mismatch for ImageCopyTexture::mipLevel"); +static_assert(offsetof(ImageCopyTexture, origin) == + offsetof(WGPUImageCopyTexture, origin), + "offsetof mismatch for ImageCopyTexture::origin"); +static_assert(offsetof(ImageCopyTexture, aspect) == + offsetof(WGPUImageCopyTexture, aspect), + "offsetof mismatch for ImageCopyTexture::aspect"); + +// InstanceDescriptor + +static_assert(sizeof(InstanceDescriptor) == sizeof(WGPUInstanceDescriptor), + "sizeof mismatch for InstanceDescriptor"); +static_assert(alignof(InstanceDescriptor) == alignof(WGPUInstanceDescriptor), + "alignof mismatch for InstanceDescriptor"); + +static_assert(offsetof(InstanceDescriptor, nextInChain) == + offsetof(WGPUInstanceDescriptor, nextInChain), + "offsetof mismatch for InstanceDescriptor::nextInChain"); +static_assert(offsetof(InstanceDescriptor, features) == + offsetof(WGPUInstanceDescriptor, features), + "offsetof mismatch for InstanceDescriptor::features"); + +// PipelineLayoutPixelLocalStorage + +static_assert(sizeof(PipelineLayoutPixelLocalStorage) == + sizeof(WGPUPipelineLayoutPixelLocalStorage), + "sizeof mismatch for PipelineLayoutPixelLocalStorage"); +static_assert(alignof(PipelineLayoutPixelLocalStorage) == + alignof(WGPUPipelineLayoutPixelLocalStorage), + "alignof mismatch for PipelineLayoutPixelLocalStorage"); + +static_assert(offsetof(PipelineLayoutPixelLocalStorage, + totalPixelLocalStorageSize) == + offsetof(WGPUPipelineLayoutPixelLocalStorage, + totalPixelLocalStorageSize), + "offsetof mismatch for " + "PipelineLayoutPixelLocalStorage::totalPixelLocalStorageSize"); +static_assert(offsetof(PipelineLayoutPixelLocalStorage, + storageAttachmentCount) == + offsetof(WGPUPipelineLayoutPixelLocalStorage, + storageAttachmentCount), + "offsetof mismatch for " + "PipelineLayoutPixelLocalStorage::storageAttachmentCount"); +static_assert(offsetof(PipelineLayoutPixelLocalStorage, storageAttachments) == + offsetof(WGPUPipelineLayoutPixelLocalStorage, + storageAttachments), + "offsetof mismatch for " + "PipelineLayoutPixelLocalStorage::storageAttachments"); + +// ProgrammableStageDescriptor + +static_assert(sizeof(ProgrammableStageDescriptor) == + sizeof(WGPUProgrammableStageDescriptor), + "sizeof mismatch for ProgrammableStageDescriptor"); +static_assert(alignof(ProgrammableStageDescriptor) == + alignof(WGPUProgrammableStageDescriptor), + "alignof mismatch for ProgrammableStageDescriptor"); + +static_assert(offsetof(ProgrammableStageDescriptor, nextInChain) == + offsetof(WGPUProgrammableStageDescriptor, nextInChain), + "offsetof mismatch for ProgrammableStageDescriptor::nextInChain"); +static_assert(offsetof(ProgrammableStageDescriptor, module) == + offsetof(WGPUProgrammableStageDescriptor, module), + "offsetof mismatch for ProgrammableStageDescriptor::module"); +static_assert(offsetof(ProgrammableStageDescriptor, entryPoint) == + offsetof(WGPUProgrammableStageDescriptor, entryPoint), + "offsetof mismatch for ProgrammableStageDescriptor::entryPoint"); +static_assert( + offsetof(ProgrammableStageDescriptor, constantCount) == + offsetof(WGPUProgrammableStageDescriptor, constantCount), + "offsetof mismatch for ProgrammableStageDescriptor::constantCount"); +static_assert(offsetof(ProgrammableStageDescriptor, constants) == + offsetof(WGPUProgrammableStageDescriptor, constants), + "offsetof mismatch for ProgrammableStageDescriptor::constants"); + +// RenderPassColorAttachment + +static_assert(sizeof(RenderPassColorAttachment) == + sizeof(WGPURenderPassColorAttachment), + "sizeof mismatch for RenderPassColorAttachment"); +static_assert(alignof(RenderPassColorAttachment) == + alignof(WGPURenderPassColorAttachment), + "alignof mismatch for RenderPassColorAttachment"); + +static_assert(offsetof(RenderPassColorAttachment, nextInChain) == + offsetof(WGPURenderPassColorAttachment, nextInChain), + "offsetof mismatch for RenderPassColorAttachment::nextInChain"); +static_assert(offsetof(RenderPassColorAttachment, view) == + offsetof(WGPURenderPassColorAttachment, view), + "offsetof mismatch for RenderPassColorAttachment::view"); +static_assert(offsetof(RenderPassColorAttachment, depthSlice) == + offsetof(WGPURenderPassColorAttachment, depthSlice), + "offsetof mismatch for RenderPassColorAttachment::depthSlice"); +static_assert(offsetof(RenderPassColorAttachment, resolveTarget) == + offsetof(WGPURenderPassColorAttachment, resolveTarget), + "offsetof mismatch for RenderPassColorAttachment::resolveTarget"); +static_assert(offsetof(RenderPassColorAttachment, loadOp) == + offsetof(WGPURenderPassColorAttachment, loadOp), + "offsetof mismatch for RenderPassColorAttachment::loadOp"); +static_assert(offsetof(RenderPassColorAttachment, storeOp) == + offsetof(WGPURenderPassColorAttachment, storeOp), + "offsetof mismatch for RenderPassColorAttachment::storeOp"); +static_assert(offsetof(RenderPassColorAttachment, clearValue) == + offsetof(WGPURenderPassColorAttachment, clearValue), + "offsetof mismatch for RenderPassColorAttachment::clearValue"); + +// RenderPassStorageAttachment + +static_assert(sizeof(RenderPassStorageAttachment) == + sizeof(WGPURenderPassStorageAttachment), + "sizeof mismatch for RenderPassStorageAttachment"); +static_assert(alignof(RenderPassStorageAttachment) == + alignof(WGPURenderPassStorageAttachment), + "alignof mismatch for RenderPassStorageAttachment"); + +static_assert(offsetof(RenderPassStorageAttachment, nextInChain) == + offsetof(WGPURenderPassStorageAttachment, nextInChain), + "offsetof mismatch for RenderPassStorageAttachment::nextInChain"); +static_assert(offsetof(RenderPassStorageAttachment, offset) == + offsetof(WGPURenderPassStorageAttachment, offset), + "offsetof mismatch for RenderPassStorageAttachment::offset"); +static_assert(offsetof(RenderPassStorageAttachment, storage) == + offsetof(WGPURenderPassStorageAttachment, storage), + "offsetof mismatch for RenderPassStorageAttachment::storage"); +static_assert(offsetof(RenderPassStorageAttachment, loadOp) == + offsetof(WGPURenderPassStorageAttachment, loadOp), + "offsetof mismatch for RenderPassStorageAttachment::loadOp"); +static_assert(offsetof(RenderPassStorageAttachment, storeOp) == + offsetof(WGPURenderPassStorageAttachment, storeOp), + "offsetof mismatch for RenderPassStorageAttachment::storeOp"); +static_assert(offsetof(RenderPassStorageAttachment, clearValue) == + offsetof(WGPURenderPassStorageAttachment, clearValue), + "offsetof mismatch for RenderPassStorageAttachment::clearValue"); + +// RequiredLimits + +static_assert(sizeof(RequiredLimits) == sizeof(WGPURequiredLimits), + "sizeof mismatch for RequiredLimits"); +static_assert(alignof(RequiredLimits) == alignof(WGPURequiredLimits), + "alignof mismatch for RequiredLimits"); + +static_assert(offsetof(RequiredLimits, nextInChain) == + offsetof(WGPURequiredLimits, nextInChain), + "offsetof mismatch for RequiredLimits::nextInChain"); +static_assert(offsetof(RequiredLimits, limits) == + offsetof(WGPURequiredLimits, limits), + "offsetof mismatch for RequiredLimits::limits"); + +// SharedTextureMemoryDmaBufDescriptor + +static_assert(sizeof(SharedTextureMemoryDmaBufDescriptor) == + sizeof(WGPUSharedTextureMemoryDmaBufDescriptor), + "sizeof mismatch for SharedTextureMemoryDmaBufDescriptor"); +static_assert(alignof(SharedTextureMemoryDmaBufDescriptor) == + alignof(WGPUSharedTextureMemoryDmaBufDescriptor), + "alignof mismatch for SharedTextureMemoryDmaBufDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryDmaBufDescriptor, size) == + offsetof(WGPUSharedTextureMemoryDmaBufDescriptor, size), + "offsetof mismatch for SharedTextureMemoryDmaBufDescriptor::size"); +static_assert( + offsetof(SharedTextureMemoryDmaBufDescriptor, drmFormat) == + offsetof(WGPUSharedTextureMemoryDmaBufDescriptor, drmFormat), + "offsetof mismatch for SharedTextureMemoryDmaBufDescriptor::drmFormat"); +static_assert( + offsetof(SharedTextureMemoryDmaBufDescriptor, drmModifier) == + offsetof(WGPUSharedTextureMemoryDmaBufDescriptor, drmModifier), + "offsetof mismatch for SharedTextureMemoryDmaBufDescriptor::drmModifier"); +static_assert( + offsetof(SharedTextureMemoryDmaBufDescriptor, planeCount) == + offsetof(WGPUSharedTextureMemoryDmaBufDescriptor, planeCount), + "offsetof mismatch for SharedTextureMemoryDmaBufDescriptor::planeCount"); +static_assert( + offsetof(SharedTextureMemoryDmaBufDescriptor, planes) == + offsetof(WGPUSharedTextureMemoryDmaBufDescriptor, planes), + "offsetof mismatch for SharedTextureMemoryDmaBufDescriptor::planes"); + +// SharedTextureMemoryProperties + +static_assert(sizeof(SharedTextureMemoryProperties) == + sizeof(WGPUSharedTextureMemoryProperties), + "sizeof mismatch for SharedTextureMemoryProperties"); +static_assert(alignof(SharedTextureMemoryProperties) == + alignof(WGPUSharedTextureMemoryProperties), + "alignof mismatch for SharedTextureMemoryProperties"); + +static_assert( + offsetof(SharedTextureMemoryProperties, nextInChain) == + offsetof(WGPUSharedTextureMemoryProperties, nextInChain), + "offsetof mismatch for SharedTextureMemoryProperties::nextInChain"); +static_assert(offsetof(SharedTextureMemoryProperties, usage) == + offsetof(WGPUSharedTextureMemoryProperties, usage), + "offsetof mismatch for SharedTextureMemoryProperties::usage"); +static_assert(offsetof(SharedTextureMemoryProperties, size) == + offsetof(WGPUSharedTextureMemoryProperties, size), + "offsetof mismatch for SharedTextureMemoryProperties::size"); +static_assert(offsetof(SharedTextureMemoryProperties, format) == + offsetof(WGPUSharedTextureMemoryProperties, format), + "offsetof mismatch for SharedTextureMemoryProperties::format"); + +// SharedTextureMemoryVkImageDescriptor + +static_assert(sizeof(SharedTextureMemoryVkImageDescriptor) == + sizeof(WGPUSharedTextureMemoryVkImageDescriptor), + "sizeof mismatch for SharedTextureMemoryVkImageDescriptor"); +static_assert(alignof(SharedTextureMemoryVkImageDescriptor) == + alignof(WGPUSharedTextureMemoryVkImageDescriptor), + "alignof mismatch for SharedTextureMemoryVkImageDescriptor"); + +static_assert( + offsetof(SharedTextureMemoryVkImageDescriptor, vkFormat) == + offsetof(WGPUSharedTextureMemoryVkImageDescriptor, vkFormat), + "offsetof mismatch for SharedTextureMemoryVkImageDescriptor::vkFormat"); +static_assert( + offsetof(SharedTextureMemoryVkImageDescriptor, vkUsageFlags) == + offsetof(WGPUSharedTextureMemoryVkImageDescriptor, vkUsageFlags), + "offsetof mismatch for SharedTextureMemoryVkImageDescriptor::vkUsageFlags"); +static_assert( + offsetof(SharedTextureMemoryVkImageDescriptor, vkExtent3D) == + offsetof(WGPUSharedTextureMemoryVkImageDescriptor, vkExtent3D), + "offsetof mismatch for SharedTextureMemoryVkImageDescriptor::vkExtent3D"); + +// SupportedLimits + +static_assert(sizeof(SupportedLimits) == sizeof(WGPUSupportedLimits), + "sizeof mismatch for SupportedLimits"); +static_assert(alignof(SupportedLimits) == alignof(WGPUSupportedLimits), + "alignof mismatch for SupportedLimits"); + +static_assert(offsetof(SupportedLimits, nextInChain) == + offsetof(WGPUSupportedLimits, nextInChain), + "offsetof mismatch for SupportedLimits::nextInChain"); +static_assert(offsetof(SupportedLimits, limits) == + offsetof(WGPUSupportedLimits, limits), + "offsetof mismatch for SupportedLimits::limits"); + +// TextureDescriptor + +static_assert(sizeof(TextureDescriptor) == sizeof(WGPUTextureDescriptor), + "sizeof mismatch for TextureDescriptor"); +static_assert(alignof(TextureDescriptor) == alignof(WGPUTextureDescriptor), + "alignof mismatch for TextureDescriptor"); + +static_assert(offsetof(TextureDescriptor, nextInChain) == + offsetof(WGPUTextureDescriptor, nextInChain), + "offsetof mismatch for TextureDescriptor::nextInChain"); +static_assert(offsetof(TextureDescriptor, label) == + offsetof(WGPUTextureDescriptor, label), + "offsetof mismatch for TextureDescriptor::label"); +static_assert(offsetof(TextureDescriptor, usage) == + offsetof(WGPUTextureDescriptor, usage), + "offsetof mismatch for TextureDescriptor::usage"); +static_assert(offsetof(TextureDescriptor, dimension) == + offsetof(WGPUTextureDescriptor, dimension), + "offsetof mismatch for TextureDescriptor::dimension"); +static_assert(offsetof(TextureDescriptor, size) == + offsetof(WGPUTextureDescriptor, size), + "offsetof mismatch for TextureDescriptor::size"); +static_assert(offsetof(TextureDescriptor, format) == + offsetof(WGPUTextureDescriptor, format), + "offsetof mismatch for TextureDescriptor::format"); +static_assert(offsetof(TextureDescriptor, mipLevelCount) == + offsetof(WGPUTextureDescriptor, mipLevelCount), + "offsetof mismatch for TextureDescriptor::mipLevelCount"); +static_assert(offsetof(TextureDescriptor, sampleCount) == + offsetof(WGPUTextureDescriptor, sampleCount), + "offsetof mismatch for TextureDescriptor::sampleCount"); +static_assert(offsetof(TextureDescriptor, viewFormatCount) == + offsetof(WGPUTextureDescriptor, viewFormatCount), + "offsetof mismatch for TextureDescriptor::viewFormatCount"); +static_assert(offsetof(TextureDescriptor, viewFormats) == + offsetof(WGPUTextureDescriptor, viewFormats), + "offsetof mismatch for TextureDescriptor::viewFormats"); + +// VertexBufferLayout + +static_assert(sizeof(VertexBufferLayout) == sizeof(WGPUVertexBufferLayout), + "sizeof mismatch for VertexBufferLayout"); +static_assert(alignof(VertexBufferLayout) == alignof(WGPUVertexBufferLayout), + "alignof mismatch for VertexBufferLayout"); + +static_assert(offsetof(VertexBufferLayout, arrayStride) == + offsetof(WGPUVertexBufferLayout, arrayStride), + "offsetof mismatch for VertexBufferLayout::arrayStride"); +static_assert(offsetof(VertexBufferLayout, stepMode) == + offsetof(WGPUVertexBufferLayout, stepMode), + "offsetof mismatch for VertexBufferLayout::stepMode"); +static_assert(offsetof(VertexBufferLayout, attributeCount) == + offsetof(WGPUVertexBufferLayout, attributeCount), + "offsetof mismatch for VertexBufferLayout::attributeCount"); +static_assert(offsetof(VertexBufferLayout, attributes) == + offsetof(WGPUVertexBufferLayout, attributes), + "offsetof mismatch for VertexBufferLayout::attributes"); + +// BindGroupLayoutDescriptor + +static_assert(sizeof(BindGroupLayoutDescriptor) == + sizeof(WGPUBindGroupLayoutDescriptor), + "sizeof mismatch for BindGroupLayoutDescriptor"); +static_assert(alignof(BindGroupLayoutDescriptor) == + alignof(WGPUBindGroupLayoutDescriptor), + "alignof mismatch for BindGroupLayoutDescriptor"); + +static_assert(offsetof(BindGroupLayoutDescriptor, nextInChain) == + offsetof(WGPUBindGroupLayoutDescriptor, nextInChain), + "offsetof mismatch for BindGroupLayoutDescriptor::nextInChain"); +static_assert(offsetof(BindGroupLayoutDescriptor, label) == + offsetof(WGPUBindGroupLayoutDescriptor, label), + "offsetof mismatch for BindGroupLayoutDescriptor::label"); +static_assert(offsetof(BindGroupLayoutDescriptor, entryCount) == + offsetof(WGPUBindGroupLayoutDescriptor, entryCount), + "offsetof mismatch for BindGroupLayoutDescriptor::entryCount"); +static_assert(offsetof(BindGroupLayoutDescriptor, entries) == + offsetof(WGPUBindGroupLayoutDescriptor, entries), + "offsetof mismatch for BindGroupLayoutDescriptor::entries"); + +// ColorTargetState + +static_assert(sizeof(ColorTargetState) == sizeof(WGPUColorTargetState), + "sizeof mismatch for ColorTargetState"); +static_assert(alignof(ColorTargetState) == alignof(WGPUColorTargetState), + "alignof mismatch for ColorTargetState"); + +static_assert(offsetof(ColorTargetState, nextInChain) == + offsetof(WGPUColorTargetState, nextInChain), + "offsetof mismatch for ColorTargetState::nextInChain"); +static_assert(offsetof(ColorTargetState, format) == + offsetof(WGPUColorTargetState, format), + "offsetof mismatch for ColorTargetState::format"); +static_assert(offsetof(ColorTargetState, blend) == + offsetof(WGPUColorTargetState, blend), + "offsetof mismatch for ColorTargetState::blend"); +static_assert(offsetof(ColorTargetState, writeMask) == + offsetof(WGPUColorTargetState, writeMask), + "offsetof mismatch for ColorTargetState::writeMask"); + +// ComputePipelineDescriptor + +static_assert(sizeof(ComputePipelineDescriptor) == + sizeof(WGPUComputePipelineDescriptor), + "sizeof mismatch for ComputePipelineDescriptor"); +static_assert(alignof(ComputePipelineDescriptor) == + alignof(WGPUComputePipelineDescriptor), + "alignof mismatch for ComputePipelineDescriptor"); + +static_assert(offsetof(ComputePipelineDescriptor, nextInChain) == + offsetof(WGPUComputePipelineDescriptor, nextInChain), + "offsetof mismatch for ComputePipelineDescriptor::nextInChain"); +static_assert(offsetof(ComputePipelineDescriptor, label) == + offsetof(WGPUComputePipelineDescriptor, label), + "offsetof mismatch for ComputePipelineDescriptor::label"); +static_assert(offsetof(ComputePipelineDescriptor, layout) == + offsetof(WGPUComputePipelineDescriptor, layout), + "offsetof mismatch for ComputePipelineDescriptor::layout"); +static_assert(offsetof(ComputePipelineDescriptor, compute) == + offsetof(WGPUComputePipelineDescriptor, compute), + "offsetof mismatch for ComputePipelineDescriptor::compute"); + +// DeviceDescriptor + +static_assert(sizeof(DeviceDescriptor) == sizeof(WGPUDeviceDescriptor), + "sizeof mismatch for DeviceDescriptor"); +static_assert(alignof(DeviceDescriptor) == alignof(WGPUDeviceDescriptor), + "alignof mismatch for DeviceDescriptor"); + +static_assert(offsetof(DeviceDescriptor, nextInChain) == + offsetof(WGPUDeviceDescriptor, nextInChain), + "offsetof mismatch for DeviceDescriptor::nextInChain"); +static_assert(offsetof(DeviceDescriptor, label) == + offsetof(WGPUDeviceDescriptor, label), + "offsetof mismatch for DeviceDescriptor::label"); +static_assert(offsetof(DeviceDescriptor, requiredFeatureCount) == + offsetof(WGPUDeviceDescriptor, requiredFeatureCount), + "offsetof mismatch for DeviceDescriptor::requiredFeatureCount"); +static_assert(offsetof(DeviceDescriptor, requiredFeatures) == + offsetof(WGPUDeviceDescriptor, requiredFeatures), + "offsetof mismatch for DeviceDescriptor::requiredFeatures"); +static_assert(offsetof(DeviceDescriptor, requiredLimits) == + offsetof(WGPUDeviceDescriptor, requiredLimits), + "offsetof mismatch for DeviceDescriptor::requiredLimits"); +static_assert(offsetof(DeviceDescriptor, defaultQueue) == + offsetof(WGPUDeviceDescriptor, defaultQueue), + "offsetof mismatch for DeviceDescriptor::defaultQueue"); +static_assert(offsetof(DeviceDescriptor, deviceLostCallback) == + offsetof(WGPUDeviceDescriptor, deviceLostCallback), + "offsetof mismatch for DeviceDescriptor::deviceLostCallback"); +static_assert(offsetof(DeviceDescriptor, deviceLostUserdata) == + offsetof(WGPUDeviceDescriptor, deviceLostUserdata), + "offsetof mismatch for DeviceDescriptor::deviceLostUserdata"); + +// RenderPassDescriptor + +static_assert(sizeof(RenderPassDescriptor) == sizeof(WGPURenderPassDescriptor), + "sizeof mismatch for RenderPassDescriptor"); +static_assert(alignof(RenderPassDescriptor) == + alignof(WGPURenderPassDescriptor), + "alignof mismatch for RenderPassDescriptor"); + +static_assert(offsetof(RenderPassDescriptor, nextInChain) == + offsetof(WGPURenderPassDescriptor, nextInChain), + "offsetof mismatch for RenderPassDescriptor::nextInChain"); +static_assert(offsetof(RenderPassDescriptor, label) == + offsetof(WGPURenderPassDescriptor, label), + "offsetof mismatch for RenderPassDescriptor::label"); +static_assert( + offsetof(RenderPassDescriptor, colorAttachmentCount) == + offsetof(WGPURenderPassDescriptor, colorAttachmentCount), + "offsetof mismatch for RenderPassDescriptor::colorAttachmentCount"); +static_assert(offsetof(RenderPassDescriptor, colorAttachments) == + offsetof(WGPURenderPassDescriptor, colorAttachments), + "offsetof mismatch for RenderPassDescriptor::colorAttachments"); +static_assert( + offsetof(RenderPassDescriptor, depthStencilAttachment) == + offsetof(WGPURenderPassDescriptor, depthStencilAttachment), + "offsetof mismatch for RenderPassDescriptor::depthStencilAttachment"); +static_assert(offsetof(RenderPassDescriptor, occlusionQuerySet) == + offsetof(WGPURenderPassDescriptor, occlusionQuerySet), + "offsetof mismatch for RenderPassDescriptor::occlusionQuerySet"); +static_assert(offsetof(RenderPassDescriptor, timestampWrites) == + offsetof(WGPURenderPassDescriptor, timestampWrites), + "offsetof mismatch for RenderPassDescriptor::timestampWrites"); + +// RenderPassPixelLocalStorage + +static_assert(sizeof(RenderPassPixelLocalStorage) == + sizeof(WGPURenderPassPixelLocalStorage), + "sizeof mismatch for RenderPassPixelLocalStorage"); +static_assert(alignof(RenderPassPixelLocalStorage) == + alignof(WGPURenderPassPixelLocalStorage), + "alignof mismatch for RenderPassPixelLocalStorage"); + +static_assert(offsetof(RenderPassPixelLocalStorage, + totalPixelLocalStorageSize) == + offsetof(WGPURenderPassPixelLocalStorage, + totalPixelLocalStorageSize), + "offsetof mismatch for " + "RenderPassPixelLocalStorage::totalPixelLocalStorageSize"); +static_assert(offsetof(RenderPassPixelLocalStorage, storageAttachmentCount) == + offsetof(WGPURenderPassPixelLocalStorage, + storageAttachmentCount), + "offsetof mismatch for " + "RenderPassPixelLocalStorage::storageAttachmentCount"); +static_assert( + offsetof(RenderPassPixelLocalStorage, storageAttachments) == + offsetof(WGPURenderPassPixelLocalStorage, storageAttachments), + "offsetof mismatch for RenderPassPixelLocalStorage::storageAttachments"); + +// VertexState + +static_assert(sizeof(VertexState) == sizeof(WGPUVertexState), + "sizeof mismatch for VertexState"); +static_assert(alignof(VertexState) == alignof(WGPUVertexState), + "alignof mismatch for VertexState"); + +static_assert(offsetof(VertexState, nextInChain) == + offsetof(WGPUVertexState, nextInChain), + "offsetof mismatch for VertexState::nextInChain"); +static_assert(offsetof(VertexState, module) == + offsetof(WGPUVertexState, module), + "offsetof mismatch for VertexState::module"); +static_assert(offsetof(VertexState, entryPoint) == + offsetof(WGPUVertexState, entryPoint), + "offsetof mismatch for VertexState::entryPoint"); +static_assert(offsetof(VertexState, constantCount) == + offsetof(WGPUVertexState, constantCount), + "offsetof mismatch for VertexState::constantCount"); +static_assert(offsetof(VertexState, constants) == + offsetof(WGPUVertexState, constants), + "offsetof mismatch for VertexState::constants"); +static_assert(offsetof(VertexState, bufferCount) == + offsetof(WGPUVertexState, bufferCount), + "offsetof mismatch for VertexState::bufferCount"); +static_assert(offsetof(VertexState, buffers) == + offsetof(WGPUVertexState, buffers), + "offsetof mismatch for VertexState::buffers"); + +// FragmentState + +static_assert(sizeof(FragmentState) == sizeof(WGPUFragmentState), + "sizeof mismatch for FragmentState"); +static_assert(alignof(FragmentState) == alignof(WGPUFragmentState), + "alignof mismatch for FragmentState"); + +static_assert(offsetof(FragmentState, nextInChain) == + offsetof(WGPUFragmentState, nextInChain), + "offsetof mismatch for FragmentState::nextInChain"); +static_assert(offsetof(FragmentState, module) == + offsetof(WGPUFragmentState, module), + "offsetof mismatch for FragmentState::module"); +static_assert(offsetof(FragmentState, entryPoint) == + offsetof(WGPUFragmentState, entryPoint), + "offsetof mismatch for FragmentState::entryPoint"); +static_assert(offsetof(FragmentState, constantCount) == + offsetof(WGPUFragmentState, constantCount), + "offsetof mismatch for FragmentState::constantCount"); +static_assert(offsetof(FragmentState, constants) == + offsetof(WGPUFragmentState, constants), + "offsetof mismatch for FragmentState::constants"); +static_assert(offsetof(FragmentState, targetCount) == + offsetof(WGPUFragmentState, targetCount), + "offsetof mismatch for FragmentState::targetCount"); +static_assert(offsetof(FragmentState, targets) == + offsetof(WGPUFragmentState, targets), + "offsetof mismatch for FragmentState::targets"); + +// RenderPipelineDescriptor + +static_assert(sizeof(RenderPipelineDescriptor) == + sizeof(WGPURenderPipelineDescriptor), + "sizeof mismatch for RenderPipelineDescriptor"); +static_assert(alignof(RenderPipelineDescriptor) == + alignof(WGPURenderPipelineDescriptor), + "alignof mismatch for RenderPipelineDescriptor"); + +static_assert(offsetof(RenderPipelineDescriptor, nextInChain) == + offsetof(WGPURenderPipelineDescriptor, nextInChain), + "offsetof mismatch for RenderPipelineDescriptor::nextInChain"); +static_assert(offsetof(RenderPipelineDescriptor, label) == + offsetof(WGPURenderPipelineDescriptor, label), + "offsetof mismatch for RenderPipelineDescriptor::label"); +static_assert(offsetof(RenderPipelineDescriptor, layout) == + offsetof(WGPURenderPipelineDescriptor, layout), + "offsetof mismatch for RenderPipelineDescriptor::layout"); +static_assert(offsetof(RenderPipelineDescriptor, vertex) == + offsetof(WGPURenderPipelineDescriptor, vertex), + "offsetof mismatch for RenderPipelineDescriptor::vertex"); +static_assert(offsetof(RenderPipelineDescriptor, primitive) == + offsetof(WGPURenderPipelineDescriptor, primitive), + "offsetof mismatch for RenderPipelineDescriptor::primitive"); +static_assert(offsetof(RenderPipelineDescriptor, depthStencil) == + offsetof(WGPURenderPipelineDescriptor, depthStencil), + "offsetof mismatch for RenderPipelineDescriptor::depthStencil"); +static_assert(offsetof(RenderPipelineDescriptor, multisample) == + offsetof(WGPURenderPipelineDescriptor, multisample), + "offsetof mismatch for RenderPipelineDescriptor::multisample"); +static_assert(offsetof(RenderPipelineDescriptor, fragment) == + offsetof(WGPURenderPipelineDescriptor, fragment), + "offsetof mismatch for RenderPipelineDescriptor::fragment"); +template static T &AsNonConstReference(const T &value) { + return const_cast(value); +} + +// AdapterProperties +AdapterProperties::~AdapterProperties() { + if (this->vendorName != nullptr || this->architecture != nullptr || + this->name != nullptr || this->driverDescription != nullptr) { + wgpuAdapterPropertiesFreeMembers( + *reinterpret_cast(this)); + } +} + +static void Reset(AdapterProperties &value) { + AdapterProperties defaultValue{}; + AsNonConstReference(value.vendorID) = defaultValue.vendorID; + AsNonConstReference(value.vendorName) = defaultValue.vendorName; + AsNonConstReference(value.architecture) = defaultValue.architecture; + AsNonConstReference(value.deviceID) = defaultValue.deviceID; + AsNonConstReference(value.name) = defaultValue.name; + AsNonConstReference(value.driverDescription) = defaultValue.driverDescription; + AsNonConstReference(value.adapterType) = defaultValue.adapterType; + AsNonConstReference(value.backendType) = defaultValue.backendType; + AsNonConstReference(value.compatibilityMode) = defaultValue.compatibilityMode; +} + +AdapterProperties::AdapterProperties(AdapterProperties &&rhs) + : vendorID(rhs.vendorID), vendorName(rhs.vendorName), + architecture(rhs.architecture), deviceID(rhs.deviceID), name(rhs.name), + driverDescription(rhs.driverDescription), adapterType(rhs.adapterType), + backendType(rhs.backendType), compatibilityMode(rhs.compatibilityMode) { + Reset(rhs); +} + +AdapterProperties &AdapterProperties::operator=(AdapterProperties &&rhs) { + if (&rhs == this) { + return *this; + } + this->~AdapterProperties(); + AsNonConstReference(this->vendorID) = std::move(rhs.vendorID); + AsNonConstReference(this->vendorName) = std::move(rhs.vendorName); + AsNonConstReference(this->architecture) = std::move(rhs.architecture); + AsNonConstReference(this->deviceID) = std::move(rhs.deviceID); + AsNonConstReference(this->name) = std::move(rhs.name); + AsNonConstReference(this->driverDescription) = + std::move(rhs.driverDescription); + AsNonConstReference(this->adapterType) = std::move(rhs.adapterType); + AsNonConstReference(this->backendType) = std::move(rhs.backendType); + AsNonConstReference(this->compatibilityMode) = + std::move(rhs.compatibilityMode); + Reset(rhs); + return *this; +} + +// SharedBufferMemoryEndAccessState +SharedBufferMemoryEndAccessState::~SharedBufferMemoryEndAccessState() { + if (this->fences != nullptr || this->signaledValues != nullptr) { + wgpuSharedBufferMemoryEndAccessStateFreeMembers( + *reinterpret_cast(this)); + } +} + +static void Reset(SharedBufferMemoryEndAccessState &value) { + SharedBufferMemoryEndAccessState defaultValue{}; + AsNonConstReference(value.initialized) = defaultValue.initialized; + AsNonConstReference(value.fenceCount) = defaultValue.fenceCount; + AsNonConstReference(value.fences) = defaultValue.fences; + AsNonConstReference(value.signaledValues) = defaultValue.signaledValues; +} + +SharedBufferMemoryEndAccessState::SharedBufferMemoryEndAccessState( + SharedBufferMemoryEndAccessState &&rhs) + : initialized(rhs.initialized), fenceCount(rhs.fenceCount), + fences(rhs.fences), signaledValues(rhs.signaledValues) { + Reset(rhs); +} + +SharedBufferMemoryEndAccessState &SharedBufferMemoryEndAccessState::operator=( + SharedBufferMemoryEndAccessState &&rhs) { + if (&rhs == this) { + return *this; + } + this->~SharedBufferMemoryEndAccessState(); + AsNonConstReference(this->initialized) = std::move(rhs.initialized); + AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount); + AsNonConstReference(this->fences) = std::move(rhs.fences); + AsNonConstReference(this->signaledValues) = std::move(rhs.signaledValues); + Reset(rhs); + return *this; +} + +// SharedTextureMemoryEndAccessState +SharedTextureMemoryEndAccessState::~SharedTextureMemoryEndAccessState() { + if (this->fences != nullptr || this->signaledValues != nullptr) { + wgpuSharedTextureMemoryEndAccessStateFreeMembers( + *reinterpret_cast(this)); + } +} + +static void Reset(SharedTextureMemoryEndAccessState &value) { + SharedTextureMemoryEndAccessState defaultValue{}; + AsNonConstReference(value.initialized) = defaultValue.initialized; + AsNonConstReference(value.fenceCount) = defaultValue.fenceCount; + AsNonConstReference(value.fences) = defaultValue.fences; + AsNonConstReference(value.signaledValues) = defaultValue.signaledValues; +} + +SharedTextureMemoryEndAccessState::SharedTextureMemoryEndAccessState( + SharedTextureMemoryEndAccessState &&rhs) + : initialized(rhs.initialized), fenceCount(rhs.fenceCount), + fences(rhs.fences), signaledValues(rhs.signaledValues) { + Reset(rhs); +} + +SharedTextureMemoryEndAccessState &SharedTextureMemoryEndAccessState::operator=( + SharedTextureMemoryEndAccessState &&rhs) { + if (&rhs == this) { + return *this; + } + this->~SharedTextureMemoryEndAccessState(); + AsNonConstReference(this->initialized) = std::move(rhs.initialized); + AsNonConstReference(this->fenceCount) = std::move(rhs.fenceCount); + AsNonConstReference(this->fences) = std::move(rhs.fences); + AsNonConstReference(this->signaledValues) = std::move(rhs.signaledValues); + Reset(rhs); + return *this; +} + +// AdapterPropertiesMemoryHeaps +AdapterPropertiesMemoryHeaps::~AdapterPropertiesMemoryHeaps() { + if (this->heapInfo != nullptr) { + wgpuAdapterPropertiesMemoryHeapsFreeMembers( + *reinterpret_cast(this)); + } +} + +static void Reset(AdapterPropertiesMemoryHeaps &value) { + AdapterPropertiesMemoryHeaps defaultValue{}; + AsNonConstReference(value.heapCount) = defaultValue.heapCount; + AsNonConstReference(value.heapInfo) = defaultValue.heapInfo; +} + +AdapterPropertiesMemoryHeaps::AdapterPropertiesMemoryHeaps( + AdapterPropertiesMemoryHeaps &&rhs) + : heapCount(rhs.heapCount), heapInfo(rhs.heapInfo) { + Reset(rhs); +} + +AdapterPropertiesMemoryHeaps & +AdapterPropertiesMemoryHeaps::operator=(AdapterPropertiesMemoryHeaps &&rhs) { + if (&rhs == this) { + return *this; + } + this->~AdapterPropertiesMemoryHeaps(); + AsNonConstReference(this->heapCount) = std::move(rhs.heapCount); + AsNonConstReference(this->heapInfo) = std::move(rhs.heapInfo); + Reset(rhs); + return *this; +} + +// DrmFormatCapabilities +DrmFormatCapabilities::~DrmFormatCapabilities() { + if (this->properties != nullptr) { + wgpuDrmFormatCapabilitiesFreeMembers( + *reinterpret_cast(this)); + } +} + +static void Reset(DrmFormatCapabilities &value) { + DrmFormatCapabilities defaultValue{}; + AsNonConstReference(value.propertiesCount) = defaultValue.propertiesCount; + AsNonConstReference(value.properties) = defaultValue.properties; +} + +DrmFormatCapabilities::DrmFormatCapabilities(DrmFormatCapabilities &&rhs) + : propertiesCount(rhs.propertiesCount), properties(rhs.properties) { + Reset(rhs); +} + +DrmFormatCapabilities & +DrmFormatCapabilities::operator=(DrmFormatCapabilities &&rhs) { + if (&rhs == this) { + return *this; + } + this->~DrmFormatCapabilities(); + AsNonConstReference(this->propertiesCount) = std::move(rhs.propertiesCount); + AsNonConstReference(this->properties) = std::move(rhs.properties); + Reset(rhs); + return *this; +} + +// Adapter + +static_assert(sizeof(Adapter) == sizeof(WGPUAdapter), + "sizeof mismatch for Adapter"); +static_assert(alignof(Adapter) == alignof(WGPUAdapter), + "alignof mismatch for Adapter"); + +Device Adapter::CreateDevice(DeviceDescriptor const *descriptor) const { + auto result = wgpuAdapterCreateDevice( + Get(), reinterpret_cast(descriptor)); + return Device::Acquire(result); +} +size_t Adapter::EnumerateFeatures(FeatureName *features) const { + auto result = wgpuAdapterEnumerateFeatures( + Get(), reinterpret_cast(features)); + return result; +} +Bool Adapter::GetFormatCapabilities(TextureFormat format, + FormatCapabilities *capabilities) const { + auto result = wgpuAdapterGetFormatCapabilities( + Get(), static_cast(format), + reinterpret_cast(capabilities)); + return result; +} +Instance Adapter::GetInstance() const { + auto result = wgpuAdapterGetInstance(Get()); + return Instance::Acquire(result); +} +Bool Adapter::GetLimits(SupportedLimits *limits) const { + auto result = wgpuAdapterGetLimits( + Get(), reinterpret_cast(limits)); + return result; +} +void Adapter::GetProperties(AdapterProperties *properties) const { + *properties = AdapterProperties(); + wgpuAdapterGetProperties( + Get(), reinterpret_cast(properties)); +} +Bool Adapter::HasFeature(FeatureName feature) const { + auto result = + wgpuAdapterHasFeature(Get(), static_cast(feature)); + return result; +} +void Adapter::RequestDevice(DeviceDescriptor const *descriptor, + RequestDeviceCallback callback, + void *userdata) const { + wgpuAdapterRequestDevice( + Get(), reinterpret_cast(descriptor), + callback, userdata); +} +Future Adapter::RequestDevice(DeviceDescriptor const *options, + RequestDeviceCallbackInfo callbackInfo) const { + auto result = wgpuAdapterRequestDeviceF( + Get(), reinterpret_cast(options), + *reinterpret_cast(&callbackInfo)); + return Future{result.id}; +} +void Adapter::WGPUReference(WGPUAdapter handle) { + if (handle != nullptr) { + wgpuAdapterReference(handle); + } +} +void Adapter::WGPURelease(WGPUAdapter handle) { + if (handle != nullptr) { + wgpuAdapterRelease(handle); + } +} + +// BindGroup + +static_assert(sizeof(BindGroup) == sizeof(WGPUBindGroup), + "sizeof mismatch for BindGroup"); +static_assert(alignof(BindGroup) == alignof(WGPUBindGroup), + "alignof mismatch for BindGroup"); + +void BindGroup::SetLabel(char const *label) const { + wgpuBindGroupSetLabel(Get(), reinterpret_cast(label)); +} +void BindGroup::WGPUReference(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupReference(handle); + } +} +void BindGroup::WGPURelease(WGPUBindGroup handle) { + if (handle != nullptr) { + wgpuBindGroupRelease(handle); + } +} + +// BindGroupLayout + +static_assert(sizeof(BindGroupLayout) == sizeof(WGPUBindGroupLayout), + "sizeof mismatch for BindGroupLayout"); +static_assert(alignof(BindGroupLayout) == alignof(WGPUBindGroupLayout), + "alignof mismatch for BindGroupLayout"); + +void BindGroupLayout::SetLabel(char const *label) const { + wgpuBindGroupLayoutSetLabel(Get(), reinterpret_cast(label)); +} +void BindGroupLayout::WGPUReference(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutReference(handle); + } +} +void BindGroupLayout::WGPURelease(WGPUBindGroupLayout handle) { + if (handle != nullptr) { + wgpuBindGroupLayoutRelease(handle); + } +} + +// Buffer + +static_assert(sizeof(Buffer) == sizeof(WGPUBuffer), + "sizeof mismatch for Buffer"); +static_assert(alignof(Buffer) == alignof(WGPUBuffer), + "alignof mismatch for Buffer"); + +void Buffer::Destroy() const { wgpuBufferDestroy(Get()); } +void const *Buffer::GetConstMappedRange(size_t offset, size_t size) const { + auto result = wgpuBufferGetConstMappedRange(Get(), offset, size); + return result; +} +BufferMapState Buffer::GetMapState() const { + auto result = wgpuBufferGetMapState(Get()); + return static_cast(result); +} +void *Buffer::GetMappedRange(size_t offset, size_t size) const { + auto result = wgpuBufferGetMappedRange(Get(), offset, size); + return result; +} +uint64_t Buffer::GetSize() const { + auto result = wgpuBufferGetSize(Get()); + return result; +} +BufferUsage Buffer::GetUsage() const { + auto result = wgpuBufferGetUsage(Get()); + return static_cast(result); +} +void Buffer::MapAsync(MapMode mode, size_t offset, size_t size, + BufferMapCallback callback, void *userdata) const { + wgpuBufferMapAsync(Get(), static_cast(mode), offset, size, + callback, userdata); +} +Future Buffer::MapAsync(MapMode mode, size_t offset, size_t size, + BufferMapCallbackInfo callbackInfo) const { + auto result = wgpuBufferMapAsyncF( + Get(), static_cast(mode), offset, size, + *reinterpret_cast(&callbackInfo)); + return Future{result.id}; +} +void Buffer::SetLabel(char const *label) const { + wgpuBufferSetLabel(Get(), reinterpret_cast(label)); +} +void Buffer::Unmap() const { wgpuBufferUnmap(Get()); } +void Buffer::WGPUReference(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferReference(handle); + } +} +void Buffer::WGPURelease(WGPUBuffer handle) { + if (handle != nullptr) { + wgpuBufferRelease(handle); + } +} + +// CommandBuffer + +static_assert(sizeof(CommandBuffer) == sizeof(WGPUCommandBuffer), + "sizeof mismatch for CommandBuffer"); +static_assert(alignof(CommandBuffer) == alignof(WGPUCommandBuffer), + "alignof mismatch for CommandBuffer"); + +void CommandBuffer::SetLabel(char const *label) const { + wgpuCommandBufferSetLabel(Get(), reinterpret_cast(label)); +} +void CommandBuffer::WGPUReference(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferReference(handle); + } +} +void CommandBuffer::WGPURelease(WGPUCommandBuffer handle) { + if (handle != nullptr) { + wgpuCommandBufferRelease(handle); + } +} + +// CommandEncoder + +static_assert(sizeof(CommandEncoder) == sizeof(WGPUCommandEncoder), + "sizeof mismatch for CommandEncoder"); +static_assert(alignof(CommandEncoder) == alignof(WGPUCommandEncoder), + "alignof mismatch for CommandEncoder"); + +ComputePassEncoder CommandEncoder::BeginComputePass( + ComputePassDescriptor const *descriptor) const { + auto result = wgpuCommandEncoderBeginComputePass( + Get(), reinterpret_cast(descriptor)); + return ComputePassEncoder::Acquire(result); +} +RenderPassEncoder +CommandEncoder::BeginRenderPass(RenderPassDescriptor const *descriptor) const { + auto result = wgpuCommandEncoderBeginRenderPass( + Get(), reinterpret_cast(descriptor)); + return RenderPassEncoder::Acquire(result); +} +void CommandEncoder::ClearBuffer(Buffer const &buffer, uint64_t offset, + uint64_t size) const { + wgpuCommandEncoderClearBuffer(Get(), buffer.Get(), offset, size); +} +void CommandEncoder::CopyBufferToBuffer(Buffer const &source, + uint64_t sourceOffset, + Buffer const &destination, + uint64_t destinationOffset, + uint64_t size) const { + wgpuCommandEncoderCopyBufferToBuffer(Get(), source.Get(), sourceOffset, + destination.Get(), destinationOffset, + size); +} +void CommandEncoder::CopyBufferToTexture(ImageCopyBuffer const *source, + ImageCopyTexture const *destination, + Extent3D const *copySize) const { + wgpuCommandEncoderCopyBufferToTexture( + Get(), reinterpret_cast(source), + reinterpret_cast(destination), + reinterpret_cast(copySize)); +} +void CommandEncoder::CopyTextureToBuffer(ImageCopyTexture const *source, + ImageCopyBuffer const *destination, + Extent3D const *copySize) const { + wgpuCommandEncoderCopyTextureToBuffer( + Get(), reinterpret_cast(source), + reinterpret_cast(destination), + reinterpret_cast(copySize)); +} +void CommandEncoder::CopyTextureToTexture(ImageCopyTexture const *source, + ImageCopyTexture const *destination, + Extent3D const *copySize) const { + wgpuCommandEncoderCopyTextureToTexture( + Get(), reinterpret_cast(source), + reinterpret_cast(destination), + reinterpret_cast(copySize)); +} +CommandBuffer +CommandEncoder::Finish(CommandBufferDescriptor const *descriptor) const { + auto result = wgpuCommandEncoderFinish( + Get(), reinterpret_cast(descriptor)); + return CommandBuffer::Acquire(result); +} +void CommandEncoder::InjectValidationError(char const *message) const { + wgpuCommandEncoderInjectValidationError( + Get(), reinterpret_cast(message)); +} +void CommandEncoder::InsertDebugMarker(char const *markerLabel) const { + wgpuCommandEncoderInsertDebugMarker( + Get(), reinterpret_cast(markerLabel)); +} +void CommandEncoder::PopDebugGroup() const { + wgpuCommandEncoderPopDebugGroup(Get()); +} +void CommandEncoder::PushDebugGroup(char const *groupLabel) const { + wgpuCommandEncoderPushDebugGroup(Get(), + reinterpret_cast(groupLabel)); +} +void CommandEncoder::ResolveQuerySet(QuerySet const &querySet, + uint32_t firstQuery, uint32_t queryCount, + Buffer const &destination, + uint64_t destinationOffset) const { + wgpuCommandEncoderResolveQuerySet(Get(), querySet.Get(), firstQuery, + queryCount, destination.Get(), + destinationOffset); +} +void CommandEncoder::SetLabel(char const *label) const { + wgpuCommandEncoderSetLabel(Get(), reinterpret_cast(label)); +} +void CommandEncoder::WriteBuffer(Buffer const &buffer, uint64_t bufferOffset, + uint8_t const *data, uint64_t size) const { + wgpuCommandEncoderWriteBuffer(Get(), buffer.Get(), bufferOffset, + reinterpret_cast(data), size); +} +void CommandEncoder::WriteTimestamp(QuerySet const &querySet, + uint32_t queryIndex) const { + wgpuCommandEncoderWriteTimestamp(Get(), querySet.Get(), queryIndex); +} +void CommandEncoder::WGPUReference(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderReference(handle); + } +} +void CommandEncoder::WGPURelease(WGPUCommandEncoder handle) { + if (handle != nullptr) { + wgpuCommandEncoderRelease(handle); + } +} + +// ComputePassEncoder + +static_assert(sizeof(ComputePassEncoder) == sizeof(WGPUComputePassEncoder), + "sizeof mismatch for ComputePassEncoder"); +static_assert(alignof(ComputePassEncoder) == alignof(WGPUComputePassEncoder), + "alignof mismatch for ComputePassEncoder"); + +void ComputePassEncoder::DispatchWorkgroups(uint32_t workgroupCountX, + uint32_t workgroupCountY, + uint32_t workgroupCountZ) const { + wgpuComputePassEncoderDispatchWorkgroups(Get(), workgroupCountX, + workgroupCountY, workgroupCountZ); +} +void ComputePassEncoder::DispatchWorkgroupsIndirect( + Buffer const &indirectBuffer, uint64_t indirectOffset) const { + wgpuComputePassEncoderDispatchWorkgroupsIndirect(Get(), indirectBuffer.Get(), + indirectOffset); +} +void ComputePassEncoder::End() const { wgpuComputePassEncoderEnd(Get()); } +void ComputePassEncoder::InsertDebugMarker(char const *markerLabel) const { + wgpuComputePassEncoderInsertDebugMarker( + Get(), reinterpret_cast(markerLabel)); +} +void ComputePassEncoder::PopDebugGroup() const { + wgpuComputePassEncoderPopDebugGroup(Get()); +} +void ComputePassEncoder::PushDebugGroup(char const *groupLabel) const { + wgpuComputePassEncoderPushDebugGroup( + Get(), reinterpret_cast(groupLabel)); +} +void ComputePassEncoder::SetBindGroup(uint32_t groupIndex, + BindGroup const &group, + size_t dynamicOffsetCount, + uint32_t const *dynamicOffsets) const { + wgpuComputePassEncoderSetBindGroup( + Get(), groupIndex, group.Get(), dynamicOffsetCount, + reinterpret_cast(dynamicOffsets)); +} +void ComputePassEncoder::SetLabel(char const *label) const { + wgpuComputePassEncoderSetLabel(Get(), reinterpret_cast(label)); +} +void ComputePassEncoder::SetPipeline(ComputePipeline const &pipeline) const { + wgpuComputePassEncoderSetPipeline(Get(), pipeline.Get()); +} +void ComputePassEncoder::WriteTimestamp(QuerySet const &querySet, + uint32_t queryIndex) const { + wgpuComputePassEncoderWriteTimestamp(Get(), querySet.Get(), queryIndex); +} +void ComputePassEncoder::WGPUReference(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderReference(handle); + } +} +void ComputePassEncoder::WGPURelease(WGPUComputePassEncoder handle) { + if (handle != nullptr) { + wgpuComputePassEncoderRelease(handle); + } +} + +// ComputePipeline + +static_assert(sizeof(ComputePipeline) == sizeof(WGPUComputePipeline), + "sizeof mismatch for ComputePipeline"); +static_assert(alignof(ComputePipeline) == alignof(WGPUComputePipeline), + "alignof mismatch for ComputePipeline"); + +BindGroupLayout ComputePipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuComputePipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); +} +void ComputePipeline::SetLabel(char const *label) const { + wgpuComputePipelineSetLabel(Get(), reinterpret_cast(label)); +} +void ComputePipeline::WGPUReference(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineReference(handle); + } +} +void ComputePipeline::WGPURelease(WGPUComputePipeline handle) { + if (handle != nullptr) { + wgpuComputePipelineRelease(handle); + } +} + +// Device + +static_assert(sizeof(Device) == sizeof(WGPUDevice), + "sizeof mismatch for Device"); +static_assert(alignof(Device) == alignof(WGPUDevice), + "alignof mismatch for Device"); + +BindGroup Device::CreateBindGroup(BindGroupDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateBindGroup( + Get(), reinterpret_cast(descriptor)); + return BindGroup::Acquire(result); +} +BindGroupLayout Device::CreateBindGroupLayout( + BindGroupLayoutDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateBindGroupLayout( + Get(), + reinterpret_cast(descriptor)); + return BindGroupLayout::Acquire(result); +} +Buffer Device::CreateBuffer(BufferDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateBuffer( + Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); +} +CommandEncoder +Device::CreateCommandEncoder(CommandEncoderDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateCommandEncoder( + Get(), + reinterpret_cast(descriptor)); + return CommandEncoder::Acquire(result); +} +ComputePipeline Device::CreateComputePipeline( + ComputePipelineDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateComputePipeline( + Get(), + reinterpret_cast(descriptor)); + return ComputePipeline::Acquire(result); +} +void Device::CreateComputePipelineAsync( + ComputePipelineDescriptor const *descriptor, + CreateComputePipelineAsyncCallback callback, void *userdata) const { + wgpuDeviceCreateComputePipelineAsync( + Get(), + reinterpret_cast(descriptor), + callback, userdata); +} +Future Device::CreateComputePipelineAsync( + ComputePipelineDescriptor const *descriptor, + CreateComputePipelineAsyncCallbackInfo callbackInfo) const { + auto result = wgpuDeviceCreateComputePipelineAsyncF( + Get(), + reinterpret_cast(descriptor), + *reinterpret_cast( + &callbackInfo)); + return Future{result.id}; +} +Buffer Device::CreateErrorBuffer(BufferDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateErrorBuffer( + Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); +} +ExternalTexture Device::CreateErrorExternalTexture() const { + auto result = wgpuDeviceCreateErrorExternalTexture(Get()); + return ExternalTexture::Acquire(result); +} +ShaderModule +Device::CreateErrorShaderModule(ShaderModuleDescriptor const *descriptor, + char const *errorMessage) const { + auto result = wgpuDeviceCreateErrorShaderModule( + Get(), reinterpret_cast(descriptor), + reinterpret_cast(errorMessage)); + return ShaderModule::Acquire(result); +} +Texture Device::CreateErrorTexture(TextureDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateErrorTexture( + Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); +} +ExternalTexture Device::CreateExternalTexture( + ExternalTextureDescriptor const *externalTextureDescriptor) const { + auto result = wgpuDeviceCreateExternalTexture( + Get(), reinterpret_cast( + externalTextureDescriptor)); + return ExternalTexture::Acquire(result); +} +PipelineLayout +Device::CreatePipelineLayout(PipelineLayoutDescriptor const *descriptor) const { + auto result = wgpuDeviceCreatePipelineLayout( + Get(), + reinterpret_cast(descriptor)); + return PipelineLayout::Acquire(result); +} +QuerySet Device::CreateQuerySet(QuerySetDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateQuerySet( + Get(), reinterpret_cast(descriptor)); + return QuerySet::Acquire(result); +} +RenderBundleEncoder Device::CreateRenderBundleEncoder( + RenderBundleEncoderDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateRenderBundleEncoder( + Get(), + reinterpret_cast(descriptor)); + return RenderBundleEncoder::Acquire(result); +} +RenderPipeline +Device::CreateRenderPipeline(RenderPipelineDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateRenderPipeline( + Get(), + reinterpret_cast(descriptor)); + return RenderPipeline::Acquire(result); +} +void Device::CreateRenderPipelineAsync( + RenderPipelineDescriptor const *descriptor, + CreateRenderPipelineAsyncCallback callback, void *userdata) const { + wgpuDeviceCreateRenderPipelineAsync( + Get(), reinterpret_cast(descriptor), + callback, userdata); +} +Future Device::CreateRenderPipelineAsync( + RenderPipelineDescriptor const *descriptor, + CreateRenderPipelineAsyncCallbackInfo callbackInfo) const { + auto result = wgpuDeviceCreateRenderPipelineAsyncF( + Get(), reinterpret_cast(descriptor), + *reinterpret_cast( + &callbackInfo)); + return Future{result.id}; +} +Sampler Device::CreateSampler(SamplerDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateSampler( + Get(), reinterpret_cast(descriptor)); + return Sampler::Acquire(result); +} +ShaderModule +Device::CreateShaderModule(ShaderModuleDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateShaderModule( + Get(), reinterpret_cast(descriptor)); + return ShaderModule::Acquire(result); +} +SwapChain Device::CreateSwapChain(Surface const &surface, + SwapChainDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateSwapChain( + Get(), surface.Get(), + reinterpret_cast(descriptor)); + return SwapChain::Acquire(result); +} +Texture Device::CreateTexture(TextureDescriptor const *descriptor) const { + auto result = wgpuDeviceCreateTexture( + Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); +} +void Device::Destroy() const { wgpuDeviceDestroy(Get()); } +size_t Device::EnumerateFeatures(FeatureName *features) const { + auto result = wgpuDeviceEnumerateFeatures( + Get(), reinterpret_cast(features)); + return result; +} +void Device::ForceLoss(DeviceLostReason type, char const *message) const { + wgpuDeviceForceLoss(Get(), static_cast(type), + reinterpret_cast(message)); +} +Adapter Device::GetAdapter() const { + auto result = wgpuDeviceGetAdapter(Get()); + return Adapter::Acquire(result); +} +Bool Device::GetLimits(SupportedLimits *limits) const { + auto result = wgpuDeviceGetLimits( + Get(), reinterpret_cast(limits)); + return result; +} +Queue Device::GetQueue() const { + auto result = wgpuDeviceGetQueue(Get()); + return Queue::Acquire(result); +} +TextureUsage Device::GetSupportedSurfaceUsage(Surface const &surface) const { + auto result = wgpuDeviceGetSupportedSurfaceUsage(Get(), surface.Get()); + return static_cast(result); +} +Bool Device::HasFeature(FeatureName feature) const { + auto result = + wgpuDeviceHasFeature(Get(), static_cast(feature)); + return result; +} +SharedBufferMemory Device::ImportSharedBufferMemory( + SharedBufferMemoryDescriptor const *descriptor) const { + auto result = wgpuDeviceImportSharedBufferMemory( + Get(), + reinterpret_cast(descriptor)); + return SharedBufferMemory::Acquire(result); +} +SharedFence +Device::ImportSharedFence(SharedFenceDescriptor const *descriptor) const { + auto result = wgpuDeviceImportSharedFence( + Get(), reinterpret_cast(descriptor)); + return SharedFence::Acquire(result); +} +SharedTextureMemory Device::ImportSharedTextureMemory( + SharedTextureMemoryDescriptor const *descriptor) const { + auto result = wgpuDeviceImportSharedTextureMemory( + Get(), + reinterpret_cast(descriptor)); + return SharedTextureMemory::Acquire(result); +} +void Device::InjectError(ErrorType type, char const *message) const { + wgpuDeviceInjectError(Get(), static_cast(type), + reinterpret_cast(message)); +} +void Device::PopErrorScope(ErrorCallback oldCallback, void *userdata) const { + wgpuDevicePopErrorScope(Get(), oldCallback, userdata); +} +Future Device::PopErrorScope(PopErrorScopeCallbackInfo callbackInfo) const { + auto result = wgpuDevicePopErrorScopeF( + Get(), + *reinterpret_cast(&callbackInfo)); + return Future{result.id}; +} +void Device::PushErrorScope(ErrorFilter filter) const { + wgpuDevicePushErrorScope(Get(), static_cast(filter)); +} +void Device::SetDeviceLostCallback(DeviceLostCallback callback, + void *userdata) const { + wgpuDeviceSetDeviceLostCallback(Get(), callback, userdata); +} +void Device::SetLabel(char const *label) const { + wgpuDeviceSetLabel(Get(), reinterpret_cast(label)); +} +void Device::SetLoggingCallback(LoggingCallback callback, + void *userdata) const { + wgpuDeviceSetLoggingCallback(Get(), callback, userdata); +} +void Device::SetUncapturedErrorCallback(ErrorCallback callback, + void *userdata) const { + wgpuDeviceSetUncapturedErrorCallback(Get(), callback, userdata); +} +void Device::Tick() const { wgpuDeviceTick(Get()); } +void Device::ValidateTextureDescriptor( + TextureDescriptor const *descriptor) const { + wgpuDeviceValidateTextureDescriptor( + Get(), reinterpret_cast(descriptor)); +} +void Device::WGPUReference(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceReference(handle); + } +} +void Device::WGPURelease(WGPUDevice handle) { + if (handle != nullptr) { + wgpuDeviceRelease(handle); + } +} + +// ExternalTexture + +static_assert(sizeof(ExternalTexture) == sizeof(WGPUExternalTexture), + "sizeof mismatch for ExternalTexture"); +static_assert(alignof(ExternalTexture) == alignof(WGPUExternalTexture), + "alignof mismatch for ExternalTexture"); + +void ExternalTexture::Destroy() const { wgpuExternalTextureDestroy(Get()); } +void ExternalTexture::Expire() const { wgpuExternalTextureExpire(Get()); } +void ExternalTexture::Refresh() const { wgpuExternalTextureRefresh(Get()); } +void ExternalTexture::SetLabel(char const *label) const { + wgpuExternalTextureSetLabel(Get(), reinterpret_cast(label)); +} +void ExternalTexture::WGPUReference(WGPUExternalTexture handle) { + if (handle != nullptr) { + wgpuExternalTextureReference(handle); + } +} +void ExternalTexture::WGPURelease(WGPUExternalTexture handle) { + if (handle != nullptr) { + wgpuExternalTextureRelease(handle); + } +} + +// Instance + +static_assert(sizeof(Instance) == sizeof(WGPUInstance), + "sizeof mismatch for Instance"); +static_assert(alignof(Instance) == alignof(WGPUInstance), + "alignof mismatch for Instance"); + +Surface Instance::CreateSurface(SurfaceDescriptor const *descriptor) const { + auto result = wgpuInstanceCreateSurface( + Get(), reinterpret_cast(descriptor)); + return Surface::Acquire(result); +} +size_t +Instance::EnumerateWGSLLanguageFeatures(WGSLFeatureName *features) const { + auto result = wgpuInstanceEnumerateWGSLLanguageFeatures( + Get(), reinterpret_cast(features)); + return result; +} +Bool Instance::HasWGSLLanguageFeature(WGSLFeatureName feature) const { + auto result = wgpuInstanceHasWGSLLanguageFeature( + Get(), static_cast(feature)); + return result; +} +void Instance::ProcessEvents() const { wgpuInstanceProcessEvents(Get()); } +void Instance::RequestAdapter(RequestAdapterOptions const *options, + RequestAdapterCallback callback, + void *userdata) const { + wgpuInstanceRequestAdapter( + Get(), reinterpret_cast(options), + callback, userdata); +} +Future Instance::RequestAdapter(RequestAdapterOptions const *options, + RequestAdapterCallbackInfo callbackInfo) const { + auto result = wgpuInstanceRequestAdapterF( + Get(), reinterpret_cast(options), + *reinterpret_cast(&callbackInfo)); + return Future{result.id}; +} +WaitStatus Instance::WaitAny(size_t futureCount, FutureWaitInfo *futures, + uint64_t timeoutNS) const { + auto result = wgpuInstanceWaitAny( + Get(), futureCount, reinterpret_cast(futures), + timeoutNS); + return static_cast(result); +} +void Instance::WGPUReference(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceReference(handle); + } +} +void Instance::WGPURelease(WGPUInstance handle) { + if (handle != nullptr) { + wgpuInstanceRelease(handle); + } +} + +// PipelineLayout + +static_assert(sizeof(PipelineLayout) == sizeof(WGPUPipelineLayout), + "sizeof mismatch for PipelineLayout"); +static_assert(alignof(PipelineLayout) == alignof(WGPUPipelineLayout), + "alignof mismatch for PipelineLayout"); + +void PipelineLayout::SetLabel(char const *label) const { + wgpuPipelineLayoutSetLabel(Get(), reinterpret_cast(label)); +} +void PipelineLayout::WGPUReference(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutReference(handle); + } +} +void PipelineLayout::WGPURelease(WGPUPipelineLayout handle) { + if (handle != nullptr) { + wgpuPipelineLayoutRelease(handle); + } +} + +// QuerySet + +static_assert(sizeof(QuerySet) == sizeof(WGPUQuerySet), + "sizeof mismatch for QuerySet"); +static_assert(alignof(QuerySet) == alignof(WGPUQuerySet), + "alignof mismatch for QuerySet"); + +void QuerySet::Destroy() const { wgpuQuerySetDestroy(Get()); } +uint32_t QuerySet::GetCount() const { + auto result = wgpuQuerySetGetCount(Get()); + return result; +} +QueryType QuerySet::GetType() const { + auto result = wgpuQuerySetGetType(Get()); + return static_cast(result); +} +void QuerySet::SetLabel(char const *label) const { + wgpuQuerySetSetLabel(Get(), reinterpret_cast(label)); +} +void QuerySet::WGPUReference(WGPUQuerySet handle) { + if (handle != nullptr) { + wgpuQuerySetReference(handle); + } +} +void QuerySet::WGPURelease(WGPUQuerySet handle) { + if (handle != nullptr) { + wgpuQuerySetRelease(handle); + } +} + +// Queue + +static_assert(sizeof(Queue) == sizeof(WGPUQueue), "sizeof mismatch for Queue"); +static_assert(alignof(Queue) == alignof(WGPUQueue), + "alignof mismatch for Queue"); + +void Queue::CopyExternalTextureForBrowser( + ImageCopyExternalTexture const *source, ImageCopyTexture const *destination, + Extent3D const *copySize, + CopyTextureForBrowserOptions const *options) const { + wgpuQueueCopyExternalTextureForBrowser( + Get(), reinterpret_cast(source), + reinterpret_cast(destination), + reinterpret_cast(copySize), + reinterpret_cast(options)); +} +void Queue::CopyTextureForBrowser( + ImageCopyTexture const *source, ImageCopyTexture const *destination, + Extent3D const *copySize, + CopyTextureForBrowserOptions const *options) const { + wgpuQueueCopyTextureForBrowser( + Get(), reinterpret_cast(source), + reinterpret_cast(destination), + reinterpret_cast(copySize), + reinterpret_cast(options)); +} +void Queue::OnSubmittedWorkDone(QueueWorkDoneCallback callback, + void *userdata) const { + wgpuQueueOnSubmittedWorkDone(Get(), callback, userdata); +} +Future +Queue::OnSubmittedWorkDone(QueueWorkDoneCallbackInfo callbackInfo) const { + auto result = wgpuQueueOnSubmittedWorkDoneF( + Get(), + *reinterpret_cast(&callbackInfo)); + return Future{result.id}; +} +void Queue::SetLabel(char const *label) const { + wgpuQueueSetLabel(Get(), reinterpret_cast(label)); +} +void Queue::Submit(size_t commandCount, CommandBuffer const *commands) const { + wgpuQueueSubmit(Get(), commandCount, + reinterpret_cast(commands)); +} +void Queue::WriteBuffer(Buffer const &buffer, uint64_t bufferOffset, + void const *data, size_t size) const { + wgpuQueueWriteBuffer(Get(), buffer.Get(), bufferOffset, + reinterpret_cast(data), size); +} +void Queue::WriteTexture(ImageCopyTexture const *destination, void const *data, + size_t dataSize, TextureDataLayout const *dataLayout, + Extent3D const *writeSize) const { + wgpuQueueWriteTexture( + Get(), reinterpret_cast(destination), + reinterpret_cast(data), dataSize, + reinterpret_cast(dataLayout), + reinterpret_cast(writeSize)); +} +void Queue::WGPUReference(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueReference(handle); + } +} +void Queue::WGPURelease(WGPUQueue handle) { + if (handle != nullptr) { + wgpuQueueRelease(handle); + } +} + +// RenderBundle + +static_assert(sizeof(RenderBundle) == sizeof(WGPURenderBundle), + "sizeof mismatch for RenderBundle"); +static_assert(alignof(RenderBundle) == alignof(WGPURenderBundle), + "alignof mismatch for RenderBundle"); + +void RenderBundle::SetLabel(char const *label) const { + wgpuRenderBundleSetLabel(Get(), reinterpret_cast(label)); +} +void RenderBundle::WGPUReference(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleReference(handle); + } +} +void RenderBundle::WGPURelease(WGPURenderBundle handle) { + if (handle != nullptr) { + wgpuRenderBundleRelease(handle); + } +} + +// RenderBundleEncoder + +static_assert(sizeof(RenderBundleEncoder) == sizeof(WGPURenderBundleEncoder), + "sizeof mismatch for RenderBundleEncoder"); +static_assert(alignof(RenderBundleEncoder) == alignof(WGPURenderBundleEncoder), + "alignof mismatch for RenderBundleEncoder"); + +void RenderBundleEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance) const { + wgpuRenderBundleEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, + firstInstance); +} +void RenderBundleEncoder::DrawIndexed(uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, int32_t baseVertex, + uint32_t firstInstance) const { + wgpuRenderBundleEncoderDrawIndexed(Get(), indexCount, instanceCount, + firstIndex, baseVertex, firstInstance); +} +void RenderBundleEncoder::DrawIndexedIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), + indirectOffset); +} +void RenderBundleEncoder::DrawIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const { + wgpuRenderBundleEncoderDrawIndirect(Get(), indirectBuffer.Get(), + indirectOffset); +} +RenderBundle +RenderBundleEncoder::Finish(RenderBundleDescriptor const *descriptor) const { + auto result = wgpuRenderBundleEncoderFinish( + Get(), reinterpret_cast(descriptor)); + return RenderBundle::Acquire(result); +} +void RenderBundleEncoder::InsertDebugMarker(char const *markerLabel) const { + wgpuRenderBundleEncoderInsertDebugMarker( + Get(), reinterpret_cast(markerLabel)); +} +void RenderBundleEncoder::PopDebugGroup() const { + wgpuRenderBundleEncoderPopDebugGroup(Get()); +} +void RenderBundleEncoder::PushDebugGroup(char const *groupLabel) const { + wgpuRenderBundleEncoderPushDebugGroup( + Get(), reinterpret_cast(groupLabel)); +} +void RenderBundleEncoder::SetBindGroup(uint32_t groupIndex, + BindGroup const &group, + size_t dynamicOffsetCount, + uint32_t const *dynamicOffsets) const { + wgpuRenderBundleEncoderSetBindGroup( + Get(), groupIndex, group.Get(), dynamicOffsetCount, + reinterpret_cast(dynamicOffsets)); +} +void RenderBundleEncoder::SetIndexBuffer(Buffer const &buffer, + IndexFormat format, uint64_t offset, + uint64_t size) const { + wgpuRenderBundleEncoderSetIndexBuffer( + Get(), buffer.Get(), static_cast(format), offset, size); +} +void RenderBundleEncoder::SetLabel(char const *label) const { + wgpuRenderBundleEncoderSetLabel(Get(), reinterpret_cast(label)); +} +void RenderBundleEncoder::SetPipeline(RenderPipeline const &pipeline) const { + wgpuRenderBundleEncoderSetPipeline(Get(), pipeline.Get()); +} +void RenderBundleEncoder::SetVertexBuffer(uint32_t slot, Buffer const &buffer, + uint64_t offset, + uint64_t size) const { + wgpuRenderBundleEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, + size); +} +void RenderBundleEncoder::WGPUReference(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderReference(handle); + } +} +void RenderBundleEncoder::WGPURelease(WGPURenderBundleEncoder handle) { + if (handle != nullptr) { + wgpuRenderBundleEncoderRelease(handle); + } +} + +// RenderPassEncoder + +static_assert(sizeof(RenderPassEncoder) == sizeof(WGPURenderPassEncoder), + "sizeof mismatch for RenderPassEncoder"); +static_assert(alignof(RenderPassEncoder) == alignof(WGPURenderPassEncoder), + "alignof mismatch for RenderPassEncoder"); + +void RenderPassEncoder::BeginOcclusionQuery(uint32_t queryIndex) const { + wgpuRenderPassEncoderBeginOcclusionQuery(Get(), queryIndex); +} +void RenderPassEncoder::Draw(uint32_t vertexCount, uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance) const { + wgpuRenderPassEncoderDraw(Get(), vertexCount, instanceCount, firstVertex, + firstInstance); +} +void RenderPassEncoder::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, + uint32_t firstIndex, int32_t baseVertex, + uint32_t firstInstance) const { + wgpuRenderPassEncoderDrawIndexed(Get(), indexCount, instanceCount, firstIndex, + baseVertex, firstInstance); +} +void RenderPassEncoder::DrawIndexedIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndexedIndirect(Get(), indirectBuffer.Get(), + indirectOffset); +} +void RenderPassEncoder::DrawIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const { + wgpuRenderPassEncoderDrawIndirect(Get(), indirectBuffer.Get(), + indirectOffset); +} +void RenderPassEncoder::End() const { wgpuRenderPassEncoderEnd(Get()); } +void RenderPassEncoder::EndOcclusionQuery() const { + wgpuRenderPassEncoderEndOcclusionQuery(Get()); +} +void RenderPassEncoder::ExecuteBundles(size_t bundleCount, + RenderBundle const *bundles) const { + wgpuRenderPassEncoderExecuteBundles( + Get(), bundleCount, reinterpret_cast(bundles)); +} +void RenderPassEncoder::InsertDebugMarker(char const *markerLabel) const { + wgpuRenderPassEncoderInsertDebugMarker( + Get(), reinterpret_cast(markerLabel)); +} +void RenderPassEncoder::PixelLocalStorageBarrier() const { + wgpuRenderPassEncoderPixelLocalStorageBarrier(Get()); +} +void RenderPassEncoder::PopDebugGroup() const { + wgpuRenderPassEncoderPopDebugGroup(Get()); +} +void RenderPassEncoder::PushDebugGroup(char const *groupLabel) const { + wgpuRenderPassEncoderPushDebugGroup( + Get(), reinterpret_cast(groupLabel)); +} +void RenderPassEncoder::SetBindGroup(uint32_t groupIndex, + BindGroup const &group, + size_t dynamicOffsetCount, + uint32_t const *dynamicOffsets) const { + wgpuRenderPassEncoderSetBindGroup( + Get(), groupIndex, group.Get(), dynamicOffsetCount, + reinterpret_cast(dynamicOffsets)); +} +void RenderPassEncoder::SetBlendConstant(Color const *color) const { + wgpuRenderPassEncoderSetBlendConstant( + Get(), reinterpret_cast(color)); +} +void RenderPassEncoder::SetIndexBuffer(Buffer const &buffer, IndexFormat format, + uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetIndexBuffer( + Get(), buffer.Get(), static_cast(format), offset, size); +} +void RenderPassEncoder::SetLabel(char const *label) const { + wgpuRenderPassEncoderSetLabel(Get(), reinterpret_cast(label)); +} +void RenderPassEncoder::SetPipeline(RenderPipeline const &pipeline) const { + wgpuRenderPassEncoderSetPipeline(Get(), pipeline.Get()); +} +void RenderPassEncoder::SetScissorRect(uint32_t x, uint32_t y, uint32_t width, + uint32_t height) const { + wgpuRenderPassEncoderSetScissorRect(Get(), x, y, width, height); +} +void RenderPassEncoder::SetStencilReference(uint32_t reference) const { + wgpuRenderPassEncoderSetStencilReference(Get(), reference); +} +void RenderPassEncoder::SetVertexBuffer(uint32_t slot, Buffer const &buffer, + uint64_t offset, uint64_t size) const { + wgpuRenderPassEncoderSetVertexBuffer(Get(), slot, buffer.Get(), offset, size); +} +void RenderPassEncoder::SetViewport(float x, float y, float width, float height, + float minDepth, float maxDepth) const { + wgpuRenderPassEncoderSetViewport(Get(), x, y, width, height, minDepth, + maxDepth); +} +void RenderPassEncoder::WriteTimestamp(QuerySet const &querySet, + uint32_t queryIndex) const { + wgpuRenderPassEncoderWriteTimestamp(Get(), querySet.Get(), queryIndex); +} +void RenderPassEncoder::WGPUReference(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderReference(handle); + } +} +void RenderPassEncoder::WGPURelease(WGPURenderPassEncoder handle) { + if (handle != nullptr) { + wgpuRenderPassEncoderRelease(handle); + } +} + +// RenderPipeline + +static_assert(sizeof(RenderPipeline) == sizeof(WGPURenderPipeline), + "sizeof mismatch for RenderPipeline"); +static_assert(alignof(RenderPipeline) == alignof(WGPURenderPipeline), + "alignof mismatch for RenderPipeline"); + +BindGroupLayout RenderPipeline::GetBindGroupLayout(uint32_t groupIndex) const { + auto result = wgpuRenderPipelineGetBindGroupLayout(Get(), groupIndex); + return BindGroupLayout::Acquire(result); +} +void RenderPipeline::SetLabel(char const *label) const { + wgpuRenderPipelineSetLabel(Get(), reinterpret_cast(label)); +} +void RenderPipeline::WGPUReference(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineReference(handle); + } +} +void RenderPipeline::WGPURelease(WGPURenderPipeline handle) { + if (handle != nullptr) { + wgpuRenderPipelineRelease(handle); + } +} + +// Sampler + +static_assert(sizeof(Sampler) == sizeof(WGPUSampler), + "sizeof mismatch for Sampler"); +static_assert(alignof(Sampler) == alignof(WGPUSampler), + "alignof mismatch for Sampler"); + +void Sampler::SetLabel(char const *label) const { + wgpuSamplerSetLabel(Get(), reinterpret_cast(label)); +} +void Sampler::WGPUReference(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerReference(handle); + } +} +void Sampler::WGPURelease(WGPUSampler handle) { + if (handle != nullptr) { + wgpuSamplerRelease(handle); + } +} + +// ShaderModule + +static_assert(sizeof(ShaderModule) == sizeof(WGPUShaderModule), + "sizeof mismatch for ShaderModule"); +static_assert(alignof(ShaderModule) == alignof(WGPUShaderModule), + "alignof mismatch for ShaderModule"); + +void ShaderModule::GetCompilationInfo(CompilationInfoCallback callback, + void *userdata) const { + wgpuShaderModuleGetCompilationInfo(Get(), callback, userdata); +} +Future ShaderModule::GetCompilationInfo( + CompilationInfoCallbackInfo callbackInfo) const { + auto result = wgpuShaderModuleGetCompilationInfoF( + Get(), *reinterpret_cast( + &callbackInfo)); + return Future{result.id}; +} +void ShaderModule::SetLabel(char const *label) const { + wgpuShaderModuleSetLabel(Get(), reinterpret_cast(label)); +} +void ShaderModule::WGPUReference(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleReference(handle); + } +} +void ShaderModule::WGPURelease(WGPUShaderModule handle) { + if (handle != nullptr) { + wgpuShaderModuleRelease(handle); + } +} + +// SharedBufferMemory + +static_assert(sizeof(SharedBufferMemory) == sizeof(WGPUSharedBufferMemory), + "sizeof mismatch for SharedBufferMemory"); +static_assert(alignof(SharedBufferMemory) == alignof(WGPUSharedBufferMemory), + "alignof mismatch for SharedBufferMemory"); + +Bool SharedBufferMemory::BeginAccess( + Buffer const &buffer, + SharedBufferMemoryBeginAccessDescriptor const *descriptor) const { + auto result = wgpuSharedBufferMemoryBeginAccess( + Get(), buffer.Get(), + reinterpret_cast( + descriptor)); + return result; +} +Buffer +SharedBufferMemory::CreateBuffer(BufferDescriptor const *descriptor) const { + auto result = wgpuSharedBufferMemoryCreateBuffer( + Get(), reinterpret_cast(descriptor)); + return Buffer::Acquire(result); +} +Bool SharedBufferMemory::EndAccess( + Buffer const &buffer, SharedBufferMemoryEndAccessState *descriptor) const { + *descriptor = SharedBufferMemoryEndAccessState(); + auto result = wgpuSharedBufferMemoryEndAccess( + Get(), buffer.Get(), + reinterpret_cast(descriptor)); + return result; +} +void SharedBufferMemory::GetProperties( + SharedBufferMemoryProperties *properties) const { + wgpuSharedBufferMemoryGetProperties( + Get(), reinterpret_cast(properties)); +} +Bool SharedBufferMemory::IsDeviceLost() const { + auto result = wgpuSharedBufferMemoryIsDeviceLost(Get()); + return result; +} +void SharedBufferMemory::SetLabel(char const *label) const { + wgpuSharedBufferMemorySetLabel(Get(), reinterpret_cast(label)); +} +void SharedBufferMemory::WGPUReference(WGPUSharedBufferMemory handle) { + if (handle != nullptr) { + wgpuSharedBufferMemoryReference(handle); + } +} +void SharedBufferMemory::WGPURelease(WGPUSharedBufferMemory handle) { + if (handle != nullptr) { + wgpuSharedBufferMemoryRelease(handle); + } +} + +// SharedFence + +static_assert(sizeof(SharedFence) == sizeof(WGPUSharedFence), + "sizeof mismatch for SharedFence"); +static_assert(alignof(SharedFence) == alignof(WGPUSharedFence), + "alignof mismatch for SharedFence"); + +void SharedFence::ExportInfo(SharedFenceExportInfo *info) const { + wgpuSharedFenceExportInfo( + Get(), reinterpret_cast(info)); +} +void SharedFence::WGPUReference(WGPUSharedFence handle) { + if (handle != nullptr) { + wgpuSharedFenceReference(handle); + } +} +void SharedFence::WGPURelease(WGPUSharedFence handle) { + if (handle != nullptr) { + wgpuSharedFenceRelease(handle); + } +} + +// SharedTextureMemory + +static_assert(sizeof(SharedTextureMemory) == sizeof(WGPUSharedTextureMemory), + "sizeof mismatch for SharedTextureMemory"); +static_assert(alignof(SharedTextureMemory) == alignof(WGPUSharedTextureMemory), + "alignof mismatch for SharedTextureMemory"); + +Bool SharedTextureMemory::BeginAccess( + Texture const &texture, + SharedTextureMemoryBeginAccessDescriptor const *descriptor) const { + auto result = wgpuSharedTextureMemoryBeginAccess( + Get(), texture.Get(), + reinterpret_cast( + descriptor)); + return result; +} +Texture +SharedTextureMemory::CreateTexture(TextureDescriptor const *descriptor) const { + auto result = wgpuSharedTextureMemoryCreateTexture( + Get(), reinterpret_cast(descriptor)); + return Texture::Acquire(result); +} +Bool SharedTextureMemory::EndAccess( + Texture const &texture, + SharedTextureMemoryEndAccessState *descriptor) const { + *descriptor = SharedTextureMemoryEndAccessState(); + auto result = wgpuSharedTextureMemoryEndAccess( + Get(), texture.Get(), + reinterpret_cast(descriptor)); + return result; +} +void SharedTextureMemory::GetProperties( + SharedTextureMemoryProperties *properties) const { + wgpuSharedTextureMemoryGetProperties( + Get(), reinterpret_cast(properties)); +} +Bool SharedTextureMemory::IsDeviceLost() const { + auto result = wgpuSharedTextureMemoryIsDeviceLost(Get()); + return result; +} +void SharedTextureMemory::SetLabel(char const *label) const { + wgpuSharedTextureMemorySetLabel(Get(), reinterpret_cast(label)); +} +void SharedTextureMemory::WGPUReference(WGPUSharedTextureMemory handle) { + if (handle != nullptr) { + wgpuSharedTextureMemoryReference(handle); + } +} +void SharedTextureMemory::WGPURelease(WGPUSharedTextureMemory handle) { + if (handle != nullptr) { + wgpuSharedTextureMemoryRelease(handle); + } +} + +// Surface + +static_assert(sizeof(Surface) == sizeof(WGPUSurface), + "sizeof mismatch for Surface"); +static_assert(alignof(Surface) == alignof(WGPUSurface), + "alignof mismatch for Surface"); + +TextureFormat Surface::GetPreferredFormat(Adapter const &adapter) const { + auto result = wgpuSurfaceGetPreferredFormat(Get(), adapter.Get()); + return static_cast(result); +} +void Surface::WGPUReference(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceReference(handle); + } +} +void Surface::WGPURelease(WGPUSurface handle) { + if (handle != nullptr) { + wgpuSurfaceRelease(handle); + } +} + +// SwapChain + +static_assert(sizeof(SwapChain) == sizeof(WGPUSwapChain), + "sizeof mismatch for SwapChain"); +static_assert(alignof(SwapChain) == alignof(WGPUSwapChain), + "alignof mismatch for SwapChain"); + +Texture SwapChain::GetCurrentTexture() const { + auto result = wgpuSwapChainGetCurrentTexture(Get()); + return Texture::Acquire(result); +} +TextureView SwapChain::GetCurrentTextureView() const { + auto result = wgpuSwapChainGetCurrentTextureView(Get()); + return TextureView::Acquire(result); +} +void SwapChain::Present() const { wgpuSwapChainPresent(Get()); } +void SwapChain::WGPUReference(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainReference(handle); + } +} +void SwapChain::WGPURelease(WGPUSwapChain handle) { + if (handle != nullptr) { + wgpuSwapChainRelease(handle); + } +} + +// Texture + +static_assert(sizeof(Texture) == sizeof(WGPUTexture), + "sizeof mismatch for Texture"); +static_assert(alignof(Texture) == alignof(WGPUTexture), + "alignof mismatch for Texture"); + +TextureView +Texture::CreateErrorView(TextureViewDescriptor const *descriptor) const { + auto result = wgpuTextureCreateErrorView( + Get(), reinterpret_cast(descriptor)); + return TextureView::Acquire(result); +} +TextureView Texture::CreateView(TextureViewDescriptor const *descriptor) const { + auto result = wgpuTextureCreateView( + Get(), reinterpret_cast(descriptor)); + return TextureView::Acquire(result); +} +void Texture::Destroy() const { wgpuTextureDestroy(Get()); } +uint32_t Texture::GetDepthOrArrayLayers() const { + auto result = wgpuTextureGetDepthOrArrayLayers(Get()); + return result; +} +TextureDimension Texture::GetDimension() const { + auto result = wgpuTextureGetDimension(Get()); + return static_cast(result); +} +TextureFormat Texture::GetFormat() const { + auto result = wgpuTextureGetFormat(Get()); + return static_cast(result); +} +uint32_t Texture::GetHeight() const { + auto result = wgpuTextureGetHeight(Get()); + return result; +} +uint32_t Texture::GetMipLevelCount() const { + auto result = wgpuTextureGetMipLevelCount(Get()); + return result; +} +uint32_t Texture::GetSampleCount() const { + auto result = wgpuTextureGetSampleCount(Get()); + return result; +} +TextureUsage Texture::GetUsage() const { + auto result = wgpuTextureGetUsage(Get()); + return static_cast(result); +} +uint32_t Texture::GetWidth() const { + auto result = wgpuTextureGetWidth(Get()); + return result; +} +void Texture::SetLabel(char const *label) const { + wgpuTextureSetLabel(Get(), reinterpret_cast(label)); +} +void Texture::WGPUReference(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureReference(handle); + } +} +void Texture::WGPURelease(WGPUTexture handle) { + if (handle != nullptr) { + wgpuTextureRelease(handle); + } +} + +// TextureView + +static_assert(sizeof(TextureView) == sizeof(WGPUTextureView), + "sizeof mismatch for TextureView"); +static_assert(alignof(TextureView) == alignof(WGPUTextureView), + "alignof mismatch for TextureView"); + +void TextureView::SetLabel(char const *label) const { + wgpuTextureViewSetLabel(Get(), reinterpret_cast(label)); +} +void TextureView::WGPUReference(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewReference(handle); + } +} +void TextureView::WGPURelease(WGPUTextureView handle) { + if (handle != nullptr) { + wgpuTextureViewRelease(handle); + } +} + +// Function + +Instance CreateInstance(InstanceDescriptor const *descriptor) { + auto result = wgpuCreateInstance( + reinterpret_cast(descriptor)); + return Instance::Acquire(result); +} +Bool GetInstanceFeatures(InstanceFeatures *features) { + auto result = wgpuGetInstanceFeatures( + reinterpret_cast(features)); + return result; +} +Proc GetProcAddress(Device device, char const *procName) { + auto result = wgpuGetProcAddress(device.Get(), + reinterpret_cast(procName)); + return reinterpret_cast(result); +} + +} // namespace wgpu diff --git a/package/android/cpp/rnskia-android/dawn/webgpu_cpp.h b/package/android/cpp/rnskia-android/dawn/webgpu_cpp.h new file mode 100644 index 0000000000..4b7ca41535 --- /dev/null +++ b/package/android/cpp/rnskia-android/dawn/webgpu_cpp.h @@ -0,0 +1,2991 @@ +#ifdef __EMSCRIPTEN__ +#error \ + "Do not include this header. Emscripten already provides headers needed for WebGPU." +#endif +#ifndef WEBGPU_CPP_H_ +#define WEBGPU_CPP_H_ + +#include "webgpu/webgpu.h" +#include "webgpu/webgpu_cpp_chained_struct.h" +#include "webgpu/webgpu_enum_class_bitmasks.h" +#include +#include +#include +#include + +namespace wgpu { + +namespace detail { +constexpr size_t ConstexprMax(size_t a, size_t b) { return a > b ? a : b; } +} // namespace detail + +static constexpr uint32_t kArrayLayerCountUndefined = + WGPU_ARRAY_LAYER_COUNT_UNDEFINED; +static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED; +static constexpr uint32_t kDepthSliceUndefined = WGPU_DEPTH_SLICE_UNDEFINED; +static constexpr uint32_t kLimitU32Undefined = WGPU_LIMIT_U32_UNDEFINED; +static constexpr uint64_t kLimitU64Undefined = WGPU_LIMIT_U64_UNDEFINED; +static constexpr uint32_t kMipLevelCountUndefined = + WGPU_MIP_LEVEL_COUNT_UNDEFINED; +static constexpr uint32_t kQuerySetIndexUndefined = + WGPU_QUERY_SET_INDEX_UNDEFINED; +static constexpr size_t kWholeMapSize = WGPU_WHOLE_MAP_SIZE; +static constexpr uint64_t kWholeSize = WGPU_WHOLE_SIZE; + +enum class WGSLFeatureName : uint32_t { + Undefined = 0x00000000, + ReadonlyAndReadwriteStorageTextures = 0x00000001, + Packed4x8IntegerDotProduct = 0x00000002, + UnrestrictedPointerParameters = 0x00000003, + PointerCompositeAccess = 0x00000004, + ChromiumTestingUnimplemented = 0x000003E8, + ChromiumTestingUnsafeExperimental = 0x000003E9, + ChromiumTestingExperimental = 0x000003EA, + ChromiumTestingShippedWithKillswitch = 0x000003EB, + ChromiumTestingShipped = 0x000003EC, +}; + +enum class AdapterType : uint32_t { + DiscreteGPU = 0x00000001, + IntegratedGPU = 0x00000002, + CPU = 0x00000003, + Unknown = 0x00000004, +}; + +enum class AddressMode : uint32_t { + Undefined = 0x00000000, + ClampToEdge = 0x00000001, + Repeat = 0x00000002, + MirrorRepeat = 0x00000003, +}; + +enum class AlphaMode : uint32_t { + Opaque = 0x00000001, + Premultiplied = 0x00000002, + Unpremultiplied = 0x00000003, +}; + +enum class BackendType : uint32_t { + Undefined = 0x00000000, + Null = 0x00000001, + WebGPU = 0x00000002, + D3D11 = 0x00000003, + D3D12 = 0x00000004, + Metal = 0x00000005, + Vulkan = 0x00000006, + OpenGL = 0x00000007, + OpenGLES = 0x00000008, +}; + +enum class BlendFactor : uint32_t { + Undefined = 0x00000000, + Zero = 0x00000001, + One = 0x00000002, + Src = 0x00000003, + OneMinusSrc = 0x00000004, + SrcAlpha = 0x00000005, + OneMinusSrcAlpha = 0x00000006, + Dst = 0x00000007, + OneMinusDst = 0x00000008, + DstAlpha = 0x00000009, + OneMinusDstAlpha = 0x0000000A, + SrcAlphaSaturated = 0x0000000B, + Constant = 0x0000000C, + OneMinusConstant = 0x0000000D, + Src1 = 0x0000000E, + OneMinusSrc1 = 0x0000000F, + Src1Alpha = 0x00000010, + OneMinusSrc1Alpha = 0x00000011, +}; + +enum class BlendOperation : uint32_t { + Undefined = 0x00000000, + Add = 0x00000001, + Subtract = 0x00000002, + ReverseSubtract = 0x00000003, + Min = 0x00000004, + Max = 0x00000005, +}; + +enum class BufferBindingType : uint32_t { + Undefined = 0x00000000, + Uniform = 0x00000001, + Storage = 0x00000002, + ReadOnlyStorage = 0x00000003, +}; + +enum class BufferMapAsyncStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + ValidationError = 0x00000002, + Unknown = 0x00000003, + DeviceLost = 0x00000004, + DestroyedBeforeCallback = 0x00000005, + UnmappedBeforeCallback = 0x00000006, + MappingAlreadyPending = 0x00000007, + OffsetOutOfRange = 0x00000008, + SizeOutOfRange = 0x00000009, +}; + +enum class BufferMapState : uint32_t { + Unmapped = 0x00000001, + Pending = 0x00000002, + Mapped = 0x00000003, +}; + +enum class CallbackMode : uint32_t { + WaitAnyOnly = 0x00000000, + AllowProcessEvents = 0x00000001, + AllowSpontaneous = 0x00000002, +}; + +enum class CompareFunction : uint32_t { + Undefined = 0x00000000, + Never = 0x00000001, + Less = 0x00000002, + Equal = 0x00000003, + LessEqual = 0x00000004, + Greater = 0x00000005, + NotEqual = 0x00000006, + GreaterEqual = 0x00000007, + Always = 0x00000008, +}; + +enum class CompilationInfoRequestStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + Error = 0x00000002, + DeviceLost = 0x00000003, + Unknown = 0x00000004, +}; + +enum class CompilationMessageType : uint32_t { + Error = 0x00000001, + Warning = 0x00000002, + Info = 0x00000003, +}; + +enum class CreatePipelineAsyncStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + ValidationError = 0x00000002, + InternalError = 0x00000003, + DeviceLost = 0x00000004, + DeviceDestroyed = 0x00000005, + Unknown = 0x00000006, +}; + +enum class CullMode : uint32_t { + Undefined = 0x00000000, + None = 0x00000001, + Front = 0x00000002, + Back = 0x00000003, +}; + +enum class DeviceLostReason : uint32_t { + Undefined = 0x00000000, + Destroyed = 0x00000001, +}; + +enum class ErrorFilter : uint32_t { + Validation = 0x00000001, + OutOfMemory = 0x00000002, + Internal = 0x00000003, +}; + +enum class ErrorType : uint32_t { + NoError = 0x00000000, + Validation = 0x00000001, + OutOfMemory = 0x00000002, + Internal = 0x00000003, + Unknown = 0x00000004, + DeviceLost = 0x00000005, +}; + +enum class ExternalTextureRotation : uint32_t { + Rotate0Degrees = 0x00000000, + Rotate90Degrees = 0x00000001, + Rotate180Degrees = 0x00000002, + Rotate270Degrees = 0x00000003, +}; + +enum class FeatureName : uint32_t { + Undefined = 0x00000000, + DepthClipControl = 0x00000001, + Depth32FloatStencil8 = 0x00000002, + TimestampQuery = 0x00000003, + TextureCompressionBC = 0x00000004, + TextureCompressionETC2 = 0x00000005, + TextureCompressionASTC = 0x00000006, + IndirectFirstInstance = 0x00000007, + ShaderF16 = 0x00000008, + RG11B10UfloatRenderable = 0x00000009, + BGRA8UnormStorage = 0x0000000A, + Float32Filterable = 0x0000000B, + DawnInternalUsages = 0x000003EA, + DawnMultiPlanarFormats = 0x000003EB, + DawnNative = 0x000003EC, + ChromiumExperimentalTimestampQueryInsidePasses = 0x000003EE, + ImplicitDeviceSynchronization = 0x000003EF, + SurfaceCapabilities = 0x000003F0, + TransientAttachments = 0x000003F1, + MSAARenderToSingleSampled = 0x000003F2, + DualSourceBlending = 0x000003F3, + D3D11MultithreadProtected = 0x000003F4, + ANGLETextureSharing = 0x000003F5, + ChromiumExperimentalSubgroups = 0x000003F6, + ChromiumExperimentalSubgroupUniformControlFlow = 0x000003F7, + PixelLocalStorageCoherent = 0x000003F9, + PixelLocalStorageNonCoherent = 0x000003FA, + Unorm16TextureFormats = 0x000003FB, + Snorm16TextureFormats = 0x000003FC, + MultiPlanarFormatExtendedUsages = 0x000003FD, + MultiPlanarFormatP010 = 0x000003FE, + HostMappedPointer = 0x000003FF, + MultiPlanarRenderTargets = 0x00000400, + MultiPlanarFormatNv12a = 0x00000401, + FramebufferFetch = 0x00000402, + BufferMapExtendedUsages = 0x00000403, + AdapterPropertiesMemoryHeaps = 0x00000404, + AdapterPropertiesD3D = 0x00000405, + AdapterPropertiesVk = 0x00000406, + R8UnormStorage = 0x00000407, + FormatCapabilities = 0x00000408, + DrmFormatCapabilities = 0x00000409, + Norm16TextureFormats = 0x0000040A, + SharedTextureMemoryVkDedicatedAllocation = 0x0000044C, + SharedTextureMemoryAHardwareBuffer = 0x0000044D, + SharedTextureMemoryDmaBuf = 0x0000044E, + SharedTextureMemoryOpaqueFD = 0x0000044F, + SharedTextureMemoryZirconHandle = 0x00000450, + SharedTextureMemoryDXGISharedHandle = 0x00000451, + SharedTextureMemoryD3D11Texture2D = 0x00000452, + SharedTextureMemoryIOSurface = 0x00000453, + SharedTextureMemoryEGLImage = 0x00000454, + SharedFenceVkSemaphoreOpaqueFD = 0x000004B0, + SharedFenceVkSemaphoreSyncFD = 0x000004B1, + SharedFenceVkSemaphoreZirconHandle = 0x000004B2, + SharedFenceDXGISharedHandle = 0x000004B3, + SharedFenceMTLSharedEvent = 0x000004B4, + SharedBufferMemoryD3D12Resource = 0x000004B5, + StaticSamplers = 0x000004B6, +}; + +enum class FilterMode : uint32_t { + Undefined = 0x00000000, + Nearest = 0x00000001, + Linear = 0x00000002, +}; + +enum class FrontFace : uint32_t { + Undefined = 0x00000000, + CCW = 0x00000001, + CW = 0x00000002, +}; + +enum class IndexFormat : uint32_t { + Undefined = 0x00000000, + Uint16 = 0x00000001, + Uint32 = 0x00000002, +}; + +enum class LoadOp : uint32_t { + Undefined = 0x00000000, + Clear = 0x00000001, + Load = 0x00000002, +}; + +enum class LoggingType : uint32_t { + Verbose = 0x00000001, + Info = 0x00000002, + Warning = 0x00000003, + Error = 0x00000004, +}; + +enum class MipmapFilterMode : uint32_t { + Undefined = 0x00000000, + Nearest = 0x00000001, + Linear = 0x00000002, +}; + +enum class PopErrorScopeStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, +}; + +enum class PowerPreference : uint32_t { + Undefined = 0x00000000, + LowPower = 0x00000001, + HighPerformance = 0x00000002, +}; + +enum class PresentMode : uint32_t { + Fifo = 0x00000001, + Immediate = 0x00000003, + Mailbox = 0x00000004, +}; + +enum class PrimitiveTopology : uint32_t { + Undefined = 0x00000000, + PointList = 0x00000001, + LineList = 0x00000002, + LineStrip = 0x00000003, + TriangleList = 0x00000004, + TriangleStrip = 0x00000005, +}; + +enum class QueryType : uint32_t { + Occlusion = 0x00000001, + Timestamp = 0x00000002, +}; + +enum class QueueWorkDoneStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + Error = 0x00000002, + Unknown = 0x00000003, + DeviceLost = 0x00000004, +}; + +enum class RequestAdapterStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + Unavailable = 0x00000002, + Error = 0x00000003, + Unknown = 0x00000004, +}; + +enum class RequestDeviceStatus : uint32_t { + Success = 0x00000000, + InstanceDropped = 0x00000001, + Error = 0x00000002, + Unknown = 0x00000003, +}; + +enum class SType : uint32_t { + Invalid = 0x00000000, + SurfaceDescriptorFromMetalLayer = 0x00000001, + SurfaceDescriptorFromWindowsHWND = 0x00000002, + SurfaceDescriptorFromXlibWindow = 0x00000003, + SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004, + ShaderModuleSPIRVDescriptor = 0x00000005, + ShaderModuleWGSLDescriptor = 0x00000006, + PrimitiveDepthClipControl = 0x00000007, + SurfaceDescriptorFromWaylandSurface = 0x00000008, + SurfaceDescriptorFromAndroidNativeWindow = 0x00000009, + SurfaceDescriptorFromWindowsCoreWindow = 0x0000000B, + ExternalTextureBindingEntry = 0x0000000C, + ExternalTextureBindingLayout = 0x0000000D, + SurfaceDescriptorFromWindowsSwapChainPanel = 0x0000000E, + RenderPassDescriptorMaxDrawCount = 0x0000000F, + DepthStencilStateDepthWriteDefinedDawn = 0x00000010, + TextureBindingViewDimensionDescriptor = 0x00000011, + DawnTextureInternalUsageDescriptor = 0x000003E8, + DawnEncoderInternalUsageDescriptor = 0x000003EB, + DawnInstanceDescriptor = 0x000003EC, + DawnCacheDeviceDescriptor = 0x000003ED, + DawnAdapterPropertiesPowerPreference = 0x000003EE, + DawnBufferDescriptorErrorInfoFromWireClient = 0x000003EF, + DawnTogglesDescriptor = 0x000003F0, + DawnShaderModuleSPIRVOptionsDescriptor = 0x000003F1, + RequestAdapterOptionsLUID = 0x000003F2, + RequestAdapterOptionsGetGLProc = 0x000003F3, + RequestAdapterOptionsD3D11Device = 0x000003F4, + DawnMultisampleStateRenderToSingleSampled = 0x000003F5, + DawnRenderPassColorAttachmentRenderToSingleSampled = 0x000003F6, + RenderPassPixelLocalStorage = 0x000003F7, + PipelineLayoutPixelLocalStorage = 0x000003F8, + BufferHostMappedPointer = 0x000003F9, + DawnExperimentalSubgroupLimits = 0x000003FA, + AdapterPropertiesMemoryHeaps = 0x000003FB, + AdapterPropertiesD3D = 0x000003FC, + AdapterPropertiesVk = 0x000003FD, + DawnComputePipelineFullSubgroups = 0x000003FE, + DawnWireWGSLControl = 0x000003FF, + DawnWGSLBlocklist = 0x00000400, + DrmFormatCapabilities = 0x00000401, + SharedTextureMemoryVkImageDescriptor = 0x0000044C, + SharedTextureMemoryVkDedicatedAllocationDescriptor = 0x0000044D, + SharedTextureMemoryAHardwareBufferDescriptor = 0x0000044E, + SharedTextureMemoryDmaBufDescriptor = 0x0000044F, + SharedTextureMemoryOpaqueFDDescriptor = 0x00000450, + SharedTextureMemoryZirconHandleDescriptor = 0x00000451, + SharedTextureMemoryDXGISharedHandleDescriptor = 0x00000452, + SharedTextureMemoryD3D11Texture2DDescriptor = 0x00000453, + SharedTextureMemoryIOSurfaceDescriptor = 0x00000454, + SharedTextureMemoryEGLImageDescriptor = 0x00000455, + SharedTextureMemoryInitializedBeginState = 0x000004B0, + SharedTextureMemoryInitializedEndState = 0x000004B1, + SharedTextureMemoryVkImageLayoutBeginState = 0x000004B2, + SharedTextureMemoryVkImageLayoutEndState = 0x000004B3, + SharedFenceVkSemaphoreOpaqueFDDescriptor = 0x000004B4, + SharedFenceVkSemaphoreOpaqueFDExportInfo = 0x000004B5, + SharedFenceVkSemaphoreSyncFDDescriptor = 0x000004B6, + SharedFenceVkSemaphoreSyncFDExportInfo = 0x000004B7, + SharedFenceVkSemaphoreZirconHandleDescriptor = 0x000004B8, + SharedFenceVkSemaphoreZirconHandleExportInfo = 0x000004B9, + SharedFenceDXGISharedHandleDescriptor = 0x000004BA, + SharedFenceDXGISharedHandleExportInfo = 0x000004BB, + SharedFenceMTLSharedEventDescriptor = 0x000004BC, + SharedFenceMTLSharedEventExportInfo = 0x000004BD, + SharedBufferMemoryD3D12ResourceDescriptor = 0x000004BE, + StaticSamplerBindingLayout = 0x000004BF, +}; + +enum class SamplerBindingType : uint32_t { + Undefined = 0x00000000, + Filtering = 0x00000001, + NonFiltering = 0x00000002, + Comparison = 0x00000003, +}; + +enum class SharedFenceType : uint32_t { + Undefined = 0x00000000, + VkSemaphoreOpaqueFD = 0x00000001, + VkSemaphoreSyncFD = 0x00000002, + VkSemaphoreZirconHandle = 0x00000003, + DXGISharedHandle = 0x00000004, + MTLSharedEvent = 0x00000005, +}; + +enum class StencilOperation : uint32_t { + Undefined = 0x00000000, + Keep = 0x00000001, + Zero = 0x00000002, + Replace = 0x00000003, + Invert = 0x00000004, + IncrementClamp = 0x00000005, + DecrementClamp = 0x00000006, + IncrementWrap = 0x00000007, + DecrementWrap = 0x00000008, +}; + +enum class StorageTextureAccess : uint32_t { + Undefined = 0x00000000, + WriteOnly = 0x00000001, + ReadOnly = 0x00000002, + ReadWrite = 0x00000003, +}; + +enum class StoreOp : uint32_t { + Undefined = 0x00000000, + Store = 0x00000001, + Discard = 0x00000002, +}; + +enum class TextureAspect : uint32_t { + Undefined = 0x00000000, + All = 0x00000001, + StencilOnly = 0x00000002, + DepthOnly = 0x00000003, + Plane0Only = 0x00000004, + Plane1Only = 0x00000005, + Plane2Only = 0x00000006, +}; + +enum class TextureDimension : uint32_t { + Undefined = 0x00000000, + e1D = 0x00000001, + e2D = 0x00000002, + e3D = 0x00000003, +}; + +enum class TextureFormat : uint32_t { + Undefined = 0x00000000, + R8Unorm = 0x00000001, + R8Snorm = 0x00000002, + R8Uint = 0x00000003, + R8Sint = 0x00000004, + R16Uint = 0x00000005, + R16Sint = 0x00000006, + R16Float = 0x00000007, + RG8Unorm = 0x00000008, + RG8Snorm = 0x00000009, + RG8Uint = 0x0000000A, + RG8Sint = 0x0000000B, + R32Float = 0x0000000C, + R32Uint = 0x0000000D, + R32Sint = 0x0000000E, + RG16Uint = 0x0000000F, + RG16Sint = 0x00000010, + RG16Float = 0x00000011, + RGBA8Unorm = 0x00000012, + RGBA8UnormSrgb = 0x00000013, + RGBA8Snorm = 0x00000014, + RGBA8Uint = 0x00000015, + RGBA8Sint = 0x00000016, + BGRA8Unorm = 0x00000017, + BGRA8UnormSrgb = 0x00000018, + RGB10A2Uint = 0x00000019, + RGB10A2Unorm = 0x0000001A, + RG11B10Ufloat = 0x0000001B, + RGB9E5Ufloat = 0x0000001C, + RG32Float = 0x0000001D, + RG32Uint = 0x0000001E, + RG32Sint = 0x0000001F, + RGBA16Uint = 0x00000020, + RGBA16Sint = 0x00000021, + RGBA16Float = 0x00000022, + RGBA32Float = 0x00000023, + RGBA32Uint = 0x00000024, + RGBA32Sint = 0x00000025, + Stencil8 = 0x00000026, + Depth16Unorm = 0x00000027, + Depth24Plus = 0x00000028, + Depth24PlusStencil8 = 0x00000029, + Depth32Float = 0x0000002A, + Depth32FloatStencil8 = 0x0000002B, + BC1RGBAUnorm = 0x0000002C, + BC1RGBAUnormSrgb = 0x0000002D, + BC2RGBAUnorm = 0x0000002E, + BC2RGBAUnormSrgb = 0x0000002F, + BC3RGBAUnorm = 0x00000030, + BC3RGBAUnormSrgb = 0x00000031, + BC4RUnorm = 0x00000032, + BC4RSnorm = 0x00000033, + BC5RGUnorm = 0x00000034, + BC5RGSnorm = 0x00000035, + BC6HRGBUfloat = 0x00000036, + BC6HRGBFloat = 0x00000037, + BC7RGBAUnorm = 0x00000038, + BC7RGBAUnormSrgb = 0x00000039, + ETC2RGB8Unorm = 0x0000003A, + ETC2RGB8UnormSrgb = 0x0000003B, + ETC2RGB8A1Unorm = 0x0000003C, + ETC2RGB8A1UnormSrgb = 0x0000003D, + ETC2RGBA8Unorm = 0x0000003E, + ETC2RGBA8UnormSrgb = 0x0000003F, + EACR11Unorm = 0x00000040, + EACR11Snorm = 0x00000041, + EACRG11Unorm = 0x00000042, + EACRG11Snorm = 0x00000043, + ASTC4x4Unorm = 0x00000044, + ASTC4x4UnormSrgb = 0x00000045, + ASTC5x4Unorm = 0x00000046, + ASTC5x4UnormSrgb = 0x00000047, + ASTC5x5Unorm = 0x00000048, + ASTC5x5UnormSrgb = 0x00000049, + ASTC6x5Unorm = 0x0000004A, + ASTC6x5UnormSrgb = 0x0000004B, + ASTC6x6Unorm = 0x0000004C, + ASTC6x6UnormSrgb = 0x0000004D, + ASTC8x5Unorm = 0x0000004E, + ASTC8x5UnormSrgb = 0x0000004F, + ASTC8x6Unorm = 0x00000050, + ASTC8x6UnormSrgb = 0x00000051, + ASTC8x8Unorm = 0x00000052, + ASTC8x8UnormSrgb = 0x00000053, + ASTC10x5Unorm = 0x00000054, + ASTC10x5UnormSrgb = 0x00000055, + ASTC10x6Unorm = 0x00000056, + ASTC10x6UnormSrgb = 0x00000057, + ASTC10x8Unorm = 0x00000058, + ASTC10x8UnormSrgb = 0x00000059, + ASTC10x10Unorm = 0x0000005A, + ASTC10x10UnormSrgb = 0x0000005B, + ASTC12x10Unorm = 0x0000005C, + ASTC12x10UnormSrgb = 0x0000005D, + ASTC12x12Unorm = 0x0000005E, + ASTC12x12UnormSrgb = 0x0000005F, + R16Unorm = 0x00000060, + RG16Unorm = 0x00000061, + RGBA16Unorm = 0x00000062, + R16Snorm = 0x00000063, + RG16Snorm = 0x00000064, + RGBA16Snorm = 0x00000065, + R8BG8Biplanar420Unorm = 0x00000066, + R10X6BG10X6Biplanar420Unorm = 0x00000067, + R8BG8A8Triplanar420Unorm = 0x00000068, +}; + +enum class TextureSampleType : uint32_t { + Undefined = 0x00000000, + Float = 0x00000001, + UnfilterableFloat = 0x00000002, + Depth = 0x00000003, + Sint = 0x00000004, + Uint = 0x00000005, +}; + +enum class TextureViewDimension : uint32_t { + Undefined = 0x00000000, + e1D = 0x00000001, + e2D = 0x00000002, + e2DArray = 0x00000003, + Cube = 0x00000004, + CubeArray = 0x00000005, + e3D = 0x00000006, +}; + +enum class VertexFormat : uint32_t { + Undefined = 0x00000000, + Uint8x2 = 0x00000001, + Uint8x4 = 0x00000002, + Sint8x2 = 0x00000003, + Sint8x4 = 0x00000004, + Unorm8x2 = 0x00000005, + Unorm8x4 = 0x00000006, + Snorm8x2 = 0x00000007, + Snorm8x4 = 0x00000008, + Uint16x2 = 0x00000009, + Uint16x4 = 0x0000000A, + Sint16x2 = 0x0000000B, + Sint16x4 = 0x0000000C, + Unorm16x2 = 0x0000000D, + Unorm16x4 = 0x0000000E, + Snorm16x2 = 0x0000000F, + Snorm16x4 = 0x00000010, + Float16x2 = 0x00000011, + Float16x4 = 0x00000012, + Float32 = 0x00000013, + Float32x2 = 0x00000014, + Float32x3 = 0x00000015, + Float32x4 = 0x00000016, + Uint32 = 0x00000017, + Uint32x2 = 0x00000018, + Uint32x3 = 0x00000019, + Uint32x4 = 0x0000001A, + Sint32 = 0x0000001B, + Sint32x2 = 0x0000001C, + Sint32x3 = 0x0000001D, + Sint32x4 = 0x0000001E, + Unorm10_10_10_2 = 0x0000001F, +}; + +enum class VertexStepMode : uint32_t { + Undefined = 0x00000000, + VertexBufferNotUsed = 0x00000001, + Vertex = 0x00000002, + Instance = 0x00000003, +}; + +enum class WaitStatus : uint32_t { + Success = 0x00000000, + TimedOut = 0x00000001, + UnsupportedTimeout = 0x00000002, + UnsupportedCount = 0x00000003, + UnsupportedMixedSources = 0x00000004, + Unknown = 0x00000005, +}; + +enum class BufferUsage : uint32_t { + None = 0x00000000, + MapRead = 0x00000001, + MapWrite = 0x00000002, + CopySrc = 0x00000004, + CopyDst = 0x00000008, + Index = 0x00000010, + Vertex = 0x00000020, + Uniform = 0x00000040, + Storage = 0x00000080, + Indirect = 0x00000100, + QueryResolve = 0x00000200, +}; + +enum class ColorWriteMask : uint32_t { + None = 0x00000000, + Red = 0x00000001, + Green = 0x00000002, + Blue = 0x00000004, + Alpha = 0x00000008, + All = 0x0000000F, +}; + +enum class HeapProperty : uint32_t { + Undefined = 0x00000000, + DeviceLocal = 0x00000001, + HostVisible = 0x00000002, + HostCoherent = 0x00000004, + HostUncached = 0x00000008, + HostCached = 0x00000010, +}; + +enum class MapMode : uint32_t { + None = 0x00000000, + Read = 0x00000001, + Write = 0x00000002, +}; + +enum class ShaderStage : uint32_t { + None = 0x00000000, + Vertex = 0x00000001, + Fragment = 0x00000002, + Compute = 0x00000004, +}; + +enum class TextureUsage : uint32_t { + None = 0x00000000, + CopySrc = 0x00000001, + CopyDst = 0x00000002, + TextureBinding = 0x00000004, + StorageBinding = 0x00000008, + RenderAttachment = 0x00000010, + TransientAttachment = 0x00000020, + StorageAttachment = 0x00000040, +}; + +using BufferMapCallback = WGPUBufferMapCallback; +using Callback = WGPUCallback; +using CompilationInfoCallback = WGPUCompilationInfoCallback; +using CreateComputePipelineAsyncCallback = + WGPUCreateComputePipelineAsyncCallback; +using CreateRenderPipelineAsyncCallback = WGPUCreateRenderPipelineAsyncCallback; +using DawnLoadCacheDataFunction = WGPUDawnLoadCacheDataFunction; +using DawnStoreCacheDataFunction = WGPUDawnStoreCacheDataFunction; +using DeviceLostCallback = WGPUDeviceLostCallback; +using ErrorCallback = WGPUErrorCallback; +using LoggingCallback = WGPULoggingCallback; +using PopErrorScopeCallback = WGPUPopErrorScopeCallback; +using Proc = WGPUProc; +using QueueWorkDoneCallback = WGPUQueueWorkDoneCallback; +using RequestAdapterCallback = WGPURequestAdapterCallback; +using RequestDeviceCallback = WGPURequestDeviceCallback; + +class Adapter; +class BindGroup; +class BindGroupLayout; +class Buffer; +class CommandBuffer; +class CommandEncoder; +class ComputePassEncoder; +class ComputePipeline; +class Device; +class ExternalTexture; +class Instance; +class PipelineLayout; +class QuerySet; +class Queue; +class RenderBundle; +class RenderBundleEncoder; +class RenderPassEncoder; +class RenderPipeline; +class Sampler; +class ShaderModule; +class SharedBufferMemory; +class SharedFence; +class SharedTextureMemory; +class Surface; +class SwapChain; +class Texture; +class TextureView; + +struct AdapterProperties; +struct AdapterPropertiesD3D; +struct AdapterPropertiesVk; +struct BindGroupEntry; +struct BlendComponent; +struct BufferBindingLayout; +struct BufferDescriptor; +struct BufferHostMappedPointer; +struct BufferMapCallbackInfo; +struct Color; +struct CommandBufferDescriptor; +struct CommandEncoderDescriptor; +struct CompilationInfoCallbackInfo; +struct CompilationMessage; +struct ComputePassTimestampWrites; +struct ConstantEntry; +struct CopyTextureForBrowserOptions; +struct CreateComputePipelineAsyncCallbackInfo; +struct CreateRenderPipelineAsyncCallbackInfo; +struct DawnWGSLBlocklist; +struct DawnAdapterPropertiesPowerPreference; +struct DawnBufferDescriptorErrorInfoFromWireClient; +struct DawnCacheDeviceDescriptor; +struct DawnComputePipelineFullSubgroups; +struct DawnEncoderInternalUsageDescriptor; +struct DawnExperimentalSubgroupLimits; +struct DawnMultisampleStateRenderToSingleSampled; +struct DawnRenderPassColorAttachmentRenderToSingleSampled; +struct DawnShaderModuleSPIRVOptionsDescriptor; +struct DawnTextureInternalUsageDescriptor; +struct DawnTogglesDescriptor; +struct DawnWireWGSLControl; +struct DepthStencilStateDepthWriteDefinedDawn; +struct DrmFormatProperties; +struct Extent2D; +struct Extent3D; +struct ExternalTextureBindingEntry; +struct ExternalTextureBindingLayout; +struct FormatCapabilities; +struct Future; +struct InstanceFeatures; +struct Limits; +struct MemoryHeapInfo; +struct MultisampleState; +struct Origin2D; +struct Origin3D; +struct PipelineLayoutDescriptor; +struct PipelineLayoutStorageAttachment; +struct PopErrorScopeCallbackInfo; +struct PrimitiveDepthClipControl; +struct PrimitiveState; +struct QuerySetDescriptor; +struct QueueDescriptor; +struct QueueWorkDoneCallbackInfo; +struct RenderBundleDescriptor; +struct RenderBundleEncoderDescriptor; +struct RenderPassDepthStencilAttachment; +struct RenderPassDescriptorMaxDrawCount; +struct RenderPassTimestampWrites; +struct RequestAdapterCallbackInfo; +struct RequestAdapterOptions; +struct RequestDeviceCallbackInfo; +struct SamplerBindingLayout; +struct SamplerDescriptor; +struct ShaderModuleSPIRVDescriptor; +struct ShaderModuleWGSLDescriptor; +struct ShaderModuleDescriptor; +struct SharedBufferMemoryBeginAccessDescriptor; +struct SharedBufferMemoryDescriptor; +struct SharedBufferMemoryEndAccessState; +struct SharedBufferMemoryProperties; +struct SharedFenceDXGISharedHandleDescriptor; +struct SharedFenceDXGISharedHandleExportInfo; +struct SharedFenceMTLSharedEventDescriptor; +struct SharedFenceMTLSharedEventExportInfo; +struct SharedFenceDescriptor; +struct SharedFenceExportInfo; +struct SharedFenceVkSemaphoreOpaqueFDDescriptor; +struct SharedFenceVkSemaphoreOpaqueFDExportInfo; +struct SharedFenceVkSemaphoreSyncFDDescriptor; +struct SharedFenceVkSemaphoreSyncFDExportInfo; +struct SharedFenceVkSemaphoreZirconHandleDescriptor; +struct SharedFenceVkSemaphoreZirconHandleExportInfo; +struct SharedTextureMemoryDXGISharedHandleDescriptor; +struct SharedTextureMemoryEGLImageDescriptor; +struct SharedTextureMemoryIOSurfaceDescriptor; +struct SharedTextureMemoryAHardwareBufferDescriptor; +struct SharedTextureMemoryBeginAccessDescriptor; +struct SharedTextureMemoryDescriptor; +struct SharedTextureMemoryDmaBufPlane; +struct SharedTextureMemoryEndAccessState; +struct SharedTextureMemoryOpaqueFDDescriptor; +struct SharedTextureMemoryVkDedicatedAllocationDescriptor; +struct SharedTextureMemoryVkImageLayoutBeginState; +struct SharedTextureMemoryVkImageLayoutEndState; +struct SharedTextureMemoryZirconHandleDescriptor; +struct StaticSamplerBindingLayout; +struct StencilFaceState; +struct StorageTextureBindingLayout; +struct SurfaceDescriptor; +struct SurfaceDescriptorFromAndroidNativeWindow; +struct SurfaceDescriptorFromCanvasHTMLSelector; +struct SurfaceDescriptorFromMetalLayer; +struct SurfaceDescriptorFromWaylandSurface; +struct SurfaceDescriptorFromWindowsHWND; +struct SurfaceDescriptorFromWindowsCoreWindow; +struct SurfaceDescriptorFromWindowsSwapChainPanel; +struct SurfaceDescriptorFromXlibWindow; +struct SwapChainDescriptor; +struct TextureBindingLayout; +struct TextureBindingViewDimensionDescriptor; +struct TextureDataLayout; +struct TextureViewDescriptor; +struct VertexAttribute; +struct AdapterPropertiesMemoryHeaps; +struct BindGroupDescriptor; +struct BindGroupLayoutEntry; +struct BlendState; +struct CompilationInfo; +struct ComputePassDescriptor; +struct DepthStencilState; +struct DrmFormatCapabilities; +struct ExternalTextureDescriptor; +struct FutureWaitInfo; +struct ImageCopyBuffer; +struct ImageCopyExternalTexture; +struct ImageCopyTexture; +struct InstanceDescriptor; +struct PipelineLayoutPixelLocalStorage; +struct ProgrammableStageDescriptor; +struct RenderPassColorAttachment; +struct RenderPassStorageAttachment; +struct RequiredLimits; +struct SharedTextureMemoryDmaBufDescriptor; +struct SharedTextureMemoryProperties; +struct SharedTextureMemoryVkImageDescriptor; +struct SupportedLimits; +struct TextureDescriptor; +struct VertexBufferLayout; +struct BindGroupLayoutDescriptor; +struct ColorTargetState; +struct ComputePipelineDescriptor; +struct DeviceDescriptor; +struct RenderPassDescriptor; +struct RenderPassPixelLocalStorage; +struct VertexState; +struct FragmentState; +struct RenderPipelineDescriptor; + +// Special class for booleans in order to allow implicit conversions. +class Bool { +public: + constexpr Bool() = default; + // NOLINTNEXTLINE(runtime/explicit) allow implicit construction + constexpr Bool(bool value) : mValue(static_cast(value)) {} + // NOLINTNEXTLINE(runtime/explicit) allow implicit construction + Bool(WGPUBool value) : mValue(value) {} + + constexpr operator bool() const { return static_cast(mValue); } + +private: + friend struct std::hash; + // Default to false. + WGPUBool mValue = static_cast(false); +}; + +template class ObjectBase { +public: + ObjectBase() = default; + ObjectBase(CType handle) : mHandle(handle) { + if (mHandle) + Derived::WGPUReference(mHandle); + } + ~ObjectBase() { + if (mHandle) + Derived::WGPURelease(mHandle); + } + + ObjectBase(ObjectBase const &other) : ObjectBase(other.Get()) {} + Derived &operator=(ObjectBase const &other) { + if (&other != this) { + if (mHandle) + Derived::WGPURelease(mHandle); + mHandle = other.mHandle; + if (mHandle) + Derived::WGPUReference(mHandle); + } + + return static_cast(*this); + } + + ObjectBase(ObjectBase &&other) { + mHandle = other.mHandle; + other.mHandle = 0; + } + Derived &operator=(ObjectBase &&other) { + if (&other != this) { + if (mHandle) + Derived::WGPURelease(mHandle); + mHandle = other.mHandle; + other.mHandle = 0; + } + + return static_cast(*this); + } + + ObjectBase(std::nullptr_t) {} + Derived &operator=(std::nullptr_t) { + if (mHandle != nullptr) { + Derived::WGPURelease(mHandle); + mHandle = nullptr; + } + return static_cast(*this); + } + + bool operator==(std::nullptr_t) const { return mHandle == nullptr; } + bool operator!=(std::nullptr_t) const { return mHandle != nullptr; } + + explicit operator bool() const { return mHandle != nullptr; } + CType Get() const { return mHandle; } + CType MoveToCHandle() { + CType result = mHandle; + mHandle = 0; + return result; + } + static Derived Acquire(CType handle) { + Derived result; + result.mHandle = handle; + return result; + } + +protected: + CType mHandle = nullptr; +}; + +class Adapter : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Device CreateDevice(DeviceDescriptor const *descriptor = nullptr) const; + size_t EnumerateFeatures(FeatureName *features) const; + Bool GetFormatCapabilities(TextureFormat format, + FormatCapabilities *capabilities) const; + Instance GetInstance() const; + Bool GetLimits(SupportedLimits *limits) const; + void GetProperties(AdapterProperties *properties) const; + Bool HasFeature(FeatureName feature) const; + void RequestDevice(DeviceDescriptor const *descriptor, + RequestDeviceCallback callback, void *userdata) const; + Future RequestDevice(DeviceDescriptor const *options, + RequestDeviceCallbackInfo callbackInfo) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUAdapter handle); + static void WGPURelease(WGPUAdapter handle); +}; + +class BindGroup : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUBindGroup handle); + static void WGPURelease(WGPUBindGroup handle); +}; + +class BindGroupLayout + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUBindGroupLayout handle); + static void WGPURelease(WGPUBindGroupLayout handle); +}; + +class Buffer : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Destroy() const; + void const *GetConstMappedRange(size_t offset = 0, + size_t size = WGPU_WHOLE_MAP_SIZE) const; + BufferMapState GetMapState() const; + void *GetMappedRange(size_t offset = 0, + size_t size = WGPU_WHOLE_MAP_SIZE) const; + uint64_t GetSize() const; + BufferUsage GetUsage() const; + void MapAsync(MapMode mode, size_t offset, size_t size, + BufferMapCallback callback, void *userdata) const; + Future MapAsync(MapMode mode, size_t offset, size_t size, + BufferMapCallbackInfo callbackInfo) const; + void SetLabel(char const *label) const; + void Unmap() const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUBuffer handle); + static void WGPURelease(WGPUBuffer handle); +}; + +class CommandBuffer : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUCommandBuffer handle); + static void WGPURelease(WGPUCommandBuffer handle); +}; + +class CommandEncoder : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + ComputePassEncoder + BeginComputePass(ComputePassDescriptor const *descriptor = nullptr) const; + RenderPassEncoder + BeginRenderPass(RenderPassDescriptor const *descriptor) const; + void ClearBuffer(Buffer const &buffer, uint64_t offset = 0, + uint64_t size = WGPU_WHOLE_SIZE) const; + void CopyBufferToBuffer(Buffer const &source, uint64_t sourceOffset, + Buffer const &destination, uint64_t destinationOffset, + uint64_t size) const; + void CopyBufferToTexture(ImageCopyBuffer const *source, + ImageCopyTexture const *destination, + Extent3D const *copySize) const; + void CopyTextureToBuffer(ImageCopyTexture const *source, + ImageCopyBuffer const *destination, + Extent3D const *copySize) const; + void CopyTextureToTexture(ImageCopyTexture const *source, + ImageCopyTexture const *destination, + Extent3D const *copySize) const; + CommandBuffer + Finish(CommandBufferDescriptor const *descriptor = nullptr) const; + void InjectValidationError(char const *message) const; + void InsertDebugMarker(char const *markerLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const *groupLabel) const; + void ResolveQuerySet(QuerySet const &querySet, uint32_t firstQuery, + uint32_t queryCount, Buffer const &destination, + uint64_t destinationOffset) const; + void SetLabel(char const *label) const; + void WriteBuffer(Buffer const &buffer, uint64_t bufferOffset, + uint8_t const *data, uint64_t size) const; + void WriteTimestamp(QuerySet const &querySet, uint32_t queryIndex) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUCommandEncoder handle); + static void WGPURelease(WGPUCommandEncoder handle); +}; + +class ComputePassEncoder + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void DispatchWorkgroups(uint32_t workgroupCountX, + uint32_t workgroupCountY = 1, + uint32_t workgroupCountZ = 1) const; + void DispatchWorkgroupsIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const; + void End() const; + void InsertDebugMarker(char const *markerLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const *groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const &group, + size_t dynamicOffsetCount = 0, + uint32_t const *dynamicOffsets = nullptr) const; + void SetLabel(char const *label) const; + void SetPipeline(ComputePipeline const &pipeline) const; + void WriteTimestamp(QuerySet const &querySet, uint32_t queryIndex) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUComputePassEncoder handle); + static void WGPURelease(WGPUComputePassEncoder handle); +}; + +class ComputePipeline + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUComputePipeline handle); + static void WGPURelease(WGPUComputePipeline handle); +}; + +class Device : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroup CreateBindGroup(BindGroupDescriptor const *descriptor) const; + BindGroupLayout + CreateBindGroupLayout(BindGroupLayoutDescriptor const *descriptor) const; + Buffer CreateBuffer(BufferDescriptor const *descriptor) const; + CommandEncoder CreateCommandEncoder( + CommandEncoderDescriptor const *descriptor = nullptr) const; + ComputePipeline + CreateComputePipeline(ComputePipelineDescriptor const *descriptor) const; + void CreateComputePipelineAsync(ComputePipelineDescriptor const *descriptor, + CreateComputePipelineAsyncCallback callback, + void *userdata) const; + Future CreateComputePipelineAsync( + ComputePipelineDescriptor const *descriptor, + CreateComputePipelineAsyncCallbackInfo callbackInfo) const; + Buffer CreateErrorBuffer(BufferDescriptor const *descriptor) const; + ExternalTexture CreateErrorExternalTexture() const; + ShaderModule CreateErrorShaderModule(ShaderModuleDescriptor const *descriptor, + char const *errorMessage) const; + Texture CreateErrorTexture(TextureDescriptor const *descriptor) const; + ExternalTexture CreateExternalTexture( + ExternalTextureDescriptor const *externalTextureDescriptor) const; + PipelineLayout + CreatePipelineLayout(PipelineLayoutDescriptor const *descriptor) const; + QuerySet CreateQuerySet(QuerySetDescriptor const *descriptor) const; + RenderBundleEncoder CreateRenderBundleEncoder( + RenderBundleEncoderDescriptor const *descriptor) const; + RenderPipeline + CreateRenderPipeline(RenderPipelineDescriptor const *descriptor) const; + void CreateRenderPipelineAsync(RenderPipelineDescriptor const *descriptor, + CreateRenderPipelineAsyncCallback callback, + void *userdata) const; + Future CreateRenderPipelineAsync( + RenderPipelineDescriptor const *descriptor, + CreateRenderPipelineAsyncCallbackInfo callbackInfo) const; + Sampler CreateSampler(SamplerDescriptor const *descriptor = nullptr) const; + ShaderModule + CreateShaderModule(ShaderModuleDescriptor const *descriptor) const; + SwapChain CreateSwapChain(Surface const &surface, + SwapChainDescriptor const *descriptor) const; + Texture CreateTexture(TextureDescriptor const *descriptor) const; + void Destroy() const; + size_t EnumerateFeatures(FeatureName *features) const; + void ForceLoss(DeviceLostReason type, char const *message) const; + Adapter GetAdapter() const; + Bool GetLimits(SupportedLimits *limits) const; + Queue GetQueue() const; + TextureUsage GetSupportedSurfaceUsage(Surface const &surface) const; + Bool HasFeature(FeatureName feature) const; + SharedBufferMemory ImportSharedBufferMemory( + SharedBufferMemoryDescriptor const *descriptor) const; + SharedFence ImportSharedFence(SharedFenceDescriptor const *descriptor) const; + SharedTextureMemory ImportSharedTextureMemory( + SharedTextureMemoryDescriptor const *descriptor) const; + void InjectError(ErrorType type, char const *message) const; + void PopErrorScope(ErrorCallback oldCallback, void *userdata) const; + Future PopErrorScope(PopErrorScopeCallbackInfo callbackInfo) const; + void PushErrorScope(ErrorFilter filter) const; + void SetDeviceLostCallback(DeviceLostCallback callback, void *userdata) const; + void SetLabel(char const *label) const; + void SetLoggingCallback(LoggingCallback callback, void *userdata) const; + void SetUncapturedErrorCallback(ErrorCallback callback, void *userdata) const; + void Tick() const; + void ValidateTextureDescriptor(TextureDescriptor const *descriptor) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUDevice handle); + static void WGPURelease(WGPUDevice handle); +}; + +class ExternalTexture + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Destroy() const; + void Expire() const; + void Refresh() const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUExternalTexture handle); + static void WGPURelease(WGPUExternalTexture handle); +}; + +class Instance : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Surface CreateSurface(SurfaceDescriptor const *descriptor) const; + size_t EnumerateWGSLLanguageFeatures(WGSLFeatureName *features) const; + Bool HasWGSLLanguageFeature(WGSLFeatureName feature) const; + void ProcessEvents() const; + void RequestAdapter(RequestAdapterOptions const *options, + RequestAdapterCallback callback, void *userdata) const; + Future RequestAdapter(RequestAdapterOptions const *options, + RequestAdapterCallbackInfo callbackInfo) const; + WaitStatus WaitAny(size_t futureCount, FutureWaitInfo *futures, + uint64_t timeoutNS) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUInstance handle); + static void WGPURelease(WGPUInstance handle); +}; + +class PipelineLayout : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUPipelineLayout handle); + static void WGPURelease(WGPUPipelineLayout handle); +}; + +class QuerySet : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Destroy() const; + uint32_t GetCount() const; + QueryType GetType() const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUQuerySet handle); + static void WGPURelease(WGPUQuerySet handle); +}; + +class Queue : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void CopyExternalTextureForBrowser( + ImageCopyExternalTexture const *source, + ImageCopyTexture const *destination, Extent3D const *copySize, + CopyTextureForBrowserOptions const *options) const; + void CopyTextureForBrowser(ImageCopyTexture const *source, + ImageCopyTexture const *destination, + Extent3D const *copySize, + CopyTextureForBrowserOptions const *options) const; + void OnSubmittedWorkDone(QueueWorkDoneCallback callback, + void *userdata) const; + Future OnSubmittedWorkDone(QueueWorkDoneCallbackInfo callbackInfo) const; + void SetLabel(char const *label) const; + void Submit(size_t commandCount, CommandBuffer const *commands) const; + void WriteBuffer(Buffer const &buffer, uint64_t bufferOffset, + void const *data, size_t size) const; + void WriteTexture(ImageCopyTexture const *destination, void const *data, + size_t dataSize, TextureDataLayout const *dataLayout, + Extent3D const *writeSize) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUQueue handle); + static void WGPURelease(WGPUQueue handle); +}; + +class RenderBundle : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPURenderBundle handle); + static void WGPURelease(WGPURenderBundle handle); +}; + +class RenderBundleEncoder + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, + uint32_t firstVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, + uint32_t firstIndex = 0, int32_t baseVertex = 0, + uint32_t firstInstance = 0) const; + void DrawIndexedIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const; + void DrawIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const; + RenderBundle Finish(RenderBundleDescriptor const *descriptor = nullptr) const; + void InsertDebugMarker(char const *markerLabel) const; + void PopDebugGroup() const; + void PushDebugGroup(char const *groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const &group, + size_t dynamicOffsetCount = 0, + uint32_t const *dynamicOffsets = nullptr) const; + void SetIndexBuffer(Buffer const &buffer, IndexFormat format, + uint64_t offset = 0, + uint64_t size = WGPU_WHOLE_SIZE) const; + void SetLabel(char const *label) const; + void SetPipeline(RenderPipeline const &pipeline) const; + void SetVertexBuffer(uint32_t slot, Buffer const &buffer, uint64_t offset = 0, + uint64_t size = WGPU_WHOLE_SIZE) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPURenderBundleEncoder handle); + static void WGPURelease(WGPURenderBundleEncoder handle); +}; + +class RenderPassEncoder + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void BeginOcclusionQuery(uint32_t queryIndex) const; + void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, + uint32_t firstVertex = 0, uint32_t firstInstance = 0) const; + void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, + uint32_t firstIndex = 0, int32_t baseVertex = 0, + uint32_t firstInstance = 0) const; + void DrawIndexedIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const; + void DrawIndirect(Buffer const &indirectBuffer, + uint64_t indirectOffset) const; + void End() const; + void EndOcclusionQuery() const; + void ExecuteBundles(size_t bundleCount, RenderBundle const *bundles) const; + void InsertDebugMarker(char const *markerLabel) const; + void PixelLocalStorageBarrier() const; + void PopDebugGroup() const; + void PushDebugGroup(char const *groupLabel) const; + void SetBindGroup(uint32_t groupIndex, BindGroup const &group, + size_t dynamicOffsetCount = 0, + uint32_t const *dynamicOffsets = nullptr) const; + void SetBlendConstant(Color const *color) const; + void SetIndexBuffer(Buffer const &buffer, IndexFormat format, + uint64_t offset = 0, + uint64_t size = WGPU_WHOLE_SIZE) const; + void SetLabel(char const *label) const; + void SetPipeline(RenderPipeline const &pipeline) const; + void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, + uint32_t height) const; + void SetStencilReference(uint32_t reference) const; + void SetVertexBuffer(uint32_t slot, Buffer const &buffer, uint64_t offset = 0, + uint64_t size = WGPU_WHOLE_SIZE) const; + void SetViewport(float x, float y, float width, float height, float minDepth, + float maxDepth) const; + void WriteTimestamp(QuerySet const &querySet, uint32_t queryIndex) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPURenderPassEncoder handle); + static void WGPURelease(WGPURenderPassEncoder handle); +}; + +class RenderPipeline : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + BindGroupLayout GetBindGroupLayout(uint32_t groupIndex) const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPURenderPipeline handle); + static void WGPURelease(WGPURenderPipeline handle); +}; + +class Sampler : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSampler handle); + static void WGPURelease(WGPUSampler handle); +}; + +class ShaderModule : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void GetCompilationInfo(CompilationInfoCallback callback, + void *userdata) const; + Future GetCompilationInfo(CompilationInfoCallbackInfo callbackInfo) const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUShaderModule handle); + static void WGPURelease(WGPUShaderModule handle); +}; + +class SharedBufferMemory + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Bool + BeginAccess(Buffer const &buffer, + SharedBufferMemoryBeginAccessDescriptor const *descriptor) const; + Buffer CreateBuffer(BufferDescriptor const *descriptor = nullptr) const; + Bool EndAccess(Buffer const &buffer, + SharedBufferMemoryEndAccessState *descriptor) const; + void GetProperties(SharedBufferMemoryProperties *properties) const; + Bool IsDeviceLost() const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSharedBufferMemory handle); + static void WGPURelease(WGPUSharedBufferMemory handle); +}; + +class SharedFence : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void ExportInfo(SharedFenceExportInfo *info) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSharedFence handle); + static void WGPURelease(WGPUSharedFence handle); +}; + +class SharedTextureMemory + : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Bool + BeginAccess(Texture const &texture, + SharedTextureMemoryBeginAccessDescriptor const *descriptor) const; + Texture CreateTexture(TextureDescriptor const *descriptor = nullptr) const; + Bool EndAccess(Texture const &texture, + SharedTextureMemoryEndAccessState *descriptor) const; + void GetProperties(SharedTextureMemoryProperties *properties) const; + Bool IsDeviceLost() const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSharedTextureMemory handle); + static void WGPURelease(WGPUSharedTextureMemory handle); +}; + +class Surface : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + TextureFormat GetPreferredFormat(Adapter const &adapter) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSurface handle); + static void WGPURelease(WGPUSurface handle); +}; + +class SwapChain : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + Texture GetCurrentTexture() const; + TextureView GetCurrentTextureView() const; + void Present() const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUSwapChain handle); + static void WGPURelease(WGPUSwapChain handle); +}; + +class Texture : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + TextureView + CreateErrorView(TextureViewDescriptor const *descriptor = nullptr) const; + TextureView + CreateView(TextureViewDescriptor const *descriptor = nullptr) const; + void Destroy() const; + uint32_t GetDepthOrArrayLayers() const; + TextureDimension GetDimension() const; + TextureFormat GetFormat() const; + uint32_t GetHeight() const; + uint32_t GetMipLevelCount() const; + uint32_t GetSampleCount() const; + TextureUsage GetUsage() const; + uint32_t GetWidth() const; + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUTexture handle); + static void WGPURelease(WGPUTexture handle); +}; + +class TextureView : public ObjectBase { +public: + using ObjectBase::ObjectBase; + using ObjectBase::operator=; + + void SetLabel(char const *label) const; + +private: + friend ObjectBase; + static void WGPUReference(WGPUTextureView handle); + static void WGPURelease(WGPUTextureView handle); +}; + +Instance CreateInstance(InstanceDescriptor const *descriptor = nullptr); +Bool GetInstanceFeatures(InstanceFeatures *features); +Proc GetProcAddress(Device device, char const *procName); + +struct AdapterProperties { + AdapterProperties() = default; + ~AdapterProperties(); + AdapterProperties(const AdapterProperties &) = delete; + AdapterProperties &operator=(const AdapterProperties &) = delete; + AdapterProperties(AdapterProperties &&); + AdapterProperties &operator=(AdapterProperties &&); + ChainedStructOut *nextInChain = nullptr; + uint32_t const vendorID = {}; + char const *const vendorName = nullptr; + char const *const architecture = nullptr; + uint32_t const deviceID = {}; + char const *const name = nullptr; + char const *const driverDescription = nullptr; + AdapterType const adapterType = {}; + BackendType const backendType = {}; + Bool const compatibilityMode = false; +}; + +// Can be chained in AdapterProperties +struct AdapterPropertiesD3D : ChainedStructOut { + AdapterPropertiesD3D() { sType = SType::AdapterPropertiesD3D; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t shaderModel; +}; + +// Can be chained in AdapterProperties +struct AdapterPropertiesVk : ChainedStructOut { + AdapterPropertiesVk() { sType = SType::AdapterPropertiesVk; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t driverVersion; +}; + +struct BindGroupEntry { + ChainedStruct const *nextInChain = nullptr; + uint32_t binding; + Buffer buffer = nullptr; + uint64_t offset = 0; + uint64_t size = WGPU_WHOLE_SIZE; + Sampler sampler = nullptr; + TextureView textureView = nullptr; +}; + +struct BlendComponent { + BlendOperation operation = BlendOperation::Add; + BlendFactor srcFactor = BlendFactor::One; + BlendFactor dstFactor = BlendFactor::Zero; +}; + +struct BufferBindingLayout { + ChainedStruct const *nextInChain = nullptr; + BufferBindingType type = BufferBindingType::Undefined; + Bool hasDynamicOffset = false; + uint64_t minBindingSize = 0; +}; + +struct BufferDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + BufferUsage usage; + uint64_t size; + Bool mappedAtCreation = false; +}; + +// Can be chained in BufferDescriptor +struct BufferHostMappedPointer : ChainedStruct { + BufferHostMappedPointer() { sType = SType::BufferHostMappedPointer; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *pointer; + Callback disposeCallback; + void *userdata; +}; + +struct BufferMapCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + BufferMapCallback callback; + void *userdata; +}; + +struct Color { + double r; + double g; + double b; + double a; +}; + +struct CommandBufferDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct CommandEncoderDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct CompilationInfoCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + CompilationInfoCallback callback; + void *userdata = nullptr; +}; + +struct CompilationMessage { + ChainedStruct const *nextInChain = nullptr; + char const *message = nullptr; + CompilationMessageType type; + uint64_t lineNum; + uint64_t linePos; + uint64_t offset; + uint64_t length; + uint64_t utf16LinePos; + uint64_t utf16Offset; + uint64_t utf16Length; +}; + +struct ComputePassTimestampWrites { + QuerySet querySet; + uint32_t beginningOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED; + uint32_t endOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED; +}; + +struct ConstantEntry { + ChainedStruct const *nextInChain = nullptr; + char const *key; + double value; +}; + +struct CopyTextureForBrowserOptions { + ChainedStruct const *nextInChain = nullptr; + Bool flipY = false; + Bool needsColorSpaceConversion = false; + AlphaMode srcAlphaMode = AlphaMode::Unpremultiplied; + float const *srcTransferFunctionParameters = nullptr; + float const *conversionMatrix = nullptr; + float const *dstTransferFunctionParameters = nullptr; + AlphaMode dstAlphaMode = AlphaMode::Unpremultiplied; + Bool internalUsage = false; +}; + +struct CreateComputePipelineAsyncCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + CreateComputePipelineAsyncCallback callback; + void *userdata; +}; + +struct CreateRenderPipelineAsyncCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + CreateRenderPipelineAsyncCallback callback; + void *userdata; +}; + +// Can be chained in InstanceDescriptor +struct DawnWGSLBlocklist : ChainedStruct { + DawnWGSLBlocklist() { sType = SType::DawnWGSLBlocklist; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(size_t)); + alignas(kFirstMemberAlignment) size_t blocklistedFeatureCount = 0; + const char *const *blocklistedFeatures; +}; + +// Can be chained in AdapterProperties +struct DawnAdapterPropertiesPowerPreference : ChainedStructOut { + DawnAdapterPropertiesPowerPreference() { + sType = SType::DawnAdapterPropertiesPowerPreference; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(PowerPreference)); + alignas(kFirstMemberAlignment) + PowerPreference powerPreference = PowerPreference::Undefined; +}; + +// Can be chained in BufferDescriptor +struct DawnBufferDescriptorErrorInfoFromWireClient : ChainedStruct { + DawnBufferDescriptorErrorInfoFromWireClient() { + sType = SType::DawnBufferDescriptorErrorInfoFromWireClient; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool outOfMemory = false; +}; + +// Can be chained in DeviceDescriptor +struct DawnCacheDeviceDescriptor : ChainedStruct { + DawnCacheDeviceDescriptor() { sType = SType::DawnCacheDeviceDescriptor; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(char const *)); + alignas(kFirstMemberAlignment) char const *isolationKey = ""; + DawnLoadCacheDataFunction loadDataFunction = nullptr; + DawnStoreCacheDataFunction storeDataFunction = nullptr; + void *functionUserdata = nullptr; +}; + +// Can be chained in ComputePipelineDescriptor +struct DawnComputePipelineFullSubgroups : ChainedStruct { + DawnComputePipelineFullSubgroups() { + sType = SType::DawnComputePipelineFullSubgroups; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool requiresFullSubgroups = false; +}; + +// Can be chained in CommandEncoderDescriptor +struct DawnEncoderInternalUsageDescriptor : ChainedStruct { + DawnEncoderInternalUsageDescriptor() { + sType = SType::DawnEncoderInternalUsageDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool useInternalUsages = false; +}; + +// Can be chained in SupportedLimits +struct DawnExperimentalSubgroupLimits : ChainedStructOut { + DawnExperimentalSubgroupLimits() { + sType = SType::DawnExperimentalSubgroupLimits; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t minSubgroupSize = + WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxSubgroupSize = WGPU_LIMIT_U32_UNDEFINED; +}; + +// Can be chained in MultisampleState +struct DawnMultisampleStateRenderToSingleSampled : ChainedStruct { + DawnMultisampleStateRenderToSingleSampled() { + sType = SType::DawnMultisampleStateRenderToSingleSampled; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool enabled = false; +}; + +// Can be chained in RenderPassColorAttachment +struct DawnRenderPassColorAttachmentRenderToSingleSampled : ChainedStruct { + DawnRenderPassColorAttachmentRenderToSingleSampled() { + sType = SType::DawnRenderPassColorAttachmentRenderToSingleSampled; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t implicitSampleCount = 1; +}; + +// Can be chained in ShaderModuleDescriptor +struct DawnShaderModuleSPIRVOptionsDescriptor : ChainedStruct { + DawnShaderModuleSPIRVOptionsDescriptor() { + sType = SType::DawnShaderModuleSPIRVOptionsDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool allowNonUniformDerivatives = false; +}; + +// Can be chained in TextureDescriptor +struct DawnTextureInternalUsageDescriptor : ChainedStruct { + DawnTextureInternalUsageDescriptor() { + sType = SType::DawnTextureInternalUsageDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(TextureUsage)); + alignas(kFirstMemberAlignment) + TextureUsage internalUsage = TextureUsage::None; +}; + +// Can be chained in InstanceDescriptor +// Can be chained in RequestAdapterOptions +// Can be chained in DeviceDescriptor +struct DawnTogglesDescriptor : ChainedStruct { + DawnTogglesDescriptor() { sType = SType::DawnTogglesDescriptor; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(size_t)); + alignas(kFirstMemberAlignment) size_t enabledToggleCount = 0; + const char *const *enabledToggles; + size_t disabledToggleCount = 0; + const char *const *disabledToggles; +}; + +// Can be chained in InstanceDescriptor +struct DawnWireWGSLControl : ChainedStruct { + DawnWireWGSLControl() { sType = SType::DawnWireWGSLControl; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool enableExperimental = false; + Bool enableUnsafe = false; + Bool enableTesting = false; +}; + +// Can be chained in DepthStencilState +struct DepthStencilStateDepthWriteDefinedDawn : ChainedStruct { + DepthStencilStateDepthWriteDefinedDawn() { + sType = SType::DepthStencilStateDepthWriteDefinedDawn; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool depthWriteDefined; +}; + +struct DrmFormatProperties { + uint64_t modifier; + uint32_t modifierPlaneCount; +}; + +struct Extent2D { + uint32_t width; + uint32_t height; +}; + +struct Extent3D { + uint32_t width; + uint32_t height = 1; + uint32_t depthOrArrayLayers = 1; +}; + +// Can be chained in BindGroupEntry +struct ExternalTextureBindingEntry : ChainedStruct { + ExternalTextureBindingEntry() { sType = SType::ExternalTextureBindingEntry; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(ExternalTexture)); + alignas(kFirstMemberAlignment) ExternalTexture externalTexture; +}; + +// Can be chained in BindGroupLayoutEntry +struct ExternalTextureBindingLayout : ChainedStruct { + ExternalTextureBindingLayout() { + sType = SType::ExternalTextureBindingLayout; + } +}; + +struct FormatCapabilities { + ChainedStructOut *nextInChain = nullptr; +}; + +struct Future { + uint64_t id; +}; + +struct InstanceFeatures { + ChainedStruct const *nextInChain = nullptr; + Bool timedWaitAnyEnable = false; + size_t timedWaitAnyMaxCount = 0; +}; + +struct Limits { + uint32_t maxTextureDimension1D = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxTextureDimension2D = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxTextureDimension3D = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxTextureArrayLayers = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxBindGroups = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxBindGroupsPlusVertexBuffers = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxBindingsPerBindGroup = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxDynamicUniformBuffersPerPipelineLayout = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxDynamicStorageBuffersPerPipelineLayout = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxSampledTexturesPerShaderStage = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxSamplersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxStorageBuffersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxStorageTexturesPerShaderStage = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxUniformBuffersPerShaderStage = WGPU_LIMIT_U32_UNDEFINED; + uint64_t maxUniformBufferBindingSize = WGPU_LIMIT_U64_UNDEFINED; + uint64_t maxStorageBufferBindingSize = WGPU_LIMIT_U64_UNDEFINED; + uint32_t minUniformBufferOffsetAlignment = WGPU_LIMIT_U32_UNDEFINED; + uint32_t minStorageBufferOffsetAlignment = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxVertexBuffers = WGPU_LIMIT_U32_UNDEFINED; + uint64_t maxBufferSize = WGPU_LIMIT_U64_UNDEFINED; + uint32_t maxVertexAttributes = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxVertexBufferArrayStride = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxInterStageShaderComponents = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxInterStageShaderVariables = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxColorAttachments = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxColorAttachmentBytesPerSample = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeWorkgroupStorageSize = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeInvocationsPerWorkgroup = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeWorkgroupSizeX = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeWorkgroupSizeY = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeWorkgroupSizeZ = WGPU_LIMIT_U32_UNDEFINED; + uint32_t maxComputeWorkgroupsPerDimension = WGPU_LIMIT_U32_UNDEFINED; +}; + +struct MemoryHeapInfo { + HeapProperty properties; + uint64_t size; +}; + +struct MultisampleState { + ChainedStruct const *nextInChain = nullptr; + uint32_t count = 1; + uint32_t mask = 0xFFFFFFFF; + Bool alphaToCoverageEnabled = false; +}; + +struct Origin2D { + uint32_t x = 0; + uint32_t y = 0; +}; + +struct Origin3D { + uint32_t x = 0; + uint32_t y = 0; + uint32_t z = 0; +}; + +struct PipelineLayoutDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + size_t bindGroupLayoutCount; + BindGroupLayout const *bindGroupLayouts; +}; + +struct PipelineLayoutStorageAttachment { + ChainedStruct const *nextInChain = nullptr; + uint64_t offset = 0; + TextureFormat format; +}; + +struct PopErrorScopeCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + PopErrorScopeCallback callback; + ErrorCallback oldCallback; + void *userdata = nullptr; +}; + +// Can be chained in PrimitiveState +struct PrimitiveDepthClipControl : ChainedStruct { + PrimitiveDepthClipControl() { sType = SType::PrimitiveDepthClipControl; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool unclippedDepth = false; +}; + +struct PrimitiveState { + ChainedStruct const *nextInChain = nullptr; + PrimitiveTopology topology = PrimitiveTopology::TriangleList; + IndexFormat stripIndexFormat = IndexFormat::Undefined; + FrontFace frontFace = FrontFace::CCW; + CullMode cullMode = CullMode::None; +}; + +struct QuerySetDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + QueryType type; + uint32_t count; +}; + +struct QueueDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct QueueWorkDoneCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + QueueWorkDoneCallback callback; + void *userdata; +}; + +struct RenderBundleDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct RenderBundleEncoderDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + size_t colorFormatCount; + TextureFormat const *colorFormats; + TextureFormat depthStencilFormat = TextureFormat::Undefined; + uint32_t sampleCount = 1; + Bool depthReadOnly = false; + Bool stencilReadOnly = false; +}; + +struct RenderPassDepthStencilAttachment { + TextureView view; + LoadOp depthLoadOp = LoadOp::Undefined; + StoreOp depthStoreOp = StoreOp::Undefined; + float depthClearValue = NAN; + Bool depthReadOnly = false; + LoadOp stencilLoadOp = LoadOp::Undefined; + StoreOp stencilStoreOp = StoreOp::Undefined; + uint32_t stencilClearValue = 0; + Bool stencilReadOnly = false; +}; + +// Can be chained in RenderPassDescriptor +struct RenderPassDescriptorMaxDrawCount : ChainedStruct { + RenderPassDescriptorMaxDrawCount() { + sType = SType::RenderPassDescriptorMaxDrawCount; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint64_t)); + alignas(kFirstMemberAlignment) uint64_t maxDrawCount = 50000000; +}; + +struct RenderPassTimestampWrites { + QuerySet querySet; + uint32_t beginningOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED; + uint32_t endOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED; +}; + +struct RequestAdapterCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + RequestAdapterCallback callback; + void *userdata; +}; + +struct RequestAdapterOptions { + ChainedStruct const *nextInChain = nullptr; + Surface compatibleSurface = nullptr; + PowerPreference powerPreference = PowerPreference::Undefined; + BackendType backendType = BackendType::Undefined; + Bool forceFallbackAdapter = false; + Bool compatibilityMode = false; +}; + +struct RequestDeviceCallbackInfo { + ChainedStruct const *nextInChain = nullptr; + CallbackMode mode; + RequestDeviceCallback callback; + void *userdata; +}; + +struct SamplerBindingLayout { + ChainedStruct const *nextInChain = nullptr; + SamplerBindingType type = SamplerBindingType::Undefined; +}; + +struct SamplerDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + AddressMode addressModeU = AddressMode::ClampToEdge; + AddressMode addressModeV = AddressMode::ClampToEdge; + AddressMode addressModeW = AddressMode::ClampToEdge; + FilterMode magFilter = FilterMode::Nearest; + FilterMode minFilter = FilterMode::Nearest; + MipmapFilterMode mipmapFilter = MipmapFilterMode::Nearest; + float lodMinClamp = 0.0f; + float lodMaxClamp = 32.0f; + CompareFunction compare = CompareFunction::Undefined; + uint16_t maxAnisotropy = 1; +}; + +// Can be chained in ShaderModuleDescriptor +struct ShaderModuleSPIRVDescriptor : ChainedStruct { + ShaderModuleSPIRVDescriptor() { sType = SType::ShaderModuleSPIRVDescriptor; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t codeSize; + uint32_t const *code; +}; + +// Can be chained in ShaderModuleDescriptor +struct ShaderModuleWGSLDescriptor : ChainedStruct { + ShaderModuleWGSLDescriptor() { sType = SType::ShaderModuleWGSLDescriptor; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(char const *)); + alignas(kFirstMemberAlignment) char const *code; +}; + +struct ShaderModuleDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct SharedBufferMemoryBeginAccessDescriptor { + ChainedStruct const *nextInChain = nullptr; + Bool initialized; + size_t fenceCount; + SharedFence const *fences; + uint64_t const *signaledValues; +}; + +struct SharedBufferMemoryDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct SharedBufferMemoryEndAccessState { + SharedBufferMemoryEndAccessState() = default; + ~SharedBufferMemoryEndAccessState(); + SharedBufferMemoryEndAccessState(const SharedBufferMemoryEndAccessState &) = + delete; + SharedBufferMemoryEndAccessState & + operator=(const SharedBufferMemoryEndAccessState &) = delete; + SharedBufferMemoryEndAccessState(SharedBufferMemoryEndAccessState &&); + SharedBufferMemoryEndAccessState & + operator=(SharedBufferMemoryEndAccessState &&); + ChainedStructOut *nextInChain = nullptr; + Bool const initialized = {}; + size_t const fenceCount = {}; + SharedFence const *const fences = {}; + uint64_t const *const signaledValues = {}; +}; + +struct SharedBufferMemoryProperties { + ChainedStructOut *nextInChain = nullptr; + BufferUsage usage; + uint64_t size; +}; + +// Can be chained in SharedFenceDescriptor +struct SharedFenceDXGISharedHandleDescriptor : ChainedStruct { + SharedFenceDXGISharedHandleDescriptor() { + sType = SType::SharedFenceDXGISharedHandleDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *handle; +}; + +// Can be chained in SharedFenceExportInfo +struct SharedFenceDXGISharedHandleExportInfo : ChainedStructOut { + SharedFenceDXGISharedHandleExportInfo() { + sType = SType::SharedFenceDXGISharedHandleExportInfo; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *handle; +}; + +// Can be chained in SharedFenceDescriptor +struct SharedFenceMTLSharedEventDescriptor : ChainedStruct { + SharedFenceMTLSharedEventDescriptor() { + sType = SType::SharedFenceMTLSharedEventDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *sharedEvent; +}; + +// Can be chained in SharedFenceExportInfo +struct SharedFenceMTLSharedEventExportInfo : ChainedStructOut { + SharedFenceMTLSharedEventExportInfo() { + sType = SType::SharedFenceMTLSharedEventExportInfo; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *sharedEvent; +}; + +struct SharedFenceDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct SharedFenceExportInfo { + ChainedStructOut *nextInChain = nullptr; + SharedFenceType type; +}; + +// Can be chained in SharedFenceDescriptor +struct SharedFenceVkSemaphoreOpaqueFDDescriptor : ChainedStruct { + SharedFenceVkSemaphoreOpaqueFDDescriptor() { + sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int)); + alignas(kFirstMemberAlignment) int handle; +}; + +// Can be chained in SharedFenceExportInfo +struct SharedFenceVkSemaphoreOpaqueFDExportInfo : ChainedStructOut { + SharedFenceVkSemaphoreOpaqueFDExportInfo() { + sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int)); + alignas(kFirstMemberAlignment) int handle; +}; + +// Can be chained in SharedFenceDescriptor +struct SharedFenceVkSemaphoreSyncFDDescriptor : ChainedStruct { + SharedFenceVkSemaphoreSyncFDDescriptor() { + sType = SType::SharedFenceVkSemaphoreSyncFDDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int)); + alignas(kFirstMemberAlignment) int handle; +}; + +// Can be chained in SharedFenceExportInfo +struct SharedFenceVkSemaphoreSyncFDExportInfo : ChainedStructOut { + SharedFenceVkSemaphoreSyncFDExportInfo() { + sType = SType::SharedFenceVkSemaphoreSyncFDExportInfo; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int)); + alignas(kFirstMemberAlignment) int handle; +}; + +// Can be chained in SharedFenceDescriptor +struct SharedFenceVkSemaphoreZirconHandleDescriptor : ChainedStruct { + SharedFenceVkSemaphoreZirconHandleDescriptor() { + sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t handle; +}; + +// Can be chained in SharedFenceExportInfo +struct SharedFenceVkSemaphoreZirconHandleExportInfo : ChainedStructOut { + SharedFenceVkSemaphoreZirconHandleExportInfo() { + sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t handle; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryDXGISharedHandleDescriptor : ChainedStruct { + SharedTextureMemoryDXGISharedHandleDescriptor() { + sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *handle; + Bool useKeyedMutex; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryEGLImageDescriptor : ChainedStruct { + SharedTextureMemoryEGLImageDescriptor() { + sType = SType::SharedTextureMemoryEGLImageDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *image; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryIOSurfaceDescriptor : ChainedStruct { + SharedTextureMemoryIOSurfaceDescriptor() { + sType = SType::SharedTextureMemoryIOSurfaceDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *ioSurface; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryAHardwareBufferDescriptor : ChainedStruct { + SharedTextureMemoryAHardwareBufferDescriptor() { + sType = SType::SharedTextureMemoryAHardwareBufferDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *handle; +}; + +struct SharedTextureMemoryBeginAccessDescriptor { + ChainedStruct const *nextInChain = nullptr; + Bool concurrentRead; + Bool initialized; + size_t fenceCount; + SharedFence const *fences; + uint64_t const *signaledValues; +}; + +struct SharedTextureMemoryDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +struct SharedTextureMemoryDmaBufPlane { + int fd; + uint64_t offset; + uint32_t stride; +}; + +struct SharedTextureMemoryEndAccessState { + SharedTextureMemoryEndAccessState() = default; + ~SharedTextureMemoryEndAccessState(); + SharedTextureMemoryEndAccessState(const SharedTextureMemoryEndAccessState &) = + delete; + SharedTextureMemoryEndAccessState & + operator=(const SharedTextureMemoryEndAccessState &) = delete; + SharedTextureMemoryEndAccessState(SharedTextureMemoryEndAccessState &&); + SharedTextureMemoryEndAccessState & + operator=(SharedTextureMemoryEndAccessState &&); + ChainedStructOut *nextInChain = nullptr; + Bool const initialized = {}; + size_t const fenceCount = {}; + SharedFence const *const fences = {}; + uint64_t const *const signaledValues = {}; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryOpaqueFDDescriptor : ChainedStruct { + SharedTextureMemoryOpaqueFDDescriptor() { + sType = SType::SharedTextureMemoryOpaqueFDDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void const *)); + alignas(kFirstMemberAlignment) void const *vkImageCreateInfo; + int memoryFD; + uint32_t memoryTypeIndex; + uint64_t allocationSize; + Bool dedicatedAllocation; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryVkDedicatedAllocationDescriptor : ChainedStruct { + SharedTextureMemoryVkDedicatedAllocationDescriptor() { + sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Bool)); + alignas(kFirstMemberAlignment) Bool dedicatedAllocation; +}; + +// Can be chained in SharedTextureMemoryBeginAccessDescriptor +struct SharedTextureMemoryVkImageLayoutBeginState : ChainedStruct { + SharedTextureMemoryVkImageLayoutBeginState() { + sType = SType::SharedTextureMemoryVkImageLayoutBeginState; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t)); + alignas(kFirstMemberAlignment) int32_t oldLayout; + int32_t newLayout; +}; + +// Can be chained in SharedTextureMemoryEndAccessState +struct SharedTextureMemoryVkImageLayoutEndState : ChainedStructOut { + SharedTextureMemoryVkImageLayoutEndState() { + sType = SType::SharedTextureMemoryVkImageLayoutEndState; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t)); + alignas(kFirstMemberAlignment) int32_t oldLayout; + int32_t newLayout; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryZirconHandleDescriptor : ChainedStruct { + SharedTextureMemoryZirconHandleDescriptor() { + sType = SType::SharedTextureMemoryZirconHandleDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint32_t)); + alignas(kFirstMemberAlignment) uint32_t memoryFD; + uint64_t allocationSize; +}; + +// Can be chained in BindGroupLayoutEntry +struct StaticSamplerBindingLayout : ChainedStruct { + StaticSamplerBindingLayout() { sType = SType::StaticSamplerBindingLayout; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Sampler)); + alignas(kFirstMemberAlignment) Sampler sampler; +}; + +struct StencilFaceState { + CompareFunction compare = CompareFunction::Always; + StencilOperation failOp = StencilOperation::Keep; + StencilOperation depthFailOp = StencilOperation::Keep; + StencilOperation passOp = StencilOperation::Keep; +}; + +struct StorageTextureBindingLayout { + ChainedStruct const *nextInChain = nullptr; + StorageTextureAccess access = StorageTextureAccess::Undefined; + TextureFormat format = TextureFormat::Undefined; + TextureViewDimension viewDimension = TextureViewDimension::e2D; +}; + +struct SurfaceDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromAndroidNativeWindow : ChainedStruct { + SurfaceDescriptorFromAndroidNativeWindow() { + sType = SType::SurfaceDescriptorFromAndroidNativeWindow; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *window; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromCanvasHTMLSelector : ChainedStruct { + SurfaceDescriptorFromCanvasHTMLSelector() { + sType = SType::SurfaceDescriptorFromCanvasHTMLSelector; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(char const *)); + alignas(kFirstMemberAlignment) char const *selector; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromMetalLayer : ChainedStruct { + SurfaceDescriptorFromMetalLayer() { + sType = SType::SurfaceDescriptorFromMetalLayer; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *layer; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromWaylandSurface : ChainedStruct { + SurfaceDescriptorFromWaylandSurface() { + sType = SType::SurfaceDescriptorFromWaylandSurface; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *display; + void *surface; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromWindowsHWND : ChainedStruct { + SurfaceDescriptorFromWindowsHWND() { + sType = SType::SurfaceDescriptorFromWindowsHWND; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *hinstance; + void *hwnd; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromWindowsCoreWindow : ChainedStruct { + SurfaceDescriptorFromWindowsCoreWindow() { + sType = SType::SurfaceDescriptorFromWindowsCoreWindow; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *coreWindow; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromWindowsSwapChainPanel : ChainedStruct { + SurfaceDescriptorFromWindowsSwapChainPanel() { + sType = SType::SurfaceDescriptorFromWindowsSwapChainPanel; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *swapChainPanel; +}; + +// Can be chained in SurfaceDescriptor +struct SurfaceDescriptorFromXlibWindow : ChainedStruct { + SurfaceDescriptorFromXlibWindow() { + sType = SType::SurfaceDescriptorFromXlibWindow; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(void *)); + alignas(kFirstMemberAlignment) void *display; + uint64_t window; +}; + +struct SwapChainDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + TextureUsage usage; + TextureFormat format; + uint32_t width; + uint32_t height; + PresentMode presentMode; +}; + +struct TextureBindingLayout { + ChainedStruct const *nextInChain = nullptr; + TextureSampleType sampleType = TextureSampleType::Undefined; + TextureViewDimension viewDimension = TextureViewDimension::e2D; + Bool multisampled = false; +}; + +// Can be chained in TextureDescriptor +struct TextureBindingViewDimensionDescriptor : ChainedStruct { + TextureBindingViewDimensionDescriptor() { + sType = SType::TextureBindingViewDimensionDescriptor; + } + static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax( + alignof(ChainedStruct), alignof(TextureViewDimension)); + alignas(kFirstMemberAlignment) TextureViewDimension + textureBindingViewDimension = TextureViewDimension::Undefined; +}; + +struct TextureDataLayout { + ChainedStruct const *nextInChain = nullptr; + uint64_t offset = 0; + uint32_t bytesPerRow = WGPU_COPY_STRIDE_UNDEFINED; + uint32_t rowsPerImage = WGPU_COPY_STRIDE_UNDEFINED; +}; + +struct TextureViewDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + TextureFormat format = TextureFormat::Undefined; + TextureViewDimension dimension = TextureViewDimension::Undefined; + uint32_t baseMipLevel = 0; + uint32_t mipLevelCount = WGPU_MIP_LEVEL_COUNT_UNDEFINED; + uint32_t baseArrayLayer = 0; + uint32_t arrayLayerCount = WGPU_ARRAY_LAYER_COUNT_UNDEFINED; + TextureAspect aspect = TextureAspect::All; +}; + +struct VertexAttribute { + VertexFormat format; + uint64_t offset; + uint32_t shaderLocation; +}; + +// Can be chained in AdapterProperties +struct AdapterPropertiesMemoryHeaps : ChainedStructOut { + AdapterPropertiesMemoryHeaps() { + sType = SType::AdapterPropertiesMemoryHeaps; + } + ~AdapterPropertiesMemoryHeaps(); + AdapterPropertiesMemoryHeaps(const AdapterPropertiesMemoryHeaps &) = delete; + AdapterPropertiesMemoryHeaps & + operator=(const AdapterPropertiesMemoryHeaps &) = delete; + AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps &&); + AdapterPropertiesMemoryHeaps &operator=(AdapterPropertiesMemoryHeaps &&); + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(size_t)); + alignas(kFirstMemberAlignment) size_t const heapCount = {}; + MemoryHeapInfo const *const heapInfo = {}; +}; + +struct BindGroupDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + BindGroupLayout layout; + size_t entryCount; + BindGroupEntry const *entries; +}; + +struct BindGroupLayoutEntry { + ChainedStruct const *nextInChain = nullptr; + uint32_t binding; + ShaderStage visibility; + BufferBindingLayout buffer; + SamplerBindingLayout sampler; + TextureBindingLayout texture; + StorageTextureBindingLayout storageTexture; +}; + +struct BlendState { + BlendComponent color; + BlendComponent alpha; +}; + +struct CompilationInfo { + ChainedStruct const *nextInChain = nullptr; + size_t messageCount; + CompilationMessage const *messages; +}; + +struct ComputePassDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + ComputePassTimestampWrites const *timestampWrites = nullptr; +}; + +struct DepthStencilState { + ChainedStruct const *nextInChain = nullptr; + TextureFormat format; + Bool depthWriteEnabled = false; + CompareFunction depthCompare = CompareFunction::Undefined; + StencilFaceState stencilFront; + StencilFaceState stencilBack; + uint32_t stencilReadMask = 0xFFFFFFFF; + uint32_t stencilWriteMask = 0xFFFFFFFF; + int32_t depthBias = 0; + float depthBiasSlopeScale = 0.0f; + float depthBiasClamp = 0.0f; +}; + +// Can be chained in FormatCapabilities +struct DrmFormatCapabilities : ChainedStructOut { + DrmFormatCapabilities() { sType = SType::DrmFormatCapabilities; } + ~DrmFormatCapabilities(); + DrmFormatCapabilities(const DrmFormatCapabilities &) = delete; + DrmFormatCapabilities &operator=(const DrmFormatCapabilities &) = delete; + DrmFormatCapabilities(DrmFormatCapabilities &&); + DrmFormatCapabilities &operator=(DrmFormatCapabilities &&); + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(size_t)); + alignas(kFirstMemberAlignment) size_t const propertiesCount = {}; + DrmFormatProperties const *const properties = {}; +}; + +struct ExternalTextureDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + TextureView plane0; + TextureView plane1 = nullptr; + Origin2D visibleOrigin; + Extent2D visibleSize; + Bool doYuvToRgbConversionOnly = false; + float const *yuvToRgbConversionMatrix = nullptr; + float const *srcTransferFunctionParameters; + float const *dstTransferFunctionParameters; + float const *gamutConversionMatrix; + Bool flipY = false; + Bool mirrored = false; + ExternalTextureRotation rotation = ExternalTextureRotation::Rotate0Degrees; +}; + +struct FutureWaitInfo { + Future future; + Bool completed = false; +}; + +struct ImageCopyBuffer { + ChainedStruct const *nextInChain = nullptr; + TextureDataLayout layout; + Buffer buffer; +}; + +struct ImageCopyExternalTexture { + ChainedStruct const *nextInChain = nullptr; + ExternalTexture externalTexture; + Origin3D origin; + Extent2D naturalSize; +}; + +struct ImageCopyTexture { + ChainedStruct const *nextInChain = nullptr; + Texture texture; + uint32_t mipLevel = 0; + Origin3D origin; + TextureAspect aspect = TextureAspect::All; +}; + +struct InstanceDescriptor { + ChainedStruct const *nextInChain = nullptr; + InstanceFeatures features; +}; + +// Can be chained in PipelineLayoutDescriptor +struct PipelineLayoutPixelLocalStorage : ChainedStruct { + PipelineLayoutPixelLocalStorage() { + sType = SType::PipelineLayoutPixelLocalStorage; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint64_t)); + alignas(kFirstMemberAlignment) uint64_t totalPixelLocalStorageSize; + size_t storageAttachmentCount = 0; + PipelineLayoutStorageAttachment const *storageAttachments; +}; + +struct ProgrammableStageDescriptor { + ChainedStruct const *nextInChain = nullptr; + ShaderModule module; + char const *entryPoint = nullptr; + size_t constantCount = 0; + ConstantEntry const *constants; +}; + +struct RenderPassColorAttachment { + ChainedStruct const *nextInChain = nullptr; + TextureView view = nullptr; + uint32_t depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; + TextureView resolveTarget = nullptr; + LoadOp loadOp; + StoreOp storeOp; + Color clearValue; +}; + +struct RenderPassStorageAttachment { + ChainedStruct const *nextInChain = nullptr; + uint64_t offset = 0; + TextureView storage; + LoadOp loadOp; + StoreOp storeOp; + Color clearValue; +}; + +struct RequiredLimits { + ChainedStruct const *nextInChain = nullptr; + Limits limits; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryDmaBufDescriptor : ChainedStruct { + SharedTextureMemoryDmaBufDescriptor() { + sType = SType::SharedTextureMemoryDmaBufDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(Extent3D)); + alignas(kFirstMemberAlignment) Extent3D size; + uint32_t drmFormat; + uint64_t drmModifier; + size_t planeCount; + SharedTextureMemoryDmaBufPlane const *planes; +}; + +struct SharedTextureMemoryProperties { + ChainedStructOut *nextInChain = nullptr; + TextureUsage usage; + Extent3D size; + TextureFormat format; +}; + +// Can be chained in SharedTextureMemoryDescriptor +struct SharedTextureMemoryVkImageDescriptor : ChainedStruct { + SharedTextureMemoryVkImageDescriptor() { + sType = SType::SharedTextureMemoryVkImageDescriptor; + } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(int32_t)); + alignas(kFirstMemberAlignment) int32_t vkFormat; + int32_t vkUsageFlags; + Extent3D vkExtent3D; +}; + +struct SupportedLimits { + ChainedStructOut *nextInChain = nullptr; + Limits limits; +}; + +struct TextureDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + TextureUsage usage; + TextureDimension dimension = TextureDimension::e2D; + Extent3D size; + TextureFormat format; + uint32_t mipLevelCount = 1; + uint32_t sampleCount = 1; + size_t viewFormatCount = 0; + TextureFormat const *viewFormats; +}; + +struct VertexBufferLayout { + uint64_t arrayStride; + VertexStepMode stepMode = VertexStepMode::Vertex; + size_t attributeCount; + VertexAttribute const *attributes; +}; + +struct BindGroupLayoutDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + size_t entryCount; + BindGroupLayoutEntry const *entries; +}; + +struct ColorTargetState { + ChainedStruct const *nextInChain = nullptr; + TextureFormat format; + BlendState const *blend = nullptr; + ColorWriteMask writeMask = ColorWriteMask::All; +}; + +struct ComputePipelineDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + PipelineLayout layout = nullptr; + ProgrammableStageDescriptor compute; +}; + +struct DeviceDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + size_t requiredFeatureCount = 0; + FeatureName const *requiredFeatures = nullptr; + RequiredLimits const *requiredLimits = nullptr; + QueueDescriptor defaultQueue; + DeviceLostCallback deviceLostCallback = nullptr; + void *deviceLostUserdata = nullptr; +}; + +struct RenderPassDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + size_t colorAttachmentCount; + RenderPassColorAttachment const *colorAttachments; + RenderPassDepthStencilAttachment const *depthStencilAttachment = nullptr; + QuerySet occlusionQuerySet = nullptr; + RenderPassTimestampWrites const *timestampWrites = nullptr; +}; + +// Can be chained in RenderPassDescriptor +struct RenderPassPixelLocalStorage : ChainedStruct { + RenderPassPixelLocalStorage() { sType = SType::RenderPassPixelLocalStorage; } + static constexpr size_t kFirstMemberAlignment = + detail::ConstexprMax(alignof(ChainedStruct), alignof(uint64_t)); + alignas(kFirstMemberAlignment) uint64_t totalPixelLocalStorageSize; + size_t storageAttachmentCount = 0; + RenderPassStorageAttachment const *storageAttachments; +}; + +struct VertexState { + ChainedStruct const *nextInChain = nullptr; + ShaderModule module; + char const *entryPoint = nullptr; + size_t constantCount = 0; + ConstantEntry const *constants; + size_t bufferCount = 0; + VertexBufferLayout const *buffers; +}; + +struct FragmentState { + ChainedStruct const *nextInChain = nullptr; + ShaderModule module; + char const *entryPoint = nullptr; + size_t constantCount = 0; + ConstantEntry const *constants; + size_t targetCount; + ColorTargetState const *targets; +}; + +struct RenderPipelineDescriptor { + ChainedStruct const *nextInChain = nullptr; + char const *label = nullptr; + PipelineLayout layout = nullptr; + VertexState vertex; + PrimitiveState primitive; + DepthStencilState const *depthStencil = nullptr; + MultisampleState multisample; + FragmentState const *fragment = nullptr; +}; + +} // namespace wgpu + +namespace wgpu { +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +template <> struct IsWGPUBitmask { + static constexpr bool enable = true; +}; + +} // namespace wgpu + +namespace std { +// Custom boolean class needs corresponding hash function so that it appears as +// a transparent bool. +template <> struct hash { +public: + size_t operator()(const wgpu::Bool &v) const { return hash()(v); } +}; +} // namespace std + +#endif // WEBGPU_CPP_H_ diff --git a/package/android/cpp/rnskia-android/webgpu.hpp b/package/android/cpp/rnskia-android/webgpu.hpp deleted file mode 100644 index 89c3fb0c9d..0000000000 --- a/package/android/cpp/rnskia-android/webgpu.hpp +++ /dev/null @@ -1,3872 +0,0 @@ -/** - * This file is part of the "Learn WebGPU for C++" book. - * https://github.com/eliemichel/LearnWebGPU - * - * MIT License - * Copyright (c) 2022 Elie Michel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * Exactly one of your source files must #define WEBGPU_CPP_IMPLEMENTATION - * before including this header. - * - * NB: This file has been generated by the webgpu-cpp generator - * (see https://github.com/eliemichel/webgpu-cpp ) - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include - -#if __EMSCRIPTEN__ -#include -#endif - -/** - * A namespace providing a more C++ idiomatic API to WebGPU. - */ -namespace wgpu { - -struct DefaultFlag {}; -constexpr DefaultFlag Default; - -#define HANDLE(Type) \ -class Type { \ -public: \ - typedef Type S; /* S == Self */ \ - typedef WGPU ## Type W; /* W == WGPU Type */ \ - Type(const W& w) : m_raw(w) {} \ - operator W&() { return m_raw; } \ - operator const W&() const { return m_raw; } \ - operator bool() const { return m_raw != nullptr; } \ - bool operator==(const Type& other) const { return m_raw == other.m_raw; } \ - bool operator!=(const Type& other) const { return m_raw != other.m_raw; } \ - bool operator==(const W& other) const { return m_raw == other; } \ - bool operator!=(const W& other) const { return m_raw != other; } \ - friend auto operator<<(std::ostream &stream, const S& self) -> std::ostream & { \ - return stream << ""; \ - } \ -private: \ - W m_raw; \ -public: - -#define DESCRIPTOR(Type) \ -struct Type : public WGPU ## Type { \ -public: \ - typedef Type S; /* S == Self */ \ - typedef WGPU ## Type W; /* W == WGPU Type */ \ - Type() : W() { nextInChain = nullptr; } \ - Type(const W &other) : W(other) { nextInChain = nullptr; } \ - Type(const DefaultFlag &) : W() { setDefault(); } \ - Type& operator=(const DefaultFlag &) { setDefault(); return *this; } \ - friend auto operator<<(std::ostream &stream, const S&) -> std::ostream & { \ - return stream << ""; \ - } \ -public: - -#define STRUCT(Type) \ -struct Type : public WGPU ## Type { \ -public: \ - typedef Type S; /* S == Self */ \ - typedef WGPU ## Type W; /* W == WGPU Type */ \ - Type() : W() {} \ - Type(const W &other) : W(other) {} \ - Type(const DefaultFlag &) : W() { setDefault(); } \ - Type& operator=(const DefaultFlag &) { setDefault(); return *this; } \ - friend auto operator<<(std::ostream &stream, const S&) -> std::ostream & { \ - return stream << ""; \ - } \ -public: - -#define ENUM(Type) \ -class Type { \ -public: \ - typedef Type S; /* S == Self */ \ - typedef WGPU ## Type W; /* W == WGPU Type */ \ - Type(const W& w) : m_raw(w) {} \ - operator W() const { return m_raw; } \ -private: \ - W m_raw; \ -public: - -#define ENUM_ENTRY(Name, Value) \ - static constexpr W Name = (W)Value; - -#define END }; - - - -// Other type aliases -using Flags = uint32_t; -using Bool = uint32_t; -using BufferUsageFlags = WGPUFlags; -using ColorWriteMaskFlags = WGPUFlags; -using HeapPropertyFlags = WGPUFlags; -using MapModeFlags = WGPUFlags; -using ShaderStageFlags = WGPUFlags; -using TextureUsageFlags = WGPUFlags; - -// Enumerations -ENUM(WGSLFeatureName) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(ReadonlyAndReadwriteStorageTextures, 0x00000001) - ENUM_ENTRY(Packed4x8IntegerDotProduct, 0x00000002) - ENUM_ENTRY(UnrestrictedPointerParameters, 0x00000003) - ENUM_ENTRY(PointerCompositeAccess, 0x00000004) - ENUM_ENTRY(ChromiumTestingUnimplemented, 0x000003E8) - ENUM_ENTRY(ChromiumTestingUnsafeExperimental, 0x000003E9) - ENUM_ENTRY(ChromiumTestingExperimental, 0x000003EA) - ENUM_ENTRY(ChromiumTestingShippedWithKillswitch, 0x000003EB) - ENUM_ENTRY(ChromiumTestingShipped, 0x000003EC) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(AdapterType) - ENUM_ENTRY(DiscreteGPU, 0x00000001) - ENUM_ENTRY(IntegratedGPU, 0x00000002) - ENUM_ENTRY(CPU, 0x00000003) - ENUM_ENTRY(Unknown, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(AddressMode) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(ClampToEdge, 0x00000001) - ENUM_ENTRY(Repeat, 0x00000002) - ENUM_ENTRY(MirrorRepeat, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(AlphaMode) - ENUM_ENTRY(Opaque, 0x00000001) - ENUM_ENTRY(Premultiplied, 0x00000002) - ENUM_ENTRY(Unpremultiplied, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BackendType) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Null, 0x00000001) - ENUM_ENTRY(WebGPU, 0x00000002) - ENUM_ENTRY(D3D11, 0x00000003) - ENUM_ENTRY(D3D12, 0x00000004) - ENUM_ENTRY(Metal, 0x00000005) - ENUM_ENTRY(Vulkan, 0x00000006) - ENUM_ENTRY(OpenGL, 0x00000007) - ENUM_ENTRY(OpenGLES, 0x00000008) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BlendFactor) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Zero, 0x00000001) - ENUM_ENTRY(One, 0x00000002) - ENUM_ENTRY(Src, 0x00000003) - ENUM_ENTRY(OneMinusSrc, 0x00000004) - ENUM_ENTRY(SrcAlpha, 0x00000005) - ENUM_ENTRY(OneMinusSrcAlpha, 0x00000006) - ENUM_ENTRY(Dst, 0x00000007) - ENUM_ENTRY(OneMinusDst, 0x00000008) - ENUM_ENTRY(DstAlpha, 0x00000009) - ENUM_ENTRY(OneMinusDstAlpha, 0x0000000A) - ENUM_ENTRY(SrcAlphaSaturated, 0x0000000B) - ENUM_ENTRY(Constant, 0x0000000C) - ENUM_ENTRY(OneMinusConstant, 0x0000000D) - ENUM_ENTRY(Src1, 0x0000000E) - ENUM_ENTRY(OneMinusSrc1, 0x0000000F) - ENUM_ENTRY(Src1Alpha, 0x00000010) - ENUM_ENTRY(OneMinusSrc1Alpha, 0x00000011) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BlendOperation) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Add, 0x00000001) - ENUM_ENTRY(Subtract, 0x00000002) - ENUM_ENTRY(ReverseSubtract, 0x00000003) - ENUM_ENTRY(Min, 0x00000004) - ENUM_ENTRY(Max, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BufferBindingType) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Uniform, 0x00000001) - ENUM_ENTRY(Storage, 0x00000002) - ENUM_ENTRY(ReadOnlyStorage, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BufferMapAsyncStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(ValidationError, 0x00000002) - ENUM_ENTRY(Unknown, 0x00000003) - ENUM_ENTRY(DeviceLost, 0x00000004) - ENUM_ENTRY(DestroyedBeforeCallback, 0x00000005) - ENUM_ENTRY(UnmappedBeforeCallback, 0x00000006) - ENUM_ENTRY(MappingAlreadyPending, 0x00000007) - ENUM_ENTRY(OffsetOutOfRange, 0x00000008) - ENUM_ENTRY(SizeOutOfRange, 0x00000009) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BufferMapState) - ENUM_ENTRY(Unmapped, 0x00000001) - ENUM_ENTRY(Pending, 0x00000002) - ENUM_ENTRY(Mapped, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CallbackMode) - ENUM_ENTRY(WaitAnyOnly, 0x00000000) - ENUM_ENTRY(AllowProcessEvents, 0x00000001) - ENUM_ENTRY(AllowSpontaneous, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CompareFunction) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Never, 0x00000001) - ENUM_ENTRY(Less, 0x00000002) - ENUM_ENTRY(Equal, 0x00000003) - ENUM_ENTRY(LessEqual, 0x00000004) - ENUM_ENTRY(Greater, 0x00000005) - ENUM_ENTRY(NotEqual, 0x00000006) - ENUM_ENTRY(GreaterEqual, 0x00000007) - ENUM_ENTRY(Always, 0x00000008) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CompilationInfoRequestStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(Error, 0x00000002) - ENUM_ENTRY(DeviceLost, 0x00000003) - ENUM_ENTRY(Unknown, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CompilationMessageType) - ENUM_ENTRY(Error, 0x00000001) - ENUM_ENTRY(Warning, 0x00000002) - ENUM_ENTRY(Info, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CreatePipelineAsyncStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(ValidationError, 0x00000002) - ENUM_ENTRY(InternalError, 0x00000003) - ENUM_ENTRY(DeviceLost, 0x00000004) - ENUM_ENTRY(DeviceDestroyed, 0x00000005) - ENUM_ENTRY(Unknown, 0x00000006) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(CullMode) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(None, 0x00000001) - ENUM_ENTRY(Front, 0x00000002) - ENUM_ENTRY(Back, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(DeviceLostReason) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Destroyed, 0x00000001) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(ErrorFilter) - ENUM_ENTRY(Validation, 0x00000001) - ENUM_ENTRY(OutOfMemory, 0x00000002) - ENUM_ENTRY(Internal, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(ErrorType) - ENUM_ENTRY(NoError, 0x00000000) - ENUM_ENTRY(Validation, 0x00000001) - ENUM_ENTRY(OutOfMemory, 0x00000002) - ENUM_ENTRY(Internal, 0x00000003) - ENUM_ENTRY(Unknown, 0x00000004) - ENUM_ENTRY(DeviceLost, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(ExternalTextureRotation) - ENUM_ENTRY(Rotate0Degrees, 0x00000000) - ENUM_ENTRY(Rotate90Degrees, 0x00000001) - ENUM_ENTRY(Rotate180Degrees, 0x00000002) - ENUM_ENTRY(Rotate270Degrees, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(FeatureName) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(DepthClipControl, 0x00000001) - ENUM_ENTRY(Depth32FloatStencil8, 0x00000002) - ENUM_ENTRY(TimestampQuery, 0x00000003) - ENUM_ENTRY(TextureCompressionBC, 0x00000004) - ENUM_ENTRY(TextureCompressionETC2, 0x00000005) - ENUM_ENTRY(TextureCompressionASTC, 0x00000006) - ENUM_ENTRY(IndirectFirstInstance, 0x00000007) - ENUM_ENTRY(ShaderF16, 0x00000008) - ENUM_ENTRY(RG11B10UfloatRenderable, 0x00000009) - ENUM_ENTRY(BGRA8UnormStorage, 0x0000000A) - ENUM_ENTRY(Float32Filterable, 0x0000000B) - ENUM_ENTRY(DawnInternalUsages, 0x000003EA) - ENUM_ENTRY(DawnMultiPlanarFormats, 0x000003EB) - ENUM_ENTRY(DawnNative, 0x000003EC) - ENUM_ENTRY(ChromiumExperimentalTimestampQueryInsidePasses, 0x000003EE) - ENUM_ENTRY(ImplicitDeviceSynchronization, 0x000003EF) - ENUM_ENTRY(SurfaceCapabilities, 0x000003F0) - ENUM_ENTRY(TransientAttachments, 0x000003F1) - ENUM_ENTRY(MSAARenderToSingleSampled, 0x000003F2) - ENUM_ENTRY(DualSourceBlending, 0x000003F3) - ENUM_ENTRY(D3D11MultithreadProtected, 0x000003F4) - ENUM_ENTRY(ANGLETextureSharing, 0x000003F5) - ENUM_ENTRY(ChromiumExperimentalSubgroups, 0x000003F6) - ENUM_ENTRY(ChromiumExperimentalSubgroupUniformControlFlow, 0x000003F7) - ENUM_ENTRY(PixelLocalStorageCoherent, 0x000003F9) - ENUM_ENTRY(PixelLocalStorageNonCoherent, 0x000003FA) - ENUM_ENTRY(Unorm16TextureFormats, 0x000003FB) - ENUM_ENTRY(Snorm16TextureFormats, 0x000003FC) - ENUM_ENTRY(MultiPlanarFormatExtendedUsages, 0x000003FD) - ENUM_ENTRY(MultiPlanarFormatP010, 0x000003FE) - ENUM_ENTRY(HostMappedPointer, 0x000003FF) - ENUM_ENTRY(MultiPlanarRenderTargets, 0x00000400) - ENUM_ENTRY(MultiPlanarFormatNv12a, 0x00000401) - ENUM_ENTRY(FramebufferFetch, 0x00000402) - ENUM_ENTRY(BufferMapExtendedUsages, 0x00000403) - ENUM_ENTRY(AdapterPropertiesMemoryHeaps, 0x00000404) - ENUM_ENTRY(AdapterPropertiesD3D, 0x00000405) - ENUM_ENTRY(AdapterPropertiesVk, 0x00000406) - ENUM_ENTRY(R8UnormStorage, 0x00000407) - ENUM_ENTRY(FormatCapabilities, 0x00000408) - ENUM_ENTRY(DrmFormatCapabilities, 0x00000409) - ENUM_ENTRY(Norm16TextureFormats, 0x0000040A) - ENUM_ENTRY(SharedTextureMemoryVkDedicatedAllocation, 0x0000044C) - ENUM_ENTRY(SharedTextureMemoryAHardwareBuffer, 0x0000044D) - ENUM_ENTRY(SharedTextureMemoryDmaBuf, 0x0000044E) - ENUM_ENTRY(SharedTextureMemoryOpaqueFD, 0x0000044F) - ENUM_ENTRY(SharedTextureMemoryZirconHandle, 0x00000450) - ENUM_ENTRY(SharedTextureMemoryDXGISharedHandle, 0x00000451) - ENUM_ENTRY(SharedTextureMemoryD3D11Texture2D, 0x00000452) - ENUM_ENTRY(SharedTextureMemoryIOSurface, 0x00000453) - ENUM_ENTRY(SharedTextureMemoryEGLImage, 0x00000454) - ENUM_ENTRY(SharedFenceVkSemaphoreOpaqueFD, 0x000004B0) - ENUM_ENTRY(SharedFenceVkSemaphoreSyncFD, 0x000004B1) - ENUM_ENTRY(SharedFenceVkSemaphoreZirconHandle, 0x000004B2) - ENUM_ENTRY(SharedFenceDXGISharedHandle, 0x000004B3) - ENUM_ENTRY(SharedFenceMTLSharedEvent, 0x000004B4) - ENUM_ENTRY(SharedBufferMemoryD3D12Resource, 0x000004B5) - ENUM_ENTRY(StaticSamplers, 0x000004B6) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(FilterMode) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Nearest, 0x00000001) - ENUM_ENTRY(Linear, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(FrontFace) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(CCW, 0x00000001) - ENUM_ENTRY(CW, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(IndexFormat) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Uint16, 0x00000001) - ENUM_ENTRY(Uint32, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(LoadOp) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Clear, 0x00000001) - ENUM_ENTRY(Load, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(LoggingType) - ENUM_ENTRY(Verbose, 0x00000001) - ENUM_ENTRY(Info, 0x00000002) - ENUM_ENTRY(Warning, 0x00000003) - ENUM_ENTRY(Error, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(MipmapFilterMode) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Nearest, 0x00000001) - ENUM_ENTRY(Linear, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(PopErrorScopeStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(PowerPreference) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(LowPower, 0x00000001) - ENUM_ENTRY(HighPerformance, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(PresentMode) - ENUM_ENTRY(Fifo, 0x00000001) - ENUM_ENTRY(Immediate, 0x00000003) - ENUM_ENTRY(Mailbox, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(PrimitiveTopology) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(PointList, 0x00000001) - ENUM_ENTRY(LineList, 0x00000002) - ENUM_ENTRY(LineStrip, 0x00000003) - ENUM_ENTRY(TriangleList, 0x00000004) - ENUM_ENTRY(TriangleStrip, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(QueryType) - ENUM_ENTRY(Occlusion, 0x00000001) - ENUM_ENTRY(Timestamp, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(QueueWorkDoneStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(Error, 0x00000002) - ENUM_ENTRY(Unknown, 0x00000003) - ENUM_ENTRY(DeviceLost, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(RequestAdapterStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(Unavailable, 0x00000002) - ENUM_ENTRY(Error, 0x00000003) - ENUM_ENTRY(Unknown, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(RequestDeviceStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(InstanceDropped, 0x00000001) - ENUM_ENTRY(Error, 0x00000002) - ENUM_ENTRY(Unknown, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(SType) - ENUM_ENTRY(Invalid, 0x00000000) - ENUM_ENTRY(SurfaceDescriptorFromMetalLayer, 0x00000001) - ENUM_ENTRY(SurfaceDescriptorFromWindowsHWND, 0x00000002) - ENUM_ENTRY(SurfaceDescriptorFromXlibWindow, 0x00000003) - ENUM_ENTRY(SurfaceDescriptorFromCanvasHTMLSelector, 0x00000004) - ENUM_ENTRY(ShaderModuleSPIRVDescriptor, 0x00000005) - ENUM_ENTRY(ShaderModuleWGSLDescriptor, 0x00000006) - ENUM_ENTRY(PrimitiveDepthClipControl, 0x00000007) - ENUM_ENTRY(SurfaceDescriptorFromWaylandSurface, 0x00000008) - ENUM_ENTRY(SurfaceDescriptorFromAndroidNativeWindow, 0x00000009) - ENUM_ENTRY(SurfaceDescriptorFromWindowsCoreWindow, 0x0000000B) - ENUM_ENTRY(ExternalTextureBindingEntry, 0x0000000C) - ENUM_ENTRY(ExternalTextureBindingLayout, 0x0000000D) - ENUM_ENTRY(SurfaceDescriptorFromWindowsSwapChainPanel, 0x0000000E) - ENUM_ENTRY(RenderPassDescriptorMaxDrawCount, 0x0000000F) - ENUM_ENTRY(DepthStencilStateDepthWriteDefinedDawn, 0x00000010) - ENUM_ENTRY(TextureBindingViewDimensionDescriptor, 0x00000011) - ENUM_ENTRY(DawnTextureInternalUsageDescriptor, 0x000003E8) - ENUM_ENTRY(DawnEncoderInternalUsageDescriptor, 0x000003EB) - ENUM_ENTRY(DawnInstanceDescriptor, 0x000003EC) - ENUM_ENTRY(DawnCacheDeviceDescriptor, 0x000003ED) - ENUM_ENTRY(DawnAdapterPropertiesPowerPreference, 0x000003EE) - ENUM_ENTRY(DawnBufferDescriptorErrorInfoFromWireClient, 0x000003EF) - ENUM_ENTRY(DawnTogglesDescriptor, 0x000003F0) - ENUM_ENTRY(DawnShaderModuleSPIRVOptionsDescriptor, 0x000003F1) - ENUM_ENTRY(RequestAdapterOptionsLUID, 0x000003F2) - ENUM_ENTRY(RequestAdapterOptionsGetGLProc, 0x000003F3) - ENUM_ENTRY(RequestAdapterOptionsD3D11Device, 0x000003F4) - ENUM_ENTRY(DawnMultisampleStateRenderToSingleSampled, 0x000003F5) - ENUM_ENTRY(DawnRenderPassColorAttachmentRenderToSingleSampled, 0x000003F6) - ENUM_ENTRY(RenderPassPixelLocalStorage, 0x000003F7) - ENUM_ENTRY(PipelineLayoutPixelLocalStorage, 0x000003F8) - ENUM_ENTRY(BufferHostMappedPointer, 0x000003F9) - ENUM_ENTRY(DawnExperimentalSubgroupLimits, 0x000003FA) - ENUM_ENTRY(AdapterPropertiesMemoryHeaps, 0x000003FB) - ENUM_ENTRY(AdapterPropertiesD3D, 0x000003FC) - ENUM_ENTRY(AdapterPropertiesVk, 0x000003FD) - ENUM_ENTRY(DawnComputePipelineFullSubgroups, 0x000003FE) - ENUM_ENTRY(DawnWireWGSLControl, 0x000003FF) - ENUM_ENTRY(DawnWGSLBlocklist, 0x00000400) - ENUM_ENTRY(DrmFormatCapabilities, 0x00000401) - ENUM_ENTRY(SharedTextureMemoryVkImageDescriptor, 0x0000044C) - ENUM_ENTRY(SharedTextureMemoryVkDedicatedAllocationDescriptor, 0x0000044D) - ENUM_ENTRY(SharedTextureMemoryAHardwareBufferDescriptor, 0x0000044E) - ENUM_ENTRY(SharedTextureMemoryDmaBufDescriptor, 0x0000044F) - ENUM_ENTRY(SharedTextureMemoryOpaqueFDDescriptor, 0x00000450) - ENUM_ENTRY(SharedTextureMemoryZirconHandleDescriptor, 0x00000451) - ENUM_ENTRY(SharedTextureMemoryDXGISharedHandleDescriptor, 0x00000452) - ENUM_ENTRY(SharedTextureMemoryD3D11Texture2DDescriptor, 0x00000453) - ENUM_ENTRY(SharedTextureMemoryIOSurfaceDescriptor, 0x00000454) - ENUM_ENTRY(SharedTextureMemoryEGLImageDescriptor, 0x00000455) - ENUM_ENTRY(SharedTextureMemoryInitializedBeginState, 0x000004B0) - ENUM_ENTRY(SharedTextureMemoryInitializedEndState, 0x000004B1) - ENUM_ENTRY(SharedTextureMemoryVkImageLayoutBeginState, 0x000004B2) - ENUM_ENTRY(SharedTextureMemoryVkImageLayoutEndState, 0x000004B3) - ENUM_ENTRY(SharedFenceVkSemaphoreOpaqueFDDescriptor, 0x000004B4) - ENUM_ENTRY(SharedFenceVkSemaphoreOpaqueFDExportInfo, 0x000004B5) - ENUM_ENTRY(SharedFenceVkSemaphoreSyncFDDescriptor, 0x000004B6) - ENUM_ENTRY(SharedFenceVkSemaphoreSyncFDExportInfo, 0x000004B7) - ENUM_ENTRY(SharedFenceVkSemaphoreZirconHandleDescriptor, 0x000004B8) - ENUM_ENTRY(SharedFenceVkSemaphoreZirconHandleExportInfo, 0x000004B9) - ENUM_ENTRY(SharedFenceDXGISharedHandleDescriptor, 0x000004BA) - ENUM_ENTRY(SharedFenceDXGISharedHandleExportInfo, 0x000004BB) - ENUM_ENTRY(SharedFenceMTLSharedEventDescriptor, 0x000004BC) - ENUM_ENTRY(SharedFenceMTLSharedEventExportInfo, 0x000004BD) - ENUM_ENTRY(SharedBufferMemoryD3D12ResourceDescriptor, 0x000004BE) - ENUM_ENTRY(StaticSamplerBindingLayout, 0x000004BF) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(SamplerBindingType) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Filtering, 0x00000001) - ENUM_ENTRY(NonFiltering, 0x00000002) - ENUM_ENTRY(Comparison, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(SharedFenceType) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(VkSemaphoreOpaqueFD, 0x00000001) - ENUM_ENTRY(VkSemaphoreSyncFD, 0x00000002) - ENUM_ENTRY(VkSemaphoreZirconHandle, 0x00000003) - ENUM_ENTRY(DXGISharedHandle, 0x00000004) - ENUM_ENTRY(MTLSharedEvent, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(StencilOperation) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Keep, 0x00000001) - ENUM_ENTRY(Zero, 0x00000002) - ENUM_ENTRY(Replace, 0x00000003) - ENUM_ENTRY(Invert, 0x00000004) - ENUM_ENTRY(IncrementClamp, 0x00000005) - ENUM_ENTRY(DecrementClamp, 0x00000006) - ENUM_ENTRY(IncrementWrap, 0x00000007) - ENUM_ENTRY(DecrementWrap, 0x00000008) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(StorageTextureAccess) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(WriteOnly, 0x00000001) - ENUM_ENTRY(ReadOnly, 0x00000002) - ENUM_ENTRY(ReadWrite, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(StoreOp) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Store, 0x00000001) - ENUM_ENTRY(Discard, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureAspect) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(All, 0x00000001) - ENUM_ENTRY(StencilOnly, 0x00000002) - ENUM_ENTRY(DepthOnly, 0x00000003) - ENUM_ENTRY(Plane0Only, 0x00000004) - ENUM_ENTRY(Plane1Only, 0x00000005) - ENUM_ENTRY(Plane2Only, 0x00000006) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureDimension) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(_1D, 0x00000001) - ENUM_ENTRY(_2D, 0x00000002) - ENUM_ENTRY(_3D, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureFormat) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(R8Unorm, 0x00000001) - ENUM_ENTRY(R8Snorm, 0x00000002) - ENUM_ENTRY(R8Uint, 0x00000003) - ENUM_ENTRY(R8Sint, 0x00000004) - ENUM_ENTRY(R16Uint, 0x00000005) - ENUM_ENTRY(R16Sint, 0x00000006) - ENUM_ENTRY(R16Float, 0x00000007) - ENUM_ENTRY(RG8Unorm, 0x00000008) - ENUM_ENTRY(RG8Snorm, 0x00000009) - ENUM_ENTRY(RG8Uint, 0x0000000A) - ENUM_ENTRY(RG8Sint, 0x0000000B) - ENUM_ENTRY(R32Float, 0x0000000C) - ENUM_ENTRY(R32Uint, 0x0000000D) - ENUM_ENTRY(R32Sint, 0x0000000E) - ENUM_ENTRY(RG16Uint, 0x0000000F) - ENUM_ENTRY(RG16Sint, 0x00000010) - ENUM_ENTRY(RG16Float, 0x00000011) - ENUM_ENTRY(RGBA8Unorm, 0x00000012) - ENUM_ENTRY(RGBA8UnormSrgb, 0x00000013) - ENUM_ENTRY(RGBA8Snorm, 0x00000014) - ENUM_ENTRY(RGBA8Uint, 0x00000015) - ENUM_ENTRY(RGBA8Sint, 0x00000016) - ENUM_ENTRY(BGRA8Unorm, 0x00000017) - ENUM_ENTRY(BGRA8UnormSrgb, 0x00000018) - ENUM_ENTRY(RGB10A2Uint, 0x00000019) - ENUM_ENTRY(RGB10A2Unorm, 0x0000001A) - ENUM_ENTRY(RG11B10Ufloat, 0x0000001B) - ENUM_ENTRY(RGB9E5Ufloat, 0x0000001C) - ENUM_ENTRY(RG32Float, 0x0000001D) - ENUM_ENTRY(RG32Uint, 0x0000001E) - ENUM_ENTRY(RG32Sint, 0x0000001F) - ENUM_ENTRY(RGBA16Uint, 0x00000020) - ENUM_ENTRY(RGBA16Sint, 0x00000021) - ENUM_ENTRY(RGBA16Float, 0x00000022) - ENUM_ENTRY(RGBA32Float, 0x00000023) - ENUM_ENTRY(RGBA32Uint, 0x00000024) - ENUM_ENTRY(RGBA32Sint, 0x00000025) - ENUM_ENTRY(Stencil8, 0x00000026) - ENUM_ENTRY(Depth16Unorm, 0x00000027) - ENUM_ENTRY(Depth24Plus, 0x00000028) - ENUM_ENTRY(Depth24PlusStencil8, 0x00000029) - ENUM_ENTRY(Depth32Float, 0x0000002A) - ENUM_ENTRY(Depth32FloatStencil8, 0x0000002B) - ENUM_ENTRY(BC1RGBAUnorm, 0x0000002C) - ENUM_ENTRY(BC1RGBAUnormSrgb, 0x0000002D) - ENUM_ENTRY(BC2RGBAUnorm, 0x0000002E) - ENUM_ENTRY(BC2RGBAUnormSrgb, 0x0000002F) - ENUM_ENTRY(BC3RGBAUnorm, 0x00000030) - ENUM_ENTRY(BC3RGBAUnormSrgb, 0x00000031) - ENUM_ENTRY(BC4RUnorm, 0x00000032) - ENUM_ENTRY(BC4RSnorm, 0x00000033) - ENUM_ENTRY(BC5RGUnorm, 0x00000034) - ENUM_ENTRY(BC5RGSnorm, 0x00000035) - ENUM_ENTRY(BC6HRGBUfloat, 0x00000036) - ENUM_ENTRY(BC6HRGBFloat, 0x00000037) - ENUM_ENTRY(BC7RGBAUnorm, 0x00000038) - ENUM_ENTRY(BC7RGBAUnormSrgb, 0x00000039) - ENUM_ENTRY(ETC2RGB8Unorm, 0x0000003A) - ENUM_ENTRY(ETC2RGB8UnormSrgb, 0x0000003B) - ENUM_ENTRY(ETC2RGB8A1Unorm, 0x0000003C) - ENUM_ENTRY(ETC2RGB8A1UnormSrgb, 0x0000003D) - ENUM_ENTRY(ETC2RGBA8Unorm, 0x0000003E) - ENUM_ENTRY(ETC2RGBA8UnormSrgb, 0x0000003F) - ENUM_ENTRY(EACR11Unorm, 0x00000040) - ENUM_ENTRY(EACR11Snorm, 0x00000041) - ENUM_ENTRY(EACRG11Unorm, 0x00000042) - ENUM_ENTRY(EACRG11Snorm, 0x00000043) - ENUM_ENTRY(ASTC4x4Unorm, 0x00000044) - ENUM_ENTRY(ASTC4x4UnormSrgb, 0x00000045) - ENUM_ENTRY(ASTC5x4Unorm, 0x00000046) - ENUM_ENTRY(ASTC5x4UnormSrgb, 0x00000047) - ENUM_ENTRY(ASTC5x5Unorm, 0x00000048) - ENUM_ENTRY(ASTC5x5UnormSrgb, 0x00000049) - ENUM_ENTRY(ASTC6x5Unorm, 0x0000004A) - ENUM_ENTRY(ASTC6x5UnormSrgb, 0x0000004B) - ENUM_ENTRY(ASTC6x6Unorm, 0x0000004C) - ENUM_ENTRY(ASTC6x6UnormSrgb, 0x0000004D) - ENUM_ENTRY(ASTC8x5Unorm, 0x0000004E) - ENUM_ENTRY(ASTC8x5UnormSrgb, 0x0000004F) - ENUM_ENTRY(ASTC8x6Unorm, 0x00000050) - ENUM_ENTRY(ASTC8x6UnormSrgb, 0x00000051) - ENUM_ENTRY(ASTC8x8Unorm, 0x00000052) - ENUM_ENTRY(ASTC8x8UnormSrgb, 0x00000053) - ENUM_ENTRY(ASTC10x5Unorm, 0x00000054) - ENUM_ENTRY(ASTC10x5UnormSrgb, 0x00000055) - ENUM_ENTRY(ASTC10x6Unorm, 0x00000056) - ENUM_ENTRY(ASTC10x6UnormSrgb, 0x00000057) - ENUM_ENTRY(ASTC10x8Unorm, 0x00000058) - ENUM_ENTRY(ASTC10x8UnormSrgb, 0x00000059) - ENUM_ENTRY(ASTC10x10Unorm, 0x0000005A) - ENUM_ENTRY(ASTC10x10UnormSrgb, 0x0000005B) - ENUM_ENTRY(ASTC12x10Unorm, 0x0000005C) - ENUM_ENTRY(ASTC12x10UnormSrgb, 0x0000005D) - ENUM_ENTRY(ASTC12x12Unorm, 0x0000005E) - ENUM_ENTRY(ASTC12x12UnormSrgb, 0x0000005F) - ENUM_ENTRY(R16Unorm, 0x00000060) - ENUM_ENTRY(RG16Unorm, 0x00000061) - ENUM_ENTRY(RGBA16Unorm, 0x00000062) - ENUM_ENTRY(R16Snorm, 0x00000063) - ENUM_ENTRY(RG16Snorm, 0x00000064) - ENUM_ENTRY(RGBA16Snorm, 0x00000065) - ENUM_ENTRY(R8BG8Biplanar420Unorm, 0x00000066) - ENUM_ENTRY(R10X6BG10X6Biplanar420Unorm, 0x00000067) - ENUM_ENTRY(R8BG8A8Triplanar420Unorm, 0x00000068) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureSampleType) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Float, 0x00000001) - ENUM_ENTRY(UnfilterableFloat, 0x00000002) - ENUM_ENTRY(Depth, 0x00000003) - ENUM_ENTRY(Sint, 0x00000004) - ENUM_ENTRY(Uint, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureViewDimension) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(_1D, 0x00000001) - ENUM_ENTRY(_2D, 0x00000002) - ENUM_ENTRY(_2DArray, 0x00000003) - ENUM_ENTRY(Cube, 0x00000004) - ENUM_ENTRY(CubeArray, 0x00000005) - ENUM_ENTRY(_3D, 0x00000006) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(VertexFormat) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(Uint8x2, 0x00000001) - ENUM_ENTRY(Uint8x4, 0x00000002) - ENUM_ENTRY(Sint8x2, 0x00000003) - ENUM_ENTRY(Sint8x4, 0x00000004) - ENUM_ENTRY(Unorm8x2, 0x00000005) - ENUM_ENTRY(Unorm8x4, 0x00000006) - ENUM_ENTRY(Snorm8x2, 0x00000007) - ENUM_ENTRY(Snorm8x4, 0x00000008) - ENUM_ENTRY(Uint16x2, 0x00000009) - ENUM_ENTRY(Uint16x4, 0x0000000A) - ENUM_ENTRY(Sint16x2, 0x0000000B) - ENUM_ENTRY(Sint16x4, 0x0000000C) - ENUM_ENTRY(Unorm16x2, 0x0000000D) - ENUM_ENTRY(Unorm16x4, 0x0000000E) - ENUM_ENTRY(Snorm16x2, 0x0000000F) - ENUM_ENTRY(Snorm16x4, 0x00000010) - ENUM_ENTRY(Float16x2, 0x00000011) - ENUM_ENTRY(Float16x4, 0x00000012) - ENUM_ENTRY(Float32, 0x00000013) - ENUM_ENTRY(Float32x2, 0x00000014) - ENUM_ENTRY(Float32x3, 0x00000015) - ENUM_ENTRY(Float32x4, 0x00000016) - ENUM_ENTRY(Uint32, 0x00000017) - ENUM_ENTRY(Uint32x2, 0x00000018) - ENUM_ENTRY(Uint32x3, 0x00000019) - ENUM_ENTRY(Uint32x4, 0x0000001A) - ENUM_ENTRY(Sint32, 0x0000001B) - ENUM_ENTRY(Sint32x2, 0x0000001C) - ENUM_ENTRY(Sint32x3, 0x0000001D) - ENUM_ENTRY(Sint32x4, 0x0000001E) - ENUM_ENTRY(Unorm10_10_10_2, 0x0000001F) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(VertexStepMode) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(VertexBufferNotUsed, 0x00000001) - ENUM_ENTRY(Vertex, 0x00000002) - ENUM_ENTRY(Instance, 0x00000003) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(WaitStatus) - ENUM_ENTRY(Success, 0x00000000) - ENUM_ENTRY(TimedOut, 0x00000001) - ENUM_ENTRY(UnsupportedTimeout, 0x00000002) - ENUM_ENTRY(UnsupportedCount, 0x00000003) - ENUM_ENTRY(UnsupportedMixedSources, 0x00000004) - ENUM_ENTRY(Unknown, 0x00000005) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(BufferUsage) - ENUM_ENTRY(None, 0x00000000) - ENUM_ENTRY(MapRead, 0x00000001) - ENUM_ENTRY(MapWrite, 0x00000002) - ENUM_ENTRY(CopySrc, 0x00000004) - ENUM_ENTRY(CopyDst, 0x00000008) - ENUM_ENTRY(Index, 0x00000010) - ENUM_ENTRY(Vertex, 0x00000020) - ENUM_ENTRY(Uniform, 0x00000040) - ENUM_ENTRY(Storage, 0x00000080) - ENUM_ENTRY(Indirect, 0x00000100) - ENUM_ENTRY(QueryResolve, 0x00000200) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(ColorWriteMask) - ENUM_ENTRY(None, 0x00000000) - ENUM_ENTRY(Red, 0x00000001) - ENUM_ENTRY(Green, 0x00000002) - ENUM_ENTRY(Blue, 0x00000004) - ENUM_ENTRY(Alpha, 0x00000008) - ENUM_ENTRY(All, 0x0000000F) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(HeapProperty) - ENUM_ENTRY(Undefined, 0x00000000) - ENUM_ENTRY(DeviceLocal, 0x00000001) - ENUM_ENTRY(HostVisible, 0x00000002) - ENUM_ENTRY(HostCoherent, 0x00000004) - ENUM_ENTRY(HostUncached, 0x00000008) - ENUM_ENTRY(HostCached, 0x00000010) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(MapMode) - ENUM_ENTRY(None, 0x00000000) - ENUM_ENTRY(Read, 0x00000001) - ENUM_ENTRY(Write, 0x00000002) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(ShaderStage) - ENUM_ENTRY(None, 0x00000000) - ENUM_ENTRY(Vertex, 0x00000001) - ENUM_ENTRY(Fragment, 0x00000002) - ENUM_ENTRY(Compute, 0x00000004) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END -ENUM(TextureUsage) - ENUM_ENTRY(None, 0x00000000) - ENUM_ENTRY(CopySrc, 0x00000001) - ENUM_ENTRY(CopyDst, 0x00000002) - ENUM_ENTRY(TextureBinding, 0x00000004) - ENUM_ENTRY(StorageBinding, 0x00000008) - ENUM_ENTRY(RenderAttachment, 0x00000010) - ENUM_ENTRY(TransientAttachment, 0x00000020) - ENUM_ENTRY(StorageAttachment, 0x00000040) - ENUM_ENTRY(Force32, 0x7FFFFFFF) -END - -// Structs -STRUCT(ChainedStruct) - void setDefault(); -END - -STRUCT(ChainedStructOut) - void setDefault(); -END - -STRUCT(AdapterPropertiesD3D) - void setDefault(); -END - -STRUCT(AdapterPropertiesVk) - void setDefault(); -END - -STRUCT(BlendComponent) - void setDefault(); -END - -STRUCT(BufferHostMappedPointer) - void setDefault(); -END - -STRUCT(Color) - void setDefault(); - Color(double r, double g, double b, double a) : WGPUColor{ r, g, b, a } {} -END - -STRUCT(ComputePassTimestampWrites) - void setDefault(); -END - -STRUCT(DawnWGSLBlocklist) - void setDefault(); -END - -STRUCT(DawnAdapterPropertiesPowerPreference) - void setDefault(); -END - -STRUCT(DawnBufferDescriptorErrorInfoFromWireClient) - void setDefault(); -END - -STRUCT(DawnCacheDeviceDescriptor) - void setDefault(); -END - -STRUCT(DawnComputePipelineFullSubgroups) - void setDefault(); -END - -STRUCT(DawnEncoderInternalUsageDescriptor) - void setDefault(); -END - -STRUCT(DawnExperimentalSubgroupLimits) - void setDefault(); -END - -STRUCT(DawnMultisampleStateRenderToSingleSampled) - void setDefault(); -END - -STRUCT(DawnRenderPassColorAttachmentRenderToSingleSampled) - void setDefault(); -END - -STRUCT(DawnShaderModuleSPIRVOptionsDescriptor) - void setDefault(); -END - -STRUCT(DawnTextureInternalUsageDescriptor) - void setDefault(); -END - -STRUCT(DawnTogglesDescriptor) - void setDefault(); -END - -STRUCT(DawnWireWGSLControl) - void setDefault(); -END - -STRUCT(DepthStencilStateDepthWriteDefinedDawn) - void setDefault(); -END - -STRUCT(DrmFormatProperties) - void setDefault(); -END - -STRUCT(Extent2D) - void setDefault(); -END - -STRUCT(Extent3D) - void setDefault(); - Extent3D(uint32_t width, uint32_t height, uint32_t depthOrArrayLayers) : WGPUExtent3D{ width, height, depthOrArrayLayers } {} -END - -STRUCT(ExternalTextureBindingEntry) - void setDefault(); -END - -STRUCT(ExternalTextureBindingLayout) - void setDefault(); -END - -STRUCT(Future) - void setDefault(); -END - -STRUCT(Limits) - void setDefault(); -END - -STRUCT(MemoryHeapInfo) - void setDefault(); -END - -STRUCT(Origin2D) - void setDefault(); -END - -STRUCT(Origin3D) - void setDefault(); - Origin3D(uint32_t x, uint32_t y, uint32_t z) : WGPUOrigin3D{ x, y, z } {} -END - -STRUCT(PrimitiveDepthClipControl) - void setDefault(); -END - -STRUCT(RenderPassDepthStencilAttachment) - void setDefault(); -END - -STRUCT(RenderPassDescriptorMaxDrawCount) - void setDefault(); -END - -STRUCT(RenderPassTimestampWrites) - void setDefault(); -END - -STRUCT(ShaderModuleSPIRVDescriptor) - void setDefault(); -END - -STRUCT(ShaderModuleWGSLDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceDXGISharedHandleDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceDXGISharedHandleExportInfo) - void setDefault(); -END - -STRUCT(SharedFenceMTLSharedEventDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceMTLSharedEventExportInfo) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreOpaqueFDDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreOpaqueFDExportInfo) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreSyncFDDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreSyncFDExportInfo) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreZirconHandleDescriptor) - void setDefault(); -END - -STRUCT(SharedFenceVkSemaphoreZirconHandleExportInfo) - void setDefault(); -END - -STRUCT(SharedTextureMemoryDXGISharedHandleDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryEGLImageDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryIOSurfaceDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryAHardwareBufferDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryDmaBufPlane) - void setDefault(); -END - -STRUCT(SharedTextureMemoryOpaqueFDDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryVkDedicatedAllocationDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryVkImageLayoutBeginState) - void setDefault(); -END - -STRUCT(SharedTextureMemoryVkImageLayoutEndState) - void setDefault(); -END - -STRUCT(SharedTextureMemoryZirconHandleDescriptor) - void setDefault(); -END - -STRUCT(StaticSamplerBindingLayout) - void setDefault(); -END - -STRUCT(StencilFaceState) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromAndroidNativeWindow) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromCanvasHTMLSelector) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromMetalLayer) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromWaylandSurface) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromWindowsHWND) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromWindowsCoreWindow) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromWindowsSwapChainPanel) - void setDefault(); -END - -STRUCT(SurfaceDescriptorFromXlibWindow) - void setDefault(); -END - -STRUCT(TextureBindingViewDimensionDescriptor) - void setDefault(); -END - -STRUCT(VertexAttribute) - void setDefault(); -END - -STRUCT(AdapterPropertiesMemoryHeaps) - void setDefault(); - void freeMembers(); -END - -STRUCT(BlendState) - void setDefault(); -END - -STRUCT(DrmFormatCapabilities) - void setDefault(); - void freeMembers(); -END - -STRUCT(FutureWaitInfo) - void setDefault(); -END - -STRUCT(PipelineLayoutPixelLocalStorage) - void setDefault(); -END - -STRUCT(SharedTextureMemoryDmaBufDescriptor) - void setDefault(); -END - -STRUCT(SharedTextureMemoryVkImageDescriptor) - void setDefault(); -END - -STRUCT(VertexBufferLayout) - void setDefault(); -END - -STRUCT(RenderPassPixelLocalStorage) - void setDefault(); -END - - -// Descriptors -DESCRIPTOR(AdapterProperties) - void setDefault(); - void freeMembers(); -END - -DESCRIPTOR(BindGroupEntry) - void setDefault(); -END - -DESCRIPTOR(BufferBindingLayout) - void setDefault(); -END - -DESCRIPTOR(BufferDescriptor) - void setDefault(); -END - -DESCRIPTOR(BufferMapCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(CommandBufferDescriptor) - void setDefault(); -END - -DESCRIPTOR(CommandEncoderDescriptor) - void setDefault(); -END - -DESCRIPTOR(CompilationInfoCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(CompilationMessage) - void setDefault(); -END - -DESCRIPTOR(ConstantEntry) - void setDefault(); -END - -DESCRIPTOR(CopyTextureForBrowserOptions) - void setDefault(); -END - -DESCRIPTOR(CreateComputePipelineAsyncCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(CreateRenderPipelineAsyncCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(FormatCapabilities) - void setDefault(); -END - -DESCRIPTOR(InstanceFeatures) - void setDefault(); -END - -DESCRIPTOR(MultisampleState) - void setDefault(); -END - -DESCRIPTOR(PipelineLayoutDescriptor) - void setDefault(); -END - -DESCRIPTOR(PipelineLayoutStorageAttachment) - void setDefault(); -END - -DESCRIPTOR(PopErrorScopeCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(PrimitiveState) - void setDefault(); -END - -DESCRIPTOR(QuerySetDescriptor) - void setDefault(); -END - -DESCRIPTOR(QueueDescriptor) - void setDefault(); -END - -DESCRIPTOR(QueueWorkDoneCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(RenderBundleDescriptor) - void setDefault(); -END - -DESCRIPTOR(RenderBundleEncoderDescriptor) - void setDefault(); -END - -DESCRIPTOR(RequestAdapterCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(RequestAdapterOptions) - void setDefault(); -END - -DESCRIPTOR(RequestDeviceCallbackInfo) - void setDefault(); -END - -DESCRIPTOR(SamplerBindingLayout) - void setDefault(); -END - -DESCRIPTOR(SamplerDescriptor) - void setDefault(); -END - -DESCRIPTOR(ShaderModuleDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedBufferMemoryBeginAccessDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedBufferMemoryDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedBufferMemoryEndAccessState) - void setDefault(); - void freeMembers(); -END - -DESCRIPTOR(SharedBufferMemoryProperties) - void setDefault(); -END - -DESCRIPTOR(SharedFenceDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedFenceExportInfo) - void setDefault(); -END - -DESCRIPTOR(SharedTextureMemoryBeginAccessDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedTextureMemoryDescriptor) - void setDefault(); -END - -DESCRIPTOR(SharedTextureMemoryEndAccessState) - void setDefault(); - void freeMembers(); -END - -DESCRIPTOR(StorageTextureBindingLayout) - void setDefault(); -END - -DESCRIPTOR(SurfaceDescriptor) - void setDefault(); -END - -DESCRIPTOR(SwapChainDescriptor) - void setDefault(); -END - -DESCRIPTOR(TextureBindingLayout) - void setDefault(); -END - -DESCRIPTOR(TextureDataLayout) - void setDefault(); -END - -DESCRIPTOR(TextureViewDescriptor) - void setDefault(); -END - -DESCRIPTOR(BindGroupDescriptor) - void setDefault(); -END - -DESCRIPTOR(BindGroupLayoutEntry) - void setDefault(); -END - -DESCRIPTOR(CompilationInfo) - void setDefault(); -END - -DESCRIPTOR(ComputePassDescriptor) - void setDefault(); -END - -DESCRIPTOR(DepthStencilState) - void setDefault(); -END - -DESCRIPTOR(ExternalTextureDescriptor) - void setDefault(); -END - -DESCRIPTOR(ImageCopyBuffer) - void setDefault(); -END - -DESCRIPTOR(ImageCopyExternalTexture) - void setDefault(); -END - -DESCRIPTOR(ImageCopyTexture) - void setDefault(); -END - -DESCRIPTOR(InstanceDescriptor) - void setDefault(); -END - -DESCRIPTOR(ProgrammableStageDescriptor) - void setDefault(); -END - -DESCRIPTOR(RenderPassColorAttachment) - void setDefault(); -END - -DESCRIPTOR(RenderPassStorageAttachment) - void setDefault(); -END - -DESCRIPTOR(RequiredLimits) - void setDefault(); -END - -DESCRIPTOR(SharedTextureMemoryProperties) - void setDefault(); -END - -DESCRIPTOR(SupportedLimits) - void setDefault(); -END - -DESCRIPTOR(TextureDescriptor) - void setDefault(); -END - -DESCRIPTOR(BindGroupLayoutDescriptor) - void setDefault(); -END - -DESCRIPTOR(ColorTargetState) - void setDefault(); -END - -DESCRIPTOR(ComputePipelineDescriptor) - void setDefault(); -END - -DESCRIPTOR(DeviceDescriptor) - void setDefault(); -END - -DESCRIPTOR(RenderPassDescriptor) - void setDefault(); -END - -DESCRIPTOR(VertexState) - void setDefault(); -END - -DESCRIPTOR(FragmentState) - void setDefault(); -END - -DESCRIPTOR(RenderPipelineDescriptor) - void setDefault(); -END - - -// Handles forward declarations -class Adapter; -class BindGroup; -class BindGroupLayout; -class Buffer; -class CommandBuffer; -class CommandEncoder; -class ComputePassEncoder; -class ComputePipeline; -class Device; -class ExternalTexture; -class Instance; -class PipelineLayout; -class QuerySet; -class Queue; -class RenderBundle; -class RenderBundleEncoder; -class RenderPassEncoder; -class RenderPipeline; -class Sampler; -class ShaderModule; -class SharedBufferMemory; -class SharedFence; -class SharedTextureMemory; -class Surface; -class SwapChain; -class Texture; -class TextureView; - -// Callback types -using BufferMapCallback = std::function; -using CompilationInfoCallback = std::function; -using CreateComputePipelineAsyncCallback = std::function; -using CreateRenderPipelineAsyncCallback = std::function; -using DeviceLostCallback = std::function; -using ErrorCallback = std::function; -using LoggingCallback = std::function; -using PopErrorScopeCallback = std::function; -using QueueWorkDoneCallback = std::function; -using RequestAdapterCallback = std::function; -using RequestDeviceCallback = std::function; -using ProcDeviceSetDeviceLostCallback = std::function; -using ProcDeviceSetLoggingCallback = std::function; -using ProcDeviceSetUncapturedErrorCallback = std::function; - -// Handles detailed declarations -HANDLE(Adapter) - Device createDevice(const DeviceDescriptor& descriptor); - Device createDevice(); - size_t enumerateFeatures(FeatureName * features); - Bool getFormatCapabilities(TextureFormat format, FormatCapabilities * capabilities); - Instance getInstance(); - Bool getLimits(SupportedLimits * limits); - void getProperties(AdapterProperties * properties); - Bool hasFeature(FeatureName feature); - std::unique_ptr requestDevice(const DeviceDescriptor& descriptor, RequestDeviceCallback&& callback); - Future requestDeviceF(const DeviceDescriptor& options, RequestDeviceCallbackInfo callbackInfo); - void reference(); - void release(); - Device requestDevice(const DeviceDescriptor& descriptor); -END - -HANDLE(BindGroup) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(BindGroupLayout) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Buffer) - void destroy(); - void const * getConstMappedRange(size_t offset, size_t size); - BufferMapState getMapState(); - void * getMappedRange(size_t offset, size_t size); - uint64_t getSize(); - BufferUsageFlags getUsage(); - std::unique_ptr mapAsync(MapModeFlags mode, size_t offset, size_t size, BufferMapCallback&& callback); - Future mapAsyncF(MapModeFlags mode, size_t offset, size_t size, BufferMapCallbackInfo callbackInfo); - void setLabel(char const * label); - void unmap(); - void reference(); - void release(); -END - -HANDLE(CommandBuffer) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(CommandEncoder) - ComputePassEncoder beginComputePass(const ComputePassDescriptor& descriptor); - ComputePassEncoder beginComputePass(); - RenderPassEncoder beginRenderPass(const RenderPassDescriptor& descriptor); - void clearBuffer(Buffer buffer, uint64_t offset, uint64_t size); - void copyBufferToBuffer(Buffer source, uint64_t sourceOffset, Buffer destination, uint64_t destinationOffset, uint64_t size); - void copyBufferToTexture(const ImageCopyBuffer& source, const ImageCopyTexture& destination, const Extent3D& copySize); - void copyTextureToBuffer(const ImageCopyTexture& source, const ImageCopyBuffer& destination, const Extent3D& copySize); - void copyTextureToTexture(const ImageCopyTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize); - CommandBuffer finish(const CommandBufferDescriptor& descriptor); - CommandBuffer finish(); - void injectValidationError(char const * message); - void insertDebugMarker(char const * markerLabel); - void popDebugGroup(); - void pushDebugGroup(char const * groupLabel); - void resolveQuerySet(QuerySet querySet, uint32_t firstQuery, uint32_t queryCount, Buffer destination, uint64_t destinationOffset); - void setLabel(char const * label); - void writeBuffer(Buffer buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size); - void writeTimestamp(QuerySet querySet, uint32_t queryIndex); - void reference(); - void release(); -END - -HANDLE(ComputePassEncoder) - void dispatchWorkgroups(uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ); - void dispatchWorkgroupsIndirect(Buffer indirectBuffer, uint64_t indirectOffset); - void end(); - void insertDebugMarker(char const * markerLabel); - void popDebugGroup(); - void pushDebugGroup(char const * groupLabel); - void setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets); - void setLabel(char const * label); - void setPipeline(ComputePipeline pipeline); - void writeTimestamp(QuerySet querySet, uint32_t queryIndex); - void reference(); - void release(); -END - -HANDLE(ComputePipeline) - BindGroupLayout getBindGroupLayout(uint32_t groupIndex); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Device) - BindGroup createBindGroup(const BindGroupDescriptor& descriptor); - BindGroupLayout createBindGroupLayout(const BindGroupLayoutDescriptor& descriptor); - Buffer createBuffer(const BufferDescriptor& descriptor); - CommandEncoder createCommandEncoder(const CommandEncoderDescriptor& descriptor); - CommandEncoder createCommandEncoder(); - ComputePipeline createComputePipeline(const ComputePipelineDescriptor& descriptor); - std::unique_ptr createComputePipelineAsync(const ComputePipelineDescriptor& descriptor, CreateComputePipelineAsyncCallback&& callback); - Future createComputePipelineAsyncF(const ComputePipelineDescriptor& descriptor, CreateComputePipelineAsyncCallbackInfo callbackInfo); - Buffer createErrorBuffer(const BufferDescriptor& descriptor); - ExternalTexture createErrorExternalTexture(); - ShaderModule createErrorShaderModule(const ShaderModuleDescriptor& descriptor, char const * errorMessage); - Texture createErrorTexture(const TextureDescriptor& descriptor); - ExternalTexture createExternalTexture(const ExternalTextureDescriptor& externalTextureDescriptor); - PipelineLayout createPipelineLayout(const PipelineLayoutDescriptor& descriptor); - QuerySet createQuerySet(const QuerySetDescriptor& descriptor); - RenderBundleEncoder createRenderBundleEncoder(const RenderBundleEncoderDescriptor& descriptor); - RenderPipeline createRenderPipeline(const RenderPipelineDescriptor& descriptor); - std::unique_ptr createRenderPipelineAsync(const RenderPipelineDescriptor& descriptor, CreateRenderPipelineAsyncCallback&& callback); - Future createRenderPipelineAsyncF(const RenderPipelineDescriptor& descriptor, CreateRenderPipelineAsyncCallbackInfo callbackInfo); - Sampler createSampler(const SamplerDescriptor& descriptor); - Sampler createSampler(); - ShaderModule createShaderModule(const ShaderModuleDescriptor& descriptor); - SwapChain createSwapChain(Surface surface, const SwapChainDescriptor& descriptor); - Texture createTexture(const TextureDescriptor& descriptor); - void destroy(); - size_t enumerateFeatures(FeatureName * features); - void forceLoss(DeviceLostReason type, char const * message); - Adapter getAdapter(); - Bool getLimits(SupportedLimits * limits); - Queue getQueue(); - TextureUsageFlags getSupportedSurfaceUsage(Surface surface); - Bool hasFeature(FeatureName feature); - SharedBufferMemory importSharedBufferMemory(const SharedBufferMemoryDescriptor& descriptor); - SharedFence importSharedFence(const SharedFenceDescriptor& descriptor); - SharedTextureMemory importSharedTextureMemory(const SharedTextureMemoryDescriptor& descriptor); - void injectError(ErrorType type, char const * message); - std::unique_ptr popErrorScope(ErrorCallback&& oldCallback); - Future popErrorScopeF(PopErrorScopeCallbackInfo callbackInfo); - void pushErrorScope(ErrorFilter filter); - std::unique_ptr setDeviceLostCallback(DeviceLostCallback&& callback); - void setLabel(char const * label); - std::unique_ptr setLoggingCallback(LoggingCallback&& callback); - std::unique_ptr setUncapturedErrorCallback(ErrorCallback&& callback); - void tick(); - void validateTextureDescriptor(const TextureDescriptor& descriptor); - void reference(); - void release(); -END - -HANDLE(ExternalTexture) - void destroy(); - void expire(); - void refresh(); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Instance) - Surface createSurface(const SurfaceDescriptor& descriptor); - size_t enumerateWGSLLanguageFeatures(WGSLFeatureName * features); - Bool hasWGSLLanguageFeature(WGSLFeatureName feature); - void processEvents(); - std::unique_ptr requestAdapter(const RequestAdapterOptions& options, RequestAdapterCallback&& callback); - Future requestAdapterF(const RequestAdapterOptions& options, RequestAdapterCallbackInfo callbackInfo); - WaitStatus waitAny(size_t futureCount, FutureWaitInfo * futures, uint64_t timeoutNS); - void reference(); - void release(); - Adapter requestAdapter(const RequestAdapterOptions& options); -END - -HANDLE(PipelineLayout) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(QuerySet) - void destroy(); - uint32_t getCount(); - QueryType getType(); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Queue) - void copyExternalTextureForBrowser(const ImageCopyExternalTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize, const CopyTextureForBrowserOptions& options); - void copyTextureForBrowser(const ImageCopyTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize, const CopyTextureForBrowserOptions& options); - std::unique_ptr onSubmittedWorkDone(QueueWorkDoneCallback&& callback); - Future onSubmittedWorkDoneF(QueueWorkDoneCallbackInfo callbackInfo); - void setLabel(char const * label); - void submit(size_t commandCount, CommandBuffer const * commands); - void submit(const std::vector& commands); - void submit(const WGPUCommandBuffer& commands); - void writeBuffer(Buffer buffer, uint64_t bufferOffset, void const * data, size_t size); - void writeTexture(const ImageCopyTexture& destination, void const * data, size_t dataSize, const TextureDataLayout& dataLayout, const Extent3D& writeSize); - void reference(); - void release(); -END - -HANDLE(RenderBundle) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(RenderBundleEncoder) - void draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); - void drawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); - void drawIndexedIndirect(Buffer indirectBuffer, uint64_t indirectOffset); - void drawIndirect(Buffer indirectBuffer, uint64_t indirectOffset); - RenderBundle finish(const RenderBundleDescriptor& descriptor); - RenderBundle finish(); - void insertDebugMarker(char const * markerLabel); - void popDebugGroup(); - void pushDebugGroup(char const * groupLabel); - void setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets); - void setIndexBuffer(Buffer buffer, IndexFormat format, uint64_t offset, uint64_t size); - void setLabel(char const * label); - void setPipeline(RenderPipeline pipeline); - void setVertexBuffer(uint32_t slot, Buffer buffer, uint64_t offset, uint64_t size); - void reference(); - void release(); -END - -HANDLE(RenderPassEncoder) - void beginOcclusionQuery(uint32_t queryIndex); - void draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); - void drawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance); - void drawIndexedIndirect(Buffer indirectBuffer, uint64_t indirectOffset); - void drawIndirect(Buffer indirectBuffer, uint64_t indirectOffset); - void end(); - void endOcclusionQuery(); - void executeBundles(size_t bundleCount, RenderBundle const * bundles); - void executeBundles(const std::vector& bundles); - void executeBundles(const WGPURenderBundle& bundles); - void insertDebugMarker(char const * markerLabel); - void pixelLocalStorageBarrier(); - void popDebugGroup(); - void pushDebugGroup(char const * groupLabel); - void setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets); - void setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets); - void setBlendConstant(const Color& color); - void setIndexBuffer(Buffer buffer, IndexFormat format, uint64_t offset, uint64_t size); - void setLabel(char const * label); - void setPipeline(RenderPipeline pipeline); - void setScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height); - void setStencilReference(uint32_t reference); - void setVertexBuffer(uint32_t slot, Buffer buffer, uint64_t offset, uint64_t size); - void setViewport(float x, float y, float width, float height, float minDepth, float maxDepth); - void writeTimestamp(QuerySet querySet, uint32_t queryIndex); - void reference(); - void release(); -END - -HANDLE(RenderPipeline) - BindGroupLayout getBindGroupLayout(uint32_t groupIndex); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Sampler) - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(ShaderModule) - std::unique_ptr getCompilationInfo(CompilationInfoCallback&& callback); - Future getCompilationInfoF(CompilationInfoCallbackInfo callbackInfo); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(SharedBufferMemory) - Bool beginAccess(Buffer buffer, const SharedBufferMemoryBeginAccessDescriptor& descriptor); - Buffer createBuffer(const BufferDescriptor& descriptor); - Buffer createBuffer(); - Bool endAccess(Buffer buffer, SharedBufferMemoryEndAccessState * descriptor); - void getProperties(SharedBufferMemoryProperties * properties); - Bool isDeviceLost(); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(SharedFence) - void exportInfo(SharedFenceExportInfo * info); - void reference(); - void release(); -END - -HANDLE(SharedTextureMemory) - Bool beginAccess(Texture texture, const SharedTextureMemoryBeginAccessDescriptor& descriptor); - Texture createTexture(const TextureDescriptor& descriptor); - Texture createTexture(); - Bool endAccess(Texture texture, SharedTextureMemoryEndAccessState * descriptor); - void getProperties(SharedTextureMemoryProperties * properties); - Bool isDeviceLost(); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(Surface) - TextureFormat getPreferredFormat(Adapter adapter); - void reference(); - void release(); -END - -HANDLE(SwapChain) - Texture getCurrentTexture(); - TextureView getCurrentTextureView(); - void present(); - void reference(); - void release(); -END - -HANDLE(Texture) - TextureView createErrorView(const TextureViewDescriptor& descriptor); - TextureView createErrorView(); - TextureView createView(const TextureViewDescriptor& descriptor); - TextureView createView(); - void destroy(); - uint32_t getDepthOrArrayLayers(); - TextureDimension getDimension(); - TextureFormat getFormat(); - uint32_t getHeight(); - uint32_t getMipLevelCount(); - uint32_t getSampleCount(); - TextureUsageFlags getUsage(); - uint32_t getWidth(); - void setLabel(char const * label); - void reference(); - void release(); -END - -HANDLE(TextureView) - void setLabel(char const * label); - void reference(); - void release(); -END - - -// Non-member procedures - - -Instance createInstance(const InstanceDescriptor& descriptor); - -#ifdef WEBGPU_CPP_IMPLEMENTATION - -Instance createInstance(const InstanceDescriptor& descriptor) { - return wgpuCreateInstance(&descriptor); -} - -// Handles members implementation -// Methods of ChainedStruct -void ChainedStruct::setDefault() { -} - - -// Methods of ChainedStructOut -void ChainedStructOut::setDefault() { -} - - -// Methods of AdapterProperties -void AdapterProperties::setDefault() { - backendType = BackendType::Undefined; -} -void AdapterProperties::freeMembers() { - return wgpuAdapterPropertiesFreeMembers(*this); -} - - -// Methods of AdapterPropertiesD3D -void AdapterPropertiesD3D::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::AdapterPropertiesD3D; -} - - -// Methods of AdapterPropertiesVk -void AdapterPropertiesVk::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::AdapterPropertiesVk; -} - - -// Methods of BindGroupEntry -void BindGroupEntry::setDefault() { - offset = 0; -} - - -// Methods of BlendComponent -void BlendComponent::setDefault() { - operation = BlendOperation::Add; - srcFactor = BlendFactor::One; - dstFactor = BlendFactor::Zero; -} - - -// Methods of BufferBindingLayout -void BufferBindingLayout::setDefault() { - type = BufferBindingType::Uniform; - hasDynamicOffset = false; - minBindingSize = 0; -} - - -// Methods of BufferDescriptor -void BufferDescriptor::setDefault() { - mappedAtCreation = false; -} - - -// Methods of BufferHostMappedPointer -void BufferHostMappedPointer::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::BufferHostMappedPointer; -} - - -// Methods of BufferMapCallbackInfo -void BufferMapCallbackInfo::setDefault() { -} - - -// Methods of Color -void Color::setDefault() { -} - - -// Methods of CommandBufferDescriptor -void CommandBufferDescriptor::setDefault() { -} - - -// Methods of CommandEncoderDescriptor -void CommandEncoderDescriptor::setDefault() { -} - - -// Methods of CompilationInfoCallbackInfo -void CompilationInfoCallbackInfo::setDefault() { -} - - -// Methods of CompilationMessage -void CompilationMessage::setDefault() { -} - - -// Methods of ComputePassTimestampWrites -void ComputePassTimestampWrites::setDefault() { -} - - -// Methods of ConstantEntry -void ConstantEntry::setDefault() { -} - - -// Methods of CopyTextureForBrowserOptions -void CopyTextureForBrowserOptions::setDefault() { -} - - -// Methods of CreateComputePipelineAsyncCallbackInfo -void CreateComputePipelineAsyncCallbackInfo::setDefault() { -} - - -// Methods of CreateRenderPipelineAsyncCallbackInfo -void CreateRenderPipelineAsyncCallbackInfo::setDefault() { -} - - -// Methods of DawnWGSLBlocklist -void DawnWGSLBlocklist::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnWGSLBlocklist; -} - - -// Methods of DawnAdapterPropertiesPowerPreference -void DawnAdapterPropertiesPowerPreference::setDefault() { - powerPreference = PowerPreference::Undefined; - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::DawnAdapterPropertiesPowerPreference; -} - - -// Methods of DawnBufferDescriptorErrorInfoFromWireClient -void DawnBufferDescriptorErrorInfoFromWireClient::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnBufferDescriptorErrorInfoFromWireClient; -} - - -// Methods of DawnCacheDeviceDescriptor -void DawnCacheDeviceDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnCacheDeviceDescriptor; -} - - -// Methods of DawnComputePipelineFullSubgroups -void DawnComputePipelineFullSubgroups::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnComputePipelineFullSubgroups; -} - - -// Methods of DawnEncoderInternalUsageDescriptor -void DawnEncoderInternalUsageDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnEncoderInternalUsageDescriptor; -} - - -// Methods of DawnExperimentalSubgroupLimits -void DawnExperimentalSubgroupLimits::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::DawnExperimentalSubgroupLimits; -} - - -// Methods of DawnMultisampleStateRenderToSingleSampled -void DawnMultisampleStateRenderToSingleSampled::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnMultisampleStateRenderToSingleSampled; -} - - -// Methods of DawnRenderPassColorAttachmentRenderToSingleSampled -void DawnRenderPassColorAttachmentRenderToSingleSampled::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnRenderPassColorAttachmentRenderToSingleSampled; -} - - -// Methods of DawnShaderModuleSPIRVOptionsDescriptor -void DawnShaderModuleSPIRVOptionsDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnShaderModuleSPIRVOptionsDescriptor; -} - - -// Methods of DawnTextureInternalUsageDescriptor -void DawnTextureInternalUsageDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnTextureInternalUsageDescriptor; -} - - -// Methods of DawnTogglesDescriptor -void DawnTogglesDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnTogglesDescriptor; -} - - -// Methods of DawnWireWGSLControl -void DawnWireWGSLControl::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DawnWireWGSLControl; -} - - -// Methods of DepthStencilStateDepthWriteDefinedDawn -void DepthStencilStateDepthWriteDefinedDawn::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::DepthStencilStateDepthWriteDefinedDawn; -} - - -// Methods of DrmFormatProperties -void DrmFormatProperties::setDefault() { -} - - -// Methods of Extent2D -void Extent2D::setDefault() { -} - - -// Methods of Extent3D -void Extent3D::setDefault() { - height = 1; - depthOrArrayLayers = 1; -} - - -// Methods of ExternalTextureBindingEntry -void ExternalTextureBindingEntry::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::ExternalTextureBindingEntry; -} - - -// Methods of ExternalTextureBindingLayout -void ExternalTextureBindingLayout::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::ExternalTextureBindingLayout; -} - - -// Methods of FormatCapabilities -void FormatCapabilities::setDefault() { -} - - -// Methods of Future -void Future::setDefault() { -} - - -// Methods of InstanceFeatures -void InstanceFeatures::setDefault() { -} - - -// Methods of Limits -void Limits::setDefault() { - maxTextureDimension1D = 0; - maxTextureDimension2D = 0; - maxTextureDimension3D = 0; - maxTextureArrayLayers = 0; - maxBindGroups = 0; - maxBindingsPerBindGroup = 0; - maxDynamicUniformBuffersPerPipelineLayout = 0; - maxDynamicStorageBuffersPerPipelineLayout = 0; - maxSampledTexturesPerShaderStage = 0; - maxSamplersPerShaderStage = 0; - maxStorageBuffersPerShaderStage = 0; - maxStorageTexturesPerShaderStage = 0; - maxUniformBuffersPerShaderStage = 0; - maxUniformBufferBindingSize = 0; - maxStorageBufferBindingSize = 0; - minUniformBufferOffsetAlignment = 64; - minStorageBufferOffsetAlignment = 16; - maxVertexBuffers = 0; - maxBufferSize = 0; - maxVertexAttributes = 0; - maxVertexBufferArrayStride = 0; - maxInterStageShaderComponents = 0; - maxInterStageShaderVariables = 0; - maxColorAttachments = 0; - maxColorAttachmentBytesPerSample = 0; - maxComputeWorkgroupStorageSize = 0; - maxComputeInvocationsPerWorkgroup = 0; - maxComputeWorkgroupSizeX = 0; - maxComputeWorkgroupSizeY = 0; - maxComputeWorkgroupSizeZ = 0; - maxComputeWorkgroupsPerDimension = 0; -} - - -// Methods of MemoryHeapInfo -void MemoryHeapInfo::setDefault() { -} - - -// Methods of MultisampleState -void MultisampleState::setDefault() { - count = 1; - mask = 0xFFFFFFFF; - alphaToCoverageEnabled = false; -} - - -// Methods of Origin2D -void Origin2D::setDefault() { -} - - -// Methods of Origin3D -void Origin3D::setDefault() { - x = 0; - y = 0; - z = 0; -} - - -// Methods of PipelineLayoutDescriptor -void PipelineLayoutDescriptor::setDefault() { -} - - -// Methods of PipelineLayoutStorageAttachment -void PipelineLayoutStorageAttachment::setDefault() { - format = TextureFormat::Undefined; -} - - -// Methods of PopErrorScopeCallbackInfo -void PopErrorScopeCallbackInfo::setDefault() { -} - - -// Methods of PrimitiveDepthClipControl -void PrimitiveDepthClipControl::setDefault() { - unclippedDepth = false; - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::PrimitiveDepthClipControl; -} - - -// Methods of PrimitiveState -void PrimitiveState::setDefault() { - topology = PrimitiveTopology::TriangleList; - stripIndexFormat = IndexFormat::Undefined; - frontFace = FrontFace::CCW; - cullMode = CullMode::None; -} - - -// Methods of QuerySetDescriptor -void QuerySetDescriptor::setDefault() { -} - - -// Methods of QueueDescriptor -void QueueDescriptor::setDefault() { -} - - -// Methods of QueueWorkDoneCallbackInfo -void QueueWorkDoneCallbackInfo::setDefault() { -} - - -// Methods of RenderBundleDescriptor -void RenderBundleDescriptor::setDefault() { -} - - -// Methods of RenderBundleEncoderDescriptor -void RenderBundleEncoderDescriptor::setDefault() { - depthStencilFormat = TextureFormat::Undefined; - depthReadOnly = false; - stencilReadOnly = false; - sampleCount = 1; -} - - -// Methods of RenderPassDepthStencilAttachment -void RenderPassDepthStencilAttachment::setDefault() { - depthLoadOp = LoadOp::Undefined; - depthStoreOp = StoreOp::Undefined; - depthReadOnly = false; - stencilLoadOp = LoadOp::Undefined; - stencilStoreOp = StoreOp::Undefined; - stencilClearValue = 0; - stencilReadOnly = false; -} - - -// Methods of RenderPassDescriptorMaxDrawCount -void RenderPassDescriptorMaxDrawCount::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::RenderPassDescriptorMaxDrawCount; -} - - -// Methods of RenderPassTimestampWrites -void RenderPassTimestampWrites::setDefault() { -} - - -// Methods of RequestAdapterCallbackInfo -void RequestAdapterCallbackInfo::setDefault() { -} - - -// Methods of RequestAdapterOptions -void RequestAdapterOptions::setDefault() { - powerPreference = PowerPreference::Undefined; - backendType = BackendType::Undefined; - forceFallbackAdapter = false; -} - - -// Methods of RequestDeviceCallbackInfo -void RequestDeviceCallbackInfo::setDefault() { -} - - -// Methods of SamplerBindingLayout -void SamplerBindingLayout::setDefault() { - type = SamplerBindingType::Filtering; -} - - -// Methods of SamplerDescriptor -void SamplerDescriptor::setDefault() { - addressModeU = AddressMode::ClampToEdge; - addressModeV = AddressMode::ClampToEdge; - addressModeW = AddressMode::ClampToEdge; - magFilter = FilterMode::Nearest; - minFilter = FilterMode::Nearest; - mipmapFilter = MipmapFilterMode::Nearest; - lodMinClamp = 0; - lodMaxClamp = 32; - compare = CompareFunction::Undefined; -} - - -// Methods of ShaderModuleSPIRVDescriptor -void ShaderModuleSPIRVDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::ShaderModuleSPIRVDescriptor; -} - - -// Methods of ShaderModuleWGSLDescriptor -void ShaderModuleWGSLDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::ShaderModuleWGSLDescriptor; -} - - -// Methods of ShaderModuleDescriptor -void ShaderModuleDescriptor::setDefault() { -} - - -// Methods of SharedBufferMemoryBeginAccessDescriptor -void SharedBufferMemoryBeginAccessDescriptor::setDefault() { -} - - -// Methods of SharedBufferMemoryDescriptor -void SharedBufferMemoryDescriptor::setDefault() { -} - - -// Methods of SharedBufferMemoryEndAccessState -void SharedBufferMemoryEndAccessState::setDefault() { -} -void SharedBufferMemoryEndAccessState::freeMembers() { - return wgpuSharedBufferMemoryEndAccessStateFreeMembers(*this); -} - - -// Methods of SharedBufferMemoryProperties -void SharedBufferMemoryProperties::setDefault() { -} - - -// Methods of SharedFenceDXGISharedHandleDescriptor -void SharedFenceDXGISharedHandleDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedFenceDXGISharedHandleDescriptor; -} - - -// Methods of SharedFenceDXGISharedHandleExportInfo -void SharedFenceDXGISharedHandleExportInfo::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedFenceDXGISharedHandleExportInfo; -} - - -// Methods of SharedFenceMTLSharedEventDescriptor -void SharedFenceMTLSharedEventDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedFenceMTLSharedEventDescriptor; -} - - -// Methods of SharedFenceMTLSharedEventExportInfo -void SharedFenceMTLSharedEventExportInfo::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedFenceMTLSharedEventExportInfo; -} - - -// Methods of SharedFenceDescriptor -void SharedFenceDescriptor::setDefault() { -} - - -// Methods of SharedFenceExportInfo -void SharedFenceExportInfo::setDefault() { - type = SharedFenceType::Undefined; -} - - -// Methods of SharedFenceVkSemaphoreOpaqueFDDescriptor -void SharedFenceVkSemaphoreOpaqueFDDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor; -} - - -// Methods of SharedFenceVkSemaphoreOpaqueFDExportInfo -void SharedFenceVkSemaphoreOpaqueFDExportInfo::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo; -} - - -// Methods of SharedFenceVkSemaphoreSyncFDDescriptor -void SharedFenceVkSemaphoreSyncFDDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreSyncFDDescriptor; -} - - -// Methods of SharedFenceVkSemaphoreSyncFDExportInfo -void SharedFenceVkSemaphoreSyncFDExportInfo::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreSyncFDExportInfo; -} - - -// Methods of SharedFenceVkSemaphoreZirconHandleDescriptor -void SharedFenceVkSemaphoreZirconHandleDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor; -} - - -// Methods of SharedFenceVkSemaphoreZirconHandleExportInfo -void SharedFenceVkSemaphoreZirconHandleExportInfo::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo; -} - - -// Methods of SharedTextureMemoryDXGISharedHandleDescriptor -void SharedTextureMemoryDXGISharedHandleDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor; -} - - -// Methods of SharedTextureMemoryEGLImageDescriptor -void SharedTextureMemoryEGLImageDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryEGLImageDescriptor; -} - - -// Methods of SharedTextureMemoryIOSurfaceDescriptor -void SharedTextureMemoryIOSurfaceDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryIOSurfaceDescriptor; -} - - -// Methods of SharedTextureMemoryAHardwareBufferDescriptor -void SharedTextureMemoryAHardwareBufferDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryAHardwareBufferDescriptor; -} - - -// Methods of SharedTextureMemoryBeginAccessDescriptor -void SharedTextureMemoryBeginAccessDescriptor::setDefault() { -} - - -// Methods of SharedTextureMemoryDescriptor -void SharedTextureMemoryDescriptor::setDefault() { -} - - -// Methods of SharedTextureMemoryDmaBufPlane -void SharedTextureMemoryDmaBufPlane::setDefault() { -} - - -// Methods of SharedTextureMemoryEndAccessState -void SharedTextureMemoryEndAccessState::setDefault() { -} -void SharedTextureMemoryEndAccessState::freeMembers() { - return wgpuSharedTextureMemoryEndAccessStateFreeMembers(*this); -} - - -// Methods of SharedTextureMemoryOpaqueFDDescriptor -void SharedTextureMemoryOpaqueFDDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryOpaqueFDDescriptor; -} - - -// Methods of SharedTextureMemoryVkDedicatedAllocationDescriptor -void SharedTextureMemoryVkDedicatedAllocationDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor; -} - - -// Methods of SharedTextureMemoryVkImageLayoutBeginState -void SharedTextureMemoryVkImageLayoutBeginState::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryVkImageLayoutBeginState; -} - - -// Methods of SharedTextureMemoryVkImageLayoutEndState -void SharedTextureMemoryVkImageLayoutEndState::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryVkImageLayoutEndState; -} - - -// Methods of SharedTextureMemoryZirconHandleDescriptor -void SharedTextureMemoryZirconHandleDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SharedTextureMemoryZirconHandleDescriptor; -} - - -// Methods of StaticSamplerBindingLayout -void StaticSamplerBindingLayout::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::StaticSamplerBindingLayout; -} - - -// Methods of StencilFaceState -void StencilFaceState::setDefault() { - compare = CompareFunction::Always; - failOp = StencilOperation::Keep; - depthFailOp = StencilOperation::Keep; - passOp = StencilOperation::Keep; -} - - -// Methods of StorageTextureBindingLayout -void StorageTextureBindingLayout::setDefault() { - access = StorageTextureAccess::WriteOnly; - format = TextureFormat::Undefined; - viewDimension = TextureViewDimension::_2D; -} - - -// Methods of SurfaceDescriptor -void SurfaceDescriptor::setDefault() { -} - - -// Methods of SurfaceDescriptorFromAndroidNativeWindow -void SurfaceDescriptorFromAndroidNativeWindow::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromAndroidNativeWindow; -} - - -// Methods of SurfaceDescriptorFromCanvasHTMLSelector -void SurfaceDescriptorFromCanvasHTMLSelector::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromCanvasHTMLSelector; -} - - -// Methods of SurfaceDescriptorFromMetalLayer -void SurfaceDescriptorFromMetalLayer::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromMetalLayer; -} - - -// Methods of SurfaceDescriptorFromWaylandSurface -void SurfaceDescriptorFromWaylandSurface::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromWaylandSurface; -} - - -// Methods of SurfaceDescriptorFromWindowsHWND -void SurfaceDescriptorFromWindowsHWND::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromWindowsHWND; -} - - -// Methods of SurfaceDescriptorFromWindowsCoreWindow -void SurfaceDescriptorFromWindowsCoreWindow::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromWindowsCoreWindow; -} - - -// Methods of SurfaceDescriptorFromWindowsSwapChainPanel -void SurfaceDescriptorFromWindowsSwapChainPanel::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromWindowsSwapChainPanel; -} - - -// Methods of SurfaceDescriptorFromXlibWindow -void SurfaceDescriptorFromXlibWindow::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::SurfaceDescriptorFromXlibWindow; -} - - -// Methods of SwapChainDescriptor -void SwapChainDescriptor::setDefault() { - format = TextureFormat::Undefined; -} - - -// Methods of TextureBindingLayout -void TextureBindingLayout::setDefault() { - sampleType = TextureSampleType::Float; - viewDimension = TextureViewDimension::_2D; - multisampled = false; -} - - -// Methods of TextureBindingViewDimensionDescriptor -void TextureBindingViewDimensionDescriptor::setDefault() { - textureBindingViewDimension = TextureViewDimension::Undefined; - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::TextureBindingViewDimensionDescriptor; -} - - -// Methods of TextureDataLayout -void TextureDataLayout::setDefault() { -} - - -// Methods of TextureViewDescriptor -void TextureViewDescriptor::setDefault() { - format = TextureFormat::Undefined; - dimension = TextureViewDimension::Undefined; - baseMipLevel = 0; - baseArrayLayer = 0; - aspect = TextureAspect::All; -} - - -// Methods of VertexAttribute -void VertexAttribute::setDefault() { - format = VertexFormat::Undefined; -} - - -// Methods of AdapterPropertiesMemoryHeaps -void AdapterPropertiesMemoryHeaps::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::AdapterPropertiesMemoryHeaps; -} -void AdapterPropertiesMemoryHeaps::freeMembers() { - return wgpuAdapterPropertiesMemoryHeapsFreeMembers(*this); -} - - -// Methods of BindGroupDescriptor -void BindGroupDescriptor::setDefault() { -} - - -// Methods of BindGroupLayoutEntry -void BindGroupLayoutEntry::setDefault() { - ((BufferBindingLayout*)&buffer)->setDefault(); - ((SamplerBindingLayout*)&sampler)->setDefault(); - ((TextureBindingLayout*)&texture)->setDefault(); - ((StorageTextureBindingLayout*)&storageTexture)->setDefault(); - buffer.type = BufferBindingType::Undefined; - sampler.type = SamplerBindingType::Undefined; - storageTexture.access = StorageTextureAccess::Undefined; - texture.sampleType = TextureSampleType::Undefined; -} - - -// Methods of BlendState -void BlendState::setDefault() { - ((BlendComponent*)&color)->setDefault(); - ((BlendComponent*)&alpha)->setDefault(); -} - - -// Methods of CompilationInfo -void CompilationInfo::setDefault() { -} - - -// Methods of ComputePassDescriptor -void ComputePassDescriptor::setDefault() { -} - - -// Methods of DepthStencilState -void DepthStencilState::setDefault() { - format = TextureFormat::Undefined; - depthCompare = CompareFunction::Undefined; - stencilReadMask = 0xFFFFFFFF; - stencilWriteMask = 0xFFFFFFFF; - depthBias = 0; - depthBiasSlopeScale = 0; - depthBiasClamp = 0; - ((StencilFaceState*)&stencilFront)->setDefault(); - ((StencilFaceState*)&stencilBack)->setDefault(); -} - - -// Methods of DrmFormatCapabilities -void DrmFormatCapabilities::setDefault() { - ((ChainedStructOut*)&chain)->setDefault(); - chain.sType = SType::DrmFormatCapabilities; -} -void DrmFormatCapabilities::freeMembers() { - return wgpuDrmFormatCapabilitiesFreeMembers(*this); -} - - -// Methods of ExternalTextureDescriptor -void ExternalTextureDescriptor::setDefault() { - ((Origin2D*)&visibleOrigin)->setDefault(); - ((Extent2D*)&visibleSize)->setDefault(); -} - - -// Methods of FutureWaitInfo -void FutureWaitInfo::setDefault() { - ((Future*)&future)->setDefault(); -} - - -// Methods of ImageCopyBuffer -void ImageCopyBuffer::setDefault() { - ((TextureDataLayout*)&layout)->setDefault(); -} - - -// Methods of ImageCopyExternalTexture -void ImageCopyExternalTexture::setDefault() { - ((Origin3D*)&origin)->setDefault(); - ((Extent2D*)&naturalSize)->setDefault(); -} - - -// Methods of ImageCopyTexture -void ImageCopyTexture::setDefault() { - mipLevel = 0; - aspect = TextureAspect::All; - ((Origin3D*)&origin)->setDefault(); -} - - -// Methods of InstanceDescriptor -void InstanceDescriptor::setDefault() { - ((InstanceFeatures*)&features)->setDefault(); -} - - -// Methods of PipelineLayoutPixelLocalStorage -void PipelineLayoutPixelLocalStorage::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::PipelineLayoutPixelLocalStorage; -} - - -// Methods of ProgrammableStageDescriptor -void ProgrammableStageDescriptor::setDefault() { -} - - -// Methods of RenderPassColorAttachment -void RenderPassColorAttachment::setDefault() { - loadOp = LoadOp::Undefined; - storeOp = StoreOp::Undefined; - ((Color*)&clearValue)->setDefault(); -} - - -// Methods of RenderPassStorageAttachment -void RenderPassStorageAttachment::setDefault() { - loadOp = LoadOp::Undefined; - storeOp = StoreOp::Undefined; - ((Color*)&clearValue)->setDefault(); -} - - -// Methods of RequiredLimits -void RequiredLimits::setDefault() { - ((Limits*)&limits)->setDefault(); -} - - -// Methods of SharedTextureMemoryDmaBufDescriptor -void SharedTextureMemoryDmaBufDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - ((Extent3D*)&size)->setDefault(); - chain.sType = SType::SharedTextureMemoryDmaBufDescriptor; -} - - -// Methods of SharedTextureMemoryProperties -void SharedTextureMemoryProperties::setDefault() { - format = TextureFormat::Undefined; - ((Extent3D*)&size)->setDefault(); -} - - -// Methods of SharedTextureMemoryVkImageDescriptor -void SharedTextureMemoryVkImageDescriptor::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - ((Extent3D*)&vkExtent3D)->setDefault(); - chain.sType = SType::SharedTextureMemoryVkImageDescriptor; -} - - -// Methods of SupportedLimits -void SupportedLimits::setDefault() { - ((Limits*)&limits)->setDefault(); -} - - -// Methods of TextureDescriptor -void TextureDescriptor::setDefault() { - dimension = TextureDimension::_2D; - format = TextureFormat::Undefined; - mipLevelCount = 1; - sampleCount = 1; - ((Extent3D*)&size)->setDefault(); -} - - -// Methods of VertexBufferLayout -void VertexBufferLayout::setDefault() { - stepMode = VertexStepMode::Vertex; -} - - -// Methods of BindGroupLayoutDescriptor -void BindGroupLayoutDescriptor::setDefault() { -} - - -// Methods of ColorTargetState -void ColorTargetState::setDefault() { - format = TextureFormat::Undefined; -} - - -// Methods of ComputePipelineDescriptor -void ComputePipelineDescriptor::setDefault() { - ((ProgrammableStageDescriptor*)&compute)->setDefault(); -} - - -// Methods of DeviceDescriptor -void DeviceDescriptor::setDefault() { - ((QueueDescriptor*)&defaultQueue)->setDefault(); -} - - -// Methods of RenderPassDescriptor -void RenderPassDescriptor::setDefault() { -} - - -// Methods of RenderPassPixelLocalStorage -void RenderPassPixelLocalStorage::setDefault() { - ((ChainedStruct*)&chain)->setDefault(); - chain.sType = SType::RenderPassPixelLocalStorage; -} - - -// Methods of VertexState -void VertexState::setDefault() { -} - - -// Methods of FragmentState -void FragmentState::setDefault() { -} - - -// Methods of RenderPipelineDescriptor -void RenderPipelineDescriptor::setDefault() { - ((VertexState*)&vertex)->setDefault(); - ((PrimitiveState*)&primitive)->setDefault(); - ((MultisampleState*)&multisample)->setDefault(); -} - - -// Methods of Adapter -Device Adapter::createDevice(const DeviceDescriptor& descriptor) { - return wgpuAdapterCreateDevice(m_raw, &descriptor); -} -Device Adapter::createDevice() { - return wgpuAdapterCreateDevice(m_raw, nullptr); -} -size_t Adapter::enumerateFeatures(FeatureName * features) { - return wgpuAdapterEnumerateFeatures(m_raw, reinterpret_cast(features)); -} -Bool Adapter::getFormatCapabilities(TextureFormat format, FormatCapabilities * capabilities) { - return wgpuAdapterGetFormatCapabilities(m_raw, static_cast(format), capabilities); -} -Instance Adapter::getInstance() { - return wgpuAdapterGetInstance(m_raw); -} -Bool Adapter::getLimits(SupportedLimits * limits) { - return wgpuAdapterGetLimits(m_raw, limits); -} -void Adapter::getProperties(AdapterProperties * properties) { - return wgpuAdapterGetProperties(m_raw, properties); -} -Bool Adapter::hasFeature(FeatureName feature) { - return wgpuAdapterHasFeature(m_raw, static_cast(feature)); -} -std::unique_ptr Adapter::requestDevice(const DeviceDescriptor& descriptor, RequestDeviceCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) -> void { - RequestDeviceCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status), device, message); - }; - wgpuAdapterRequestDevice(m_raw, &descriptor, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Adapter::requestDeviceF(const DeviceDescriptor& options, RequestDeviceCallbackInfo callbackInfo) { - return wgpuAdapterRequestDeviceF(m_raw, &options, callbackInfo); -} -void Adapter::reference() { - return wgpuAdapterReference(m_raw); -} -void Adapter::release() { - return wgpuAdapterRelease(m_raw); -} - - -// Methods of BindGroup -void BindGroup::setLabel(char const * label) { - return wgpuBindGroupSetLabel(m_raw, label); -} -void BindGroup::reference() { - return wgpuBindGroupReference(m_raw); -} -void BindGroup::release() { - return wgpuBindGroupRelease(m_raw); -} - - -// Methods of BindGroupLayout -void BindGroupLayout::setLabel(char const * label) { - return wgpuBindGroupLayoutSetLabel(m_raw, label); -} -void BindGroupLayout::reference() { - return wgpuBindGroupLayoutReference(m_raw); -} -void BindGroupLayout::release() { - return wgpuBindGroupLayoutRelease(m_raw); -} - - -// Methods of Buffer -void Buffer::destroy() { - return wgpuBufferDestroy(m_raw); -} -void const * Buffer::getConstMappedRange(size_t offset, size_t size) { - return wgpuBufferGetConstMappedRange(m_raw, offset, size); -} -BufferMapState Buffer::getMapState() { - return static_cast(wgpuBufferGetMapState(m_raw)); -} -void * Buffer::getMappedRange(size_t offset, size_t size) { - return wgpuBufferGetMappedRange(m_raw, offset, size); -} -uint64_t Buffer::getSize() { - return wgpuBufferGetSize(m_raw); -} -BufferUsageFlags Buffer::getUsage() { - return wgpuBufferGetUsage(m_raw); -} -std::unique_ptr Buffer::mapAsync(MapModeFlags mode, size_t offset, size_t size, BufferMapCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUBufferMapAsyncStatus status, void * userdata) -> void { - BufferMapCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status)); - }; - wgpuBufferMapAsync(m_raw, mode, offset, size, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Buffer::mapAsyncF(MapModeFlags mode, size_t offset, size_t size, BufferMapCallbackInfo callbackInfo) { - return wgpuBufferMapAsyncF(m_raw, mode, offset, size, callbackInfo); -} -void Buffer::setLabel(char const * label) { - return wgpuBufferSetLabel(m_raw, label); -} -void Buffer::unmap() { - return wgpuBufferUnmap(m_raw); -} -void Buffer::reference() { - return wgpuBufferReference(m_raw); -} -void Buffer::release() { - return wgpuBufferRelease(m_raw); -} - - -// Methods of CommandBuffer -void CommandBuffer::setLabel(char const * label) { - return wgpuCommandBufferSetLabel(m_raw, label); -} -void CommandBuffer::reference() { - return wgpuCommandBufferReference(m_raw); -} -void CommandBuffer::release() { - return wgpuCommandBufferRelease(m_raw); -} - - -// Methods of CommandEncoder -ComputePassEncoder CommandEncoder::beginComputePass(const ComputePassDescriptor& descriptor) { - return wgpuCommandEncoderBeginComputePass(m_raw, &descriptor); -} -ComputePassEncoder CommandEncoder::beginComputePass() { - return wgpuCommandEncoderBeginComputePass(m_raw, nullptr); -} -RenderPassEncoder CommandEncoder::beginRenderPass(const RenderPassDescriptor& descriptor) { - return wgpuCommandEncoderBeginRenderPass(m_raw, &descriptor); -} -void CommandEncoder::clearBuffer(Buffer buffer, uint64_t offset, uint64_t size) { - return wgpuCommandEncoderClearBuffer(m_raw, buffer, offset, size); -} -void CommandEncoder::copyBufferToBuffer(Buffer source, uint64_t sourceOffset, Buffer destination, uint64_t destinationOffset, uint64_t size) { - return wgpuCommandEncoderCopyBufferToBuffer(m_raw, source, sourceOffset, destination, destinationOffset, size); -} -void CommandEncoder::copyBufferToTexture(const ImageCopyBuffer& source, const ImageCopyTexture& destination, const Extent3D& copySize) { - return wgpuCommandEncoderCopyBufferToTexture(m_raw, &source, &destination, ©Size); -} -void CommandEncoder::copyTextureToBuffer(const ImageCopyTexture& source, const ImageCopyBuffer& destination, const Extent3D& copySize) { - return wgpuCommandEncoderCopyTextureToBuffer(m_raw, &source, &destination, ©Size); -} -void CommandEncoder::copyTextureToTexture(const ImageCopyTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize) { - return wgpuCommandEncoderCopyTextureToTexture(m_raw, &source, &destination, ©Size); -} -CommandBuffer CommandEncoder::finish(const CommandBufferDescriptor& descriptor) { - return wgpuCommandEncoderFinish(m_raw, &descriptor); -} -CommandBuffer CommandEncoder::finish() { - return wgpuCommandEncoderFinish(m_raw, nullptr); -} -void CommandEncoder::injectValidationError(char const * message) { - return wgpuCommandEncoderInjectValidationError(m_raw, message); -} -void CommandEncoder::insertDebugMarker(char const * markerLabel) { - return wgpuCommandEncoderInsertDebugMarker(m_raw, markerLabel); -} -void CommandEncoder::popDebugGroup() { - return wgpuCommandEncoderPopDebugGroup(m_raw); -} -void CommandEncoder::pushDebugGroup(char const * groupLabel) { - return wgpuCommandEncoderPushDebugGroup(m_raw, groupLabel); -} -void CommandEncoder::resolveQuerySet(QuerySet querySet, uint32_t firstQuery, uint32_t queryCount, Buffer destination, uint64_t destinationOffset) { - return wgpuCommandEncoderResolveQuerySet(m_raw, querySet, firstQuery, queryCount, destination, destinationOffset); -} -void CommandEncoder::setLabel(char const * label) { - return wgpuCommandEncoderSetLabel(m_raw, label); -} -void CommandEncoder::writeBuffer(Buffer buffer, uint64_t bufferOffset, uint8_t const * data, uint64_t size) { - return wgpuCommandEncoderWriteBuffer(m_raw, buffer, bufferOffset, data, size); -} -void CommandEncoder::writeTimestamp(QuerySet querySet, uint32_t queryIndex) { - return wgpuCommandEncoderWriteTimestamp(m_raw, querySet, queryIndex); -} -void CommandEncoder::reference() { - return wgpuCommandEncoderReference(m_raw); -} -void CommandEncoder::release() { - return wgpuCommandEncoderRelease(m_raw); -} - - -// Methods of ComputePassEncoder -void ComputePassEncoder::dispatchWorkgroups(uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) { - return wgpuComputePassEncoderDispatchWorkgroups(m_raw, workgroupCountX, workgroupCountY, workgroupCountZ); -} -void ComputePassEncoder::dispatchWorkgroupsIndirect(Buffer indirectBuffer, uint64_t indirectOffset) { - return wgpuComputePassEncoderDispatchWorkgroupsIndirect(m_raw, indirectBuffer, indirectOffset); -} -void ComputePassEncoder::end() { - return wgpuComputePassEncoderEnd(m_raw); -} -void ComputePassEncoder::insertDebugMarker(char const * markerLabel) { - return wgpuComputePassEncoderInsertDebugMarker(m_raw, markerLabel); -} -void ComputePassEncoder::popDebugGroup() { - return wgpuComputePassEncoderPopDebugGroup(m_raw); -} -void ComputePassEncoder::pushDebugGroup(char const * groupLabel) { - return wgpuComputePassEncoderPushDebugGroup(m_raw, groupLabel); -} -void ComputePassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { - return wgpuComputePassEncoderSetBindGroup(m_raw, groupIndex, group, dynamicOffsetCount, dynamicOffsets); -} -void ComputePassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets) { - return wgpuComputePassEncoderSetBindGroup(m_raw, groupIndex, group, static_cast(dynamicOffsets.size()), dynamicOffsets.data()); -} -void ComputePassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets) { - return wgpuComputePassEncoderSetBindGroup(m_raw, groupIndex, group, 1, &dynamicOffsets); -} -void ComputePassEncoder::setLabel(char const * label) { - return wgpuComputePassEncoderSetLabel(m_raw, label); -} -void ComputePassEncoder::setPipeline(ComputePipeline pipeline) { - return wgpuComputePassEncoderSetPipeline(m_raw, pipeline); -} -void ComputePassEncoder::writeTimestamp(QuerySet querySet, uint32_t queryIndex) { - return wgpuComputePassEncoderWriteTimestamp(m_raw, querySet, queryIndex); -} -void ComputePassEncoder::reference() { - return wgpuComputePassEncoderReference(m_raw); -} -void ComputePassEncoder::release() { - return wgpuComputePassEncoderRelease(m_raw); -} - - -// Methods of ComputePipeline -BindGroupLayout ComputePipeline::getBindGroupLayout(uint32_t groupIndex) { - return wgpuComputePipelineGetBindGroupLayout(m_raw, groupIndex); -} -void ComputePipeline::setLabel(char const * label) { - return wgpuComputePipelineSetLabel(m_raw, label); -} -void ComputePipeline::reference() { - return wgpuComputePipelineReference(m_raw); -} -void ComputePipeline::release() { - return wgpuComputePipelineRelease(m_raw); -} - - -// Methods of Device -BindGroup Device::createBindGroup(const BindGroupDescriptor& descriptor) { - return wgpuDeviceCreateBindGroup(m_raw, &descriptor); -} -BindGroupLayout Device::createBindGroupLayout(const BindGroupLayoutDescriptor& descriptor) { - return wgpuDeviceCreateBindGroupLayout(m_raw, &descriptor); -} -Buffer Device::createBuffer(const BufferDescriptor& descriptor) { - return wgpuDeviceCreateBuffer(m_raw, &descriptor); -} -CommandEncoder Device::createCommandEncoder(const CommandEncoderDescriptor& descriptor) { - return wgpuDeviceCreateCommandEncoder(m_raw, &descriptor); -} -CommandEncoder Device::createCommandEncoder() { - return wgpuDeviceCreateCommandEncoder(m_raw, nullptr); -} -ComputePipeline Device::createComputePipeline(const ComputePipelineDescriptor& descriptor) { - return wgpuDeviceCreateComputePipeline(m_raw, &descriptor); -} -std::unique_ptr Device::createComputePipelineAsync(const ComputePipelineDescriptor& descriptor, CreateComputePipelineAsyncCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) -> void { - CreateComputePipelineAsyncCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status), pipeline, message); - }; - wgpuDeviceCreateComputePipelineAsync(m_raw, &descriptor, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Device::createComputePipelineAsyncF(const ComputePipelineDescriptor& descriptor, CreateComputePipelineAsyncCallbackInfo callbackInfo) { - return wgpuDeviceCreateComputePipelineAsyncF(m_raw, &descriptor, callbackInfo); -} -Buffer Device::createErrorBuffer(const BufferDescriptor& descriptor) { - return wgpuDeviceCreateErrorBuffer(m_raw, &descriptor); -} -ExternalTexture Device::createErrorExternalTexture() { - return wgpuDeviceCreateErrorExternalTexture(m_raw); -} -ShaderModule Device::createErrorShaderModule(const ShaderModuleDescriptor& descriptor, char const * errorMessage) { - return wgpuDeviceCreateErrorShaderModule(m_raw, &descriptor, errorMessage); -} -Texture Device::createErrorTexture(const TextureDescriptor& descriptor) { - return wgpuDeviceCreateErrorTexture(m_raw, &descriptor); -} -ExternalTexture Device::createExternalTexture(const ExternalTextureDescriptor& externalTextureDescriptor) { - return wgpuDeviceCreateExternalTexture(m_raw, &externalTextureDescriptor); -} -PipelineLayout Device::createPipelineLayout(const PipelineLayoutDescriptor& descriptor) { - return wgpuDeviceCreatePipelineLayout(m_raw, &descriptor); -} -QuerySet Device::createQuerySet(const QuerySetDescriptor& descriptor) { - return wgpuDeviceCreateQuerySet(m_raw, &descriptor); -} -RenderBundleEncoder Device::createRenderBundleEncoder(const RenderBundleEncoderDescriptor& descriptor) { - return wgpuDeviceCreateRenderBundleEncoder(m_raw, &descriptor); -} -RenderPipeline Device::createRenderPipeline(const RenderPipelineDescriptor& descriptor) { - return wgpuDeviceCreateRenderPipeline(m_raw, &descriptor); -} -std::unique_ptr Device::createRenderPipelineAsync(const RenderPipelineDescriptor& descriptor, CreateRenderPipelineAsyncCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) -> void { - CreateRenderPipelineAsyncCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status), pipeline, message); - }; - wgpuDeviceCreateRenderPipelineAsync(m_raw, &descriptor, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Device::createRenderPipelineAsyncF(const RenderPipelineDescriptor& descriptor, CreateRenderPipelineAsyncCallbackInfo callbackInfo) { - return wgpuDeviceCreateRenderPipelineAsyncF(m_raw, &descriptor, callbackInfo); -} -Sampler Device::createSampler(const SamplerDescriptor& descriptor) { - return wgpuDeviceCreateSampler(m_raw, &descriptor); -} -Sampler Device::createSampler() { - return wgpuDeviceCreateSampler(m_raw, nullptr); -} -ShaderModule Device::createShaderModule(const ShaderModuleDescriptor& descriptor) { - return wgpuDeviceCreateShaderModule(m_raw, &descriptor); -} -SwapChain Device::createSwapChain(Surface surface, const SwapChainDescriptor& descriptor) { - return wgpuDeviceCreateSwapChain(m_raw, surface, &descriptor); -} -Texture Device::createTexture(const TextureDescriptor& descriptor) { - return wgpuDeviceCreateTexture(m_raw, &descriptor); -} -void Device::destroy() { - return wgpuDeviceDestroy(m_raw); -} -size_t Device::enumerateFeatures(FeatureName * features) { - return wgpuDeviceEnumerateFeatures(m_raw, reinterpret_cast(features)); -} -void Device::forceLoss(DeviceLostReason type, char const * message) { - return wgpuDeviceForceLoss(m_raw, static_cast(type), message); -} -Adapter Device::getAdapter() { - return wgpuDeviceGetAdapter(m_raw); -} -Bool Device::getLimits(SupportedLimits * limits) { - return wgpuDeviceGetLimits(m_raw, limits); -} -Queue Device::getQueue() { - return wgpuDeviceGetQueue(m_raw); -} -TextureUsageFlags Device::getSupportedSurfaceUsage(Surface surface) { - return wgpuDeviceGetSupportedSurfaceUsage(m_raw, surface); -} -Bool Device::hasFeature(FeatureName feature) { - return wgpuDeviceHasFeature(m_raw, static_cast(feature)); -} -SharedBufferMemory Device::importSharedBufferMemory(const SharedBufferMemoryDescriptor& descriptor) { - return wgpuDeviceImportSharedBufferMemory(m_raw, &descriptor); -} -SharedFence Device::importSharedFence(const SharedFenceDescriptor& descriptor) { - return wgpuDeviceImportSharedFence(m_raw, &descriptor); -} -SharedTextureMemory Device::importSharedTextureMemory(const SharedTextureMemoryDescriptor& descriptor) { - return wgpuDeviceImportSharedTextureMemory(m_raw, &descriptor); -} -void Device::injectError(ErrorType type, char const * message) { - return wgpuDeviceInjectError(m_raw, static_cast(type), message); -} -std::unique_ptr Device::popErrorScope(ErrorCallback&& oldCallback) { - auto handle = std::make_unique(oldCallback);//callback - static auto cCallback = [](WGPUErrorType type, char const * message, void * userdata) -> void { - ErrorCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(type), message); - }; - wgpuDevicePopErrorScope(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Device::popErrorScopeF(PopErrorScopeCallbackInfo callbackInfo) { - return wgpuDevicePopErrorScopeF(m_raw, callbackInfo); -} -void Device::pushErrorScope(ErrorFilter filter) { - return wgpuDevicePushErrorScope(m_raw, static_cast(filter)); -} -std::unique_ptr Device::setDeviceLostCallback(DeviceLostCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUDeviceLostReason reason, char const * message, void * userdata) -> void { - DeviceLostCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(reason), message); - }; - wgpuDeviceSetDeviceLostCallback(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -void Device::setLabel(char const * label) { - return wgpuDeviceSetLabel(m_raw, label); -} -std::unique_ptr Device::setLoggingCallback(LoggingCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPULoggingType type, char const * message, void * userdata) -> void { - LoggingCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(type), message); - }; - wgpuDeviceSetLoggingCallback(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -std::unique_ptr Device::setUncapturedErrorCallback(ErrorCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUErrorType type, char const * message, void * userdata) -> void { - ErrorCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(type), message); - }; - wgpuDeviceSetUncapturedErrorCallback(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -void Device::tick() { - return wgpuDeviceTick(m_raw); -} -void Device::validateTextureDescriptor(const TextureDescriptor& descriptor) { - return wgpuDeviceValidateTextureDescriptor(m_raw, &descriptor); -} -void Device::reference() { - return wgpuDeviceReference(m_raw); -} -void Device::release() { - return wgpuDeviceRelease(m_raw); -} - - -// Methods of ExternalTexture -void ExternalTexture::destroy() { - return wgpuExternalTextureDestroy(m_raw); -} -void ExternalTexture::expire() { - return wgpuExternalTextureExpire(m_raw); -} -void ExternalTexture::refresh() { - return wgpuExternalTextureRefresh(m_raw); -} -void ExternalTexture::setLabel(char const * label) { - return wgpuExternalTextureSetLabel(m_raw, label); -} -void ExternalTexture::reference() { - return wgpuExternalTextureReference(m_raw); -} -void ExternalTexture::release() { - return wgpuExternalTextureRelease(m_raw); -} - - -// Methods of Instance -Surface Instance::createSurface(const SurfaceDescriptor& descriptor) { - return wgpuInstanceCreateSurface(m_raw, &descriptor); -} -size_t Instance::enumerateWGSLLanguageFeatures(WGSLFeatureName * features) { - return wgpuInstanceEnumerateWGSLLanguageFeatures(m_raw, reinterpret_cast(features)); -} -Bool Instance::hasWGSLLanguageFeature(WGSLFeatureName feature) { - return wgpuInstanceHasWGSLLanguageFeature(m_raw, static_cast(feature)); -} -void Instance::processEvents() { - return wgpuInstanceProcessEvents(m_raw); -} -std::unique_ptr Instance::requestAdapter(const RequestAdapterOptions& options, RequestAdapterCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) -> void { - RequestAdapterCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status), adapter, message); - }; - wgpuInstanceRequestAdapter(m_raw, &options, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Instance::requestAdapterF(const RequestAdapterOptions& options, RequestAdapterCallbackInfo callbackInfo) { - return wgpuInstanceRequestAdapterF(m_raw, &options, callbackInfo); -} -WaitStatus Instance::waitAny(size_t futureCount, FutureWaitInfo * futures, uint64_t timeoutNS) { - return static_cast(wgpuInstanceWaitAny(m_raw, futureCount, futures, timeoutNS)); -} -void Instance::reference() { - return wgpuInstanceReference(m_raw); -} -void Instance::release() { - return wgpuInstanceRelease(m_raw); -} - - -// Methods of PipelineLayout -void PipelineLayout::setLabel(char const * label) { - return wgpuPipelineLayoutSetLabel(m_raw, label); -} -void PipelineLayout::reference() { - return wgpuPipelineLayoutReference(m_raw); -} -void PipelineLayout::release() { - return wgpuPipelineLayoutRelease(m_raw); -} - - -// Methods of QuerySet -void QuerySet::destroy() { - return wgpuQuerySetDestroy(m_raw); -} -uint32_t QuerySet::getCount() { - return wgpuQuerySetGetCount(m_raw); -} -QueryType QuerySet::getType() { - return static_cast(wgpuQuerySetGetType(m_raw)); -} -void QuerySet::setLabel(char const * label) { - return wgpuQuerySetSetLabel(m_raw, label); -} -void QuerySet::reference() { - return wgpuQuerySetReference(m_raw); -} -void QuerySet::release() { - return wgpuQuerySetRelease(m_raw); -} - - -// Methods of Queue -void Queue::copyExternalTextureForBrowser(const ImageCopyExternalTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize, const CopyTextureForBrowserOptions& options) { - return wgpuQueueCopyExternalTextureForBrowser(m_raw, &source, &destination, ©Size, &options); -} -void Queue::copyTextureForBrowser(const ImageCopyTexture& source, const ImageCopyTexture& destination, const Extent3D& copySize, const CopyTextureForBrowserOptions& options) { - return wgpuQueueCopyTextureForBrowser(m_raw, &source, &destination, ©Size, &options); -} -std::unique_ptr Queue::onSubmittedWorkDone(QueueWorkDoneCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUQueueWorkDoneStatus status, void * userdata) -> void { - QueueWorkDoneCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status)); - }; - wgpuQueueOnSubmittedWorkDone(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future Queue::onSubmittedWorkDoneF(QueueWorkDoneCallbackInfo callbackInfo) { - return wgpuQueueOnSubmittedWorkDoneF(m_raw, callbackInfo); -} -void Queue::setLabel(char const * label) { - return wgpuQueueSetLabel(m_raw, label); -} -void Queue::submit(size_t commandCount, CommandBuffer const * commands) { - return wgpuQueueSubmit(m_raw, commandCount, reinterpret_cast(commands)); -} -void Queue::submit(const std::vector& commands) { - return wgpuQueueSubmit(m_raw, static_cast(commands.size()), commands.data()); -} -void Queue::submit(const WGPUCommandBuffer& commands) { - return wgpuQueueSubmit(m_raw, 1, &commands); -} -void Queue::writeBuffer(Buffer buffer, uint64_t bufferOffset, void const * data, size_t size) { - return wgpuQueueWriteBuffer(m_raw, buffer, bufferOffset, data, size); -} -void Queue::writeTexture(const ImageCopyTexture& destination, void const * data, size_t dataSize, const TextureDataLayout& dataLayout, const Extent3D& writeSize) { - return wgpuQueueWriteTexture(m_raw, &destination, data, dataSize, &dataLayout, &writeSize); -} -void Queue::reference() { - return wgpuQueueReference(m_raw); -} -void Queue::release() { - return wgpuQueueRelease(m_raw); -} - - -// Methods of RenderBundle -void RenderBundle::setLabel(char const * label) { - return wgpuRenderBundleSetLabel(m_raw, label); -} -void RenderBundle::reference() { - return wgpuRenderBundleReference(m_raw); -} -void RenderBundle::release() { - return wgpuRenderBundleRelease(m_raw); -} - - -// Methods of RenderBundleEncoder -void RenderBundleEncoder::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { - return wgpuRenderBundleEncoderDraw(m_raw, vertexCount, instanceCount, firstVertex, firstInstance); -} -void RenderBundleEncoder::drawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) { - return wgpuRenderBundleEncoderDrawIndexed(m_raw, indexCount, instanceCount, firstIndex, baseVertex, firstInstance); -} -void RenderBundleEncoder::drawIndexedIndirect(Buffer indirectBuffer, uint64_t indirectOffset) { - return wgpuRenderBundleEncoderDrawIndexedIndirect(m_raw, indirectBuffer, indirectOffset); -} -void RenderBundleEncoder::drawIndirect(Buffer indirectBuffer, uint64_t indirectOffset) { - return wgpuRenderBundleEncoderDrawIndirect(m_raw, indirectBuffer, indirectOffset); -} -RenderBundle RenderBundleEncoder::finish(const RenderBundleDescriptor& descriptor) { - return wgpuRenderBundleEncoderFinish(m_raw, &descriptor); -} -RenderBundle RenderBundleEncoder::finish() { - return wgpuRenderBundleEncoderFinish(m_raw, nullptr); -} -void RenderBundleEncoder::insertDebugMarker(char const * markerLabel) { - return wgpuRenderBundleEncoderInsertDebugMarker(m_raw, markerLabel); -} -void RenderBundleEncoder::popDebugGroup() { - return wgpuRenderBundleEncoderPopDebugGroup(m_raw); -} -void RenderBundleEncoder::pushDebugGroup(char const * groupLabel) { - return wgpuRenderBundleEncoderPushDebugGroup(m_raw, groupLabel); -} -void RenderBundleEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { - return wgpuRenderBundleEncoderSetBindGroup(m_raw, groupIndex, group, dynamicOffsetCount, dynamicOffsets); -} -void RenderBundleEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets) { - return wgpuRenderBundleEncoderSetBindGroup(m_raw, groupIndex, group, static_cast(dynamicOffsets.size()), dynamicOffsets.data()); -} -void RenderBundleEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets) { - return wgpuRenderBundleEncoderSetBindGroup(m_raw, groupIndex, group, 1, &dynamicOffsets); -} -void RenderBundleEncoder::setIndexBuffer(Buffer buffer, IndexFormat format, uint64_t offset, uint64_t size) { - return wgpuRenderBundleEncoderSetIndexBuffer(m_raw, buffer, static_cast(format), offset, size); -} -void RenderBundleEncoder::setLabel(char const * label) { - return wgpuRenderBundleEncoderSetLabel(m_raw, label); -} -void RenderBundleEncoder::setPipeline(RenderPipeline pipeline) { - return wgpuRenderBundleEncoderSetPipeline(m_raw, pipeline); -} -void RenderBundleEncoder::setVertexBuffer(uint32_t slot, Buffer buffer, uint64_t offset, uint64_t size) { - return wgpuRenderBundleEncoderSetVertexBuffer(m_raw, slot, buffer, offset, size); -} -void RenderBundleEncoder::reference() { - return wgpuRenderBundleEncoderReference(m_raw); -} -void RenderBundleEncoder::release() { - return wgpuRenderBundleEncoderRelease(m_raw); -} - - -// Methods of RenderPassEncoder -void RenderPassEncoder::beginOcclusionQuery(uint32_t queryIndex) { - return wgpuRenderPassEncoderBeginOcclusionQuery(m_raw, queryIndex); -} -void RenderPassEncoder::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { - return wgpuRenderPassEncoderDraw(m_raw, vertexCount, instanceCount, firstVertex, firstInstance); -} -void RenderPassEncoder::drawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) { - return wgpuRenderPassEncoderDrawIndexed(m_raw, indexCount, instanceCount, firstIndex, baseVertex, firstInstance); -} -void RenderPassEncoder::drawIndexedIndirect(Buffer indirectBuffer, uint64_t indirectOffset) { - return wgpuRenderPassEncoderDrawIndexedIndirect(m_raw, indirectBuffer, indirectOffset); -} -void RenderPassEncoder::drawIndirect(Buffer indirectBuffer, uint64_t indirectOffset) { - return wgpuRenderPassEncoderDrawIndirect(m_raw, indirectBuffer, indirectOffset); -} -void RenderPassEncoder::end() { - return wgpuRenderPassEncoderEnd(m_raw); -} -void RenderPassEncoder::endOcclusionQuery() { - return wgpuRenderPassEncoderEndOcclusionQuery(m_raw); -} -void RenderPassEncoder::executeBundles(size_t bundleCount, RenderBundle const * bundles) { - return wgpuRenderPassEncoderExecuteBundles(m_raw, bundleCount, reinterpret_cast(bundles)); -} -void RenderPassEncoder::executeBundles(const std::vector& bundles) { - return wgpuRenderPassEncoderExecuteBundles(m_raw, static_cast(bundles.size()), bundles.data()); -} -void RenderPassEncoder::executeBundles(const WGPURenderBundle& bundles) { - return wgpuRenderPassEncoderExecuteBundles(m_raw, 1, &bundles); -} -void RenderPassEncoder::insertDebugMarker(char const * markerLabel) { - return wgpuRenderPassEncoderInsertDebugMarker(m_raw, markerLabel); -} -void RenderPassEncoder::pixelLocalStorageBarrier() { - return wgpuRenderPassEncoderPixelLocalStorageBarrier(m_raw); -} -void RenderPassEncoder::popDebugGroup() { - return wgpuRenderPassEncoderPopDebugGroup(m_raw); -} -void RenderPassEncoder::pushDebugGroup(char const * groupLabel) { - return wgpuRenderPassEncoderPushDebugGroup(m_raw, groupLabel); -} -void RenderPassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) { - return wgpuRenderPassEncoderSetBindGroup(m_raw, groupIndex, group, dynamicOffsetCount, dynamicOffsets); -} -void RenderPassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const std::vector& dynamicOffsets) { - return wgpuRenderPassEncoderSetBindGroup(m_raw, groupIndex, group, static_cast(dynamicOffsets.size()), dynamicOffsets.data()); -} -void RenderPassEncoder::setBindGroup(uint32_t groupIndex, BindGroup group, const uint32_t& dynamicOffsets) { - return wgpuRenderPassEncoderSetBindGroup(m_raw, groupIndex, group, 1, &dynamicOffsets); -} -void RenderPassEncoder::setBlendConstant(const Color& color) { - return wgpuRenderPassEncoderSetBlendConstant(m_raw, &color); -} -void RenderPassEncoder::setIndexBuffer(Buffer buffer, IndexFormat format, uint64_t offset, uint64_t size) { - return wgpuRenderPassEncoderSetIndexBuffer(m_raw, buffer, static_cast(format), offset, size); -} -void RenderPassEncoder::setLabel(char const * label) { - return wgpuRenderPassEncoderSetLabel(m_raw, label); -} -void RenderPassEncoder::setPipeline(RenderPipeline pipeline) { - return wgpuRenderPassEncoderSetPipeline(m_raw, pipeline); -} -void RenderPassEncoder::setScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { - return wgpuRenderPassEncoderSetScissorRect(m_raw, x, y, width, height); -} -void RenderPassEncoder::setStencilReference(uint32_t reference) { - return wgpuRenderPassEncoderSetStencilReference(m_raw, reference); -} -void RenderPassEncoder::setVertexBuffer(uint32_t slot, Buffer buffer, uint64_t offset, uint64_t size) { - return wgpuRenderPassEncoderSetVertexBuffer(m_raw, slot, buffer, offset, size); -} -void RenderPassEncoder::setViewport(float x, float y, float width, float height, float minDepth, float maxDepth) { - return wgpuRenderPassEncoderSetViewport(m_raw, x, y, width, height, minDepth, maxDepth); -} -void RenderPassEncoder::writeTimestamp(QuerySet querySet, uint32_t queryIndex) { - return wgpuRenderPassEncoderWriteTimestamp(m_raw, querySet, queryIndex); -} -void RenderPassEncoder::reference() { - return wgpuRenderPassEncoderReference(m_raw); -} -void RenderPassEncoder::release() { - return wgpuRenderPassEncoderRelease(m_raw); -} - - -// Methods of RenderPipeline -BindGroupLayout RenderPipeline::getBindGroupLayout(uint32_t groupIndex) { - return wgpuRenderPipelineGetBindGroupLayout(m_raw, groupIndex); -} -void RenderPipeline::setLabel(char const * label) { - return wgpuRenderPipelineSetLabel(m_raw, label); -} -void RenderPipeline::reference() { - return wgpuRenderPipelineReference(m_raw); -} -void RenderPipeline::release() { - return wgpuRenderPipelineRelease(m_raw); -} - - -// Methods of Sampler -void Sampler::setLabel(char const * label) { - return wgpuSamplerSetLabel(m_raw, label); -} -void Sampler::reference() { - return wgpuSamplerReference(m_raw); -} -void Sampler::release() { - return wgpuSamplerRelease(m_raw); -} - - -// Methods of ShaderModule -std::unique_ptr ShaderModule::getCompilationInfo(CompilationInfoCallback&& callback) { - auto handle = std::make_unique(callback); - static auto cCallback = [](WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, void * userdata) -> void { - CompilationInfoCallback& callback = *reinterpret_cast(userdata); - callback(static_cast(status), *reinterpret_cast(compilationInfo)); - }; - wgpuShaderModuleGetCompilationInfo(m_raw, cCallback, reinterpret_cast(handle.get())); - return handle; -} -Future ShaderModule::getCompilationInfoF(CompilationInfoCallbackInfo callbackInfo) { - return wgpuShaderModuleGetCompilationInfoF(m_raw, callbackInfo); -} -void ShaderModule::setLabel(char const * label) { - return wgpuShaderModuleSetLabel(m_raw, label); -} -void ShaderModule::reference() { - return wgpuShaderModuleReference(m_raw); -} -void ShaderModule::release() { - return wgpuShaderModuleRelease(m_raw); -} - - -// Methods of SharedBufferMemory -Bool SharedBufferMemory::beginAccess(Buffer buffer, const SharedBufferMemoryBeginAccessDescriptor& descriptor) { - return wgpuSharedBufferMemoryBeginAccess(m_raw, buffer, &descriptor); -} -Buffer SharedBufferMemory::createBuffer(const BufferDescriptor& descriptor) { - return wgpuSharedBufferMemoryCreateBuffer(m_raw, &descriptor); -} -Buffer SharedBufferMemory::createBuffer() { - return wgpuSharedBufferMemoryCreateBuffer(m_raw, nullptr); -} -Bool SharedBufferMemory::endAccess(Buffer buffer, SharedBufferMemoryEndAccessState * descriptor) { - return wgpuSharedBufferMemoryEndAccess(m_raw, buffer, descriptor); -} -void SharedBufferMemory::getProperties(SharedBufferMemoryProperties * properties) { - return wgpuSharedBufferMemoryGetProperties(m_raw, properties); -} -Bool SharedBufferMemory::isDeviceLost() { - return wgpuSharedBufferMemoryIsDeviceLost(m_raw); -} -void SharedBufferMemory::setLabel(char const * label) { - return wgpuSharedBufferMemorySetLabel(m_raw, label); -} -void SharedBufferMemory::reference() { - return wgpuSharedBufferMemoryReference(m_raw); -} -void SharedBufferMemory::release() { - return wgpuSharedBufferMemoryRelease(m_raw); -} - - -// Methods of SharedFence -void SharedFence::exportInfo(SharedFenceExportInfo * info) { - return wgpuSharedFenceExportInfo(m_raw, info); -} -void SharedFence::reference() { - return wgpuSharedFenceReference(m_raw); -} -void SharedFence::release() { - return wgpuSharedFenceRelease(m_raw); -} - - -// Methods of SharedTextureMemory -Bool SharedTextureMemory::beginAccess(Texture texture, const SharedTextureMemoryBeginAccessDescriptor& descriptor) { - return wgpuSharedTextureMemoryBeginAccess(m_raw, texture, &descriptor); -} -Texture SharedTextureMemory::createTexture(const TextureDescriptor& descriptor) { - return wgpuSharedTextureMemoryCreateTexture(m_raw, &descriptor); -} -Texture SharedTextureMemory::createTexture() { - return wgpuSharedTextureMemoryCreateTexture(m_raw, nullptr); -} -Bool SharedTextureMemory::endAccess(Texture texture, SharedTextureMemoryEndAccessState * descriptor) { - return wgpuSharedTextureMemoryEndAccess(m_raw, texture, descriptor); -} -void SharedTextureMemory::getProperties(SharedTextureMemoryProperties * properties) { - return wgpuSharedTextureMemoryGetProperties(m_raw, properties); -} -Bool SharedTextureMemory::isDeviceLost() { - return wgpuSharedTextureMemoryIsDeviceLost(m_raw); -} -void SharedTextureMemory::setLabel(char const * label) { - return wgpuSharedTextureMemorySetLabel(m_raw, label); -} -void SharedTextureMemory::reference() { - return wgpuSharedTextureMemoryReference(m_raw); -} -void SharedTextureMemory::release() { - return wgpuSharedTextureMemoryRelease(m_raw); -} - - -// Methods of Surface -TextureFormat Surface::getPreferredFormat(Adapter adapter) { - return static_cast(wgpuSurfaceGetPreferredFormat(m_raw, adapter)); -} -void Surface::reference() { - return wgpuSurfaceReference(m_raw); -} -void Surface::release() { - return wgpuSurfaceRelease(m_raw); -} - - -// Methods of SwapChain -Texture SwapChain::getCurrentTexture() { - return wgpuSwapChainGetCurrentTexture(m_raw); -} -TextureView SwapChain::getCurrentTextureView() { - return wgpuSwapChainGetCurrentTextureView(m_raw); -} -void SwapChain::present() { - return wgpuSwapChainPresent(m_raw); -} -void SwapChain::reference() { - return wgpuSwapChainReference(m_raw); -} -void SwapChain::release() { - return wgpuSwapChainRelease(m_raw); -} - - -// Methods of Texture -TextureView Texture::createErrorView(const TextureViewDescriptor& descriptor) { - return wgpuTextureCreateErrorView(m_raw, &descriptor); -} -TextureView Texture::createErrorView() { - return wgpuTextureCreateErrorView(m_raw, nullptr); -} -TextureView Texture::createView(const TextureViewDescriptor& descriptor) { - return wgpuTextureCreateView(m_raw, &descriptor); -} -TextureView Texture::createView() { - return wgpuTextureCreateView(m_raw, nullptr); -} -void Texture::destroy() { - return wgpuTextureDestroy(m_raw); -} -uint32_t Texture::getDepthOrArrayLayers() { - return wgpuTextureGetDepthOrArrayLayers(m_raw); -} -TextureDimension Texture::getDimension() { - return static_cast(wgpuTextureGetDimension(m_raw)); -} -TextureFormat Texture::getFormat() { - return static_cast(wgpuTextureGetFormat(m_raw)); -} -uint32_t Texture::getHeight() { - return wgpuTextureGetHeight(m_raw); -} -uint32_t Texture::getMipLevelCount() { - return wgpuTextureGetMipLevelCount(m_raw); -} -uint32_t Texture::getSampleCount() { - return wgpuTextureGetSampleCount(m_raw); -} -TextureUsageFlags Texture::getUsage() { - return wgpuTextureGetUsage(m_raw); -} -uint32_t Texture::getWidth() { - return wgpuTextureGetWidth(m_raw); -} -void Texture::setLabel(char const * label) { - return wgpuTextureSetLabel(m_raw, label); -} -void Texture::reference() { - return wgpuTextureReference(m_raw); -} -void Texture::release() { - return wgpuTextureRelease(m_raw); -} - - -// Methods of TextureView -void TextureView::setLabel(char const * label) { - return wgpuTextureViewSetLabel(m_raw, label); -} -void TextureView::reference() { - return wgpuTextureViewReference(m_raw); -} -void TextureView::release() { - return wgpuTextureViewRelease(m_raw); -} - - - -// Extra implementations -Adapter Instance::requestAdapter(const RequestAdapterOptions& options) { - Adapter adapter = nullptr; - bool requestEnded = false; - - auto onAdapterRequestEnded = [&adapter, &requestEnded](RequestAdapterStatus status, Adapter _adapter, char const * message) { - if (status == RequestAdapterStatus::Success) { - adapter = _adapter; - } else { - std::cout << "Could not get WebGPU adapter: " << message << std::endl; - } - requestEnded = true; - }; - - auto h = requestAdapter(options, onAdapterRequestEnded); - -#if __EMSCRIPTEN__ - while (!requestEnded) { - emscripten_sleep(100); - } -#endif - - assert(requestEnded); - return adapter; -} - -Device Adapter::requestDevice(const DeviceDescriptor& descriptor) { - WGPUDevice device = nullptr; - bool requestEnded = false; - - auto onDeviceRequestEnded = [&device, &requestEnded](RequestDeviceStatus status, Device _device, char const * message) { - if (status == RequestDeviceStatus::Success) { - device = _device; - } else { - std::cout << "Could not get WebGPU adapter: " << message << std::endl; - } - requestEnded = true; - }; - - auto h = requestDevice(descriptor, onDeviceRequestEnded); - -#if __EMSCRIPTEN__ - while (!requestEnded) { - emscripten_sleep(100); - } -#endif - - assert(requestEnded); - return device; -} - -#endif // WEBGPU_CPP_IMPLEMENTATION - -#undef HANDLE -#undef DESCRIPTOR -#undef ENUM -#undef ENUM_ENTRY -#undef END - -} // namespace wgpu diff --git a/package/android/cpp/rnskia-android/webgpu.h b/package/android/cpp/rnskia-android/webgpu/webgpu.h similarity index 100% rename from package/android/cpp/rnskia-android/webgpu.h rename to package/android/cpp/rnskia-android/webgpu/webgpu.h diff --git a/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_chained_struct.h b/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_chained_struct.h new file mode 100644 index 0000000000..49340c3afb --- /dev/null +++ b/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_chained_struct.h @@ -0,0 +1,31 @@ +#ifdef __EMSCRIPTEN__ +#error \ + "Do not include this header. Emscripten already provides headers needed for WebGPU." +#endif +#ifndef WEBGPU_CPP_CHAINED_STRUCT_H_ +#define WEBGPU_CPP_CHAINED_STRUCT_H_ + +#include +#include + +// This header file declares the ChainedStruct structures separately from the +// WebGPU headers so that dependencies can directly extend structures without +// including the larger header which exposes capabilities that may require +// correctly set proc tables. +namespace wgpu { + +enum class SType : uint32_t; + +struct ChainedStruct { + ChainedStruct const *nextInChain = nullptr; + SType sType = SType(0u); +}; + +struct ChainedStructOut { + ChainedStructOut *nextInChain = nullptr; + SType sType = SType(0u); +}; + +} // namespace wgpu + +#endif // WEBGPU_CPP_CHAINED_STRUCT_H_ diff --git a/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_print.h b/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_print.h new file mode 100644 index 0000000000..2fb01b6c2c --- /dev/null +++ b/package/android/cpp/rnskia-android/webgpu/webgpu_cpp_print.h @@ -0,0 +1,2494 @@ + +#ifndef WEBGPU_CPP_PRINT_H_ +#define WEBGPU_CPP_PRINT_H_ + +#include "dawn/webgpu_cpp.h" + +#include +#include +#include +#include + +namespace wgpu { + +template +std::basic_ostream & +operator<<(std::basic_ostream &o, WGSLFeatureName value) { + switch (value) { + case WGSLFeatureName::Undefined: + o << "WGSLFeatureName::Undefined"; + break; + case WGSLFeatureName::ReadonlyAndReadwriteStorageTextures: + o << "WGSLFeatureName::ReadonlyAndReadwriteStorageTextures"; + break; + case WGSLFeatureName::Packed4x8IntegerDotProduct: + o << "WGSLFeatureName::Packed4x8IntegerDotProduct"; + break; + case WGSLFeatureName::UnrestrictedPointerParameters: + o << "WGSLFeatureName::UnrestrictedPointerParameters"; + break; + case WGSLFeatureName::PointerCompositeAccess: + o << "WGSLFeatureName::PointerCompositeAccess"; + break; + case WGSLFeatureName::ChromiumTestingUnimplemented: + o << "WGSLFeatureName::ChromiumTestingUnimplemented"; + break; + case WGSLFeatureName::ChromiumTestingUnsafeExperimental: + o << "WGSLFeatureName::ChromiumTestingUnsafeExperimental"; + break; + case WGSLFeatureName::ChromiumTestingExperimental: + o << "WGSLFeatureName::ChromiumTestingExperimental"; + break; + case WGSLFeatureName::ChromiumTestingShippedWithKillswitch: + o << "WGSLFeatureName::ChromiumTestingShippedWithKillswitch"; + break; + case WGSLFeatureName::ChromiumTestingShipped: + o << "WGSLFeatureName::ChromiumTestingShipped"; + break; + default: + o << "WGSLFeatureName::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, AdapterType value) { + switch (value) { + case AdapterType::DiscreteGPU: + o << "AdapterType::DiscreteGPU"; + break; + case AdapterType::IntegratedGPU: + o << "AdapterType::IntegratedGPU"; + break; + case AdapterType::CPU: + o << "AdapterType::CPU"; + break; + case AdapterType::Unknown: + o << "AdapterType::Unknown"; + break; + default: + o << "AdapterType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, AddressMode value) { + switch (value) { + case AddressMode::Undefined: + o << "AddressMode::Undefined"; + break; + case AddressMode::ClampToEdge: + o << "AddressMode::ClampToEdge"; + break; + case AddressMode::Repeat: + o << "AddressMode::Repeat"; + break; + case AddressMode::MirrorRepeat: + o << "AddressMode::MirrorRepeat"; + break; + default: + o << "AddressMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, AlphaMode value) { + switch (value) { + case AlphaMode::Opaque: + o << "AlphaMode::Opaque"; + break; + case AlphaMode::Premultiplied: + o << "AlphaMode::Premultiplied"; + break; + case AlphaMode::Unpremultiplied: + o << "AlphaMode::Unpremultiplied"; + break; + default: + o << "AlphaMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BackendType value) { + switch (value) { + case BackendType::Undefined: + o << "BackendType::Undefined"; + break; + case BackendType::Null: + o << "BackendType::Null"; + break; + case BackendType::WebGPU: + o << "BackendType::WebGPU"; + break; + case BackendType::D3D11: + o << "BackendType::D3D11"; + break; + case BackendType::D3D12: + o << "BackendType::D3D12"; + break; + case BackendType::Metal: + o << "BackendType::Metal"; + break; + case BackendType::Vulkan: + o << "BackendType::Vulkan"; + break; + case BackendType::OpenGL: + o << "BackendType::OpenGL"; + break; + case BackendType::OpenGLES: + o << "BackendType::OpenGLES"; + break; + default: + o << "BackendType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BlendFactor value) { + switch (value) { + case BlendFactor::Undefined: + o << "BlendFactor::Undefined"; + break; + case BlendFactor::Zero: + o << "BlendFactor::Zero"; + break; + case BlendFactor::One: + o << "BlendFactor::One"; + break; + case BlendFactor::Src: + o << "BlendFactor::Src"; + break; + case BlendFactor::OneMinusSrc: + o << "BlendFactor::OneMinusSrc"; + break; + case BlendFactor::SrcAlpha: + o << "BlendFactor::SrcAlpha"; + break; + case BlendFactor::OneMinusSrcAlpha: + o << "BlendFactor::OneMinusSrcAlpha"; + break; + case BlendFactor::Dst: + o << "BlendFactor::Dst"; + break; + case BlendFactor::OneMinusDst: + o << "BlendFactor::OneMinusDst"; + break; + case BlendFactor::DstAlpha: + o << "BlendFactor::DstAlpha"; + break; + case BlendFactor::OneMinusDstAlpha: + o << "BlendFactor::OneMinusDstAlpha"; + break; + case BlendFactor::SrcAlphaSaturated: + o << "BlendFactor::SrcAlphaSaturated"; + break; + case BlendFactor::Constant: + o << "BlendFactor::Constant"; + break; + case BlendFactor::OneMinusConstant: + o << "BlendFactor::OneMinusConstant"; + break; + case BlendFactor::Src1: + o << "BlendFactor::Src1"; + break; + case BlendFactor::OneMinusSrc1: + o << "BlendFactor::OneMinusSrc1"; + break; + case BlendFactor::Src1Alpha: + o << "BlendFactor::Src1Alpha"; + break; + case BlendFactor::OneMinusSrc1Alpha: + o << "BlendFactor::OneMinusSrc1Alpha"; + break; + default: + o << "BlendFactor::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BlendOperation value) { + switch (value) { + case BlendOperation::Undefined: + o << "BlendOperation::Undefined"; + break; + case BlendOperation::Add: + o << "BlendOperation::Add"; + break; + case BlendOperation::Subtract: + o << "BlendOperation::Subtract"; + break; + case BlendOperation::ReverseSubtract: + o << "BlendOperation::ReverseSubtract"; + break; + case BlendOperation::Min: + o << "BlendOperation::Min"; + break; + case BlendOperation::Max: + o << "BlendOperation::Max"; + break; + default: + o << "BlendOperation::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BufferBindingType value) { + switch (value) { + case BufferBindingType::Undefined: + o << "BufferBindingType::Undefined"; + break; + case BufferBindingType::Uniform: + o << "BufferBindingType::Uniform"; + break; + case BufferBindingType::Storage: + o << "BufferBindingType::Storage"; + break; + case BufferBindingType::ReadOnlyStorage: + o << "BufferBindingType::ReadOnlyStorage"; + break; + default: + o << "BufferBindingType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BufferMapAsyncStatus value) { + switch (value) { + case BufferMapAsyncStatus::Success: + o << "BufferMapAsyncStatus::Success"; + break; + case BufferMapAsyncStatus::InstanceDropped: + o << "BufferMapAsyncStatus::InstanceDropped"; + break; + case BufferMapAsyncStatus::ValidationError: + o << "BufferMapAsyncStatus::ValidationError"; + break; + case BufferMapAsyncStatus::Unknown: + o << "BufferMapAsyncStatus::Unknown"; + break; + case BufferMapAsyncStatus::DeviceLost: + o << "BufferMapAsyncStatus::DeviceLost"; + break; + case BufferMapAsyncStatus::DestroyedBeforeCallback: + o << "BufferMapAsyncStatus::DestroyedBeforeCallback"; + break; + case BufferMapAsyncStatus::UnmappedBeforeCallback: + o << "BufferMapAsyncStatus::UnmappedBeforeCallback"; + break; + case BufferMapAsyncStatus::MappingAlreadyPending: + o << "BufferMapAsyncStatus::MappingAlreadyPending"; + break; + case BufferMapAsyncStatus::OffsetOutOfRange: + o << "BufferMapAsyncStatus::OffsetOutOfRange"; + break; + case BufferMapAsyncStatus::SizeOutOfRange: + o << "BufferMapAsyncStatus::SizeOutOfRange"; + break; + default: + o << "BufferMapAsyncStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BufferMapState value) { + switch (value) { + case BufferMapState::Unmapped: + o << "BufferMapState::Unmapped"; + break; + case BufferMapState::Pending: + o << "BufferMapState::Pending"; + break; + case BufferMapState::Mapped: + o << "BufferMapState::Mapped"; + break; + default: + o << "BufferMapState::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, CallbackMode value) { + switch (value) { + case CallbackMode::WaitAnyOnly: + o << "CallbackMode::WaitAnyOnly"; + break; + case CallbackMode::AllowProcessEvents: + o << "CallbackMode::AllowProcessEvents"; + break; + case CallbackMode::AllowSpontaneous: + o << "CallbackMode::AllowSpontaneous"; + break; + default: + o << "CallbackMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, CompareFunction value) { + switch (value) { + case CompareFunction::Undefined: + o << "CompareFunction::Undefined"; + break; + case CompareFunction::Never: + o << "CompareFunction::Never"; + break; + case CompareFunction::Less: + o << "CompareFunction::Less"; + break; + case CompareFunction::Equal: + o << "CompareFunction::Equal"; + break; + case CompareFunction::LessEqual: + o << "CompareFunction::LessEqual"; + break; + case CompareFunction::Greater: + o << "CompareFunction::Greater"; + break; + case CompareFunction::NotEqual: + o << "CompareFunction::NotEqual"; + break; + case CompareFunction::GreaterEqual: + o << "CompareFunction::GreaterEqual"; + break; + case CompareFunction::Always: + o << "CompareFunction::Always"; + break; + default: + o << "CompareFunction::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, + CompilationInfoRequestStatus value) { + switch (value) { + case CompilationInfoRequestStatus::Success: + o << "CompilationInfoRequestStatus::Success"; + break; + case CompilationInfoRequestStatus::InstanceDropped: + o << "CompilationInfoRequestStatus::InstanceDropped"; + break; + case CompilationInfoRequestStatus::Error: + o << "CompilationInfoRequestStatus::Error"; + break; + case CompilationInfoRequestStatus::DeviceLost: + o << "CompilationInfoRequestStatus::DeviceLost"; + break; + case CompilationInfoRequestStatus::Unknown: + o << "CompilationInfoRequestStatus::Unknown"; + break; + default: + o << "CompilationInfoRequestStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast< + typename std::underlying_type::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, CompilationMessageType value) { + switch (value) { + case CompilationMessageType::Error: + o << "CompilationMessageType::Error"; + break; + case CompilationMessageType::Warning: + o << "CompilationMessageType::Warning"; + break; + case CompilationMessageType::Info: + o << "CompilationMessageType::Info"; + break; + default: + o << "CompilationMessageType::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast< + typename std::underlying_type::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, + CreatePipelineAsyncStatus value) { + switch (value) { + case CreatePipelineAsyncStatus::Success: + o << "CreatePipelineAsyncStatus::Success"; + break; + case CreatePipelineAsyncStatus::InstanceDropped: + o << "CreatePipelineAsyncStatus::InstanceDropped"; + break; + case CreatePipelineAsyncStatus::ValidationError: + o << "CreatePipelineAsyncStatus::ValidationError"; + break; + case CreatePipelineAsyncStatus::InternalError: + o << "CreatePipelineAsyncStatus::InternalError"; + break; + case CreatePipelineAsyncStatus::DeviceLost: + o << "CreatePipelineAsyncStatus::DeviceLost"; + break; + case CreatePipelineAsyncStatus::DeviceDestroyed: + o << "CreatePipelineAsyncStatus::DeviceDestroyed"; + break; + case CreatePipelineAsyncStatus::Unknown: + o << "CreatePipelineAsyncStatus::Unknown"; + break; + default: + o << "CreatePipelineAsyncStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast< + typename std::underlying_type::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, CullMode value) { + switch (value) { + case CullMode::Undefined: + o << "CullMode::Undefined"; + break; + case CullMode::None: + o << "CullMode::None"; + break; + case CullMode::Front: + o << "CullMode::Front"; + break; + case CullMode::Back: + o << "CullMode::Back"; + break; + default: + o << "CullMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, DeviceLostReason value) { + switch (value) { + case DeviceLostReason::Undefined: + o << "DeviceLostReason::Undefined"; + break; + case DeviceLostReason::Destroyed: + o << "DeviceLostReason::Destroyed"; + break; + default: + o << "DeviceLostReason::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, ErrorFilter value) { + switch (value) { + case ErrorFilter::Validation: + o << "ErrorFilter::Validation"; + break; + case ErrorFilter::OutOfMemory: + o << "ErrorFilter::OutOfMemory"; + break; + case ErrorFilter::Internal: + o << "ErrorFilter::Internal"; + break; + default: + o << "ErrorFilter::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, ErrorType value) { + switch (value) { + case ErrorType::NoError: + o << "ErrorType::NoError"; + break; + case ErrorType::Validation: + o << "ErrorType::Validation"; + break; + case ErrorType::OutOfMemory: + o << "ErrorType::OutOfMemory"; + break; + case ErrorType::Internal: + o << "ErrorType::Internal"; + break; + case ErrorType::Unknown: + o << "ErrorType::Unknown"; + break; + case ErrorType::DeviceLost: + o << "ErrorType::DeviceLost"; + break; + default: + o << "ErrorType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, + ExternalTextureRotation value) { + switch (value) { + case ExternalTextureRotation::Rotate0Degrees: + o << "ExternalTextureRotation::Rotate0Degrees"; + break; + case ExternalTextureRotation::Rotate90Degrees: + o << "ExternalTextureRotation::Rotate90Degrees"; + break; + case ExternalTextureRotation::Rotate180Degrees: + o << "ExternalTextureRotation::Rotate180Degrees"; + break; + case ExternalTextureRotation::Rotate270Degrees: + o << "ExternalTextureRotation::Rotate270Degrees"; + break; + default: + o << "ExternalTextureRotation::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast< + typename std::underlying_type::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, FeatureName value) { + switch (value) { + case FeatureName::Undefined: + o << "FeatureName::Undefined"; + break; + case FeatureName::DepthClipControl: + o << "FeatureName::DepthClipControl"; + break; + case FeatureName::Depth32FloatStencil8: + o << "FeatureName::Depth32FloatStencil8"; + break; + case FeatureName::TimestampQuery: + o << "FeatureName::TimestampQuery"; + break; + case FeatureName::TextureCompressionBC: + o << "FeatureName::TextureCompressionBC"; + break; + case FeatureName::TextureCompressionETC2: + o << "FeatureName::TextureCompressionETC2"; + break; + case FeatureName::TextureCompressionASTC: + o << "FeatureName::TextureCompressionASTC"; + break; + case FeatureName::IndirectFirstInstance: + o << "FeatureName::IndirectFirstInstance"; + break; + case FeatureName::ShaderF16: + o << "FeatureName::ShaderF16"; + break; + case FeatureName::RG11B10UfloatRenderable: + o << "FeatureName::RG11B10UfloatRenderable"; + break; + case FeatureName::BGRA8UnormStorage: + o << "FeatureName::BGRA8UnormStorage"; + break; + case FeatureName::Float32Filterable: + o << "FeatureName::Float32Filterable"; + break; + case FeatureName::DawnInternalUsages: + o << "FeatureName::DawnInternalUsages"; + break; + case FeatureName::DawnMultiPlanarFormats: + o << "FeatureName::DawnMultiPlanarFormats"; + break; + case FeatureName::DawnNative: + o << "FeatureName::DawnNative"; + break; + case FeatureName::ChromiumExperimentalTimestampQueryInsidePasses: + o << "FeatureName::ChromiumExperimentalTimestampQueryInsidePasses"; + break; + case FeatureName::ImplicitDeviceSynchronization: + o << "FeatureName::ImplicitDeviceSynchronization"; + break; + case FeatureName::SurfaceCapabilities: + o << "FeatureName::SurfaceCapabilities"; + break; + case FeatureName::TransientAttachments: + o << "FeatureName::TransientAttachments"; + break; + case FeatureName::MSAARenderToSingleSampled: + o << "FeatureName::MSAARenderToSingleSampled"; + break; + case FeatureName::DualSourceBlending: + o << "FeatureName::DualSourceBlending"; + break; + case FeatureName::D3D11MultithreadProtected: + o << "FeatureName::D3D11MultithreadProtected"; + break; + case FeatureName::ANGLETextureSharing: + o << "FeatureName::ANGLETextureSharing"; + break; + case FeatureName::ChromiumExperimentalSubgroups: + o << "FeatureName::ChromiumExperimentalSubgroups"; + break; + case FeatureName::ChromiumExperimentalSubgroupUniformControlFlow: + o << "FeatureName::ChromiumExperimentalSubgroupUniformControlFlow"; + break; + case FeatureName::PixelLocalStorageCoherent: + o << "FeatureName::PixelLocalStorageCoherent"; + break; + case FeatureName::PixelLocalStorageNonCoherent: + o << "FeatureName::PixelLocalStorageNonCoherent"; + break; + case FeatureName::Unorm16TextureFormats: + o << "FeatureName::Unorm16TextureFormats"; + break; + case FeatureName::Snorm16TextureFormats: + o << "FeatureName::Snorm16TextureFormats"; + break; + case FeatureName::MultiPlanarFormatExtendedUsages: + o << "FeatureName::MultiPlanarFormatExtendedUsages"; + break; + case FeatureName::MultiPlanarFormatP010: + o << "FeatureName::MultiPlanarFormatP010"; + break; + case FeatureName::HostMappedPointer: + o << "FeatureName::HostMappedPointer"; + break; + case FeatureName::MultiPlanarRenderTargets: + o << "FeatureName::MultiPlanarRenderTargets"; + break; + case FeatureName::MultiPlanarFormatNv12a: + o << "FeatureName::MultiPlanarFormatNv12a"; + break; + case FeatureName::FramebufferFetch: + o << "FeatureName::FramebufferFetch"; + break; + case FeatureName::BufferMapExtendedUsages: + o << "FeatureName::BufferMapExtendedUsages"; + break; + case FeatureName::AdapterPropertiesMemoryHeaps: + o << "FeatureName::AdapterPropertiesMemoryHeaps"; + break; + case FeatureName::AdapterPropertiesD3D: + o << "FeatureName::AdapterPropertiesD3D"; + break; + case FeatureName::AdapterPropertiesVk: + o << "FeatureName::AdapterPropertiesVk"; + break; + case FeatureName::R8UnormStorage: + o << "FeatureName::R8UnormStorage"; + break; + case FeatureName::FormatCapabilities: + o << "FeatureName::FormatCapabilities"; + break; + case FeatureName::DrmFormatCapabilities: + o << "FeatureName::DrmFormatCapabilities"; + break; + case FeatureName::Norm16TextureFormats: + o << "FeatureName::Norm16TextureFormats"; + break; + case FeatureName::SharedTextureMemoryVkDedicatedAllocation: + o << "FeatureName::SharedTextureMemoryVkDedicatedAllocation"; + break; + case FeatureName::SharedTextureMemoryAHardwareBuffer: + o << "FeatureName::SharedTextureMemoryAHardwareBuffer"; + break; + case FeatureName::SharedTextureMemoryDmaBuf: + o << "FeatureName::SharedTextureMemoryDmaBuf"; + break; + case FeatureName::SharedTextureMemoryOpaqueFD: + o << "FeatureName::SharedTextureMemoryOpaqueFD"; + break; + case FeatureName::SharedTextureMemoryZirconHandle: + o << "FeatureName::SharedTextureMemoryZirconHandle"; + break; + case FeatureName::SharedTextureMemoryDXGISharedHandle: + o << "FeatureName::SharedTextureMemoryDXGISharedHandle"; + break; + case FeatureName::SharedTextureMemoryD3D11Texture2D: + o << "FeatureName::SharedTextureMemoryD3D11Texture2D"; + break; + case FeatureName::SharedTextureMemoryIOSurface: + o << "FeatureName::SharedTextureMemoryIOSurface"; + break; + case FeatureName::SharedTextureMemoryEGLImage: + o << "FeatureName::SharedTextureMemoryEGLImage"; + break; + case FeatureName::SharedFenceVkSemaphoreOpaqueFD: + o << "FeatureName::SharedFenceVkSemaphoreOpaqueFD"; + break; + case FeatureName::SharedFenceVkSemaphoreSyncFD: + o << "FeatureName::SharedFenceVkSemaphoreSyncFD"; + break; + case FeatureName::SharedFenceVkSemaphoreZirconHandle: + o << "FeatureName::SharedFenceVkSemaphoreZirconHandle"; + break; + case FeatureName::SharedFenceDXGISharedHandle: + o << "FeatureName::SharedFenceDXGISharedHandle"; + break; + case FeatureName::SharedFenceMTLSharedEvent: + o << "FeatureName::SharedFenceMTLSharedEvent"; + break; + case FeatureName::SharedBufferMemoryD3D12Resource: + o << "FeatureName::SharedBufferMemoryD3D12Resource"; + break; + case FeatureName::StaticSamplers: + o << "FeatureName::StaticSamplers"; + break; + default: + o << "FeatureName::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, FilterMode value) { + switch (value) { + case FilterMode::Undefined: + o << "FilterMode::Undefined"; + break; + case FilterMode::Nearest: + o << "FilterMode::Nearest"; + break; + case FilterMode::Linear: + o << "FilterMode::Linear"; + break; + default: + o << "FilterMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, FrontFace value) { + switch (value) { + case FrontFace::Undefined: + o << "FrontFace::Undefined"; + break; + case FrontFace::CCW: + o << "FrontFace::CCW"; + break; + case FrontFace::CW: + o << "FrontFace::CW"; + break; + default: + o << "FrontFace::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, IndexFormat value) { + switch (value) { + case IndexFormat::Undefined: + o << "IndexFormat::Undefined"; + break; + case IndexFormat::Uint16: + o << "IndexFormat::Uint16"; + break; + case IndexFormat::Uint32: + o << "IndexFormat::Uint32"; + break; + default: + o << "IndexFormat::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, LoadOp value) { + switch (value) { + case LoadOp::Undefined: + o << "LoadOp::Undefined"; + break; + case LoadOp::Clear: + o << "LoadOp::Clear"; + break; + case LoadOp::Load: + o << "LoadOp::Load"; + break; + default: + o << "LoadOp::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, LoggingType value) { + switch (value) { + case LoggingType::Verbose: + o << "LoggingType::Verbose"; + break; + case LoggingType::Info: + o << "LoggingType::Info"; + break; + case LoggingType::Warning: + o << "LoggingType::Warning"; + break; + case LoggingType::Error: + o << "LoggingType::Error"; + break; + default: + o << "LoggingType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, MipmapFilterMode value) { + switch (value) { + case MipmapFilterMode::Undefined: + o << "MipmapFilterMode::Undefined"; + break; + case MipmapFilterMode::Nearest: + o << "MipmapFilterMode::Nearest"; + break; + case MipmapFilterMode::Linear: + o << "MipmapFilterMode::Linear"; + break; + default: + o << "MipmapFilterMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, PopErrorScopeStatus value) { + switch (value) { + case PopErrorScopeStatus::Success: + o << "PopErrorScopeStatus::Success"; + break; + case PopErrorScopeStatus::InstanceDropped: + o << "PopErrorScopeStatus::InstanceDropped"; + break; + default: + o << "PopErrorScopeStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, PowerPreference value) { + switch (value) { + case PowerPreference::Undefined: + o << "PowerPreference::Undefined"; + break; + case PowerPreference::LowPower: + o << "PowerPreference::LowPower"; + break; + case PowerPreference::HighPerformance: + o << "PowerPreference::HighPerformance"; + break; + default: + o << "PowerPreference::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, PresentMode value) { + switch (value) { + case PresentMode::Fifo: + o << "PresentMode::Fifo"; + break; + case PresentMode::Immediate: + o << "PresentMode::Immediate"; + break; + case PresentMode::Mailbox: + o << "PresentMode::Mailbox"; + break; + default: + o << "PresentMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, PrimitiveTopology value) { + switch (value) { + case PrimitiveTopology::Undefined: + o << "PrimitiveTopology::Undefined"; + break; + case PrimitiveTopology::PointList: + o << "PrimitiveTopology::PointList"; + break; + case PrimitiveTopology::LineList: + o << "PrimitiveTopology::LineList"; + break; + case PrimitiveTopology::LineStrip: + o << "PrimitiveTopology::LineStrip"; + break; + case PrimitiveTopology::TriangleList: + o << "PrimitiveTopology::TriangleList"; + break; + case PrimitiveTopology::TriangleStrip: + o << "PrimitiveTopology::TriangleStrip"; + break; + default: + o << "PrimitiveTopology::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, QueryType value) { + switch (value) { + case QueryType::Occlusion: + o << "QueryType::Occlusion"; + break; + case QueryType::Timestamp: + o << "QueryType::Timestamp"; + break; + default: + o << "QueryType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, QueueWorkDoneStatus value) { + switch (value) { + case QueueWorkDoneStatus::Success: + o << "QueueWorkDoneStatus::Success"; + break; + case QueueWorkDoneStatus::InstanceDropped: + o << "QueueWorkDoneStatus::InstanceDropped"; + break; + case QueueWorkDoneStatus::Error: + o << "QueueWorkDoneStatus::Error"; + break; + case QueueWorkDoneStatus::Unknown: + o << "QueueWorkDoneStatus::Unknown"; + break; + case QueueWorkDoneStatus::DeviceLost: + o << "QueueWorkDoneStatus::DeviceLost"; + break; + default: + o << "QueueWorkDoneStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, RequestAdapterStatus value) { + switch (value) { + case RequestAdapterStatus::Success: + o << "RequestAdapterStatus::Success"; + break; + case RequestAdapterStatus::InstanceDropped: + o << "RequestAdapterStatus::InstanceDropped"; + break; + case RequestAdapterStatus::Unavailable: + o << "RequestAdapterStatus::Unavailable"; + break; + case RequestAdapterStatus::Error: + o << "RequestAdapterStatus::Error"; + break; + case RequestAdapterStatus::Unknown: + o << "RequestAdapterStatus::Unknown"; + break; + default: + o << "RequestAdapterStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, RequestDeviceStatus value) { + switch (value) { + case RequestDeviceStatus::Success: + o << "RequestDeviceStatus::Success"; + break; + case RequestDeviceStatus::InstanceDropped: + o << "RequestDeviceStatus::InstanceDropped"; + break; + case RequestDeviceStatus::Error: + o << "RequestDeviceStatus::Error"; + break; + case RequestDeviceStatus::Unknown: + o << "RequestDeviceStatus::Unknown"; + break; + default: + o << "RequestDeviceStatus::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, SType value) { + switch (value) { + case SType::Invalid: + o << "SType::Invalid"; + break; + case SType::SurfaceDescriptorFromMetalLayer: + o << "SType::SurfaceDescriptorFromMetalLayer"; + break; + case SType::SurfaceDescriptorFromWindowsHWND: + o << "SType::SurfaceDescriptorFromWindowsHWND"; + break; + case SType::SurfaceDescriptorFromXlibWindow: + o << "SType::SurfaceDescriptorFromXlibWindow"; + break; + case SType::SurfaceDescriptorFromCanvasHTMLSelector: + o << "SType::SurfaceDescriptorFromCanvasHTMLSelector"; + break; + case SType::ShaderModuleSPIRVDescriptor: + o << "SType::ShaderModuleSPIRVDescriptor"; + break; + case SType::ShaderModuleWGSLDescriptor: + o << "SType::ShaderModuleWGSLDescriptor"; + break; + case SType::PrimitiveDepthClipControl: + o << "SType::PrimitiveDepthClipControl"; + break; + case SType::SurfaceDescriptorFromWaylandSurface: + o << "SType::SurfaceDescriptorFromWaylandSurface"; + break; + case SType::SurfaceDescriptorFromAndroidNativeWindow: + o << "SType::SurfaceDescriptorFromAndroidNativeWindow"; + break; + case SType::SurfaceDescriptorFromWindowsCoreWindow: + o << "SType::SurfaceDescriptorFromWindowsCoreWindow"; + break; + case SType::ExternalTextureBindingEntry: + o << "SType::ExternalTextureBindingEntry"; + break; + case SType::ExternalTextureBindingLayout: + o << "SType::ExternalTextureBindingLayout"; + break; + case SType::SurfaceDescriptorFromWindowsSwapChainPanel: + o << "SType::SurfaceDescriptorFromWindowsSwapChainPanel"; + break; + case SType::RenderPassDescriptorMaxDrawCount: + o << "SType::RenderPassDescriptorMaxDrawCount"; + break; + case SType::DepthStencilStateDepthWriteDefinedDawn: + o << "SType::DepthStencilStateDepthWriteDefinedDawn"; + break; + case SType::TextureBindingViewDimensionDescriptor: + o << "SType::TextureBindingViewDimensionDescriptor"; + break; + case SType::DawnTextureInternalUsageDescriptor: + o << "SType::DawnTextureInternalUsageDescriptor"; + break; + case SType::DawnEncoderInternalUsageDescriptor: + o << "SType::DawnEncoderInternalUsageDescriptor"; + break; + case SType::DawnInstanceDescriptor: + o << "SType::DawnInstanceDescriptor"; + break; + case SType::DawnCacheDeviceDescriptor: + o << "SType::DawnCacheDeviceDescriptor"; + break; + case SType::DawnAdapterPropertiesPowerPreference: + o << "SType::DawnAdapterPropertiesPowerPreference"; + break; + case SType::DawnBufferDescriptorErrorInfoFromWireClient: + o << "SType::DawnBufferDescriptorErrorInfoFromWireClient"; + break; + case SType::DawnTogglesDescriptor: + o << "SType::DawnTogglesDescriptor"; + break; + case SType::DawnShaderModuleSPIRVOptionsDescriptor: + o << "SType::DawnShaderModuleSPIRVOptionsDescriptor"; + break; + case SType::RequestAdapterOptionsLUID: + o << "SType::RequestAdapterOptionsLUID"; + break; + case SType::RequestAdapterOptionsGetGLProc: + o << "SType::RequestAdapterOptionsGetGLProc"; + break; + case SType::RequestAdapterOptionsD3D11Device: + o << "SType::RequestAdapterOptionsD3D11Device"; + break; + case SType::DawnMultisampleStateRenderToSingleSampled: + o << "SType::DawnMultisampleStateRenderToSingleSampled"; + break; + case SType::DawnRenderPassColorAttachmentRenderToSingleSampled: + o << "SType::DawnRenderPassColorAttachmentRenderToSingleSampled"; + break; + case SType::RenderPassPixelLocalStorage: + o << "SType::RenderPassPixelLocalStorage"; + break; + case SType::PipelineLayoutPixelLocalStorage: + o << "SType::PipelineLayoutPixelLocalStorage"; + break; + case SType::BufferHostMappedPointer: + o << "SType::BufferHostMappedPointer"; + break; + case SType::DawnExperimentalSubgroupLimits: + o << "SType::DawnExperimentalSubgroupLimits"; + break; + case SType::AdapterPropertiesMemoryHeaps: + o << "SType::AdapterPropertiesMemoryHeaps"; + break; + case SType::AdapterPropertiesD3D: + o << "SType::AdapterPropertiesD3D"; + break; + case SType::AdapterPropertiesVk: + o << "SType::AdapterPropertiesVk"; + break; + case SType::DawnComputePipelineFullSubgroups: + o << "SType::DawnComputePipelineFullSubgroups"; + break; + case SType::DawnWireWGSLControl: + o << "SType::DawnWireWGSLControl"; + break; + case SType::DawnWGSLBlocklist: + o << "SType::DawnWGSLBlocklist"; + break; + case SType::DrmFormatCapabilities: + o << "SType::DrmFormatCapabilities"; + break; + case SType::SharedTextureMemoryVkImageDescriptor: + o << "SType::SharedTextureMemoryVkImageDescriptor"; + break; + case SType::SharedTextureMemoryVkDedicatedAllocationDescriptor: + o << "SType::SharedTextureMemoryVkDedicatedAllocationDescriptor"; + break; + case SType::SharedTextureMemoryAHardwareBufferDescriptor: + o << "SType::SharedTextureMemoryAHardwareBufferDescriptor"; + break; + case SType::SharedTextureMemoryDmaBufDescriptor: + o << "SType::SharedTextureMemoryDmaBufDescriptor"; + break; + case SType::SharedTextureMemoryOpaqueFDDescriptor: + o << "SType::SharedTextureMemoryOpaqueFDDescriptor"; + break; + case SType::SharedTextureMemoryZirconHandleDescriptor: + o << "SType::SharedTextureMemoryZirconHandleDescriptor"; + break; + case SType::SharedTextureMemoryDXGISharedHandleDescriptor: + o << "SType::SharedTextureMemoryDXGISharedHandleDescriptor"; + break; + case SType::SharedTextureMemoryD3D11Texture2DDescriptor: + o << "SType::SharedTextureMemoryD3D11Texture2DDescriptor"; + break; + case SType::SharedTextureMemoryIOSurfaceDescriptor: + o << "SType::SharedTextureMemoryIOSurfaceDescriptor"; + break; + case SType::SharedTextureMemoryEGLImageDescriptor: + o << "SType::SharedTextureMemoryEGLImageDescriptor"; + break; + case SType::SharedTextureMemoryInitializedBeginState: + o << "SType::SharedTextureMemoryInitializedBeginState"; + break; + case SType::SharedTextureMemoryInitializedEndState: + o << "SType::SharedTextureMemoryInitializedEndState"; + break; + case SType::SharedTextureMemoryVkImageLayoutBeginState: + o << "SType::SharedTextureMemoryVkImageLayoutBeginState"; + break; + case SType::SharedTextureMemoryVkImageLayoutEndState: + o << "SType::SharedTextureMemoryVkImageLayoutEndState"; + break; + case SType::SharedFenceVkSemaphoreOpaqueFDDescriptor: + o << "SType::SharedFenceVkSemaphoreOpaqueFDDescriptor"; + break; + case SType::SharedFenceVkSemaphoreOpaqueFDExportInfo: + o << "SType::SharedFenceVkSemaphoreOpaqueFDExportInfo"; + break; + case SType::SharedFenceVkSemaphoreSyncFDDescriptor: + o << "SType::SharedFenceVkSemaphoreSyncFDDescriptor"; + break; + case SType::SharedFenceVkSemaphoreSyncFDExportInfo: + o << "SType::SharedFenceVkSemaphoreSyncFDExportInfo"; + break; + case SType::SharedFenceVkSemaphoreZirconHandleDescriptor: + o << "SType::SharedFenceVkSemaphoreZirconHandleDescriptor"; + break; + case SType::SharedFenceVkSemaphoreZirconHandleExportInfo: + o << "SType::SharedFenceVkSemaphoreZirconHandleExportInfo"; + break; + case SType::SharedFenceDXGISharedHandleDescriptor: + o << "SType::SharedFenceDXGISharedHandleDescriptor"; + break; + case SType::SharedFenceDXGISharedHandleExportInfo: + o << "SType::SharedFenceDXGISharedHandleExportInfo"; + break; + case SType::SharedFenceMTLSharedEventDescriptor: + o << "SType::SharedFenceMTLSharedEventDescriptor"; + break; + case SType::SharedFenceMTLSharedEventExportInfo: + o << "SType::SharedFenceMTLSharedEventExportInfo"; + break; + case SType::SharedBufferMemoryD3D12ResourceDescriptor: + o << "SType::SharedBufferMemoryD3D12ResourceDescriptor"; + break; + case SType::StaticSamplerBindingLayout: + o << "SType::StaticSamplerBindingLayout"; + break; + default: + o << "SType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, SamplerBindingType value) { + switch (value) { + case SamplerBindingType::Undefined: + o << "SamplerBindingType::Undefined"; + break; + case SamplerBindingType::Filtering: + o << "SamplerBindingType::Filtering"; + break; + case SamplerBindingType::NonFiltering: + o << "SamplerBindingType::NonFiltering"; + break; + case SamplerBindingType::Comparison: + o << "SamplerBindingType::Comparison"; + break; + default: + o << "SamplerBindingType::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, SharedFenceType value) { + switch (value) { + case SharedFenceType::Undefined: + o << "SharedFenceType::Undefined"; + break; + case SharedFenceType::VkSemaphoreOpaqueFD: + o << "SharedFenceType::VkSemaphoreOpaqueFD"; + break; + case SharedFenceType::VkSemaphoreSyncFD: + o << "SharedFenceType::VkSemaphoreSyncFD"; + break; + case SharedFenceType::VkSemaphoreZirconHandle: + o << "SharedFenceType::VkSemaphoreZirconHandle"; + break; + case SharedFenceType::DXGISharedHandle: + o << "SharedFenceType::DXGISharedHandle"; + break; + case SharedFenceType::MTLSharedEvent: + o << "SharedFenceType::MTLSharedEvent"; + break; + default: + o << "SharedFenceType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, StencilOperation value) { + switch (value) { + case StencilOperation::Undefined: + o << "StencilOperation::Undefined"; + break; + case StencilOperation::Keep: + o << "StencilOperation::Keep"; + break; + case StencilOperation::Zero: + o << "StencilOperation::Zero"; + break; + case StencilOperation::Replace: + o << "StencilOperation::Replace"; + break; + case StencilOperation::Invert: + o << "StencilOperation::Invert"; + break; + case StencilOperation::IncrementClamp: + o << "StencilOperation::IncrementClamp"; + break; + case StencilOperation::DecrementClamp: + o << "StencilOperation::DecrementClamp"; + break; + case StencilOperation::IncrementWrap: + o << "StencilOperation::IncrementWrap"; + break; + case StencilOperation::DecrementWrap: + o << "StencilOperation::DecrementWrap"; + break; + default: + o << "StencilOperation::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, StorageTextureAccess value) { + switch (value) { + case StorageTextureAccess::Undefined: + o << "StorageTextureAccess::Undefined"; + break; + case StorageTextureAccess::WriteOnly: + o << "StorageTextureAccess::WriteOnly"; + break; + case StorageTextureAccess::ReadOnly: + o << "StorageTextureAccess::ReadOnly"; + break; + case StorageTextureAccess::ReadWrite: + o << "StorageTextureAccess::ReadWrite"; + break; + default: + o << "StorageTextureAccess::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, StoreOp value) { + switch (value) { + case StoreOp::Undefined: + o << "StoreOp::Undefined"; + break; + case StoreOp::Store: + o << "StoreOp::Store"; + break; + case StoreOp::Discard: + o << "StoreOp::Discard"; + break; + default: + o << "StoreOp::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureAspect value) { + switch (value) { + case TextureAspect::Undefined: + o << "TextureAspect::Undefined"; + break; + case TextureAspect::All: + o << "TextureAspect::All"; + break; + case TextureAspect::StencilOnly: + o << "TextureAspect::StencilOnly"; + break; + case TextureAspect::DepthOnly: + o << "TextureAspect::DepthOnly"; + break; + case TextureAspect::Plane0Only: + o << "TextureAspect::Plane0Only"; + break; + case TextureAspect::Plane1Only: + o << "TextureAspect::Plane1Only"; + break; + case TextureAspect::Plane2Only: + o << "TextureAspect::Plane2Only"; + break; + default: + o << "TextureAspect::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureDimension value) { + switch (value) { + case TextureDimension::Undefined: + o << "TextureDimension::Undefined"; + break; + case TextureDimension::e1D: + o << "TextureDimension::e1D"; + break; + case TextureDimension::e2D: + o << "TextureDimension::e2D"; + break; + case TextureDimension::e3D: + o << "TextureDimension::e3D"; + break; + default: + o << "TextureDimension::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureFormat value) { + switch (value) { + case TextureFormat::Undefined: + o << "TextureFormat::Undefined"; + break; + case TextureFormat::R8Unorm: + o << "TextureFormat::R8Unorm"; + break; + case TextureFormat::R8Snorm: + o << "TextureFormat::R8Snorm"; + break; + case TextureFormat::R8Uint: + o << "TextureFormat::R8Uint"; + break; + case TextureFormat::R8Sint: + o << "TextureFormat::R8Sint"; + break; + case TextureFormat::R16Uint: + o << "TextureFormat::R16Uint"; + break; + case TextureFormat::R16Sint: + o << "TextureFormat::R16Sint"; + break; + case TextureFormat::R16Float: + o << "TextureFormat::R16Float"; + break; + case TextureFormat::RG8Unorm: + o << "TextureFormat::RG8Unorm"; + break; + case TextureFormat::RG8Snorm: + o << "TextureFormat::RG8Snorm"; + break; + case TextureFormat::RG8Uint: + o << "TextureFormat::RG8Uint"; + break; + case TextureFormat::RG8Sint: + o << "TextureFormat::RG8Sint"; + break; + case TextureFormat::R32Float: + o << "TextureFormat::R32Float"; + break; + case TextureFormat::R32Uint: + o << "TextureFormat::R32Uint"; + break; + case TextureFormat::R32Sint: + o << "TextureFormat::R32Sint"; + break; + case TextureFormat::RG16Uint: + o << "TextureFormat::RG16Uint"; + break; + case TextureFormat::RG16Sint: + o << "TextureFormat::RG16Sint"; + break; + case TextureFormat::RG16Float: + o << "TextureFormat::RG16Float"; + break; + case TextureFormat::RGBA8Unorm: + o << "TextureFormat::RGBA8Unorm"; + break; + case TextureFormat::RGBA8UnormSrgb: + o << "TextureFormat::RGBA8UnormSrgb"; + break; + case TextureFormat::RGBA8Snorm: + o << "TextureFormat::RGBA8Snorm"; + break; + case TextureFormat::RGBA8Uint: + o << "TextureFormat::RGBA8Uint"; + break; + case TextureFormat::RGBA8Sint: + o << "TextureFormat::RGBA8Sint"; + break; + case TextureFormat::BGRA8Unorm: + o << "TextureFormat::BGRA8Unorm"; + break; + case TextureFormat::BGRA8UnormSrgb: + o << "TextureFormat::BGRA8UnormSrgb"; + break; + case TextureFormat::RGB10A2Uint: + o << "TextureFormat::RGB10A2Uint"; + break; + case TextureFormat::RGB10A2Unorm: + o << "TextureFormat::RGB10A2Unorm"; + break; + case TextureFormat::RG11B10Ufloat: + o << "TextureFormat::RG11B10Ufloat"; + break; + case TextureFormat::RGB9E5Ufloat: + o << "TextureFormat::RGB9E5Ufloat"; + break; + case TextureFormat::RG32Float: + o << "TextureFormat::RG32Float"; + break; + case TextureFormat::RG32Uint: + o << "TextureFormat::RG32Uint"; + break; + case TextureFormat::RG32Sint: + o << "TextureFormat::RG32Sint"; + break; + case TextureFormat::RGBA16Uint: + o << "TextureFormat::RGBA16Uint"; + break; + case TextureFormat::RGBA16Sint: + o << "TextureFormat::RGBA16Sint"; + break; + case TextureFormat::RGBA16Float: + o << "TextureFormat::RGBA16Float"; + break; + case TextureFormat::RGBA32Float: + o << "TextureFormat::RGBA32Float"; + break; + case TextureFormat::RGBA32Uint: + o << "TextureFormat::RGBA32Uint"; + break; + case TextureFormat::RGBA32Sint: + o << "TextureFormat::RGBA32Sint"; + break; + case TextureFormat::Stencil8: + o << "TextureFormat::Stencil8"; + break; + case TextureFormat::Depth16Unorm: + o << "TextureFormat::Depth16Unorm"; + break; + case TextureFormat::Depth24Plus: + o << "TextureFormat::Depth24Plus"; + break; + case TextureFormat::Depth24PlusStencil8: + o << "TextureFormat::Depth24PlusStencil8"; + break; + case TextureFormat::Depth32Float: + o << "TextureFormat::Depth32Float"; + break; + case TextureFormat::Depth32FloatStencil8: + o << "TextureFormat::Depth32FloatStencil8"; + break; + case TextureFormat::BC1RGBAUnorm: + o << "TextureFormat::BC1RGBAUnorm"; + break; + case TextureFormat::BC1RGBAUnormSrgb: + o << "TextureFormat::BC1RGBAUnormSrgb"; + break; + case TextureFormat::BC2RGBAUnorm: + o << "TextureFormat::BC2RGBAUnorm"; + break; + case TextureFormat::BC2RGBAUnormSrgb: + o << "TextureFormat::BC2RGBAUnormSrgb"; + break; + case TextureFormat::BC3RGBAUnorm: + o << "TextureFormat::BC3RGBAUnorm"; + break; + case TextureFormat::BC3RGBAUnormSrgb: + o << "TextureFormat::BC3RGBAUnormSrgb"; + break; + case TextureFormat::BC4RUnorm: + o << "TextureFormat::BC4RUnorm"; + break; + case TextureFormat::BC4RSnorm: + o << "TextureFormat::BC4RSnorm"; + break; + case TextureFormat::BC5RGUnorm: + o << "TextureFormat::BC5RGUnorm"; + break; + case TextureFormat::BC5RGSnorm: + o << "TextureFormat::BC5RGSnorm"; + break; + case TextureFormat::BC6HRGBUfloat: + o << "TextureFormat::BC6HRGBUfloat"; + break; + case TextureFormat::BC6HRGBFloat: + o << "TextureFormat::BC6HRGBFloat"; + break; + case TextureFormat::BC7RGBAUnorm: + o << "TextureFormat::BC7RGBAUnorm"; + break; + case TextureFormat::BC7RGBAUnormSrgb: + o << "TextureFormat::BC7RGBAUnormSrgb"; + break; + case TextureFormat::ETC2RGB8Unorm: + o << "TextureFormat::ETC2RGB8Unorm"; + break; + case TextureFormat::ETC2RGB8UnormSrgb: + o << "TextureFormat::ETC2RGB8UnormSrgb"; + break; + case TextureFormat::ETC2RGB8A1Unorm: + o << "TextureFormat::ETC2RGB8A1Unorm"; + break; + case TextureFormat::ETC2RGB8A1UnormSrgb: + o << "TextureFormat::ETC2RGB8A1UnormSrgb"; + break; + case TextureFormat::ETC2RGBA8Unorm: + o << "TextureFormat::ETC2RGBA8Unorm"; + break; + case TextureFormat::ETC2RGBA8UnormSrgb: + o << "TextureFormat::ETC2RGBA8UnormSrgb"; + break; + case TextureFormat::EACR11Unorm: + o << "TextureFormat::EACR11Unorm"; + break; + case TextureFormat::EACR11Snorm: + o << "TextureFormat::EACR11Snorm"; + break; + case TextureFormat::EACRG11Unorm: + o << "TextureFormat::EACRG11Unorm"; + break; + case TextureFormat::EACRG11Snorm: + o << "TextureFormat::EACRG11Snorm"; + break; + case TextureFormat::ASTC4x4Unorm: + o << "TextureFormat::ASTC4x4Unorm"; + break; + case TextureFormat::ASTC4x4UnormSrgb: + o << "TextureFormat::ASTC4x4UnormSrgb"; + break; + case TextureFormat::ASTC5x4Unorm: + o << "TextureFormat::ASTC5x4Unorm"; + break; + case TextureFormat::ASTC5x4UnormSrgb: + o << "TextureFormat::ASTC5x4UnormSrgb"; + break; + case TextureFormat::ASTC5x5Unorm: + o << "TextureFormat::ASTC5x5Unorm"; + break; + case TextureFormat::ASTC5x5UnormSrgb: + o << "TextureFormat::ASTC5x5UnormSrgb"; + break; + case TextureFormat::ASTC6x5Unorm: + o << "TextureFormat::ASTC6x5Unorm"; + break; + case TextureFormat::ASTC6x5UnormSrgb: + o << "TextureFormat::ASTC6x5UnormSrgb"; + break; + case TextureFormat::ASTC6x6Unorm: + o << "TextureFormat::ASTC6x6Unorm"; + break; + case TextureFormat::ASTC6x6UnormSrgb: + o << "TextureFormat::ASTC6x6UnormSrgb"; + break; + case TextureFormat::ASTC8x5Unorm: + o << "TextureFormat::ASTC8x5Unorm"; + break; + case TextureFormat::ASTC8x5UnormSrgb: + o << "TextureFormat::ASTC8x5UnormSrgb"; + break; + case TextureFormat::ASTC8x6Unorm: + o << "TextureFormat::ASTC8x6Unorm"; + break; + case TextureFormat::ASTC8x6UnormSrgb: + o << "TextureFormat::ASTC8x6UnormSrgb"; + break; + case TextureFormat::ASTC8x8Unorm: + o << "TextureFormat::ASTC8x8Unorm"; + break; + case TextureFormat::ASTC8x8UnormSrgb: + o << "TextureFormat::ASTC8x8UnormSrgb"; + break; + case TextureFormat::ASTC10x5Unorm: + o << "TextureFormat::ASTC10x5Unorm"; + break; + case TextureFormat::ASTC10x5UnormSrgb: + o << "TextureFormat::ASTC10x5UnormSrgb"; + break; + case TextureFormat::ASTC10x6Unorm: + o << "TextureFormat::ASTC10x6Unorm"; + break; + case TextureFormat::ASTC10x6UnormSrgb: + o << "TextureFormat::ASTC10x6UnormSrgb"; + break; + case TextureFormat::ASTC10x8Unorm: + o << "TextureFormat::ASTC10x8Unorm"; + break; + case TextureFormat::ASTC10x8UnormSrgb: + o << "TextureFormat::ASTC10x8UnormSrgb"; + break; + case TextureFormat::ASTC10x10Unorm: + o << "TextureFormat::ASTC10x10Unorm"; + break; + case TextureFormat::ASTC10x10UnormSrgb: + o << "TextureFormat::ASTC10x10UnormSrgb"; + break; + case TextureFormat::ASTC12x10Unorm: + o << "TextureFormat::ASTC12x10Unorm"; + break; + case TextureFormat::ASTC12x10UnormSrgb: + o << "TextureFormat::ASTC12x10UnormSrgb"; + break; + case TextureFormat::ASTC12x12Unorm: + o << "TextureFormat::ASTC12x12Unorm"; + break; + case TextureFormat::ASTC12x12UnormSrgb: + o << "TextureFormat::ASTC12x12UnormSrgb"; + break; + case TextureFormat::R16Unorm: + o << "TextureFormat::R16Unorm"; + break; + case TextureFormat::RG16Unorm: + o << "TextureFormat::RG16Unorm"; + break; + case TextureFormat::RGBA16Unorm: + o << "TextureFormat::RGBA16Unorm"; + break; + case TextureFormat::R16Snorm: + o << "TextureFormat::R16Snorm"; + break; + case TextureFormat::RG16Snorm: + o << "TextureFormat::RG16Snorm"; + break; + case TextureFormat::RGBA16Snorm: + o << "TextureFormat::RGBA16Snorm"; + break; + case TextureFormat::R8BG8Biplanar420Unorm: + o << "TextureFormat::R8BG8Biplanar420Unorm"; + break; + case TextureFormat::R10X6BG10X6Biplanar420Unorm: + o << "TextureFormat::R10X6BG10X6Biplanar420Unorm"; + break; + case TextureFormat::R8BG8A8Triplanar420Unorm: + o << "TextureFormat::R8BG8A8Triplanar420Unorm"; + break; + default: + o << "TextureFormat::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureSampleType value) { + switch (value) { + case TextureSampleType::Undefined: + o << "TextureSampleType::Undefined"; + break; + case TextureSampleType::Float: + o << "TextureSampleType::Float"; + break; + case TextureSampleType::UnfilterableFloat: + o << "TextureSampleType::UnfilterableFloat"; + break; + case TextureSampleType::Depth: + o << "TextureSampleType::Depth"; + break; + case TextureSampleType::Sint: + o << "TextureSampleType::Sint"; + break; + case TextureSampleType::Uint: + o << "TextureSampleType::Uint"; + break; + default: + o << "TextureSampleType::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureViewDimension value) { + switch (value) { + case TextureViewDimension::Undefined: + o << "TextureViewDimension::Undefined"; + break; + case TextureViewDimension::e1D: + o << "TextureViewDimension::e1D"; + break; + case TextureViewDimension::e2D: + o << "TextureViewDimension::e2D"; + break; + case TextureViewDimension::e2DArray: + o << "TextureViewDimension::e2DArray"; + break; + case TextureViewDimension::Cube: + o << "TextureViewDimension::Cube"; + break; + case TextureViewDimension::CubeArray: + o << "TextureViewDimension::CubeArray"; + break; + case TextureViewDimension::e3D: + o << "TextureViewDimension::e3D"; + break; + default: + o << "TextureViewDimension::" << std::showbase << std::hex + << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, VertexFormat value) { + switch (value) { + case VertexFormat::Undefined: + o << "VertexFormat::Undefined"; + break; + case VertexFormat::Uint8x2: + o << "VertexFormat::Uint8x2"; + break; + case VertexFormat::Uint8x4: + o << "VertexFormat::Uint8x4"; + break; + case VertexFormat::Sint8x2: + o << "VertexFormat::Sint8x2"; + break; + case VertexFormat::Sint8x4: + o << "VertexFormat::Sint8x4"; + break; + case VertexFormat::Unorm8x2: + o << "VertexFormat::Unorm8x2"; + break; + case VertexFormat::Unorm8x4: + o << "VertexFormat::Unorm8x4"; + break; + case VertexFormat::Snorm8x2: + o << "VertexFormat::Snorm8x2"; + break; + case VertexFormat::Snorm8x4: + o << "VertexFormat::Snorm8x4"; + break; + case VertexFormat::Uint16x2: + o << "VertexFormat::Uint16x2"; + break; + case VertexFormat::Uint16x4: + o << "VertexFormat::Uint16x4"; + break; + case VertexFormat::Sint16x2: + o << "VertexFormat::Sint16x2"; + break; + case VertexFormat::Sint16x4: + o << "VertexFormat::Sint16x4"; + break; + case VertexFormat::Unorm16x2: + o << "VertexFormat::Unorm16x2"; + break; + case VertexFormat::Unorm16x4: + o << "VertexFormat::Unorm16x4"; + break; + case VertexFormat::Snorm16x2: + o << "VertexFormat::Snorm16x2"; + break; + case VertexFormat::Snorm16x4: + o << "VertexFormat::Snorm16x4"; + break; + case VertexFormat::Float16x2: + o << "VertexFormat::Float16x2"; + break; + case VertexFormat::Float16x4: + o << "VertexFormat::Float16x4"; + break; + case VertexFormat::Float32: + o << "VertexFormat::Float32"; + break; + case VertexFormat::Float32x2: + o << "VertexFormat::Float32x2"; + break; + case VertexFormat::Float32x3: + o << "VertexFormat::Float32x3"; + break; + case VertexFormat::Float32x4: + o << "VertexFormat::Float32x4"; + break; + case VertexFormat::Uint32: + o << "VertexFormat::Uint32"; + break; + case VertexFormat::Uint32x2: + o << "VertexFormat::Uint32x2"; + break; + case VertexFormat::Uint32x3: + o << "VertexFormat::Uint32x3"; + break; + case VertexFormat::Uint32x4: + o << "VertexFormat::Uint32x4"; + break; + case VertexFormat::Sint32: + o << "VertexFormat::Sint32"; + break; + case VertexFormat::Sint32x2: + o << "VertexFormat::Sint32x2"; + break; + case VertexFormat::Sint32x3: + o << "VertexFormat::Sint32x3"; + break; + case VertexFormat::Sint32x4: + o << "VertexFormat::Sint32x4"; + break; + case VertexFormat::Unorm10_10_10_2: + o << "VertexFormat::Unorm10_10_10_2"; + break; + default: + o << "VertexFormat::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, VertexStepMode value) { + switch (value) { + case VertexStepMode::Undefined: + o << "VertexStepMode::Undefined"; + break; + case VertexStepMode::VertexBufferNotUsed: + o << "VertexStepMode::VertexBufferNotUsed"; + break; + case VertexStepMode::Vertex: + o << "VertexStepMode::Vertex"; + break; + case VertexStepMode::Instance: + o << "VertexStepMode::Instance"; + break; + default: + o << "VertexStepMode::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>( + value); + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, WaitStatus value) { + switch (value) { + case WaitStatus::Success: + o << "WaitStatus::Success"; + break; + case WaitStatus::TimedOut: + o << "WaitStatus::TimedOut"; + break; + case WaitStatus::UnsupportedTimeout: + o << "WaitStatus::UnsupportedTimeout"; + break; + case WaitStatus::UnsupportedCount: + o << "WaitStatus::UnsupportedCount"; + break; + case WaitStatus::UnsupportedMixedSources: + o << "WaitStatus::UnsupportedMixedSources"; + break; + case WaitStatus::Unknown: + o << "WaitStatus::Unknown"; + break; + default: + o << "WaitStatus::" << std::showbase << std::hex << std::setfill('0') + << std::setw(4) + << static_cast::type>(value); + } + return o; +} + +template +std::basic_ostream & +operator<<(std::basic_ostream &o, BufferUsage value) { + o << "BufferUsage::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "None"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & BufferUsage::MapRead) { + if (!first) { + o << "|"; + } + first = false; + o << "MapRead"; + value &= ~BufferUsage::MapRead; + } + if (value & BufferUsage::MapWrite) { + if (!first) { + o << "|"; + } + first = false; + o << "MapWrite"; + value &= ~BufferUsage::MapWrite; + } + if (value & BufferUsage::CopySrc) { + if (!first) { + o << "|"; + } + first = false; + o << "CopySrc"; + value &= ~BufferUsage::CopySrc; + } + if (value & BufferUsage::CopyDst) { + if (!first) { + o << "|"; + } + first = false; + o << "CopyDst"; + value &= ~BufferUsage::CopyDst; + } + if (value & BufferUsage::Index) { + if (!first) { + o << "|"; + } + first = false; + o << "Index"; + value &= ~BufferUsage::Index; + } + if (value & BufferUsage::Vertex) { + if (!first) { + o << "|"; + } + first = false; + o << "Vertex"; + value &= ~BufferUsage::Vertex; + } + if (value & BufferUsage::Uniform) { + if (!first) { + o << "|"; + } + first = false; + o << "Uniform"; + value &= ~BufferUsage::Uniform; + } + if (value & BufferUsage::Storage) { + if (!first) { + o << "|"; + } + first = false; + o << "Storage"; + value &= ~BufferUsage::Storage; + } + if (value & BufferUsage::Indirect) { + if (!first) { + o << "|"; + } + first = false; + o << "Indirect"; + value &= ~BufferUsage::Indirect; + } + if (value & BufferUsage::QueryResolve) { + if (!first) { + o << "|"; + } + first = false; + o << "QueryResolve"; + value &= ~BufferUsage::QueryResolve; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>(value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, ColorWriteMask value) { + o << "ColorWriteMask::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "None"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & ColorWriteMask::Red) { + if (!first) { + o << "|"; + } + first = false; + o << "Red"; + value &= ~ColorWriteMask::Red; + } + if (value & ColorWriteMask::Green) { + if (!first) { + o << "|"; + } + first = false; + o << "Green"; + value &= ~ColorWriteMask::Green; + } + if (value & ColorWriteMask::Blue) { + if (!first) { + o << "|"; + } + first = false; + o << "Blue"; + value &= ~ColorWriteMask::Blue; + } + if (value & ColorWriteMask::Alpha) { + if (!first) { + o << "|"; + } + first = false; + o << "Alpha"; + value &= ~ColorWriteMask::Alpha; + } + if (value & ColorWriteMask::All) { + if (!first) { + o << "|"; + } + first = false; + o << "All"; + value &= ~ColorWriteMask::All; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>( + value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, HeapProperty value) { + o << "HeapProperty::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "Undefined"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & HeapProperty::DeviceLocal) { + if (!first) { + o << "|"; + } + first = false; + o << "DeviceLocal"; + value &= ~HeapProperty::DeviceLocal; + } + if (value & HeapProperty::HostVisible) { + if (!first) { + o << "|"; + } + first = false; + o << "HostVisible"; + value &= ~HeapProperty::HostVisible; + } + if (value & HeapProperty::HostCoherent) { + if (!first) { + o << "|"; + } + first = false; + o << "HostCoherent"; + value &= ~HeapProperty::HostCoherent; + } + if (value & HeapProperty::HostUncached) { + if (!first) { + o << "|"; + } + first = false; + o << "HostUncached"; + value &= ~HeapProperty::HostUncached; + } + if (value & HeapProperty::HostCached) { + if (!first) { + o << "|"; + } + first = false; + o << "HostCached"; + value &= ~HeapProperty::HostCached; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>(value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, MapMode value) { + o << "MapMode::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "None"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & MapMode::Read) { + if (!first) { + o << "|"; + } + first = false; + o << "Read"; + value &= ~MapMode::Read; + } + if (value & MapMode::Write) { + if (!first) { + o << "|"; + } + first = false; + o << "Write"; + value &= ~MapMode::Write; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>(value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, ShaderStage value) { + o << "ShaderStage::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "None"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & ShaderStage::Vertex) { + if (!first) { + o << "|"; + } + first = false; + o << "Vertex"; + value &= ~ShaderStage::Vertex; + } + if (value & ShaderStage::Fragment) { + if (!first) { + o << "|"; + } + first = false; + o << "Fragment"; + value &= ~ShaderStage::Fragment; + } + if (value & ShaderStage::Compute) { + if (!first) { + o << "|"; + } + first = false; + o << "Compute"; + value &= ~ShaderStage::Compute; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>(value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} +template +std::basic_ostream & +operator<<(std::basic_ostream &o, TextureUsage value) { + o << "TextureUsage::"; + if (!static_cast(value)) { + // 0 is often explicitly declared as None. + o << "None"; + return o; + } + + bool moreThanOneBit = !HasZeroOrOneBits(value); + if (moreThanOneBit) { + o << "("; + } + + bool first = true; + if (value & TextureUsage::CopySrc) { + if (!first) { + o << "|"; + } + first = false; + o << "CopySrc"; + value &= ~TextureUsage::CopySrc; + } + if (value & TextureUsage::CopyDst) { + if (!first) { + o << "|"; + } + first = false; + o << "CopyDst"; + value &= ~TextureUsage::CopyDst; + } + if (value & TextureUsage::TextureBinding) { + if (!first) { + o << "|"; + } + first = false; + o << "TextureBinding"; + value &= ~TextureUsage::TextureBinding; + } + if (value & TextureUsage::StorageBinding) { + if (!first) { + o << "|"; + } + first = false; + o << "StorageBinding"; + value &= ~TextureUsage::StorageBinding; + } + if (value & TextureUsage::RenderAttachment) { + if (!first) { + o << "|"; + } + first = false; + o << "RenderAttachment"; + value &= ~TextureUsage::RenderAttachment; + } + if (value & TextureUsage::TransientAttachment) { + if (!first) { + o << "|"; + } + first = false; + o << "TransientAttachment"; + value &= ~TextureUsage::TransientAttachment; + } + if (value & TextureUsage::StorageAttachment) { + if (!first) { + o << "|"; + } + first = false; + o << "StorageAttachment"; + value &= ~TextureUsage::StorageAttachment; + } + + if (static_cast(value)) { + if (!first) { + o << "|"; + } + o << std::showbase << std::hex << std::setfill('0') << std::setw(4) + << static_cast::type>(value); + } + + if (moreThanOneBit) { + o << ")"; + } + return o; +} + +} // namespace wgpu + +#endif // WEBGPU_CPP_PRINT_H_ diff --git a/package/android/cpp/rnskia-android/webgpu/webgpu_enum_class_bitmasks.h b/package/android/cpp/rnskia-android/webgpu/webgpu_enum_class_bitmasks.h new file mode 100644 index 0000000000..8490375c7d --- /dev/null +++ b/package/android/cpp/rnskia-android/webgpu/webgpu_enum_class_bitmasks.h @@ -0,0 +1,160 @@ +// Copyright 2017 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#ifndef WEBGPU_ENUM_CLASS_BITMASKS_H_ +#define WEBGPU_ENUM_CLASS_BITMASKS_H_ + +#include + +// The operators in wgpu:: namespace need be introduced into other namespaces +// with using-declarations for C++ Argument Dependent Lookup to work. +#define WGPU_IMPORT_BITMASK_OPERATORS \ + using wgpu::operator|; \ + using wgpu::operator&; \ + using wgpu::operator^; \ + using wgpu::operator~; \ + using wgpu::operator&=; \ + using wgpu::operator|=; \ + using wgpu::operator^=; \ + using wgpu::HasZeroOrOneBits; + +namespace wgpu { + +template struct IsWGPUBitmask { + static constexpr bool enable = false; +}; + +template struct LowerBitmask { + static constexpr bool enable = false; +}; + +template +struct LowerBitmask::enable>::type> { + static constexpr bool enable = true; + using type = T; + constexpr static T Lower(T t) { return t; } +}; + +template struct BoolConvertible { + using Integral = typename std::underlying_type::type; + + // NOLINTNEXTLINE(runtime/explicit) + explicit constexpr BoolConvertible(Integral value) : value(value) {} + constexpr operator bool() const { return value != 0; } + constexpr operator T() const { return static_cast(value); } + + Integral value; +}; + +template struct LowerBitmask> { + static constexpr bool enable = true; + using type = T; + static constexpr type Lower(BoolConvertible t) { return t; } +}; + +template ::enable && + LowerBitmask::enable>::type> +constexpr BoolConvertible::type> operator|(T1 left, + T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return BoolConvertible( + static_cast(LowerBitmask::Lower(left)) | + static_cast(LowerBitmask::Lower(right))); +} + +template ::enable && + LowerBitmask::enable>::type> +constexpr BoolConvertible::type> operator&(T1 left, + T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return BoolConvertible( + static_cast(LowerBitmask::Lower(left)) & + static_cast(LowerBitmask::Lower(right))); +} + +template ::enable && + LowerBitmask::enable>::type> +constexpr BoolConvertible::type> operator^(T1 left, + T2 right) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return BoolConvertible( + static_cast(LowerBitmask::Lower(left)) ^ + static_cast(LowerBitmask::Lower(right))); +} + +template +constexpr BoolConvertible::type> operator~(T1 t) { + using T = typename LowerBitmask::type; + using Integral = typename std::underlying_type::type; + return BoolConvertible(~static_cast(LowerBitmask::Lower(t))); +} + +template ::enable && + LowerBitmask::enable>::type> +constexpr T &operator&=(T &l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l & r; + return l; +} + +template ::enable && + LowerBitmask::enable>::type> +constexpr T &operator|=(T &l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l | r; + return l; +} + +template ::enable && + LowerBitmask::enable>::type> +constexpr T &operator^=(T &l, T2 right) { + T r = LowerBitmask::Lower(right); + l = l ^ r; + return l; +} + +template constexpr bool HasZeroOrOneBits(T value) { + using Integral = typename std::underlying_type::type; + return (static_cast(value) & (static_cast(value) - 1)) == + 0; +} + +} // namespace wgpu + +#endif // WEBGPU_ENUM_CLASS_BITMASKS_H_ diff --git a/package/cpp/rnskia/RNSkManager.cpp b/package/cpp/rnskia/RNSkManager.cpp index aeaff1ceba..9e155934bc 100644 --- a/package/cpp/rnskia/RNSkManager.cpp +++ b/package/cpp/rnskia/RNSkManager.cpp @@ -5,6 +5,7 @@ #include +#include "JsiConstants.h" #include "JsiGPU.h" #include "JsiSkApi.h" #include "RNSkJsiViewApi.h" @@ -70,8 +71,11 @@ void RNSkManager::setSkiaView(size_t nativeId, std::shared_ptr view) { void RNSkManager::installBindings() { // Create the API objects and install it on the global object in the // provided runtime. - auto instance = wgpuCreateInstance(nullptr); - auto gpu = std::make_shared(_platformContext, instance); + auto gpu = std::make_shared(_platformContext, + _platformContext->getInstance()); + + installConstants(*_jsRuntime); + _jsRuntime->global().setProperty( *_jsRuntime, "GPU", jsi::Object::createFromHostObject(*_jsRuntime, std::move(gpu))); diff --git a/package/cpp/rnskia/RNSkPlatformContext.h b/package/cpp/rnskia/RNSkPlatformContext.h index 1ee4c50b38..a6b1e5fa04 100644 --- a/package/cpp/rnskia/RNSkPlatformContext.h +++ b/package/cpp/rnskia/RNSkPlatformContext.h @@ -9,8 +9,7 @@ #include #include -#include "webgpu.h" -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include "RNSkDispatchQueue.h" @@ -179,6 +178,7 @@ class RNSkPlatformContext { int height) = 0; virtual std::tuple, int, int> getSurfaceDescriptor(int nativeId) = 0; + virtual wgpu::Instance getInstance() = 0; /** * Starts (if not started) a loop that will call back on display sync diff --git a/package/cpp/wgpu/JsiAdapter.h b/package/cpp/wgpu/JsiAdapter.h index 4698cbf816..75ea668ec6 100644 --- a/package/cpp/wgpu/JsiAdapter.h +++ b/package/cpp/wgpu/JsiAdapter.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,6 +13,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,13 +41,30 @@ class JsiAdapter : public JsiSkWrappingSharedPtrHostObject { descriptor = std::move(descriptor)]( jsi::Runtime &runtime, std::shared_ptr promise) -> void { - auto ret = object->requestDevice(*descriptor); - if (ret == nullptr) { + wgpu::Device device = nullptr; + object->RequestDevice( + nullptr, + [](WGPURequestDeviceStatus, WGPUDevice cDevice, + const char *message, void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = + wgpu::Device::Acquire(cDevice); + }, + &device); + if (device == nullptr) { promise->resolve(jsi::Value::null()); } else { + device.SetUncapturedErrorCallback( + [](WGPUErrorType type, const char *message, void *userdata) { + RNSkLogger::logToConsole("Error: %s", message); + }, + nullptr); promise->resolve(jsi::Object::createFromHostObject( runtime, std::make_shared(std::move(context), - std::move(ret)))); + std::move(device)))); } }); } diff --git a/package/cpp/wgpu/JsiBindGroup.h b/package/cpp/wgpu/JsiBindGroup.h index cb89b788df..fa9328d472 100644 --- a/package/cpp/wgpu/JsiBindGroup.h +++ b/package/cpp/wgpu/JsiBindGroup.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiBindGroupDescriptor.h b/package/cpp/wgpu/JsiBindGroupDescriptor.h index 7c1e1cd419..195b692087 100644 --- a/package/cpp/wgpu/JsiBindGroupDescriptor.h +++ b/package/cpp/wgpu/JsiBindGroupDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,6 +13,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -44,7 +46,6 @@ class JsiBindGroupDescriptor .get(); } else { auto object = new wgpu::BindGroupDescriptor(); - object->setDefault(); if (obj.hasProperty(runtime, "layout")) { auto layout = obj.getProperty(runtime, "layout"); diff --git a/package/cpp/wgpu/JsiBindGroupEntry.h b/package/cpp/wgpu/JsiBindGroupEntry.h index cfe822a5fa..eeea78cd68 100644 --- a/package/cpp/wgpu/JsiBindGroupEntry.h +++ b/package/cpp/wgpu/JsiBindGroupEntry.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,7 +11,10 @@ #include "JsiEnums.h" #include "JsiHostObject.h" #include "JsiPromises.h" +#include "JsiSampler.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -30,9 +33,6 @@ class JsiBindGroupEntry // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead EXPORT_JSI_API_BRANDNAME(JsiBindGroupEntry, BindGroupEntry) - /** - * Returns the underlying object from a host object of this type - */ static wgpu::BindGroupEntry *fromValue(jsi::Runtime &runtime, const jsi::Value &raw) { const auto &obj = raw.asObject(runtime); @@ -40,7 +40,6 @@ class JsiBindGroupEntry return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::BindGroupEntry(); - object->setDefault(); if (obj.hasProperty(runtime, "binding")) { auto binding = obj.getProperty(runtime, "binding"); @@ -50,13 +49,50 @@ class JsiBindGroupEntry throw jsi::JSError(runtime, "Missing mandatory prop binding in BindGroupEntry"); } - if (obj.hasProperty(runtime, "buffer")) { - auto buffer = obj.getProperty(runtime, "buffer"); - object->buffer = *JsiBuffer::fromValue(runtime, buffer); + if (obj.hasProperty(runtime, "resource") && + obj.getProperty(runtime, "resource").isObject()) { + auto resource = obj.getProperty(runtime, "resource").asObject(runtime); + if (resource.isHostObject(runtime)) { + if (auto textureView = dynamic_pointer_cast( + resource.asHostObject(runtime))) { + object->textureView = *JsiTextureView::fromValue( + runtime, obj.getProperty(runtime, "resource")); + } else if (auto sampler = dynamic_pointer_cast( + resource.asHostObject(runtime))) { + object->sampler = *JsiSampler::fromValue( + runtime, obj.getProperty(runtime, "resource")); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop textureView or " + "sampler in BindGroupEntry"); + } + } else { + if (resource.hasProperty(runtime, "buffer")) { + auto buffer = resource.getProperty(runtime, "buffer"); + + object->buffer = *JsiBuffer::fromValue(runtime, buffer); + } else { + throw jsi::JSError( + runtime, "Missing mandatory prop buffer in BindGroupEntry"); + } + if (resource.hasProperty(runtime, "size")) { + auto size = resource.getProperty(runtime, "size"); + + object->size = static_cast(size.getNumber()); + } else { + object->size = object->buffer.GetSize(); + } + if (resource.hasProperty(runtime, "offset")) { + auto offset = resource.getProperty(runtime, "offset"); + + object->offset = static_cast(offset.getNumber()); + } else { + object->offset = 0; + } + } } else { throw jsi::JSError(runtime, - "Missing mandatory prop buffer in BindGroupEntry"); + "Missing mandatory prop binding in BindGroupEntry"); } return object; } diff --git a/package/cpp/wgpu/JsiBindGroupLayout.h b/package/cpp/wgpu/JsiBindGroupLayout.h index b3a4fbee6d..b7316ce482 100644 --- a/package/cpp/wgpu/JsiBindGroupLayout.h +++ b/package/cpp/wgpu/JsiBindGroupLayout.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiBlendComponent.h b/package/cpp/wgpu/JsiBlendComponent.h index 70670663b8..72d97d9651 100644 --- a/package/cpp/wgpu/JsiBlendComponent.h +++ b/package/cpp/wgpu/JsiBlendComponent.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,7 +41,6 @@ class JsiBlendComponent return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::BlendComponent(); - object->setDefault(); if (obj.hasProperty(runtime, "operation")) { auto operation = obj.getProperty(runtime, "operation"); diff --git a/package/cpp/wgpu/JsiBlendState.h b/package/cpp/wgpu/JsiBlendState.h index ec006e3efe..b61b70c433 100644 --- a/package/cpp/wgpu/JsiBlendState.h +++ b/package/cpp/wgpu/JsiBlendState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -40,7 +42,6 @@ class JsiBlendState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::BlendState(); - object->setDefault(); if (obj.hasProperty(runtime, "color")) { auto color = obj.getProperty(runtime, "color"); diff --git a/package/cpp/wgpu/JsiBuffer.h b/package/cpp/wgpu/JsiBuffer.h index 22ed18b39e..81d7231d71 100644 --- a/package/cpp/wgpu/JsiBuffer.h +++ b/package/cpp/wgpu/JsiBuffer.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -26,29 +28,68 @@ class JsiBuffer : public JsiSkWrappingSharedPtrHostObject { JSI_HOST_FUNCTION(unmap) { - getObject()->unmap(); + getObject()->Unmap(); + return jsi::Value::undefined(); } + JSI_HOST_FUNCTION(mapAsync) { + + auto object = getObject(); + auto mode = static_cast(arguments[0].getNumber()); + auto offset = + count > 1 ? static_cast(arguments[1].getNumber()) : 0; + auto size = count > 2 ? static_cast(arguments[2].getNumber()) + : getObject()->GetSize(); + auto instance = getContext()->getInstance(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, [object = std::move(object), mode, offset, size, + instance = std::move(instance)]( + jsi::Runtime &runtime, + std::shared_ptr promise) { + RNSkLogger::logToConsole("Buffer::MapAsync start"); + auto callback = [](WGPUBufferMapAsyncStatus status, void *userdata) { + RNSkLogger::logToConsole("Buffer::MapAsync callback status: " + + std::to_string(static_cast(status))); + auto promise = static_cast(userdata); + promise->resolve(jsi::Value::undefined()); + }; + wgpu::BufferMapCallbackInfo callbackInfo = { + nullptr, wgpu::CallbackMode::WaitAnyOnly, callback, + promise.get()}; + wgpu::Future future = + object->MapAsync(mode, offset, size, callbackInfo); + wgpu::FutureWaitInfo waitInfo = {future}; + RNSkia::RNSkLogger::logToConsole("before WaitAny"); + instance.WaitAny(1, &waitInfo, UINT64_MAX); + }); + } + JSI_HOST_FUNCTION(getMappedRange) { - size_t offset = static_cast(arguments[0].getNumber()); - size_t size = static_cast(arguments[1].getNumber()); - auto data = getObject()->getMappedRange(offset, size); - auto arrayBufferCtor = - runtime.global().getPropertyAsFunction(runtime, "ArrayBuffer"); - auto o = - arrayBufferCtor.callAsConstructor(runtime, static_cast(size)) - .getObject(runtime); - auto buf = o.getArrayBuffer(runtime); - memcpy(buf.data(runtime), data, size); - return o; + size_t offset = + count > 0 ? static_cast(arguments[0].getNumber()) : 0; + size_t size = count > 1 ? static_cast(arguments[1].getNumber()) + : getObject()->GetSize(); + auto usage = getObject()->GetUsage(); + void *data = (usage & wgpu::BufferUsage::MapWrite) + ? getObject()->GetMappedRange(offset, size) + : const_cast( + getObject()->GetConstMappedRange(offset, size)); + if (data == nullptr) { + throw jsi::JSError(runtime, "Buffer::GetMappedRange failed"); + } + auto buf = std::make_shared(data, size); + auto val = jsi::ArrayBuffer(runtime, buf); + auto d = val.data(runtime); + return val; } // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead EXPORT_JSI_API_BRANDNAME(JsiBuffer, Buffer) JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiBuffer, unmap), + JSI_EXPORT_FUNC(JsiBuffer, mapAsync), JSI_EXPORT_FUNC(JsiBuffer, getMappedRange)) /** diff --git a/package/cpp/wgpu/JsiBufferDescriptor.h b/package/cpp/wgpu/JsiBufferDescriptor.h index 0186a04524..17ddea0236 100644 --- a/package/cpp/wgpu/JsiBufferDescriptor.h +++ b/package/cpp/wgpu/JsiBufferDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,7 +41,6 @@ class JsiBufferDescriptor return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::BufferDescriptor(); - object->setDefault(); if (obj.hasProperty(runtime, "size")) { auto size = obj.getProperty(runtime, "size"); @@ -52,7 +53,7 @@ class JsiBufferDescriptor if (obj.hasProperty(runtime, "usage")) { auto usage = obj.getProperty(runtime, "usage"); - object->usage = static_cast(usage.getNumber()); + object->usage = static_cast(usage.getNumber()); } else { throw jsi::JSError(runtime, "Missing mandatory prop usage in BufferDescriptor"); @@ -62,10 +63,6 @@ class JsiBufferDescriptor object->mappedAtCreation = static_cast(mappedAtCreation.getBool()); - } else { - throw jsi::JSError( - runtime, - "Missing mandatory prop mappedAtCreation in BufferDescriptor"); } return object; } diff --git a/package/cpp/wgpu/JsiColor.h b/package/cpp/wgpu/JsiColor.h index 192d9a6ac4..91bf26e898 100644 --- a/package/cpp/wgpu/JsiColor.h +++ b/package/cpp/wgpu/JsiColor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -47,7 +49,6 @@ class JsiColor : public JsiSkWrappingSharedPtrHostObject { return object; } auto object = new wgpu::Color(); - object->setDefault(); if (obj.hasProperty(runtime, "r")) { auto r = obj.getProperty(runtime, "r"); diff --git a/package/cpp/wgpu/JsiColorTargetState.h b/package/cpp/wgpu/JsiColorTargetState.h index 19b09f31f0..f803df01ff 100644 --- a/package/cpp/wgpu/JsiColorTargetState.h +++ b/package/cpp/wgpu/JsiColorTargetState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -40,8 +42,7 @@ class JsiColorTargetState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::ColorTargetState(); - object->setDefault(); - object->writeMask = wgpu::ColorWriteMask::All; + if (obj.hasProperty(runtime, "format")) { auto format = obj.getProperty(runtime, "format"); @@ -59,7 +60,8 @@ class JsiColorTargetState if (obj.hasProperty(runtime, "writeMask")) { auto writeMask = obj.getProperty(runtime, "writeMask"); - object->writeMask = static_cast(writeMask.getNumber()); + object->writeMask = + static_cast(writeMask.getNumber()); } return object; } diff --git a/package/cpp/wgpu/JsiCommandBuffer.h b/package/cpp/wgpu/JsiCommandBuffer.h index 6830b26b87..038081d49c 100644 --- a/package/cpp/wgpu/JsiCommandBuffer.h +++ b/package/cpp/wgpu/JsiCommandBuffer.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiCommandEncoder.h b/package/cpp/wgpu/JsiCommandEncoder.h index 6fa7322ebe..6ffda6ab9e 100644 --- a/package/cpp/wgpu/JsiCommandEncoder.h +++ b/package/cpp/wgpu/JsiCommandEncoder.h @@ -3,17 +3,22 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include +#include "JsiBuffer.h" #include "JsiCommandBuffer.h" +#include "JsiComputePassDescriptor.h" +#include "JsiComputePassEncoder.h" #include "JsiEnums.h" #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiRenderPassDescriptor.h" #include "JsiRenderPassEncoder.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -32,23 +37,59 @@ class JsiCommandEncoder JSI_HOST_FUNCTION(beginRenderPass) { auto descriptor = JsiRenderPassDescriptor::fromValue(runtime, arguments[0]); - auto ret = getObject()->beginRenderPass(*descriptor); + auto ret = getObject()->BeginRenderPass(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "beginRenderPass returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } JSI_HOST_FUNCTION(finish) { - auto ret = getObject()->finish(); + auto ret = getObject()->Finish(); + if (ret == nullptr) { + throw jsi::JSError(runtime, "finish returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } + JSI_HOST_FUNCTION(beginComputePass) { + + auto defaultDescriptor = new wgpu::ComputePassDescriptor(); + auto descriptor = + count > 0 ? JsiComputePassDescriptor::fromValue(runtime, arguments[0]) + : defaultDescriptor; + + auto ret = getObject()->BeginComputePass(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "beginComputePass returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret)); + } + + JSI_HOST_FUNCTION(copyBufferToBuffer) { + auto source = JsiBuffer::fromValue(runtime, arguments[0]); + auto sourceOffset = static_cast(arguments[1].getNumber()); + auto destination = JsiBuffer::fromValue(runtime, arguments[2]); + auto destinationOffset = static_cast(arguments[3].getNumber()); + auto size = static_cast(arguments[4].getNumber()); + + getObject()->CopyBufferToBuffer(*source, sourceOffset, *destination, + destinationOffset, size); + + return jsi::Value::undefined(); + } + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead EXPORT_JSI_API_BRANDNAME(JsiCommandEncoder, CommandEncoder) JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiCommandEncoder, beginRenderPass), - JSI_EXPORT_FUNC(JsiCommandEncoder, finish)) + JSI_EXPORT_FUNC(JsiCommandEncoder, finish), + JSI_EXPORT_FUNC(JsiCommandEncoder, beginComputePass), + JSI_EXPORT_FUNC(JsiCommandEncoder, copyBufferToBuffer)) /** * Returns the underlying object from a host object of this type diff --git a/package/cpp/wgpu/JsiCommandEncoderDescriptor.h b/package/cpp/wgpu/JsiCommandEncoderDescriptor.h index cf0c4e5d00..683c4dac59 100644 --- a/package/cpp/wgpu/JsiCommandEncoderDescriptor.h +++ b/package/cpp/wgpu/JsiCommandEncoderDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiComputePassDescriptor.h b/package/cpp/wgpu/JsiComputePassDescriptor.h new file mode 100644 index 0000000000..4738ef61ff --- /dev/null +++ b/package/cpp/wgpu/JsiComputePassDescriptor.h @@ -0,0 +1,52 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiComputePassDescriptor + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiComputePassDescriptor(std::shared_ptr context, + wgpu::ComputePassDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, + std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiComputePassDescriptor, ComputePassDescriptor) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::ComputePassDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + throw jsi::JSError( + runtime, "Expected a JsiComputePassDescriptor object, but got a " + + raw.toString(runtime).utf8(runtime)); + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiComputePassEncoder.h b/package/cpp/wgpu/JsiComputePassEncoder.h new file mode 100644 index 0000000000..8701206580 --- /dev/null +++ b/package/cpp/wgpu/JsiComputePassEncoder.h @@ -0,0 +1,97 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiBindGroup.h" +#include "JsiComputePipeline.h" +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiComputePassEncoder + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiComputePassEncoder(std::shared_ptr context, + wgpu::ComputePassEncoder m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) { + } + + JSI_HOST_FUNCTION(setPipeline) { + auto pipeline = JsiComputePipeline::fromValue(runtime, arguments[0]); + + getObject()->SetPipeline(*pipeline); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(setBindGroup) { + auto index = static_cast(arguments[0].getNumber()); + auto bindGroup = JsiBindGroup::fromValue(runtime, arguments[1]); + // auto dynamicOffsetCount = static_cast(arguments[2].getNumber()); + getObject()->SetBindGroup(index, *bindGroup, 0, nullptr); + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(dispatchWorkgroups) { + auto x = static_cast(arguments[0].getNumber()); + uint32_t defaultY = 1; + auto y = + count > 1 ? static_cast(arguments[1].getNumber()) : defaultY; + uint32_t defaultZ = 1; + auto z = + count > 2 ? static_cast(arguments[2].getNumber()) : defaultZ; + + getObject()->DispatchWorkgroups(x, y, z); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(end) { + + getObject()->End(); + + return jsi::Value::undefined(); + } + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiComputePassEncoder, ComputePassEncoder) + + JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiComputePassEncoder, setPipeline), + JSI_EXPORT_FUNC(JsiComputePassEncoder, setBindGroup), + JSI_EXPORT_FUNC(JsiComputePassEncoder, + dispatchWorkgroups), + JSI_EXPORT_FUNC(JsiComputePassEncoder, end)) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::ComputePassEncoder *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + throw jsi::JSError(runtime, + "Expected a JsiComputePassEncoder object, but got a " + + raw.toString(runtime).utf8(runtime)); + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiComputePipeline.h b/package/cpp/wgpu/JsiComputePipeline.h new file mode 100644 index 0000000000..9b50ab66f6 --- /dev/null +++ b/package/cpp/wgpu/JsiComputePipeline.h @@ -0,0 +1,63 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiBindGroupLayout.h" +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiComputePipeline + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiComputePipeline(std::shared_ptr context, + wgpu::ComputePipeline m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + JSI_HOST_FUNCTION(getBindGroupLayout) { + auto index = static_cast(arguments[0].getNumber()); + + auto ret = getObject()->GetBindGroupLayout(index); + if (ret == nullptr) { + throw jsi::JSError(runtime, "getBindGroupLayout returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret)); + } + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiComputePipeline, ComputePipeline) + + JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiComputePipeline, getBindGroupLayout)) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::ComputePipeline *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + throw jsi::JSError(runtime, + "Expected a JsiComputePipeline object, but got a " + + raw.toString(runtime).utf8(runtime)); + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiComputePipelineDescriptor.h b/package/cpp/wgpu/JsiComputePipelineDescriptor.h new file mode 100644 index 0000000000..b68e9c92aa --- /dev/null +++ b/package/cpp/wgpu/JsiComputePipelineDescriptor.h @@ -0,0 +1,67 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPipelineLayout.h" +#include "JsiProgrammableStageDescriptor.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiComputePipelineDescriptor + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiComputePipelineDescriptor(std::shared_ptr context, + wgpu::ComputePipelineDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, + std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiComputePipelineDescriptor, + ComputePipelineDescriptor) + + static wgpu::ComputePipelineDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::ComputePipelineDescriptor(); + + // if (obj.hasProperty(runtime, "layout")) { + // auto layout = obj.getProperty(runtime, "layout"); + + // object->layout = *JsiPipelineLayout::fromValue(runtime, layout); + // } + if (obj.hasProperty(runtime, "compute")) { + auto compute = obj.getProperty(runtime, "compute"); + + object->compute = + *JsiProgrammableStageDescriptor::fromValue(runtime, compute); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop compute in ComputePipelineDescriptor"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiConstants.h b/package/cpp/wgpu/JsiConstants.h new file mode 100644 index 0000000000..40b8355b32 --- /dev/null +++ b/package/cpp/wgpu/JsiConstants.h @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include "dawn/webgpu_cpp.h" + +namespace RNSkia { + +void installConstants(jsi::Runtime &runtime) { + + jsi::Object GPUBufferUsage(runtime); + GPUBufferUsage.setProperty(runtime, "MAP_READ", jsi::Value(1)); + GPUBufferUsage.setProperty(runtime, "MAP_WRITE", jsi::Value(2)); + GPUBufferUsage.setProperty(runtime, "COPY_SRC", jsi::Value(4)); + GPUBufferUsage.setProperty(runtime, "COPY_DST", jsi::Value(8)); + GPUBufferUsage.setProperty(runtime, "INDEX", jsi::Value(16)); + GPUBufferUsage.setProperty(runtime, "VERTEX", jsi::Value(32)); + GPUBufferUsage.setProperty(runtime, "UNIFORM", jsi::Value(64)); + GPUBufferUsage.setProperty(runtime, "STORAGE", jsi::Value(128)); + GPUBufferUsage.setProperty(runtime, "INDIRECT", jsi::Value(256)); + GPUBufferUsage.setProperty(runtime, "QUERY_RESOLVE", jsi::Value(512)); + runtime.global().setProperty(runtime, "GPUBufferUsage", GPUBufferUsage); + + jsi::Object GPUColorWrite(runtime); + GPUColorWrite.setProperty(runtime, "RED", jsi::Value(1)); + GPUColorWrite.setProperty(runtime, "GREEN", jsi::Value(2)); + GPUColorWrite.setProperty(runtime, "BLUE", jsi::Value(4)); + GPUColorWrite.setProperty(runtime, "ALPHA", jsi::Value(8)); + GPUColorWrite.setProperty(runtime, "ALL", jsi::Value(15)); + runtime.global().setProperty(runtime, "GPUColorWrite", GPUColorWrite); + + jsi::Object GPUMapMode(runtime); + GPUMapMode.setProperty(runtime, "READ", jsi::Value(1)); + GPUMapMode.setProperty(runtime, "WRITE", jsi::Value(2)); + runtime.global().setProperty(runtime, "GPUMapMode", GPUMapMode); + + jsi::Object GPUShaderStage(runtime); + GPUShaderStage.setProperty(runtime, "VERTEX", jsi::Value(1)); + GPUShaderStage.setProperty(runtime, "FRAGMENT", jsi::Value(2)); + GPUShaderStage.setProperty(runtime, "COMPUTE", jsi::Value(4)); + runtime.global().setProperty(runtime, "GPUShaderStage", GPUShaderStage); + + jsi::Object GPUTextureUsage(runtime); + GPUTextureUsage.setProperty(runtime, "COPY_SRC", jsi::Value(1)); + GPUTextureUsage.setProperty(runtime, "COPY_DST", jsi::Value(2)); + GPUTextureUsage.setProperty(runtime, "TEXTURE_BINDING", jsi::Value(4)); + GPUTextureUsage.setProperty(runtime, "STORAGE_BINDING", jsi::Value(8)); + GPUTextureUsage.setProperty(runtime, "RENDER_ATTACHMENT", jsi::Value(16)); + runtime.global().setProperty(runtime, "GPUTextureUsage", GPUTextureUsage); +} + +} // namespace RNSkia \ No newline at end of file diff --git a/package/cpp/wgpu/JsiContext.h b/package/cpp/wgpu/JsiContext.h index 0ead11308a..aeef7f278d 100644 --- a/package/cpp/wgpu/JsiContext.h +++ b/package/cpp/wgpu/JsiContext.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -38,7 +40,6 @@ class JsiContext : public JsiSkWrappingSharedPtrHostObject { return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::Context(); - object->setDefault(); if (obj.hasProperty(runtime, "gpu")) { auto gpu = obj.getProperty(runtime, "gpu"); diff --git a/package/cpp/wgpu/JsiDepthStencilState.h b/package/cpp/wgpu/JsiDepthStencilState.h index 39a19a91f1..13875a9f2a 100644 --- a/package/cpp/wgpu/JsiDepthStencilState.h +++ b/package/cpp/wgpu/JsiDepthStencilState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiPromises.h" #include "JsiSkHostObjects.h" #include "JsiStencilFaceState.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -40,7 +42,6 @@ class JsiDepthStencilState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::DepthStencilState(); - object->setDefault(); if (obj.hasProperty(runtime, "format")) { auto format = obj.getProperty(runtime, "format"); diff --git a/package/cpp/wgpu/JsiDevice.h b/package/cpp/wgpu/JsiDevice.h index 5724e92b36..9300e93bb0 100644 --- a/package/cpp/wgpu/JsiDevice.h +++ b/package/cpp/wgpu/JsiDevice.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,17 +13,24 @@ #include "JsiBufferDescriptor.h" #include "JsiCommandEncoder.h" #include "JsiCommandEncoderDescriptor.h" +#include "JsiComputePipeline.h" +#include "JsiComputePipelineDescriptor.h" #include "JsiEnums.h" #include "JsiHostObject.h" +#include "JsiPipelineLayoutDescriptor.h" #include "JsiPromises.h" #include "JsiQueue.h" #include "JsiRenderPipeline.h" #include "JsiRenderPipelineDescriptor.h" +#include "JsiSampler.h" +#include "JsiSamplerDescriptor.h" #include "JsiShaderModule.h" #include "JsiShaderModuleWGSLDescriptor.h" #include "JsiSkHostObjects.h" #include "JsiTexture.h" #include "JsiTextureDescriptor.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,15 +46,41 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { JSI_PROPERTY_GET(queue) { - auto ret = getObject()->getQueue(); + auto ret = getObject()->GetQueue(); + if (ret == nullptr) { + throw jsi::JSError(runtime, "getQueue returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } + JSI_HOST_FUNCTION(createPipelineLayout) { + auto descriptor = + JsiPipelineLayoutDescriptor::fromValue(runtime, arguments[0]); + + getObject()->CreatePipelineLayout(descriptor); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(createSampler) { + auto descriptor = JsiSamplerDescriptor::fromValue(runtime, arguments[0]); + + auto ret = getObject()->CreateSampler(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createSampler returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret)); + } + JSI_HOST_FUNCTION(createBindGroup) { auto descriptor = JsiBindGroupDescriptor::fromValue(runtime, arguments[0]); - auto ret = getObject()->createBindGroup(*descriptor); + auto ret = getObject()->CreateBindGroup(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createBindGroup returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } @@ -56,19 +89,37 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { auto descriptor = JsiRenderPipelineDescriptor::fromValue(runtime, arguments[0]); - auto ret = getObject()->createRenderPipeline(*descriptor); + auto ret = getObject()->CreateRenderPipeline(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createRenderPipeline returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } + JSI_HOST_FUNCTION(createComputePipeline) { + auto descriptor = + JsiComputePipelineDescriptor::fromValue(runtime, arguments[0]); + + auto ret = getObject()->CreateComputePipeline(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createComputePipeline returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret)); + } + JSI_HOST_FUNCTION(createShaderModule) { auto moduleDescriptor = JsiShaderModuleWGSLDescriptor::fromValue(runtime, arguments[0]); auto moduleDescriptorNext = *moduleDescriptor; - wgpu::ShaderModuleDescriptor baseModuleDescriptor; - baseModuleDescriptor.nextInChain = &moduleDescriptorNext.chain; - auto ret = getObject()->createShaderModule(baseModuleDescriptor); + auto baseModuleDescriptor = new wgpu::ShaderModuleDescriptor(); + baseModuleDescriptor->nextInChain = &moduleDescriptorNext; + auto ret = getObject()->CreateShaderModule(baseModuleDescriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createShaderModule returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } @@ -80,7 +131,10 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { ? JsiCommandEncoderDescriptor::fromValue(runtime, arguments[0]) : defaultDescriptor; - auto ret = getObject()->createCommandEncoder(*descriptor); + auto ret = getObject()->CreateCommandEncoder(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createCommandEncoder returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } @@ -88,7 +142,10 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { JSI_HOST_FUNCTION(createBuffer) { auto descritor = JsiBufferDescriptor::fromValue(runtime, arguments[0]); - auto ret = getObject()->createBuffer(*descritor); + auto ret = getObject()->CreateBuffer(descritor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createBuffer returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } @@ -96,7 +153,10 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { JSI_HOST_FUNCTION(createTexture) { auto descriptor = JsiTextureDescriptor::fromValue(runtime, arguments[0]); - auto ret = getObject()->createTexture(*descriptor); + auto ret = getObject()->CreateTexture(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createTexture returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } @@ -105,8 +165,11 @@ class JsiDevice : public JsiSkWrappingSharedPtrHostObject { JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiDevice, queue)) - JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiDevice, createBindGroup), + JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiDevice, createPipelineLayout), + JSI_EXPORT_FUNC(JsiDevice, createSampler), + JSI_EXPORT_FUNC(JsiDevice, createBindGroup), JSI_EXPORT_FUNC(JsiDevice, createRenderPipeline), + JSI_EXPORT_FUNC(JsiDevice, createComputePipeline), JSI_EXPORT_FUNC(JsiDevice, createShaderModule), JSI_EXPORT_FUNC(JsiDevice, createCommandEncoder), JSI_EXPORT_FUNC(JsiDevice, createBuffer), diff --git a/package/cpp/wgpu/JsiDeviceDescriptor.h b/package/cpp/wgpu/JsiDeviceDescriptor.h index fe48be9409..8ed757b5a4 100644 --- a/package/cpp/wgpu/JsiDeviceDescriptor.h +++ b/package/cpp/wgpu/JsiDeviceDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiEnums.h b/package/cpp/wgpu/JsiEnums.h index 37fe0c486e..409ddc0be6 100644 --- a/package/cpp/wgpu/JsiEnums.h +++ b/package/cpp/wgpu/JsiEnums.h @@ -2,7 +2,7 @@ #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" namespace RNSkia { wgpu::AddressMode getAddressMode(const char *value) { @@ -391,13 +391,13 @@ wgpu::TextureAspect getTextureAspect(const char *value) { wgpu::TextureDimension getTextureDimension(const char *value) { if (strcmp(value, "1d") == 0) { - return wgpu::TextureDimension::_1D; + return wgpu::TextureDimension::e1D; } if (strcmp(value, "2d") == 0) { - return wgpu::TextureDimension::_2D; + return wgpu::TextureDimension::e2D; } if (strcmp(value, "3d") == 0) { - return wgpu::TextureDimension::_3D; + return wgpu::TextureDimension::e3D; } throw std::invalid_argument("Invalid value " + std::string(value) + " for enum TextureDimension"); @@ -712,13 +712,13 @@ wgpu::TextureSampleType getTextureSampleType(const char *value) { wgpu::TextureViewDimension getTextureViewDimension(const char *value) { if (strcmp(value, "1d") == 0) { - return wgpu::TextureViewDimension::_1D; + return wgpu::TextureViewDimension::e1D; } if (strcmp(value, "2d") == 0) { - return wgpu::TextureViewDimension::_2D; + return wgpu::TextureViewDimension::e2D; } if (strcmp(value, "2d-array") == 0) { - return wgpu::TextureViewDimension::_2DArray; + return wgpu::TextureViewDimension::e2DArray; } if (strcmp(value, "cube") == 0) { return wgpu::TextureViewDimension::Cube; @@ -727,7 +727,7 @@ wgpu::TextureViewDimension getTextureViewDimension(const char *value) { return wgpu::TextureViewDimension::CubeArray; } if (strcmp(value, "3d") == 0) { - return wgpu::TextureViewDimension::_3D; + return wgpu::TextureViewDimension::e3D; } throw std::invalid_argument("Invalid value " + std::string(value) + " for enum TextureViewDimension"); diff --git a/package/cpp/wgpu/JsiExtent3D.h b/package/cpp/wgpu/JsiExtent3D.h index 1418e516c2..9f4ebbd4a3 100644 --- a/package/cpp/wgpu/JsiExtent3D.h +++ b/package/cpp/wgpu/JsiExtent3D.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -37,7 +39,6 @@ class JsiExtent3D : public JsiSkWrappingSharedPtrHostObject { return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::Extent3D(); - object->setDefault(); if (obj.hasProperty(runtime, "width")) { auto width = obj.getProperty(runtime, "width"); diff --git a/package/cpp/wgpu/JsiFragmentState.h b/package/cpp/wgpu/JsiFragmentState.h index 2588206445..b7d7faf081 100644 --- a/package/cpp/wgpu/JsiFragmentState.h +++ b/package/cpp/wgpu/JsiFragmentState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,6 +13,8 @@ #include "JsiPromises.h" #include "JsiShaderModule.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -41,7 +43,6 @@ class JsiFragmentState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::FragmentState(); - object->setDefault(); if (obj.hasProperty(runtime, "module")) { auto module = obj.getProperty(runtime, "module"); diff --git a/package/cpp/wgpu/JsiGPU.h b/package/cpp/wgpu/JsiGPU.h index 30bf9adb2e..ba049ccecb 100644 --- a/package/cpp/wgpu/JsiGPU.h +++ b/package/cpp/wgpu/JsiGPU.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,6 +13,8 @@ #include "JsiPromises.h" #include "JsiRequestAdapterOptions.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -26,10 +28,6 @@ class JsiGPU : public JsiSkWrappingSharedPtrHostObject { : JsiSkWrappingSharedPtrHostObject( context, std::make_shared(std::move(m))) {} - JSI_HOST_FUNCTION(getPreferredCanvasFormat) { - return jsi::String::createFromUtf8(runtime, "rgba8unorm"); - } - JSI_HOST_FUNCTION(requestAdapter) { auto defaultOptions = new wgpu::RequestAdapterOptions(); auto options = @@ -43,17 +41,33 @@ class JsiGPU : public JsiSkWrappingSharedPtrHostObject { options = std::move(options)]( jsi::Runtime &runtime, std::shared_ptr promise) -> void { - auto ret = object->requestAdapter(*options); - if (ret == nullptr) { + wgpu::Adapter adapter = nullptr; + object->RequestAdapter( + nullptr, + [](WGPURequestAdapterStatus, WGPUAdapter cAdapter, + const char *message, void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = + wgpu::Adapter::Acquire(cAdapter); + }, + &adapter); + if (adapter == nullptr) { promise->resolve(jsi::Value::null()); } else { promise->resolve(jsi::Object::createFromHostObject( runtime, std::make_shared(std::move(context), - std::move(ret)))); + std::move(adapter)))); } }); } + JSI_HOST_FUNCTION(getPreferredCanvasFormat) { + return jsi::String::createFromUtf8(runtime, "rgba8unorm"); + } + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead EXPORT_JSI_API_BRANDNAME(JsiGPU, GPU) diff --git a/package/cpp/wgpu/JsiImageCopyTexture.h b/package/cpp/wgpu/JsiImageCopyTexture.h new file mode 100644 index 0000000000..9dfa3c70a6 --- /dev/null +++ b/package/cpp/wgpu/JsiImageCopyTexture.h @@ -0,0 +1,84 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiExtent3D.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTexture.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiImageCopyTexture + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiImageCopyTexture(std::shared_ptr context, + wgpu::ImageCopyTexture m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiImageCopyTexture, ImageCopyTexture) + + static wgpu::ImageCopyTexture *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::ImageCopyTexture(); + + if (obj.hasProperty(runtime, "texture")) { + auto texture = obj.getProperty(runtime, "texture"); + + object->texture = *JsiTexture::fromValue(runtime, texture); + } else { + throw jsi::JSError( + runtime, "Missing mandatory prop texture in ImageCopyTexture"); + } + if (obj.hasProperty(runtime, "mipLevel")) { + auto mipLevel = obj.getProperty(runtime, "mipLevel"); + + object->mipLevel = static_cast(mipLevel.getNumber()); + } + if (obj.hasProperty(runtime, "origin")) { + auto origin = obj.getProperty(runtime, "origin").asObject(runtime); + auto x = origin.hasProperty(runtime, "x") + ? origin.getProperty(runtime, "x").getNumber() + : 0; + auto y = origin.hasProperty(runtime, "y") + ? origin.getProperty(runtime, "y").getNumber() + : 0; + auto z = origin.hasProperty(runtime, "z") + ? origin.getProperty(runtime, "z").getNumber() + : 0; + object->origin = {static_cast(x), static_cast(y), + static_cast(z)}; + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop origin in ImageCopyTexture"); + } + if (obj.hasProperty(runtime, "aspect")) { + auto aspect = obj.getProperty(runtime, "aspect"); + + object->aspect = + getTextureAspect(aspect.getString(runtime).utf8(runtime).c_str()); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiImageDataLayout.h b/package/cpp/wgpu/JsiImageDataLayout.h new file mode 100644 index 0000000000..55a9fe44fb --- /dev/null +++ b/package/cpp/wgpu/JsiImageDataLayout.h @@ -0,0 +1,64 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiImageDataLayout + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiImageDataLayout(std::shared_ptr context, + wgpu::ImageDataLayout m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiImageDataLayout, ImageDataLayout) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::TextureDataLayout *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::TextureDataLayout(); + + if (obj.hasProperty(runtime, "offset")) { + auto offset = obj.getProperty(runtime, "offset"); + + object->offset = static_cast(offset.getNumber()); + } + if (obj.hasProperty(runtime, "bytes per row")) { + auto bytesPerRow = obj.getProperty(runtime, "bytes per row"); + + object->bytesPerRow = static_cast(bytesPerRow.getNumber()); + } + if (obj.hasProperty(runtime, "rows per image")) { + auto rowsPerImage = obj.getProperty(runtime, "rows per image"); + + object->rowsPerImage = static_cast(rowsPerImage.getNumber()); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiMultisampleState.h b/package/cpp/wgpu/JsiMultisampleState.h index 468f554630..114436f421 100644 --- a/package/cpp/wgpu/JsiMultisampleState.h +++ b/package/cpp/wgpu/JsiMultisampleState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,7 +41,6 @@ class JsiMultisampleState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::MultisampleState(); - object->setDefault(); if (obj.hasProperty(runtime, "count")) { auto count = obj.getProperty(runtime, "count"); diff --git a/package/cpp/wgpu/JsiPipelineLayout.h b/package/cpp/wgpu/JsiPipelineLayout.h new file mode 100644 index 0000000000..0f84da7eb9 --- /dev/null +++ b/package/cpp/wgpu/JsiPipelineLayout.h @@ -0,0 +1,49 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiPipelineLayout + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiPipelineLayout(std::shared_ptr context, + wgpu::PipelineLayout m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiPipelineLayout, PipelineLayout) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::PipelineLayout *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + throw jsi::JSError(runtime, + "Expected a JsiPipelineLayout object, but got a " + + raw.toString(runtime).utf8(runtime)); + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiPipelineLayoutDescriptor.h b/package/cpp/wgpu/JsiPipelineLayoutDescriptor.h new file mode 100644 index 0000000000..316a9d9541 --- /dev/null +++ b/package/cpp/wgpu/JsiPipelineLayoutDescriptor.h @@ -0,0 +1,72 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiBindGroupLayout.h" +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiPipelineLayoutDescriptor + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiPipelineLayoutDescriptor(std::shared_ptr context, + wgpu::PipelineLayoutDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, + std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiPipelineLayoutDescriptor, + PipelineLayoutDescriptor) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::PipelineLayoutDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::PipelineLayoutDescriptor(); + + if (obj.hasProperty(runtime, "bindGroupLayouts")) { + auto bindGroupLayouts = obj.getProperty(runtime, "bindGroupLayouts"); + auto jsiArray0 = bindGroupLayouts.asObject(runtime).asArray(runtime); + auto jsiArray0Size = static_cast(jsiArray0.size(runtime)); + auto array0 = new std::vector(); + array0->reserve(jsiArray0Size); + for (int i = 0; i < jsiArray0Size; i++) { + auto element = JsiBindGroupLayout::fromValue( + runtime, jsiArray0.getValueAtIndex(runtime, i)); + array0->push_back(*element); + } + + object->bindGroupLayoutCount = jsiArray0Size; + object->bindGroupLayouts = array0->data(); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop bindGroupLayouts " + "in PipelineLayoutDescriptor"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiPrimitiveState.h b/package/cpp/wgpu/JsiPrimitiveState.h index cb797baf6c..6983ae81d4 100644 --- a/package/cpp/wgpu/JsiPrimitiveState.h +++ b/package/cpp/wgpu/JsiPrimitiveState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,7 +41,6 @@ class JsiPrimitiveState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::PrimitiveState(); - object->setDefault(); if (obj.hasProperty(runtime, "topology")) { auto topology = obj.getProperty(runtime, "topology"); diff --git a/package/cpp/wgpu/JsiProgrammableStageDescriptor.h b/package/cpp/wgpu/JsiProgrammableStageDescriptor.h new file mode 100644 index 0000000000..544640b33e --- /dev/null +++ b/package/cpp/wgpu/JsiProgrammableStageDescriptor.h @@ -0,0 +1,74 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiShaderModule.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiProgrammableStageDescriptor : public JsiSkWrappingSharedPtrHostObject< + wgpu::ProgrammableStageDescriptor> { +public: + JsiProgrammableStageDescriptor(std::shared_ptr context, + wgpu::ProgrammableStageDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, + std::make_shared(std::move(m))) { + } + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiProgrammableStageDescriptor, + ProgrammableStageDescriptor) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::ProgrammableStageDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::ProgrammableStageDescriptor(); + + if (obj.hasProperty(runtime, "module")) { + auto module = obj.getProperty(runtime, "module"); + + object->module = *JsiShaderModule::fromValue(runtime, module); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop module in ProgrammableStageDescriptor"); + } + if (obj.hasProperty(runtime, "entryPoint")) { + auto entryPoint = obj.getProperty(runtime, "entryPoint"); + + object->entryPoint = + strdup(entryPoint.getString(runtime).utf8(runtime).c_str()); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop entryPoint in ProgrammableStageDescriptor"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiQueue.h b/package/cpp/wgpu/JsiQueue.h index 52f678746a..6a6d814107 100644 --- a/package/cpp/wgpu/JsiQueue.h +++ b/package/cpp/wgpu/JsiQueue.h @@ -3,15 +3,20 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include #include "JsiCommandBuffer.h" #include "JsiEnums.h" +#include "JsiExtent3D.h" #include "JsiHostObject.h" +#include "JsiImageCopyTexture.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureDataLayout.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -26,7 +31,7 @@ class JsiQueue : public JsiSkWrappingSharedPtrHostObject { context, std::make_shared(std::move(m))) {} JSI_HOST_FUNCTION(submit) { - std::vector commandBuffers; + std::vector commandBuffers; auto jsiArray = arguments[0].asObject(runtime).asArray(runtime); auto jsiArraySize = static_cast(jsiArray.size(runtime)); for (int i = 0; i < jsiArraySize; i++) { @@ -34,7 +39,25 @@ class JsiQueue : public JsiSkWrappingSharedPtrHostObject { commandBuffers.push_back(*JsiCommandBuffer::fromValue(runtime, val)); } - getObject()->submit(commandBuffers); + getObject()->Submit(commandBuffers.size(), commandBuffers.data()); + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(writeTexture) { + auto destination = JsiImageCopyTexture::fromValue(runtime, arguments[0]); + if (!arguments[1].isObject()) { + throw jsi::JSError(runtime, "writeTexture: data must be an ArrayBuffer"); + } + if (!arguments[1].getObject(runtime).isArrayBuffer(runtime)) { + throw jsi::JSError(runtime, "Expected an ArrayBuffer"); + } + auto data = arguments[1].getObject(runtime).getArrayBuffer(runtime); + auto dataLayout = JsiTextureDataLayout::fromValue(runtime, arguments[2]); + auto size = JsiExtent3D::fromValue(runtime, arguments[3]); + + getObject()->WriteTexture(destination, data.data(runtime), + data.size(runtime), dataLayout, size); + return jsi::Value::undefined(); } @@ -43,16 +66,47 @@ class JsiQueue : public JsiSkWrappingSharedPtrHostObject { auto buffer = JsiBuffer::fromValue(runtime, arguments[0]); auto offset = static_cast(arguments[1].getNumber()); auto data = arguments[2].getObject(runtime).getArrayBuffer(runtime); - auto size = static_cast(arguments[3].getNumber()); - getObject()->writeBuffer(*buffer, offset, data.data(runtime), size); + auto offset2 = + count > 3 ? static_cast(arguments[3].getNumber()) : 0; + auto size = count > 4 ? static_cast(arguments[4].getNumber()) + : buffer->GetSize(); + getObject()->WriteBuffer(*buffer, offset, data.data(runtime) + offset2, + size); return jsi::Value::undefined(); } + JSI_HOST_FUNCTION(onSubmittedWorkDone) { + + auto object = getObject(); + auto instance = getContext()->getInstance(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, [object = std::move(object), instance = std::move(instance)]( + jsi::Runtime &runtime, + std::shared_ptr promise) { + RNSkLogger::logToConsole("onSubmittedWorkDone start"); + auto callback = [](WGPUQueueWorkDoneStatus status, void *userdata) { + RNSkLogger::logToConsole("onSubmittedWorkDone callback status: " + + std::to_string(static_cast(status))); + auto promise = static_cast(userdata); + promise->resolve(jsi::Value::undefined()); + RNSkLogger::logToConsole("onSubmittedWorkDone end"); + }; + wgpu::QueueWorkDoneCallbackInfo callbackInfo = { + nullptr, wgpu::CallbackMode::WaitAnyOnly, callback, + promise.get()}; + wgpu::Future future = object->OnSubmittedWorkDone(callbackInfo); + wgpu::FutureWaitInfo waitInfo = {future}; + instance.WaitAny(1, &waitInfo, UINT64_MAX); + }); + } + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead EXPORT_JSI_API_BRANDNAME(JsiQueue, Queue) JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiQueue, submit), - JSI_EXPORT_FUNC(JsiQueue, writeBuffer)) + JSI_EXPORT_FUNC(JsiQueue, writeTexture), + JSI_EXPORT_FUNC(JsiQueue, writeBuffer), + JSI_EXPORT_FUNC(JsiQueue, onSubmittedWorkDone)) /** * Returns the underlying object from a host object of this type diff --git a/package/cpp/wgpu/JsiRenderPassColorAttachment.h b/package/cpp/wgpu/JsiRenderPassColorAttachment.h index 282c048156..f249658a0f 100644 --- a/package/cpp/wgpu/JsiRenderPassColorAttachment.h +++ b/package/cpp/wgpu/JsiRenderPassColorAttachment.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -13,6 +13,7 @@ #include "JsiPromises.h" #include "JsiSkHostObjects.h" #include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -45,9 +46,7 @@ class JsiRenderPassColorAttachment .get(); } else { auto object = new wgpu::RenderPassColorAttachment(); - object->setDefault(); - object->resolveTarget = nullptr; - object->depthSlice = UINT32_MAX; + if (obj.hasProperty(runtime, "view")) { auto view = obj.getProperty(runtime, "view"); diff --git a/package/cpp/wgpu/JsiRenderPassDepthStencilAttachment.h b/package/cpp/wgpu/JsiRenderPassDepthStencilAttachment.h new file mode 100644 index 0000000000..18e52500f2 --- /dev/null +++ b/package/cpp/wgpu/JsiRenderPassDepthStencilAttachment.h @@ -0,0 +1,92 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiRenderPassDepthStencilAttachment + : public JsiSkWrappingSharedPtrHostObject< + wgpu::RenderPassDepthStencilAttachment> { +public: + JsiRenderPassDepthStencilAttachment( + std::shared_ptr context, + wgpu::RenderPassDepthStencilAttachment m) + : JsiSkWrappingSharedPtrHostObject< + wgpu::RenderPassDepthStencilAttachment>( + context, std::make_shared( + std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiRenderPassDepthStencilAttachment, + RenderPassDepthStencilAttachment) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::RenderPassDepthStencilAttachment * + fromValue(jsi::Runtime &runtime, const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::RenderPassDepthStencilAttachment(); + + if (obj.hasProperty(runtime, "view")) { + auto view = obj.getProperty(runtime, "view"); + + object->view = *JsiTextureView::fromValue(runtime, view); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop view in RenderPassDepthStencilAttachment"); + } + if (obj.hasProperty(runtime, "depthClearValue")) { + auto depthClearValue = obj.getProperty(runtime, "depthClearValue"); + + object->depthClearValue = + static_cast(depthClearValue.getNumber()); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop depthClearValue in " + "RenderPassDepthStencilAttachment"); + } + if (obj.hasProperty(runtime, "depthLoadOp")) { + auto depthLoadOp = obj.getProperty(runtime, "depthLoadOp"); + + object->depthLoadOp = + getLoadOp(depthLoadOp.getString(runtime).utf8(runtime).c_str()); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop depthLoadOp in " + "RenderPassDepthStencilAttachment"); + } + if (obj.hasProperty(runtime, "depthStoreOp")) { + auto depthStoreOp = obj.getProperty(runtime, "depthStoreOp"); + + object->depthStoreOp = + getStoreOp(depthStoreOp.getString(runtime).utf8(runtime).c_str()); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop depthStoreOp in " + "RenderPassDepthStencilAttachment"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiRenderPassDescriptor.h b/package/cpp/wgpu/JsiRenderPassDescriptor.h index 5fe24183b2..3ad36b0505 100644 --- a/package/cpp/wgpu/JsiRenderPassDescriptor.h +++ b/package/cpp/wgpu/JsiRenderPassDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiPromises.h" #include "JsiRenderPassColorAttachment.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -43,7 +45,6 @@ class JsiRenderPassDescriptor .get(); } else { auto object = new wgpu::RenderPassDescriptor(); - object->setDefault(); if (obj.hasProperty(runtime, "colorAttachments")) { auto colorAttachments = obj.getProperty(runtime, "colorAttachments"); diff --git a/package/cpp/wgpu/JsiRenderPassEncoder.h b/package/cpp/wgpu/JsiRenderPassEncoder.h index fd51f40556..31448ee95b 100644 --- a/package/cpp/wgpu/JsiRenderPassEncoder.h +++ b/package/cpp/wgpu/JsiRenderPassEncoder.h @@ -3,15 +3,19 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include +#include "JsiBindGroup.h" +#include "JsiBuffer.h" #include "JsiEnums.h" #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiRenderPipeline.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -30,7 +34,8 @@ class JsiRenderPassEncoder JSI_HOST_FUNCTION(setPipeline) { auto pipeline = JsiRenderPipeline::fromValue(runtime, arguments[0]); - getObject()->setPipeline(*pipeline); + getObject()->SetPipeline(*pipeline); + return jsi::Value::undefined(); } @@ -49,13 +54,50 @@ class JsiRenderPassEncoder ? static_cast(arguments[3].getNumber()) : defaultFirstInstance; - getObject()->draw(vertexCount, instanceCount, firstVertex, firstInstance); + getObject()->Draw(vertexCount, instanceCount, firstVertex, firstInstance); + return jsi::Value::undefined(); } JSI_HOST_FUNCTION(end) { - getObject()->end(); + getObject()->End(); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(pushDebugGroup) { + auto label = strdup(arguments[0].asString(runtime).utf8(runtime).c_str()); + + getObject()->PushDebugGroup(label); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(popDebugGroup) { + + getObject()->PopDebugGroup(); + + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(setBindGroup) { + auto index = static_cast(arguments[0].getNumber()); + auto bindGroup = JsiBindGroup::fromValue(runtime, arguments[1]); + // auto dynamicOffsetCount = static_cast(arguments[2].getNumber()); + getObject()->SetBindGroup(index, *bindGroup, 0, nullptr); + return jsi::Value::undefined(); + } + + JSI_HOST_FUNCTION(setVertexBuffer) { + auto slot = static_cast(arguments[0].getNumber()); + auto buffer = JsiBuffer::fromValue(runtime, arguments[1]); + auto offset = + count > 2 ? static_cast(arguments[2].getNumber()) : 0; + auto size = count > 3 ? static_cast(arguments[3].getNumber()) + : buffer->GetSize(); + + getObject()->SetVertexBuffer(slot, *buffer, offset, size); return jsi::Value::undefined(); } @@ -64,7 +106,11 @@ class JsiRenderPassEncoder JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiRenderPassEncoder, setPipeline), JSI_EXPORT_FUNC(JsiRenderPassEncoder, draw), - JSI_EXPORT_FUNC(JsiRenderPassEncoder, end)) + JSI_EXPORT_FUNC(JsiRenderPassEncoder, end), + JSI_EXPORT_FUNC(JsiRenderPassEncoder, pushDebugGroup), + JSI_EXPORT_FUNC(JsiRenderPassEncoder, popDebugGroup), + JSI_EXPORT_FUNC(JsiRenderPassEncoder, setBindGroup), + JSI_EXPORT_FUNC(JsiRenderPassEncoder, setVertexBuffer)) /** * Returns the underlying object from a host object of this type diff --git a/package/cpp/wgpu/JsiRenderPipeline.h b/package/cpp/wgpu/JsiRenderPipeline.h index a5c2df751a..74c3397d69 100644 --- a/package/cpp/wgpu/JsiRenderPipeline.h +++ b/package/cpp/wgpu/JsiRenderPipeline.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -30,7 +32,10 @@ class JsiRenderPipeline JSI_HOST_FUNCTION(getBindGroupLayout) { auto index = static_cast(arguments[0].getNumber()); - auto ret = getObject()->getBindGroupLayout(index); + auto ret = getObject()->GetBindGroupLayout(index); + if (ret == nullptr) { + throw jsi::JSError(runtime, "getBindGroupLayout returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } diff --git a/package/cpp/wgpu/JsiRenderPipelineDescriptor.h b/package/cpp/wgpu/JsiRenderPipelineDescriptor.h index d595d10549..0983f4d308 100644 --- a/package/cpp/wgpu/JsiRenderPipelineDescriptor.h +++ b/package/cpp/wgpu/JsiRenderPipelineDescriptor.h @@ -3,11 +3,10 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include -#include "JsiDepthStencilState.h" #include "JsiEnums.h" #include "JsiFragmentState.h" #include "JsiHostObject.h" @@ -15,7 +14,9 @@ #include "JsiPrimitiveState.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" #include "JsiVertexState.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -48,10 +49,6 @@ class JsiRenderPipelineDescriptor .get(); } else { auto object = new wgpu::RenderPipelineDescriptor(); - object->setDefault(); - object->multisample.count = 1; - object->multisample.mask = ~0u; - object->multisample.alphaToCoverageEnabled = false; if (obj.hasProperty(runtime, "vertex")) { auto vertex = obj.getProperty(runtime, "vertex"); @@ -71,12 +68,6 @@ class JsiRenderPipelineDescriptor runtime, "Missing mandatory prop primitive in RenderPipelineDescriptor"); } - if (obj.hasProperty(runtime, "depthStencil")) { - auto depthStencil = obj.getProperty(runtime, "depthStencil"); - - object->depthStencil = - JsiDepthStencilState::fromValue(runtime, depthStencil); - } if (obj.hasProperty(runtime, "multisample")) { auto multisample = obj.getProperty(runtime, "multisample"); diff --git a/package/cpp/wgpu/JsiRequestAdapterOptions.h b/package/cpp/wgpu/JsiRequestAdapterOptions.h index 49a2e1443a..c87cf3dda9 100644 --- a/package/cpp/wgpu/JsiRequestAdapterOptions.h +++ b/package/cpp/wgpu/JsiRequestAdapterOptions.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -42,7 +44,6 @@ class JsiRequestAdapterOptions .get(); } else { auto object = new wgpu::RequestAdapterOptions(); - object->setDefault(); if (obj.hasProperty(runtime, "powerPreference")) { auto powerPreference = obj.getProperty(runtime, "powerPreference"); diff --git a/package/cpp/wgpu/JsiSampler.h b/package/cpp/wgpu/JsiSampler.h new file mode 100644 index 0000000000..6f0062713c --- /dev/null +++ b/package/cpp/wgpu/JsiSampler.h @@ -0,0 +1,46 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiSampler : public JsiSkWrappingSharedPtrHostObject { +public: + JsiSampler(std::shared_ptr context, wgpu::Sampler m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiSampler, Sampler) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::Sampler *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + throw jsi::JSError(runtime, "Expected a JsiSampler object, but got a " + + raw.toString(runtime).utf8(runtime)); + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiSamplerDescriptor.h b/package/cpp/wgpu/JsiSamplerDescriptor.h new file mode 100644 index 0000000000..773eecf8a3 --- /dev/null +++ b/package/cpp/wgpu/JsiSamplerDescriptor.h @@ -0,0 +1,95 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiSamplerDescriptor + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiSamplerDescriptor(std::shared_ptr context, + wgpu::SamplerDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiSamplerDescriptor, SamplerDescriptor) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::SamplerDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::SamplerDescriptor(); + + if (obj.hasProperty(runtime, "addressModeU")) { + auto addressModeU = obj.getProperty(runtime, "addressModeU"); + + object->addressModeU = getAddressMode( + addressModeU.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "addressModeV")) { + auto addressModeV = obj.getProperty(runtime, "addressModeV"); + + object->addressModeV = getAddressMode( + addressModeV.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "addressModeW")) { + auto addressModeW = obj.getProperty(runtime, "addressModeW"); + + object->addressModeW = getAddressMode( + addressModeW.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "magFilter")) { + auto magFilter = obj.getProperty(runtime, "magFilter"); + + object->magFilter = + getFilterMode(magFilter.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "minFilter")) { + auto minFilter = obj.getProperty(runtime, "minFilter"); + + object->minFilter = + getFilterMode(minFilter.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "mipmapFilter")) { + auto mipmapFilter = obj.getProperty(runtime, "mipmapFilter"); + + object->mipmapFilter = getMipmapFilterMode( + mipmapFilter.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "lodMinClamp")) { + auto lodMinClamp = obj.getProperty(runtime, "lodMinClamp"); + + object->lodMinClamp = static_cast(lodMinClamp.getNumber()); + } + if (obj.hasProperty(runtime, "lodMaxClamp")) { + auto lodMaxClamp = obj.getProperty(runtime, "lodMaxClamp"); + + object->lodMaxClamp = static_cast(lodMaxClamp.getNumber()); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiShaderModule.h b/package/cpp/wgpu/JsiShaderModule.h index 8ff9549113..581742dfc0 100644 --- a/package/cpp/wgpu/JsiShaderModule.h +++ b/package/cpp/wgpu/JsiShaderModule.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiShaderModuleWGSLDescriptor.h b/package/cpp/wgpu/JsiShaderModuleWGSLDescriptor.h index f771a60ed1..0afb97c35f 100644 --- a/package/cpp/wgpu/JsiShaderModuleWGSLDescriptor.h +++ b/package/cpp/wgpu/JsiShaderModuleWGSLDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -43,9 +45,8 @@ class JsiShaderModuleWGSLDescriptor : public JsiSkWrappingSharedPtrHostObject< .get(); } else { auto object = new wgpu::ShaderModuleWGSLDescriptor(); - object->setDefault(); - object->chain.next = nullptr; - object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor; + + object->sType = wgpu::SType::ShaderModuleWGSLDescriptor; if (obj.hasProperty(runtime, "code")) { auto code = obj.getProperty(runtime, "code"); diff --git a/package/cpp/wgpu/JsiStencilFaceState.h b/package/cpp/wgpu/JsiStencilFaceState.h index 33d5812431..87782d87d1 100644 --- a/package/cpp/wgpu/JsiStencilFaceState.h +++ b/package/cpp/wgpu/JsiStencilFaceState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -39,7 +41,6 @@ class JsiStencilFaceState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::StencilFaceState(); - object->setDefault(); if (obj.hasProperty(runtime, "compare")) { auto compare = obj.getProperty(runtime, "compare"); diff --git a/package/cpp/wgpu/JsiTexture.h b/package/cpp/wgpu/JsiTexture.h index 8e9974f7ed..a3135d2594 100644 --- a/package/cpp/wgpu/JsiTexture.h +++ b/package/cpp/wgpu/JsiTexture.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiPromises.h" #include "JsiSkHostObjects.h" #include "JsiTextureView.h" +#include "JsiTextureViewDescriptor.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -26,8 +28,15 @@ class JsiTexture : public JsiSkWrappingSharedPtrHostObject { context, std::make_shared(std::move(m))) {} JSI_HOST_FUNCTION(createView) { - - auto ret = getObject()->createView(); + auto defaultDescriptor = nullptr; + auto descriptor = + count > 0 ? JsiTextureViewDescriptor::fromValue(runtime, arguments[0]) + : defaultDescriptor; + + auto ret = getObject()->CreateView(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createView returned null"); + } return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), ret)); } diff --git a/package/cpp/wgpu/JsiTextureDataLayout.h b/package/cpp/wgpu/JsiTextureDataLayout.h new file mode 100644 index 0000000000..fd1f9db4c6 --- /dev/null +++ b/package/cpp/wgpu/JsiTextureDataLayout.h @@ -0,0 +1,64 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiTextureDataLayout + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiTextureDataLayout(std::shared_ptr context, + wgpu::TextureDataLayout m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiTextureDataLayout, TextureDataLayout) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::TextureDataLayout *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::TextureDataLayout(); + + if (obj.hasProperty(runtime, "offset")) { + auto offset = obj.getProperty(runtime, "offset"); + + object->offset = static_cast(offset.getNumber()); + } + if (obj.hasProperty(runtime, "bytesPerRow")) { + auto bytesPerRow = obj.getProperty(runtime, "bytesPerRow"); + + object->bytesPerRow = static_cast(bytesPerRow.getNumber()); + } + if (obj.hasProperty(runtime, "rowsPerImage")) { + auto rowsPerImage = obj.getProperty(runtime, "rowsPerImage"); + + object->rowsPerImage = static_cast(rowsPerImage.getNumber()); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiTextureDescriptor.h b/package/cpp/wgpu/JsiTextureDescriptor.h index c7333d3af5..ada5b524f6 100644 --- a/package/cpp/wgpu/JsiTextureDescriptor.h +++ b/package/cpp/wgpu/JsiTextureDescriptor.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -40,7 +42,6 @@ class JsiTextureDescriptor return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::TextureDescriptor(); - object->setDefault(); if (obj.hasProperty(runtime, "size")) { auto size = obj.getProperty(runtime, "size"); @@ -62,11 +63,17 @@ class JsiTextureDescriptor if (obj.hasProperty(runtime, "usage")) { auto usage = obj.getProperty(runtime, "usage"); - object->usage = static_cast(usage.getNumber()); + object->usage = static_cast(usage.getNumber()); } else { throw jsi::JSError(runtime, "Missing mandatory prop usage in TextureDescriptor"); } + if (obj.hasProperty(runtime, "mipLevelCount")) { + auto mipLevelCount = obj.getProperty(runtime, "mipLevelCount"); + + object->mipLevelCount = + static_cast(mipLevelCount.getNumber()); + } return object; } } diff --git a/package/cpp/wgpu/JsiTextureView.h b/package/cpp/wgpu/JsiTextureView.h index 1b50e5699f..ae09da78cd 100644 --- a/package/cpp/wgpu/JsiTextureView.h +++ b/package/cpp/wgpu/JsiTextureView.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -11,6 +11,8 @@ #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" diff --git a/package/cpp/wgpu/JsiTextureViewDescriptor.h b/package/cpp/wgpu/JsiTextureViewDescriptor.h new file mode 100644 index 0000000000..99fc1dde3a --- /dev/null +++ b/package/cpp/wgpu/JsiTextureViewDescriptor.h @@ -0,0 +1,75 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiTextureViewDescriptor + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiTextureViewDescriptor(std::shared_ptr context, + wgpu::TextureViewDescriptor m) + : JsiSkWrappingSharedPtrHostObject( + context, + std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiTextureViewDescriptor, TextureViewDescriptor) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::TextureViewDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::TextureViewDescriptor(); + + if (obj.hasProperty(runtime, "format")) { + auto format = obj.getProperty(runtime, "format"); + + object->format = + getTextureFormat(format.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "dimension")) { + auto dimension = obj.getProperty(runtime, "dimension"); + + object->dimension = getTextureViewDimension( + dimension.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "baseMipLevel")) { + auto baseMipLevel = obj.getProperty(runtime, "baseMipLevel"); + + object->baseMipLevel = static_cast(baseMipLevel.getNumber()); + } + if (obj.hasProperty(runtime, "mipLevelCount")) { + auto mipLevelCount = obj.getProperty(runtime, "mipLevelCount"); + + object->mipLevelCount = + static_cast(mipLevelCount.getNumber()); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiVertexAttribute.h b/package/cpp/wgpu/JsiVertexAttribute.h new file mode 100644 index 0000000000..bce09e2d65 --- /dev/null +++ b/package/cpp/wgpu/JsiVertexAttribute.h @@ -0,0 +1,76 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiVertexAttribute + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiVertexAttribute(std::shared_ptr context, + wgpu::VertexAttribute m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) {} + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiVertexAttribute, VertexAttribute) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::VertexAttribute *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::VertexAttribute(); + + if (obj.hasProperty(runtime, "shaderLocation")) { + auto shaderLocation = obj.getProperty(runtime, "shaderLocation"); + + object->shaderLocation = + static_cast(shaderLocation.getNumber()); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop shaderLocation in VertexAttribute"); + } + if (obj.hasProperty(runtime, "format")) { + auto format = obj.getProperty(runtime, "format"); + + object->format = + getVertexFormat(format.getString(runtime).utf8(runtime).c_str()); + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop format in VertexAttribute"); + } + if (obj.hasProperty(runtime, "offset")) { + auto offset = obj.getProperty(runtime, "offset"); + + object->offset = static_cast(offset.getNumber()); + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop offset in VertexAttribute"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiVertexBufferLayout.h b/package/cpp/wgpu/JsiVertexBufferLayout.h new file mode 100644 index 0000000000..7242d3f37e --- /dev/null +++ b/package/cpp/wgpu/JsiVertexBufferLayout.h @@ -0,0 +1,86 @@ +#pragma once +#include +#include +#include + +#include "dawn/webgpu_cpp.h" + +#include + +#include "JsiEnums.h" +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "JsiVertexAttribute.h" +#include "MutableJSIBuffer.h" +#include "RNSkLog.h" +#include "RNSkPlatformContext.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +class JsiVertexBufferLayout + : public JsiSkWrappingSharedPtrHostObject { +public: + JsiVertexBufferLayout(std::shared_ptr context, + wgpu::VertexBufferLayout m) + : JsiSkWrappingSharedPtrHostObject( + context, std::make_shared(std::move(m))) { + } + + // TODO: this fix, use JSI_EXPORT_PROPERTY_GETTERS instead + EXPORT_JSI_API_BRANDNAME(JsiVertexBufferLayout, VertexBufferLayout) + + /** + * Returns the underlying object from a host object of this type + */ + static wgpu::VertexBufferLayout *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime) + ->getObject() + .get(); + } else { + auto object = new wgpu::VertexBufferLayout(); + + if (obj.hasProperty(runtime, "arrayStride")) { + auto arrayStride = obj.getProperty(runtime, "arrayStride"); + + object->arrayStride = static_cast(arrayStride.getNumber()); + } else { + throw jsi::JSError( + runtime, + "Missing mandatory prop arrayStride in VertexBufferLayout"); + } + if (obj.hasProperty(runtime, "stepMode")) { + auto stepMode = obj.getProperty(runtime, "stepMode"); + + object->stepMode = getVertexStepMode( + stepMode.getString(runtime).utf8(runtime).c_str()); + } + if (obj.hasProperty(runtime, "attributes")) { + auto attributes = obj.getProperty(runtime, "attributes"); + auto jsiArray2 = attributes.asObject(runtime).asArray(runtime); + auto jsiArray2Size = static_cast(jsiArray2.size(runtime)); + auto array2 = new std::vector(); + array2->reserve(jsiArray2Size); + for (int i = 0; i < jsiArray2Size; i++) { + auto element = JsiVertexAttribute::fromValue( + runtime, jsiArray2.getValueAtIndex(runtime, i)); + array2->push_back(*element); + } + + object->attributeCount = jsiArray2Size; + object->attributes = array2->data(); + } else { + throw jsi::JSError( + runtime, "Missing mandatory prop attributes in VertexBufferLayout"); + } + return object; + } + } +}; +} // namespace RNSkia diff --git a/package/cpp/wgpu/JsiVertexState.h b/package/cpp/wgpu/JsiVertexState.h index c1ba822605..8c5b6b74bc 100644 --- a/package/cpp/wgpu/JsiVertexState.h +++ b/package/cpp/wgpu/JsiVertexState.h @@ -3,7 +3,7 @@ #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -12,6 +12,9 @@ #include "JsiPromises.h" #include "JsiShaderModule.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" +#include "JsiVertexBufferLayout.h" +#include "MutableJSIBuffer.h" #include "RNSkLog.h" #include "RNSkPlatformContext.h" @@ -40,7 +43,6 @@ class JsiVertexState return obj.asHostObject(runtime)->getObject().get(); } else { auto object = new wgpu::VertexState(); - object->setDefault(); if (obj.hasProperty(runtime, "module")) { auto module = obj.getProperty(runtime, "module"); @@ -59,6 +61,21 @@ class JsiVertexState throw jsi::JSError(runtime, "Missing mandatory prop entryPoint in VertexState"); } + if (obj.hasProperty(runtime, "buffers")) { + auto buffers = obj.getProperty(runtime, "buffers"); + auto jsiArray2 = buffers.asObject(runtime).asArray(runtime); + auto jsiArray2Size = static_cast(jsiArray2.size(runtime)); + auto array2 = new std::vector(); + array2->reserve(jsiArray2Size); + for (int i = 0; i < jsiArray2Size; i++) { + auto element = JsiVertexBufferLayout::fromValue( + runtime, jsiArray2.getValueAtIndex(runtime, i)); + array2->push_back(*element); + } + + object->bufferCount = jsiArray2Size; + object->buffers = array2->data(); + } return object; } } diff --git a/package/cpp/wgpu/JsiWGPUContext.h b/package/cpp/wgpu/JsiWGPUContext.h index 335ef94cc8..748c08b6ea 100644 --- a/package/cpp/wgpu/JsiWGPUContext.h +++ b/package/cpp/wgpu/JsiWGPUContext.h @@ -1,6 +1,6 @@ #pragma once -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -32,17 +32,20 @@ class JsiWGPUContext : public JsiSkWrappingSharedPtrHostObject { auto device = JsiDevice::fromValue( runtime, arguments[0].asObject(runtime).getPropertyAsObject(runtime, "device")); - auto adapter = device->getAdapter(); + auto adapter = device->GetAdapter(); wgpu::Surface surface = *getObject().get(); wgpu::SwapChainDescriptor swapChainDesc; swapChainDesc.width = _width; swapChainDesc.height = _height; swapChainDesc.usage = wgpu::TextureUsage::RenderAttachment; - swapChainDesc.format = surface.getPreferredFormat(adapter); + swapChainDesc.format = + wgpu::TextureFormat::RGBA8Unorm; // surface.GetPreferredFormat(adapter); swapChainDesc.presentMode = wgpu::PresentMode::Fifo; + // swapChainDesc.compositingAlphaMode = + // wgpu::CompositingAlphaMode::PreMultiplied; _surface = std::make_shared(surface); _swapChain = std::make_shared( - device->createSwapChain(surface, swapChainDesc)); + device->CreateSwapChain(surface, &swapChainDesc)); return jsi::Value::undefined(); } @@ -50,7 +53,7 @@ class JsiWGPUContext : public JsiSkWrappingSharedPtrHostObject { if (!_swapChain) { throw jsi::JSError(runtime, "WGPU Context is not configured"); } - wgpu::Texture texture = _swapChain->getCurrentTexture(); + wgpu::Texture texture = _swapChain->GetCurrentTexture(); return jsi::Object::createFromHostObject( runtime, std::make_shared(getContext(), texture)); } @@ -59,78 +62,14 @@ class JsiWGPUContext : public JsiSkWrappingSharedPtrHostObject { if (!_swapChain) { throw jsi::JSError(runtime, "WGPU Context is not configured"); } - _swapChain->present(); + _swapChain->Present(); return jsi::Value::undefined(); } - JSI_HOST_FUNCTION(runDemo) { - auto device = JsiDevice::fromValue(runtime, arguments[0].asObject(runtime)); - // auto pipeline2 = - // JsiRenderPipeline::fromValue(runtime, - // arguments[1].asObject(runtime)); - auto commandEncoder = - JsiCommandEncoder::fromValue(runtime, arguments[2].asObject(runtime)); - auto vertexState = - JsiVertexState::fromValue(runtime, arguments[3].asObject(runtime)); - auto fragState = - JsiFragmentState::fromValue(runtime, arguments[4].asObject(runtime)); - - wgpu::RenderPipelineDescriptor pipelineDesc; - - // Vertex fetch - // (We don't use any input buffer so far) - pipelineDesc.vertex = *vertexState; - - // Primitive assembly and rasterization - // Each sequence of 3 vertices is considered as a triangle - pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::TriangleList; - // We'll see later how to specify the order in which vertices should be - // connected. When not specified, vertices are considered sequentially. - pipelineDesc.primitive.stripIndexFormat = wgpu::IndexFormat::Undefined; - // The face orientation is defined by assuming that when looking - // from the front of the face, its corner vertices are enumerated - // in the counter-clockwise (CCW) order. - pipelineDesc.primitive.frontFace = wgpu::FrontFace::CCW; - // But the face orientation does not matter much because we do not - // cull (i.e. "hide") the faces pointing away from us (which is often - // used for optimization). - pipelineDesc.primitive.cullMode = wgpu::CullMode::None; - - // Fragment shader - pipelineDesc.fragment = fragState; - - // wgpu::ColorTargetState colorTarget; - // colorTarget.format = fragState->targets[0].format; - // colorTarget.writeMask = fragState->targets[0].writeMask; - // fragState->targetCount = 1; - // fragState->targets = &colorTarget; - - // Depth and stencil tests are not used here - pipelineDesc.depthStencil = nullptr; - - // Multi-sampling - // Samples per pixel - pipelineDesc.multisample.count = 1; - // Default value for the mask, meaning "all bits on" - pipelineDesc.multisample.mask = ~0u; - // Default value as well (irrelevant for count = 1 anyways) - pipelineDesc.multisample.alphaToCoverageEnabled = false; - - // Pipeline layout - pipelineDesc.layout = nullptr; - - wgpu::RenderPipeline pipeline = device->createRenderPipeline(pipelineDesc); - std::cout << "Render pipeline: " << pipeline << std::endl; - - return jsi::Object::createFromHostObject( - runtime, std::make_shared(getContext(), pipeline)); - } - EXPORT_JSI_API_TYPENAME(JsiWGPUContext, WGPUContext) JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiWGPUContext, configure), JSI_EXPORT_FUNC(JsiWGPUContext, getCurrentTexture), - JSI_EXPORT_FUNC(JsiWGPUContext, present), - JSI_EXPORT_FUNC(JsiWGPUContext, runDemo)) + JSI_EXPORT_FUNC(JsiWGPUContext, present)) }; } // namespace RNSkia \ No newline at end of file diff --git a/package/cpp/wgpu/MutableJSIBuffer.h b/package/cpp/wgpu/MutableJSIBuffer.h new file mode 100644 index 0000000000..1d29ebb6ce --- /dev/null +++ b/package/cpp/wgpu/MutableJSIBuffer.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include "JsiHostObject.h" +#include "JsiPromises.h" +#include "JsiSkHostObjects.h" + +namespace RNSkia { + +namespace jsi = facebook::jsi; + +struct MutableJSIBuffer : jsi::MutableBuffer { + MutableJSIBuffer(void *data, size_t size) : _data(data), _size(size) {} + + size_t size() const override { return _size; } + + uint8_t *data() override { return reinterpret_cast(_data); } + + void *_data; + size_t _size; +}; + +} // namespace RNSkia \ No newline at end of file diff --git a/scripts/generator/common.ts b/scripts/generator/common.ts index 66bbfd3d0e..13d3812be5 100644 --- a/scripts/generator/common.ts +++ b/scripts/generator/common.ts @@ -2,9 +2,10 @@ import _ from "lodash"; import { JSIObject } from "./model"; import { isEnum } from "./enums"; -export const objectName = (name: string) => _.upperFirst(_.camelCase(name)).replace(/Wgsl/g, 'WGSL'); +const enums = ["BufferUsage", "TextureUsage", "ColorWriteMask"]; -export const isNumberType = (type: string) => type === "uint64_t" || type === "uint32_t" || type === "float" || type === "int32_t" || type === "size_t"; +export const objectName = (name: string) => _.upperFirst(_.camelCase(name)).replace(/Wgsl/g, 'WGSL'); +export const isNumberType = (type: string) => type === "uint64_t" || type === "uint32_t" || type === "float" || type === "int32_t" || type === "size_t" || enums.indexOf(type) > -1; export const isDouble = (type: string) => type === "double"; export const isAtomicType = (type: string) => type === "bool" || isDouble(type) || isNumberType(type) || type === "string"; @@ -14,6 +15,9 @@ export const unWrapType = (obj: string, type: string, pointer: boolean) => { } else if (isDouble(type)) { return `${obj}.getNumber()`; } else if (isNumberType(type)) { + if (enums.indexOf(type) > -1) { + return `static_cast(${obj}.getNumber())`; + } return `static_cast<${type}>(${obj}.getNumber())`; } else if (type === "string") { // TODO: the copy needs to be freed diff --git a/scripts/generator/constants.ts b/scripts/generator/constants.ts new file mode 100644 index 0000000000..a812a46a57 --- /dev/null +++ b/scripts/generator/constants.ts @@ -0,0 +1,67 @@ +import _ from "lodash"; + +const aliases: Record = { ColorWrite: "ColorWriteMask" }; + +const mapKey = (name: string) => { + const result = name.substring(3); + return aliases[result] ?? result; +} + +const constants: Record> = { + GPUBufferUsage: { + MAP_READ: 1, + MAP_WRITE: 2, + COPY_SRC: 4, + COPY_DST: 8, + INDEX: 16, + VERTEX: 32, + UNIFORM: 64, + STORAGE: 128, + INDIRECT: 256, + QUERY_RESOLVE: 512, + }, + GPUColorWrite: { + RED: 1, + GREEN: 2, + BLUE: 4, + ALPHA: 8, + ALL: 15, + }, + GPUMapMode: { + READ: 1, + WRITE: 2, + }, + GPUShaderStage: { + VERTEX: 1, + FRAGMENT: 2, + COMPUTE: 4, + }, + GPUTextureUsage: { + COPY_SRC: 1, + COPY_DST: 2, + TEXTURE_BINDING: 4, + STORAGE_BINDING: 8, + RENDER_ATTACHMENT: 16, + }, +} + +export const generateConstants = () => { + return `#pragma once + + #include + + #include "dawn/webgpu_cpp.h" + +namespace RNSkia { + +void installConstants (jsi::Runtime &runtime) { + ${Object.keys(constants).map((key) => { + return ` +jsi::Object ${key}(runtime); +${Object.keys(constants[key]).map((constant) => `${key}.setProperty(runtime, "${constant}", jsi::Value(${constants[key][constant]}));`).join('\n')} +runtime.global().setProperty(runtime, "${key}", ${key});`; + }).join('\n')} +} + +}`; +}; \ No newline at end of file diff --git a/scripts/generator/dawn.json b/scripts/generator/dawn.json index 9ef013214b..e777ef90d9 100644 --- a/scripts/generator/dawn.json +++ b/scripts/generator/dawn.json @@ -1,4 +1,44 @@ { + "_comment": [ + "Copyright 2017 The Dawn & Tint Authors", + "", + "Redistribution and use in source and binary forms, with or without", + "modification, are permitted provided that the following conditions are met:", + "", + " 1. Redistributions of source code must retain the above copyright notice, this", + " list of conditions and the following disclaimer.", + "", + " 2. Redistributions in binary form must reproduce the above copyright notice,", + " this list of conditions and the following disclaimer in the documentation", + " and/or other materials provided with the distribution.", + "", + " 3. Neither the name of the copyright holder nor the names of its", + " contributors may be used to endorse or promote products derived from", + " this software without specific prior written permission.", + " ", + "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"", + "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE", + "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE", + "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE", + "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL", + "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR", + "SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER", + "CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,", + "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE", + "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ], + + "_doc": "See docs/dawn/codegen.md", + + "_metadata": { + "api": "WebGPU", + "c_prefix": "WGPU", + "namespace": "wgpu", + "proc_table_prefix": "Dawn", + "native_namespace": "dawn native", + "copyright_year": "2019" + }, + "create instance": { "category": "function", "returns": "instance", @@ -55,9 +95,10 @@ "emscripten_no_enum_table": true, "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "unavailable"}, - {"value": 2, "name": "error"}, - {"value": 3, "name": "unknown"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "unavailable"}, + {"value": 3, "name": "error"}, + {"value": 4, "name": "unknown"} ] }, "adapter": { @@ -104,6 +145,16 @@ {"name": "userdata", "type": "void *"} ] }, + { + "name": "request device f", + "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.", + "tags": ["dawn", "emscripten"], + "returns": "future", + "args": [ + {"name": "options", "type": "device descriptor", "annotation": "const*", "optional": true, "no_default": true}, + {"name": "callback info", "type": "request device callback info"} + ] + }, { "name": "create device", "tags": ["dawn"], @@ -111,6 +162,15 @@ "args": [ {"name": "descriptor", "type": "device descriptor", "annotation": "const*", "optional": true} ] + }, + { + "name": "get format capabilities", + "tags": ["dawn"], + "returns": "bool", + "args": [ + {"name": "format", "type": "texture format"}, + {"name": "capabilities", "type": "format capabilities", "annotation": "*"} + ] } ] }, @@ -133,10 +193,10 @@ "category": "enum", "emscripten_no_enum_table": true, "values": [ - {"value": 0, "name": "discrete GPU"}, - {"value": 1, "name": "integrated GPU"}, - {"value": 2, "name": "CPU"}, - {"value": 3, "name": "unknown"} + {"value": 1, "name": "discrete GPU"}, + {"value": 2, "name": "integrated GPU"}, + {"value": 3, "name": "CPU"}, + {"value": 4, "name": "unknown"} ] }, "device descriptor": { @@ -164,21 +224,58 @@ {"name": "disabled toggles", "type": "char", "annotation": "const*const*", "length": "disabled toggle count"} ] }, + "dawn load cache data function": { + "tags": ["dawn", "native"], + "category": "function pointer", + "returns": "size_t", + "args": [ + {"name": "key", "type": "void const *"}, + {"name": "key size", "type": "size_t"}, + {"name": "value", "type": "void *"}, + {"name": "value size", "type": "size_t"}, + {"name": "userdata", "type": "void *"} + ] + }, + "dawn store cache data function": { + "tags": ["dawn", "native"], + "category": "function pointer", + "args": [ + {"name": "key", "type": "void const *"}, + {"name": "key size", "type": "size_t"}, + {"name": "value", "type": "void const *"}, + {"name": "value size", "type": "size_t"}, + {"name": "userdata", "type": "void *"} + ] + }, "dawn cache device descriptor" : { "tags": ["dawn", "native"], "category": "structure", "chained": "in", "chain roots": ["device descriptor"], "members": [ - {"name": "isolation key", "type": "char", "annotation": "const*", "length": "strlen", "default": "\"\""} + {"name": "isolation key", "type": "char", "annotation": "const*", "length": "strlen", "default": "\"\""}, + {"name": "load data function", "type": "dawn load cache data function", "default": "nullptr"}, + {"name": "store data function", "type": "dawn store cache data function", "default": "nullptr"}, + {"name": "function userdata", "type": "void *", "default": "nullptr"} + ] + }, + "dawn WGSL blocklist": { + "tags": ["dawn", "native"], + "category": "structure", + "chained": "in", + "chain roots": ["instance descriptor"], + "members": [ + {"name": "blocklisted feature count", "type": "size_t", "default": 0}, + {"name": "blocklisted features", "type": "char", "annotation": "const*const*", "length": "blocklisted feature count"} ] }, "address mode": { "category": "enum", "values": [ - {"value": 0, "name": "repeat"}, - {"value": 1, "name": "mirror repeat"}, - {"value": 2, "name": "clamp to edge"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "clamp to edge"}, + {"value": 2, "name": "repeat"}, + {"value": 3, "name": "mirror repeat"} ] }, "backend type": { @@ -278,7 +375,15 @@ {"name": "type", "type": "sampler binding type", "default": "undefined"} ] }, - + "static sampler binding layout": { + "category": "structure", + "chained": "in", + "chain roots": ["bind group layout entry"], + "tags": ["dawn"], + "members": [ + {"name": "sampler", "type": "sampler"} + ] + }, "texture sample type": { "category": "enum", "values": [ @@ -295,7 +400,7 @@ "extensible": "in", "members": [ {"name": "sample type", "type": "texture sample type", "default": "undefined"}, - {"name": "view dimension", "type": "texture view dimension", "default": "undefined"}, + {"name": "view dimension", "type": "texture view dimension", "default": "2D"}, {"name": "multisampled", "type": "bool", "default": "false"} ] }, @@ -358,8 +463,8 @@ "values": [ {"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false}, {"value": 1, "name": "write only"}, - {"value": 2, "name": "read only", "tags": ["dawn"]}, - {"value": 3, "name": "read write", "tags": ["dawn"]} + {"value": 2, "name": "read only"}, + {"value": 3, "name": "read write"} ] }, "storage texture binding layout": { @@ -368,7 +473,7 @@ "members": [ {"name": "access", "type": "storage texture access", "default": "undefined"}, {"name": "format", "type": "texture format", "default": "undefined"}, - {"name": "view dimension", "type": "texture view dimension", "default": "undefined"} + {"name": "view dimension", "type": "texture view dimension", "default": "2D"} ] }, @@ -404,34 +509,37 @@ }, "blend factor": { "category": "enum", + "_comment": "TODO(github.com/gpuweb/gpuweb/issues/4283): make sure the dual source blending names match the spec when it lands, and remove the tags.", "values": [ - {"value": 0, "name": "zero"}, - {"value": 1, "name": "one"}, - {"value": 2, "name": "src"}, - {"value": 3, "name": "one minus src"}, - {"value": 4, "name": "src alpha"}, - {"value": 5, "name": "one minus src alpha"}, - {"value": 6, "name": "dst"}, - {"value": 7, "name": "one minus dst"}, - {"value": 8, "name": "dst alpha"}, - {"value": 9, "name": "one minus dst alpha"}, - {"value": 10, "name": "src alpha saturated"}, - {"value": 11, "name": "constant"}, - {"value": 12, "name": "one minus constant"}, - {"value": 13, "name": "src1", "tags": ["dawn"]}, - {"value": 14, "name": "one minus src1", "tags": ["dawn"]}, - {"value": 15, "name": "src1 alpha", "tags": ["dawn"]}, - {"value": 16, "name": "one minus src1 alpha", "tags": ["dawn"]} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "zero"}, + {"value": 2, "name": "one"}, + {"value": 3, "name": "src"}, + {"value": 4, "name": "one minus src"}, + {"value": 5, "name": "src alpha"}, + {"value": 6, "name": "one minus src alpha"}, + {"value": 7, "name": "dst"}, + {"value": 8, "name": "one minus dst"}, + {"value": 9, "name": "dst alpha"}, + {"value": 10, "name": "one minus dst alpha"}, + {"value": 11, "name": "src alpha saturated"}, + {"value": 12, "name": "constant"}, + {"value": 13, "name": "one minus constant"}, + {"value": 14, "name": "src1", "tags": ["dawn"]}, + {"value": 15, "name": "one minus src1", "tags": ["dawn"]}, + {"value": 16, "name": "src1 alpha", "tags": ["dawn"]}, + {"value": 17, "name": "one minus src1 alpha", "tags": ["dawn"]} ] }, "blend operation": { "category": "enum", "values": [ - {"value": 0, "name": "add"}, - {"value": 1, "name": "subtract"}, - {"value": 2, "name": "reverse subtract"}, - {"value": 3, "name": "min"}, - {"value": 4, "name": "max"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "add"}, + {"value": 2, "name": "subtract"}, + {"value": 3, "name": "reverse subtract"}, + {"value": 4, "name": "min"}, + {"value": 5, "name": "max"} ] }, "bool": { @@ -554,22 +662,23 @@ "emscripten_no_enum_table": true, "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "validation error"}, - {"value": 2, "name": "unknown"}, - {"value": 3, "name": "device lost"}, - {"value": 4, "name": "destroyed before callback"}, - {"value": 5, "name": "unmapped before callback"}, - {"value": 6, "name": "mapping already pending"}, - {"value": 7, "name": "offset out of range"}, - {"value": 8, "name": "size out of range"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "validation error"}, + {"value": 3, "name": "unknown"}, + {"value": 4, "name": "device lost"}, + {"value": 5, "name": "destroyed before callback"}, + {"value": 6, "name": "unmapped before callback"}, + {"value": 7, "name": "mapping already pending"}, + {"value": 8, "name": "offset out of range"}, + {"value": 9, "name": "size out of range"} ] }, "buffer map state": { "category": "enum", "values": [ - {"value": 0, "name": "unmapped"}, - {"value": 1, "name": "pending"}, - {"value": 2, "name": "mapped"} + {"value": 1, "name": "unmapped"}, + {"value": 2, "name": "pending"}, + {"value": 3, "name": "mapped"} ] }, "buffer usage": { @@ -774,14 +883,14 @@ "compare function": { "category": "enum", "values": [ - {"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false}, + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, {"value": 1, "name": "never"}, {"value": 2, "name": "less"}, - {"value": 3, "name": "less equal"}, - {"value": 4, "name": "greater"}, - {"value": 5, "name": "greater equal"}, - {"value": 6, "name": "equal"}, - {"value": 7, "name": "not equal"}, + {"value": 3, "name": "equal"}, + {"value": 4, "name": "less equal"}, + {"value": 5, "name": "greater"}, + {"value": 6, "name": "not equal"}, + {"value": 7, "name": "greater equal"}, {"value": 8, "name": "always"} ] }, @@ -801,13 +910,23 @@ {"name": "userdata", "type": "void *"} ] }, + "compilation info callback info": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "mode", "type": "callback mode"}, + {"name": "callback", "type": "compilation info callback"}, + {"name": "userdata", "type": "void *", "default": "nullptr"} + ] + }, "compilation info request status": { "category": "enum", "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "error"}, - {"value": 2, "name": "device lost"}, - {"value": 3, "name": "unknown"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "error"}, + {"value": 3, "name": "device lost"}, + {"value": 4, "name": "unknown"} ] }, "compilation message": { @@ -829,9 +948,9 @@ "category": "enum", "emscripten_no_enum_table": true, "values": [ - {"value": 0, "name": "error"}, - {"value": 1, "name": "warning"}, - {"value": 2, "name": "info"} + {"value": 1, "name": "error"}, + {"value": 2, "name": "warning"}, + {"value": 3, "name": "info"} ] }, "compute pass descriptor": { @@ -963,6 +1082,7 @@ "category": "structure", "chained": "in", "chain roots": ["compute pipeline descriptor"], + "tags": ["dawn"], "members": [ {"name": "requires full subgroups", "type": "bool", "default": "false"} ] @@ -971,9 +1091,9 @@ "category": "enum", "tags": ["dawn"], "values": [ - {"value": 0, "name": "premultiplied"}, - {"value": 1, "name": "unpremultiplied"}, - {"value": 2, "name": "opaque"} + {"value": 1, "name": "opaque"}, + {"value": 2, "name": "premultiplied"}, + {"value": 3, "name": "unpremultiplied"} ] }, "copy texture for browser options": { @@ -1003,16 +1123,26 @@ {"name": "userdata", "type": "void *"} ] }, + "create compute pipeline async callback info": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "mode", "type": "callback mode"}, + {"name": "callback", "type": "create compute pipeline async callback"}, + {"name": "userdata", "type": "void *"} + ] + }, "create pipeline async status": { "category": "enum", "emscripten_no_enum_table": true, "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "validation error"}, - {"value": 2, "name": "internal error"}, - {"value": 3, "name": "device lost"}, - {"value": 4, "name": "device destroyed"}, - {"value": 5, "name": "unknown"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "validation error"}, + {"value": 3, "name": "internal error"}, + {"value": 4, "name": "device lost"}, + {"value": 5, "name": "device destroyed"}, + {"value": 6, "name": "unknown"} ] }, "create render pipeline async callback": { @@ -1024,12 +1154,22 @@ {"name": "userdata", "type": "void *"} ] }, + "create render pipeline async callback info": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "mode", "type": "callback mode"}, + {"name": "callback", "type": "create render pipeline async callback"}, + {"name": "userdata", "type": "void *"} + ] + }, "cull mode": { "category": "enum", "values": [ - {"value": 0, "name": "none"}, - {"value": 1, "name": "front"}, - {"value": 2, "name": "back"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "none"}, + {"value": 2, "name": "front"}, + {"value": 3, "name": "back"} ] }, "device": { @@ -1051,6 +1191,7 @@ }, { "name": "create buffer", + "no autolock": true, "returns": "buffer", "args": [ {"name": "descriptor", "type": "buffer descriptor", "annotation": "const*"} @@ -1073,6 +1214,7 @@ }, { "name": "create compute pipeline", + "no autolock": true, "returns": "compute pipeline", "args": [ {"name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"} @@ -1087,6 +1229,16 @@ {"name": "userdata", "type": "void *"} ] }, + { + "name": "create compute pipeline async f", + "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.", + "tags": ["dawn", "emscripten"], + "returns": "future", + "args": [ + {"name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"}, + {"name": "callback info", "type": "create compute pipeline async callback info"} + ] + }, { "name": "create external texture", "returns": "external texture", @@ -1123,6 +1275,16 @@ {"name": "userdata", "type": "void *"} ] }, + { + "name": "create render pipeline async f", + "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.", + "tags": ["dawn", "emscripten"], + "returns": "future", + "args": [ + {"name": "descriptor", "type": "render pipeline descriptor", "annotation": "const*"}, + {"name": "callback info", "type": "create render pipeline async callback info"} + ] + }, { "name": "create render bundle encoder", "returns": "render bundle encoder", @@ -1132,6 +1294,7 @@ }, { "name": "create render pipeline", + "no autolock": true, "returns": "render pipeline", "args": [ {"name": "descriptor", "type": "render pipeline descriptor", "annotation": "const*"} @@ -1146,6 +1309,7 @@ }, { "name": "create shader module", + "no autolock": true, "returns": "shader module", "args": [ {"name": "descriptor", "type": "shader module descriptor", "annotation": "const*"} @@ -1176,6 +1340,14 @@ {"name": "descriptor", "type": "texture descriptor", "annotation": "const*"} ] }, + { + "name": "import shared buffer memory", + "returns": "shared buffer memory", + "tags": ["dawn", "native"], + "args": [ + {"name": "descriptor", "type": "shared buffer memory descriptor", "annotation": "const*"} + ] + }, { "name": "import shared texture memory", "returns": "shared texture memory", @@ -1288,11 +1460,21 @@ }, { "name": "pop error scope", + "no autolock": true, "args": [ - {"name": "callback", "type": "error callback"}, + {"name": "old callback", "type": "error callback"}, {"name": "userdata", "type": "void *"} ] }, + { + "name": "pop error scope f", + "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.", + "tags": ["dawn", "emscripten"], + "returns": "future", + "args": [ + {"name": "callback info", "type": "pop error scope callback info"} + ] + }, { "name": "set label", "returns": "void", @@ -1344,6 +1526,33 @@ {"name": "userdata", "type": "void *"} ] }, + "pop error scope status": { + "category": "enum", + "emscripten_no_enum_table": true, + "values": [ + {"value": 0, "name": "success"}, + {"value": 1, "name": "instance dropped"} + ] + }, + "pop error scope callback": { + "category": "function pointer", + "args": [ + {"name": "status", "type": "pop error scope status"}, + {"name": "type", "type": "error type"}, + {"name": "message", "type": "char", "annotation": "const*", "length": "strlen"}, + {"name": "userdata", "type": "void *"} + ] + }, + "pop error scope callback info": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "mode", "type": "callback mode"}, + {"name": "callback", "type": "pop error scope callback"}, + {"name": "old callback", "type": "error callback", "_comment": "TODO(crbug.com/dawn/2021) Deprecate this field once we have moved callers to use the new callback signature."}, + {"name": "userdata", "type": "void *", "default": "nullptr"} + ] + }, "limits": { "category": "structure", "members": [ @@ -1385,6 +1594,7 @@ "category": "structure", "chained": "out", "chain roots": ["supported limits"], + "tags": ["dawn"], "members": [ {"name": "min subgroup size", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"}, {"name": "max subgroup size", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"} @@ -1416,9 +1626,9 @@ "error filter": { "category": "enum", "values": [ - {"value": 0, "name": "validation"}, - {"value": 1, "name": "out of memory"}, - {"value": 2, "name": "internal"} + {"value": 1, "name": "validation"}, + {"value": 2, "name": "out of memory"}, + {"value": 3, "name": "internal"} ] }, "error type": { @@ -1437,10 +1647,10 @@ "category": "enum", "tags": ["dawn"], "values": [ - {"value": 0, "name": "verbose"}, - {"value": 1, "name": "info"}, - {"value": 2, "name": "warning"}, - {"value": 3, "name": "error"} + {"value": 1, "name": "verbose"}, + {"value": 2, "name": "info"}, + {"value": 3, "name": "warning"}, + {"value": 4, "name": "error"} ] }, "extent 2D": { @@ -1487,6 +1697,7 @@ "external texture rotation":{ "category": "enum", "tags": ["dawn"], + "_comment": "ANGLEs are clockwise rotation degrees and not trigonometric.", "values": [ {"value": 0, "name": "rotate 0 degrees"}, {"value": 1, "name": "rotate 90 degrees"}, @@ -1498,6 +1709,7 @@ "category": "structure", "extensible": "in", "tags": ["dawn"], + "_comment": "TODO(crbug.com/1514732): deprecate flipY", "members": [ {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true}, {"name": "plane 0", "type": "texture view"}, @@ -1513,10 +1725,76 @@ "length": 7}, {"name": "gamut conversion matrix", "type": "float", "annotation": "const*", "length": 9}, - {"name": "flip y", "type": "bool", "default": "false"}, + {"name": "flip y", "type": "bool", "default": "false", "tags": ["deprecated"]}, + {"name": "mirrored", "type": "bool", "default": "false"}, {"name": "rotation", "type": "external texture rotation", "default": "rotate 0 degrees"} ] }, + "shared buffer memory": { + "category": "object", + "tags": ["dawn", "native"], + "methods": [ + { + "name": "set label", + "returns": "void", + "args": [ + {"name": "label", "type": "char", "annotation": "const*", "length": "strlen"} + ] + }, + { + "name": "get properties", + "returns": "void", + "args": [ + {"name": "properties", "type": "shared buffer memory properties", "annotation": "*"} + ] + }, + { + "name": "create buffer", + "returns": "buffer", + "args": [ + {"name": "descriptor", "type": "buffer descriptor", "annotation": "const*", "optional": true, "default": "nullptr"} + ] + }, + { + "name": "begin access", + "returns": "bool", + "args": [ + {"name": "buffer", "type": "buffer"}, + {"name": "descriptor", "type": "shared buffer memory begin access descriptor", "annotation": "const*"} + ] + }, + { + "name": "end access", + "returns": "bool", + "args": [ + {"name": "buffer", "type": "buffer"}, + {"name": "descriptor", "type": "shared buffer memory end access state", "annotation": "*"} + ] + }, + { + "name": "is device lost", + "returns": "bool", + "args": [] + } + ] + }, + "shared buffer memory properties": { + "category": "structure", + "extensible": "out", + "tags": ["dawn", "native"], + "members": [ + {"name": "usage", "type": "buffer usage"}, + {"name": "size", "type": "uint64_t"} + ] + }, + "shared buffer memory descriptor": { + "category": "structure", + "extensible": "in", + "tags": ["dawn", "native"], + "members": [ + {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true} + ] + }, "shared texture memory": { "category": "object", "tags": ["dawn", "native"], @@ -1583,6 +1861,28 @@ {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true} ] }, + "shared buffer memory begin access descriptor": { + "category": "structure", + "extensible": "in", + "tags": ["dawn", "native"], + "members": [ + {"name": "initialized", "type": "bool"}, + {"name": "fence count", "type": "size_t"}, + {"name": "fences", "type": "shared fence", "annotation": "const*", "length": "fence count"}, + {"name": "signaled values", "type": "uint64_t", "annotation": "const*", "length": "fence count"} + ] + }, + "shared buffer memory end access state": { + "category": "structure", + "extensible": "out", + "tags": ["dawn", "native"], + "members": [ + {"name": "initialized", "type": "bool"}, + {"name": "fence count", "type": "size_t"}, + {"name": "fences", "type": "shared fence", "annotation": "const*", "length": "fence count"}, + {"name": "signaled values", "type": "uint64_t", "annotation": "const*", "length": "fence count"} + ] + }, "shared texture memory vk image descriptor": { "category": "structure", "chained": "in", @@ -1640,8 +1940,11 @@ "chain roots": ["shared texture memory descriptor"], "tags": ["dawn", "native"], "members": [ + {"name": "vk image create info", "type": "void const *"}, {"name": "memory FD", "type": "int"}, - {"name": "allocation size", "type": "uint64_t"} + {"name": "memory type index", "type": "uint32_t"}, + {"name": "allocation size", "type": "uint64_t"}, + {"name": "dedicated allocation", "type": "bool"} ] }, "shared texture memory zircon handle descriptor": { @@ -1661,7 +1964,8 @@ "tags": ["dawn", "native"], "_comment": "TODO(crbug.com/dawn/1745): improve type safety", "members": [ - {"name": "handle", "type": "void *"} + {"name": "handle", "type": "void *"}, + {"name": "use keyed mutex", "type": "bool"} ] }, "shared texture memory IO surface descriptor": { @@ -1689,6 +1993,7 @@ "extensible": "in", "tags": ["dawn", "native"], "members": [ + {"name": "concurrent read", "type": "bool"}, {"name": "initialized", "type": "bool"}, {"name": "fence count", "type": "size_t"}, {"name": "fences", "type": "shared fence", "annotation": "const*", "length": "fence count"}, @@ -1875,12 +2180,11 @@ {"value": 8, "name": "shader f16"}, {"value": 9, "name": "RG11B10 ufloat renderable"}, {"value": 10, "name": "BGRA8 unorm storage"}, - {"value": 11, "name": "float32 filterable"}, + {"value": 11, "name": "float32 filterable", "jsrepr": "'float32-filterable'"}, {"value": 1002, "name": "dawn internal usages", "tags": ["dawn"]}, {"value": 1003, "name": "dawn multi planar formats", "tags": ["dawn"]}, {"value": 1004, "name": "dawn native", "tags": ["dawn", "native"]}, - {"value": 1005, "name": "chromium experimental dp4a", "tags": ["dawn"]}, {"value": 1006, "name": "chromium experimental timestamp query inside passes", "tags": ["dawn"]}, {"value": 1007, "name": "implicit device synchronization", "tags": ["dawn", "native"]}, {"value": 1008, "name": "surface capabilities", "tags": ["dawn", "native"]}, @@ -1893,15 +2197,22 @@ {"value": 1015, "name": "chromium experimental subgroup uniform control flow", "tags": ["dawn"]}, {"value": 1017, "name": "pixel local storage coherent", "tags": ["dawn"]}, {"value": 1018, "name": "pixel local storage non coherent", "tags": ["dawn"]}, - {"value": 1019, "name": "norm16 texture formats", "tags": ["dawn"]}, - {"value": 1020, "name": "multi planar format extended usages", "tags": ["dawn"]}, - {"value": 1021, "name": "multi planar format p010", "tags": ["dawn"]}, - {"value": 1022, "name": "host mapped pointer", "tags": ["dawn"]}, - {"value": 1023, "name": "multi planar render targets", "tags": ["dawn"]}, - {"value": 1024, "name": "multi planar format nv12a", "tags": ["dawn"]}, - {"value": 1025, "name": "framebuffer fetch", "tags": ["dawn"]}, - {"value": 1026, "name": "buffer map extended usages", "tags": ["dawn"]}, - {"value": 1027, "name": "adapter properties memory heaps", "tags": ["dawn"]}, + {"value": 1019, "name": "unorm16 texture formats", "tags": ["dawn"]}, + {"value": 1020, "name": "snorm16 texture formats", "tags": ["dawn"]}, + {"value": 1021, "name": "multi planar format extended usages", "tags": ["dawn"]}, + {"value": 1022, "name": "multi planar format p010", "tags": ["dawn"]}, + {"value": 1023, "name": "host mapped pointer", "tags": ["dawn"]}, + {"value": 1024, "name": "multi planar render targets", "tags": ["dawn"]}, + {"value": 1025, "name": "multi planar format nv12a", "tags": ["dawn"]}, + {"value": 1026, "name": "framebuffer fetch", "tags": ["dawn"]}, + {"value": 1027, "name": "buffer map extended usages", "tags": ["dawn"]}, + {"value": 1028, "name": "adapter properties memory heaps", "tags": ["dawn"]}, + {"value": 1029, "name": "adapter properties D3D", "tags": ["dawn"]}, + {"value": 1030, "name": "adapter properties vk", "tags": ["dawn"]}, + {"value": 1031, "name": "r8 unorm storage", "tags": ["dawn"]}, + {"value": 1032, "name": "format capabilities", "tags": ["dawn"]}, + {"value": 1033, "name": "drm format capabilities", "tags": ["dawn"]}, + {"value": 1034, "name": "norm16 texture formats", "tags": ["dawn"]}, {"value": 1100, "name": "shared texture memory vk dedicated allocation", "tags": ["dawn", "native"]}, {"value": 1101, "name": "shared texture memory a hardware buffer", "tags": ["dawn", "native"]}, @@ -1916,24 +2227,52 @@ {"value": 1201, "name": "shared fence vk semaphore sync FD", "tags": ["dawn", "native"]}, {"value": 1202, "name": "shared fence vk semaphore zircon handle", "tags": ["dawn", "native"]}, {"value": 1203, "name": "shared fence DXGI shared handle", "tags": ["dawn", "native"]}, - {"value": 1204, "name": "shared fence MTL shared event", "tags": ["dawn", "native"]} + {"value": 1204, "name": "shared fence MTL shared event", "tags": ["dawn", "native"]}, + {"value": 1205, "name": "shared buffer memory D3D12 resource", "tags": ["dawn", "native"]}, + {"value": 1206, "name": "static samplers", "tags": ["dawn"]} ] }, "filter mode": { "category": "enum", "values": [ - {"value": 0, "name": "nearest"}, - {"value": 1, "name": "linear"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "nearest"}, + {"value": 2, "name": "linear"} ] }, "float": { "category": "native" }, + "format capabilities": { + "category": "structure", + "tags": ["dawn"], + "extensible": "out", + "members": [] + }, + "drm format capabilities": { + "category": "structure", + "tags": ["dawn"], + "chained": "out", + "chain roots": ["format capabilities"], + "members": [ + {"name": "properties count", "type": "size_t"}, + {"name": "properties", "type": "drm format properties", "annotation": "const*", "length": "properties count"} + ] + }, + "drm format properties": { + "category": "structure", + "tags": ["dawn"], + "members": [ + {"name": "modifier", "type": "uint64_t"}, + {"name": "modifier plane count", "type": "uint32_t"} + ] + }, "front face": { "category": "enum", "values": [ - {"value": 0, "name": "CCW"}, - {"value": 1, "name": "CW"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "CCW"}, + {"value": 2, "name": "CW"} ] }, "image copy buffer": { @@ -2031,10 +2370,12 @@ }, "callback mode": { "category": "enum", + "emscripten_no_enum_table": true, + "_comment": "TODO(crbug.com/dawn/2224): Should this be renumbered to reserve 0?", "values": [ - {"name": "wait any only", "value": 0}, - {"name": "allow process events", "value": 1}, - {"name": "allow spontaneous", "value": 2} + {"value": 0, "name": "wait any only"}, + {"value": 1, "name": "allow process events"}, + {"value": 2, "name": "allow spontaneous"} ] }, "future": { @@ -2048,12 +2389,12 @@ "_comment": "TODO(crbug.com/dawn/2053): This could possibly be [[nodiscard]].", "emscripten_no_enum_table": true, "values": [ - {"name": "success", "value": 0}, - {"name": "timed out", "value": 1}, - {"name": "unsupported timeout", "value": 2}, - {"name": "unsupported count", "value": 3}, - {"name": "unsupported mixed sources", "value": 4}, - {"name": "unknown", "value": 5} + {"value": 0, "name": "success"}, + {"value": 1, "name": "timed out"}, + {"value": 2, "name": "unsupported timeout"}, + {"value": 3, "name": "unsupported count"}, + {"value": 4, "name": "unsupported mixed sources"}, + {"value": 5, "name": "unknown"} ] }, "future wait info": { @@ -2086,6 +2427,17 @@ {"name": "features", "type": "instance features", "annotation": "*"} ] }, + "dawn wire WGSL control": { + "category": "structure", + "tags": ["dawn"], + "chained": "in", + "chain roots": ["instance descriptor"], + "members": [ + {"name": "enable experimental", "type": "bool", "default": "false"}, + {"name": "enable unsafe", "type": "bool", "default": "false"}, + {"name": "enable testing", "type": "bool", "default": "false"} + ] + }, "vertex attribute": { "category": "structure", "extensible": false, @@ -2108,9 +2460,10 @@ "vertex step mode": { "category": "enum", "values": [ - {"value": 0, "name": "vertex"}, - {"value": 1, "name": "instance"}, - {"value": 2, "name": "vertex buffer not used", "jsrepr": "undefined", "valid": true} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "vertex buffer not used"}, + {"value": 2, "name": "vertex"}, + {"value": 3, "name": "instance"} ] }, "load op": { @@ -2132,8 +2485,9 @@ "mipmap filter mode": { "category": "enum", "values": [ - {"value": 0, "name": "nearest"}, - {"value": 1, "name": "linear"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "nearest"}, + {"value": 2, "name": "linear"} ] }, "store op": { @@ -2213,10 +2567,10 @@ "category": "enum", "emscripten_no_enum_table": true, "values": [ - {"value": 0, "name": "fifo"}, - {"value": 1, "name": "fifo relaxed", "tags": ["upstream"]}, - {"value": 2, "name": "immediate"}, - {"value": 3, "name": "mailbox"} + {"value": 1, "name": "fifo"}, + {"value": 2, "name": "fifo relaxed", "tags": ["upstream"]}, + {"value": 3, "name": "immediate"}, + {"value": 4, "name": "mailbox"} ] }, "programmable stage descriptor": { @@ -2232,11 +2586,12 @@ "primitive topology": { "category": "enum", "values": [ - {"value": 0, "name": "point list"}, - {"value": 1, "name": "line list"}, - {"value": 2, "name": "line strip"}, - {"value": 3, "name": "triangle list"}, - {"value": 4, "name": "triangle strip"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "point list"}, + {"value": 2, "name": "line list"}, + {"value": 3, "name": "line strip"}, + {"value": 4, "name": "triangle list"}, + {"value": 5, "name": "triangle strip"} ] }, "query set": { @@ -2274,8 +2629,8 @@ "query type": { "category": "enum", "values": [ - {"value": 0, "name": "occlusion"}, - {"value": 1, "name": "timestamp"} + {"value": 1, "name": "occlusion"}, + {"value": 2, "name": "timestamp"} ] }, "queue": { @@ -2392,9 +2747,10 @@ "emscripten_no_enum_table": true, "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "error"}, - {"value": 2, "name": "unknown"}, - {"value": 3, "name": "device lost"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "error"}, + {"value": 3, "name": "unknown"}, + {"value": 4, "name": "device lost"} ] }, @@ -2812,14 +3168,24 @@ {"name": "userdata", "type": "void *"} ] }, + "request device callback info": { + "category": "structure", + "extensible": "in", + "members": [ + {"name": "mode", "type": "callback mode"}, + {"name": "callback", "type": "request device callback"}, + {"name": "userdata", "type": "void *"} + ] + }, "request device status": { "category": "enum", "emscripten_no_enum_table": true, "values": [ {"value": 0, "name": "success"}, - {"value": 1, "name": "error"}, - {"value": 2, "name": "unknown"} + {"value": 1, "name": "instance dropped"}, + {"value": 2, "name": "error"}, + {"value": 3, "name": "unknown"} ] }, @@ -2986,6 +3352,15 @@ {"name": "userdata", "type": "void *"} ] }, + { + "name": "get compilation info f", + "_comment": "TODO(crbug.com/dawn/2021): This is dawn/emscripten-only until we rename it to replace the old API. See bug for details.", + "tags": ["dawn", "emscripten"], + "returns": "future", + "args": [ + {"name": "callback info", "type": "compilation info callback info"} + ] + }, { "name": "set label", "returns": "void", @@ -3051,14 +3426,15 @@ "stencil operation": { "category": "enum", "values": [ - {"value": 0, "name": "keep"}, - {"value": 1, "name": "zero"}, - {"value": 2, "name": "replace"}, - {"value": 3, "name": "invert"}, - {"value": 4, "name": "increment clamp"}, - {"value": 5, "name": "decrement clamp"}, - {"value": 6, "name": "increment wrap"}, - {"value": 7, "name": "decrement wrap"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "keep"}, + {"value": 2, "name": "zero"}, + {"value": 3, "name": "replace"}, + {"value": 4, "name": "invert"}, + {"value": 5, "name": "increment clamp"}, + {"value": 6, "name": "decrement clamp"}, + {"value": 7, "name": "increment wrap"}, + {"value": 8, "name": "decrement wrap"} ] }, "stencil face state": { @@ -3103,7 +3479,6 @@ { "name": "get preferred format", "returns": "texture format", - "tags": ["upstream", "emscripten"], "args": [ {"name": "adapter", "type": "adapter"} ] @@ -3284,7 +3659,12 @@ {"value": 1017, "name": "buffer host mapped pointer", "tags": ["dawn"]}, {"value": 1018, "name": "dawn experimental subgroup limits", "tags": ["dawn"]}, {"value": 1019, "name": "adapter properties memory heaps", "tags": ["dawn"]}, - {"value": 1020, "name": "dawn compute pipeline full subgroups", "tags": ["dawn"]}, + {"value": 1020, "name": "adapter properties D3D", "tags": ["dawn"]}, + {"value": 1021, "name": "adapter properties vk", "tags": ["dawn"]}, + {"value": 1022, "name": "dawn compute pipeline full subgroups", "tags": ["dawn"]}, + {"value": 1023, "name": "dawn wire WGSL control", "tags": ["dawn"]}, + {"value": 1024, "name": "dawn WGSL blocklist", "tags": ["dawn", "native"]}, + {"value": 1025, "name": "drm format capabilities", "tags": ["dawn"]}, {"value": 1100, "name": "shared texture memory vk image descriptor", "tags": ["dawn", "native"]}, {"value": 1101, "name": "shared texture memory vk dedicated allocation descriptor", "tags": ["dawn", "native"]}, @@ -3309,7 +3689,9 @@ {"value": 1210, "name": "shared fence DXGI shared handle descriptor", "tags": ["dawn", "native"]}, {"value": 1211, "name": "shared fence DXGI shared handle export info", "tags": ["dawn", "native"]}, {"value": 1212, "name": "shared fence MTL shared event descriptor", "tags": ["dawn", "native"]}, - {"value": 1213, "name": "shared fence MTL shared event export info", "tags": ["dawn", "native"]} + {"value": 1213, "name": "shared fence MTL shared event export info", "tags": ["dawn", "native"]}, + {"value": 1214, "name": "shared buffer memory D3D12 resource descriptor", "tags": ["dawn", "native"]}, + {"value": 1215, "name": "static sampler binding layout", "tags": ["dawn"]} ] }, "texture": { @@ -3322,6 +3704,14 @@ {"name": "descriptor", "type": "texture view descriptor", "annotation": "const*", "optional": true} ] }, + { + "name": "create error view", + "returns": "texture view", + "tags": ["dawn"], + "args": [ + {"name": "descriptor", "type": "texture view descriptor", "annotation": "const*", "optional": true} + ] + }, { "name": "set label", "returns": "void", @@ -3381,12 +3771,13 @@ "texture aspect": { "category": "enum", "values": [ - {"value": 0, "name": "all"}, - {"value": 1, "name": "stencil only"}, - {"value": 2, "name": "depth only"}, - {"value": 3, "name": "plane 0 only", "tags": ["dawn"]}, - {"value": 4, "name": "plane 1 only", "tags": ["dawn"]}, - {"value": 5, "name": "plane 2 only", "tags": ["dawn"]} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "all"}, + {"value": 2, "name": "stencil only"}, + {"value": 3, "name": "depth only"}, + {"value": 4, "name": "plane 0 only", "tags": ["dawn"]}, + {"value": 5, "name": "plane 1 only", "tags": ["dawn"]}, + {"value": 6, "name": "plane 2 only", "tags": ["dawn"]} ] }, "texture data layout": { @@ -3424,15 +3815,16 @@ "texture dimension": { "category": "enum", "values": [ - {"value": 0, "name": "1D"}, - {"value": 1, "name": "2D"}, - {"value": 2, "name": "3D"} + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, + {"value": 1, "name": "1D"}, + {"value": 2, "name": "2D"}, + {"value": 3, "name": "3D"} ] }, "texture format": { "category": "enum", "values": [ - {"value": 0, "name": "undefined", "valid": false, "jsrepr": "undefined"}, + {"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false}, {"value": 1, "name": "R8 unorm"}, {"value": 2, "name": "R8 snorm"}, @@ -3592,7 +3984,7 @@ "texture view dimension": { "category": "enum", "values": [ - {"value": 0, "name": "undefined", "valid": false, "jsrepr": "undefined"}, + {"value": 0, "name": "undefined", "jsrepr": "undefined"}, {"value": 1, "name": "1D"}, {"value": 2, "name": "2D"}, {"value": 3, "name": "2D array"}, @@ -3604,7 +3996,7 @@ "vertex format": { "category": "enum", "values": [ - {"value": 0, "name": "undefined", "valid": false, "jsrepr": "undefined"}, + {"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false}, {"value": 1, "name": "uint8x2"}, {"value": 2, "name": "uint8x4"}, {"value": 3, "name": "sint8x2"}, @@ -3642,15 +4034,15 @@ "category": "enum", "values": [ {"value": 0, "name": "undefined", "valid": false, "jsrepr": "undefined"}, - {"value": 1, "name": "readonly and readwrite storage textures"}, - {"value": 2, "name": "packed 4x8 integer dot product"}, - {"value": 3, "name": "unrestricted pointer parameters"}, - {"value": 4, "name": "pointer composite access"}, - {"value": 1000, "name": "chromium testing unimplemented", "tags": ["dawn"]}, - {"value": 1001, "name": "chromium testing unsafe experimental", "tags": ["dawn"]}, - {"value": 1002, "name": "chromium testing experimental", "tags": ["dawn"]}, - {"value": 1003, "name": "chromium testing shipped with killswitch", "tags": ["dawn"]}, - {"value": 1004, "name": "chromium testing shipped", "tags": ["dawn"]} + {"value": 1, "name": "readonly and readwrite storage textures", "jsrepr": "'readonly_and_readwrite_storage_textures'"}, + {"value": 2, "name": "packed 4x8 integer dot product", "jsrepr": "'packed_4x8_integer_dot_product'"}, + {"value": 3, "name": "unrestricted pointer parameters", "jsrepr": "'unrestricted_pointer_parameters'"}, + {"value": 4, "name": "pointer composite access", "jsrepr": "'pointer_composite_access'"}, + {"value": 1000, "name": "chromium testing unimplemented", "jsrepr": "'chromium_testing_unimplemented'", "tags": ["dawn"]}, + {"value": 1001, "name": "chromium testing unsafe experimental", "jsrepr": "'chromium_testing_unsafe_experimental'", "tags": ["dawn"]}, + {"value": 1002, "name": "chromium testing experimental", "jsrepr": "'chromium_testing_experimental'", "tags": ["dawn"]}, + {"value": 1003, "name": "chromium testing shipped with killswitch", "jsrepr": "'chromium_testing_shipped_with_killswitch'", "tags": ["dawn"]}, + {"value": 1004, "name": "chromium testing shipped", "jsrepr": "'chromium_testing_shipped'", "tags": ["dawn"]} ] }, "whole size" : { @@ -3691,7 +4083,7 @@ "depth slice undefined" : { "category": "constant", "type": "uint32_t", - "value": "(0xffffffffUL)" + "value": "UINT32_MAX" }, "query set index undefined" : { "category": "constant", @@ -3798,6 +4190,24 @@ {"name": "heap info", "type": "memory heap info", "annotation": "const*", "length": "heap count"} ] }, + "adapter properties D3D": { + "category": "structure", + "chained": "out", + "chain roots": ["adapter properties"], + "tags": ["dawn"], + "members": [ + {"name": "shader model", "type": "uint32_t"} + ] + }, + "adapter properties vk": { + "category": "structure", + "chained": "out", + "chain roots": ["adapter properties"], + "tags": ["dawn"], + "members": [ + {"name": "driver version", "type": "uint32_t"} + ] + }, "dawn buffer descriptor error info from wire client": { "category": "structure", "chained": "in", diff --git a/scripts/generator/enums.ts b/scripts/generator/enums.ts index 529333b5d4..bb681e45bb 100644 --- a/scripts/generator/enums.ts +++ b/scripts/generator/enums.ts @@ -6,10 +6,10 @@ export const isEnum = (type: string) => enums[type] !== undefined; const convertString = (input: string) => { const map: Record = { - "1d": "_1D", - "2d": "_2D", - "3d": "_3D", - "2d-array": "_2DArray", + "1d": "e1D", + "2d": "e2D", + "3d": "e3D", + "2d-array": "e2DArray", } if (map[input] !== undefined) { return map[input]; @@ -48,7 +48,7 @@ export const generateEnums = (enums: Record) => { #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" namespace RNSkia { ${Object.keys(enums).map(name => { diff --git a/scripts/generator/generateObject.ts b/scripts/generator/generateObject.ts index 0a80291ee2..e7e84c7fce 100644 --- a/scripts/generator/generateObject.ts +++ b/scripts/generator/generateObject.ts @@ -26,10 +26,12 @@ for (int i = 0; i < jsiArraySize; i++) { let unwrap = ''; if (arg.type === "bool") { unwrap = `${name}.asBool()`; + } else if (arg.type === "string") { + unwrap = `strdup(arguments[${index}].asString(runtime).utf8(runtime).c_str())`; } else if (isNumberType(arg.type)) { unwrap = unWrapType(`arguments[${index}]`, arg.type, false); } else if (isEnum(arg.type)) { - unwrap = `get${arg.type}(arguments[${index}].asString().utf8(runtime).c_str())`; + unwrap = `get${arg.type}(arguments[${index}].asString(runtime).utf8(runtime).c_str())`; } else { const name = objectName(arg.type); const className = `Jsi${name}`; @@ -81,13 +83,13 @@ export const wrapReturnValue = (returns: string | undefined) => { } }; -const argList = (args: Arg[]) => args.map(arg => arg.baseType ? `base${_.upperFirst(arg.name)}`: (isAtomicType(arg.type) || arg.type.endsWith("[]")) ? `${arg.name}` : `*${arg.name}`).join(", "); +const argList = (args: Arg[]) => args.map(arg => arg.baseType ? `base${_.upperFirst(arg.name)}`: (isAtomicType(arg.type) || arg.type.endsWith("[]") || arg.type.endsWith("Descriptor")) ? `${arg.name}` : `*${arg.name}`).join(", "); const baseType = (arg: Arg) => { return ` auto ${arg.name}Next = *moduleDescriptor; -wgpu::${arg.baseType} base${_.upperFirst(arg.name)}; -base${_.upperFirst(arg.name)}.nextInChain = &${arg.name}Next.chain;` +auto base${_.upperFirst(arg.name)} = new wgpu::${arg.baseType}(); +base${_.upperFirst(arg.name)}->nextInChain = &${arg.name}Next;` }; const generatorMethod = (method: Method) => { @@ -107,7 +109,10 @@ const generatorMethod = (method: Method) => { ${ args.filter(arg => arg.baseType).map(arg => baseType(arg)) } - ${returns ? 'auto ret = ' : ''}getObject()->${_.camelCase(method.name)}(${argList(args)}); + ${returns ? 'auto ret = ' : ''}getObject()->${_.upperFirst(_.camelCase(method.name))}(${argList(args)}); + ${returns ? `if (ret == nullptr) { + throw jsi::JSError(runtime, "${method.name} returned null"); + }` : ""} return ${wrapReturnValue(returns)}; } `; @@ -125,7 +130,7 @@ const generatorAsyncMethod = (method: Method) => { [context = std::move(context), object = std::move(object) ${depList}]( jsi::Runtime &runtime, std::shared_ptr promise) -> void { - auto ret = object->${method.name}(${argList(args)}); + auto ret = object->${_.upperFirst(method.name)}(${argList(args)}); if (ret == nullptr) { promise->resolve(jsi::Value::null()); } else { @@ -140,7 +145,6 @@ const generatorAsyncMethod = (method: Method) => { const unpackProperties = (name: string, properties: Property[], defaultProperties: string) => { return `auto object = new wgpu::${name}(); -object->setDefault(); ${defaultProperties} ${properties.map((property, index) => { const propName = _.camelCase(property.name); @@ -180,7 +184,7 @@ export const generateObject = (object: JSIObject) => { #include #include -#include "webgpu.hpp" +#include "dawn/webgpu_cpp.h" #include @@ -188,7 +192,9 @@ export const generateObject = (object: JSIObject) => { #include "JsiHostObject.h" #include "JsiPromises.h" #include "JsiSkHostObjects.h" +#include "JsiTextureView.h" #include "RNSkPlatformContext.h" +#include "MutableJSIBuffer.h" #include "JsiEnums.h" ${computeDependencies(object)} @@ -214,6 +220,7 @@ ${className}(std::shared_ptr context, ${objectName} m) ${nonMemberMethods.filter(m => !m.member).map(method => `JSI_EXPORT_FUNC(${className}, ${_.camelCase(method.name)})`).join(",\n ")} )` : ''} + ${object.fromValueImpl ? object.fromValueImpl : ` /** * Returns the underlying object from a host object of this type */ @@ -228,6 +235,8 @@ ${className}(std::shared_ptr context, ${objectName} m) "Expected a ${className} object, but got a " + raw.toString(runtime).utf8(runtime));`} } } + `} + }; } // namespace RNSkia `; diff --git a/scripts/generator/model.ts b/scripts/generator/model.ts index 75450b211a..20eccaefa5 100644 --- a/scripts/generator/model.ts +++ b/scripts/generator/model.ts @@ -21,7 +21,7 @@ export interface Property { name: string; type: string; optional?: boolean; - default?: string; + defaultAtomicValue?: string; pointer?: boolean; } @@ -29,8 +29,9 @@ export interface JSIObject { name: string; host?: string; methods?: Method[]; - defaultProperties?: string; properties?: Property[]; + defaultProperties?: string; + fromValueImpl?: string; iterable?: string; } @@ -45,7 +46,39 @@ export const model: JSIObject[] = [ { name: "options", optional: true, type: "RequestAdapterOptions", defaultValue: true } ], returns: "Adapter", - async: true + implementation: ` auto defaultOptions = new wgpu::RequestAdapterOptions(); + auto options = + count > 0 ? JsiRequestAdapterOptions::fromValue(runtime, arguments[0]) + : defaultOptions; + auto context = getContext(); + auto object = getObject(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, + [context = std::move(context), object = std::move(object), + options = std::move(options)]( + jsi::Runtime &runtime, + std::shared_ptr promise) -> void { + wgpu::Adapter adapter = nullptr; + object->RequestAdapter( + nullptr, + [](WGPURequestAdapterStatus, WGPUAdapter cAdapter, const char *message, + void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = + wgpu::Adapter::Acquire(cAdapter); + }, + &adapter); + if (adapter == nullptr) { + promise->resolve(jsi::Value::null()); + } else { + promise->resolve(jsi::Object::createFromHostObject( + runtime, std::make_shared(std::move(context), + std::move(adapter)))); + } + });` }, { name: "getPreferredCanvasFormat", @@ -70,10 +103,117 @@ export const model: JSIObject[] = [ { name: "descriptor", type: "DeviceDescriptor", optional: true, defaultValue: true } ], returns: "Device", - async: true + // async: true, + implementation: ` auto defaultDescriptor = new wgpu::DeviceDescriptor(); + auto descriptor = + count > 0 ? JsiDeviceDescriptor::fromValue(runtime, arguments[0]) + : defaultDescriptor; + auto context = getContext(); + auto object = getObject(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, + [context = std::move(context), object = std::move(object), + descriptor = std::move(descriptor)]( + jsi::Runtime &runtime, + std::shared_ptr promise) -> void { + wgpu::Device device = nullptr; + object->RequestDevice( + nullptr, + [](WGPURequestDeviceStatus, WGPUDevice cDevice, const char *message, + void *userdata) { + if (message != nullptr) { + fprintf(stderr, "%s", message); + return; + } + *static_cast(userdata) = wgpu::Device::Acquire(cDevice); + }, + &device); + if (device == nullptr) { + promise->resolve(jsi::Value::null()); + } else { + device.SetUncapturedErrorCallback( + [](WGPUErrorType type, const char *message, void *userdata) { + RNSkLogger::logToConsole("Error: %s", message); + }, + nullptr); + promise->resolve(jsi::Object::createFromHostObject( + runtime, std::make_shared(std::move(context), + std::move(device)))); + } + });` } ] }, + { + name: "SamplerDescriptor", + properties: [ + { name: "addressModeU", type: "AddressMode", "optional": true, "defaultAtomicValue": "clamp-to-edge" }, + { name: "addressModeV", type: "AddressMode", "optional": true, "defaultAtomicValue": "clamp-to-edge" }, + { name: "addressModeW", type: "AddressMode", "optional": true, "defaultAtomicValue": "clamp-to-edge" }, + { name: "magFilter", type: "FilterMode", "optional": true, "defaultAtomicValue": "nearest" }, + { name: "minFilter", type: "FilterMode", "optional": true, "defaultAtomicValue": "nearest" }, + { name: "mipmapFilter", type: "MipmapFilterMode", "optional": true, "defaultAtomicValue": "nearest" }, + { name: "lodMinClamp", type: "float", "optional": true, "defaultAtomicValue": "0.0f" }, + { name: "lodMaxClamp", type: "float", "optional": true, "defaultAtomicValue": "32.0f" } + ] + }, + { + name: "ImageCopyTexture", + properties: [ + { name: "texture", type: "Texture" }, + { name: "mipLevel", type: "uint32_t", optional: true, defaultAtomicValue: "0" }, + { name: "origin", type: "Extent3D" }, + { name: "aspect", type: "TextureAspect", optional: true, defaultAtomicValue: "wgpu:TextureAspect::All" } + ], + fromValueImpl: ` static wgpu::ImageCopyTexture *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { +const auto &obj = raw.asObject(runtime); +if (obj.isHostObject(runtime)) { +return obj.asHostObject(runtime)->getObject().get(); +} else { +auto object = new wgpu::ImageCopyTexture(); + +if (obj.hasProperty(runtime, "texture")) { +auto texture = obj.getProperty(runtime, "texture"); + +object->texture = *JsiTexture::fromValue(runtime, texture); +} else { +throw jsi::JSError( +runtime, "Missing mandatory prop texture in ImageCopyTexture"); +} +if (obj.hasProperty(runtime, "mipLevel")) { +auto mipLevel = obj.getProperty(runtime, "mipLevel"); + +object->mipLevel = static_cast(mipLevel.getNumber()); +} +if (obj.hasProperty(runtime, "origin")) { +auto origin = obj.getProperty(runtime, "origin").asObject(runtime); +auto x = origin.hasProperty(runtime, "x") ? origin.getProperty(runtime, "x").getNumber() : 0; +auto y = origin.hasProperty(runtime, "y") ? origin.getProperty(runtime, "y").getNumber() : 0; +auto z = origin.hasProperty(runtime, "z") ? origin.getProperty(runtime, "z").getNumber() : 0; +object->origin = { static_cast(x), static_cast(y), static_cast(z) }; +} else { +throw jsi::JSError(runtime, +"Missing mandatory prop origin in ImageCopyTexture"); +} +if (obj.hasProperty(runtime, "aspect")) { +auto aspect = obj.getProperty(runtime, "aspect"); + +object->aspect = +getTextureAspect(aspect.getString(runtime).utf8(runtime).c_str()); +} +return object; +} +}` + }, + { + name: "TextureDataLayout", + properties: [ + {"name": "offset", "type": "uint64_t", "defaultAtomicValue": "0", optional: true }, + {"name": "bytesPerRow", "type": "uint32_t", optional: true, "defaultAtomicValue": "WGPU_COPY_STRIDE_UNDEFINED"}, + {"name": "rowsPerImage", "type": "uint32_t", optional: true, "defaultAtomicValue": "WGPU_COPY_STRIDE_UNDEFINED"} + ] + }, { name: "Device", methods: [ @@ -83,6 +223,19 @@ export const model: JSIObject[] = [ returns: "Queue", member: "queue" }, + { + name: "createPipelineLayout", + args: [ + { name: "descriptor", type: "PipelineLayoutDescriptor" } + ], + }, + { + name: "createSampler", + args: [ + { name: "descriptor", type: "SamplerDescriptor" } + ], + returns: "Sampler" + }, { name: "createBindGroup", args: [{ @@ -99,6 +252,14 @@ export const model: JSIObject[] = [ }], returns: "RenderPipeline", }, + { + name: "createComputePipeline", + args: [{ + name: "descriptor", + type: "ComputePipelineDescriptor", + }], + returns: "ComputePipeline", + }, { name: "createShaderModule", args: [{ @@ -152,8 +313,72 @@ export const model: JSIObject[] = [ name: "BindGroupEntry", properties: [ { name: "binding", type: "uint32_t" }, - { name: "buffer", type: "Buffer" } - ] + { name: "buffer", type: "Buffer" }, + { name: "size", type: "uint32_t" }, + { name: "offset", type: "uint32_t" }, + { name: "sampler", type: "Sampler" }, // dummy + + ], + fromValueImpl: ` + static wgpu::BindGroupEntry *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { + const auto &obj = raw.asObject(runtime); + if (obj.isHostObject(runtime)) { + return obj.asHostObject(runtime)->getObject().get(); + } else { + auto object = new wgpu::BindGroupEntry(); + + if (obj.hasProperty(runtime, "binding")) { + auto binding = obj.getProperty(runtime, "binding"); + + object->binding = static_cast(binding.getNumber()); + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop binding in BindGroupEntry"); + } + + if (obj.hasProperty(runtime, "resource") && + obj.getProperty(runtime, "resource").isObject()) { + auto resource = obj.getProperty(runtime, "resource").asObject(runtime); + if (resource.isHostObject(runtime)) { + if (auto textureView = dynamic_pointer_cast(resource.asHostObject(runtime))) { + object->textureView = *JsiTextureView::fromValue(runtime, obj.getProperty(runtime, "resource")); + } else if (auto sampler = dynamic_pointer_cast(resource.asHostObject(runtime))) { + object->sampler = *JsiSampler::fromValue(runtime, obj.getProperty(runtime, "resource")); + } else { + throw jsi::JSError(runtime, "Missing mandatory prop textureView or sampler in BindGroupEntry"); + } + } else { + if (resource.hasProperty(runtime, "buffer")) { + auto buffer = resource.getProperty(runtime, "buffer"); + + object->buffer = *JsiBuffer::fromValue(runtime, buffer); + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop buffer in BindGroupEntry"); + } + if (resource.hasProperty(runtime, "size")) { + auto size = resource.getProperty(runtime, "size"); + + object->size = static_cast(size.getNumber()); + } else { + object->size = object->buffer.GetSize(); + } + if (resource.hasProperty(runtime, "offset")) { + auto offset = resource.getProperty(runtime, "offset"); + + object->offset = static_cast(offset.getNumber()); + } else { + object->offset = 0; + } + } + } else { + throw jsi::JSError(runtime, + "Missing mandatory prop binding in BindGroupEntry"); + } + return object; + } + }` }, { name: "BindGroup" @@ -163,21 +388,57 @@ export const model: JSIObject[] = [ properties: [ { name: "size", type: "Extent3D" }, { name: "format", type: "TextureFormat" }, - { name: "usage", type: "uint32_t" } // TextureUsage + { name: "usage", type: "TextureUsage" }, + { name: "mipLevelCount", type: "uint32_t", optional: true } ] }, { "name": "BufferDescriptor", properties: [ { name: "size", type: "uint64_t" }, - {"name": "usage", "type": "uint32_t"}, //BufferUsage - {"name": "mappedAtCreation", "type": "bool", "default": "false"} + {"name": "usage", "type": "BufferUsage"}, + {"name": "mappedAtCreation", "type": "bool", optional: true }, ] }, { name: "Buffer", methods: [ { name: "unmap", args: [] }, + { + name: "mapAsync", + args: [ + { + name: "mode", + type: "uint32_t", + } + ], + implementation: ` + auto object = getObject(); + auto mode = static_cast(arguments[0].getNumber()); + auto offset = count > 1 ? static_cast(arguments[1].getNumber()) : 0; + auto size = count > 2 ? static_cast(arguments[2].getNumber()) : getObject()->GetSize(); + auto instance = getContext()->getInstance(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, [object = std::move(object), mode, offset, + size, instance = std::move(instance)](jsi::Runtime &runtime, + std::shared_ptr promise) { + RNSkLogger::logToConsole("Buffer::MapAsync start"); + auto callback = [](WGPUBufferMapAsyncStatus status, void *userdata) { + RNSkLogger::logToConsole( + "Buffer::MapAsync callback status: " + + std::to_string(static_cast(status))); + auto promise = + static_cast(userdata); + promise->resolve(jsi::Value::undefined()); + }; + wgpu::BufferMapCallbackInfo callbackInfo = {nullptr, wgpu::CallbackMode::WaitAnyOnly, callback, + promise.get()}; + wgpu::Future future = object->MapAsync(mode, offset, size, callbackInfo); + wgpu::FutureWaitInfo waitInfo = {future}; + RNSkia::RNSkLogger::logToConsole("before WaitAny"); + instance.WaitAny(1, &waitInfo, UINT64_MAX); + });` + }, { name: "getMappedRange", args: [ @@ -185,26 +446,99 @@ export const model: JSIObject[] = [ {"name": "size", "type": "size_t", "defaultAtomicValue": "SIZE_MAX"} ], implementation: ` - size_t offset = static_cast(arguments[0].getNumber()); - size_t size = static_cast(arguments[1].getNumber()); - auto data = getObject()->getMappedRange(offset, size); - auto arrayBufferCtor = - runtime.global().getPropertyAsFunction(runtime, "ArrayBuffer"); - auto o = arrayBufferCtor.callAsConstructor(runtime, static_cast(size)).getObject(runtime); - auto buf = o.getArrayBuffer(runtime); - memcpy(buf.data(runtime), data, size); - return o;` + size_t offset = count > 0 ? static_cast(arguments[0].getNumber()) : 0; + size_t size = count > 1 ? static_cast(arguments[1].getNumber()) : getObject()->GetSize(); + auto usage = getObject()->GetUsage(); + void *data = (usage & wgpu::BufferUsage::MapWrite) + ? getObject()->GetMappedRange(offset, size) + : const_cast( + getObject()->GetConstMappedRange(offset, size)); + if (data == nullptr) { + throw jsi::JSError(runtime, "Buffer::GetMappedRange failed"); + } + auto buf = std::make_shared(data, size); + auto val = jsi::ArrayBuffer(runtime, buf); + auto d = val.data(runtime); + return val; + ` } ] }, { "name": "CommandEncoderDescriptor" }, + { + "name": "ComputePassDescriptor" + }, + { + name: "ComputePassEncoder", + methods: [ + { + name: "setPipeline", + args: [ + { name: "pipeline", type: "ComputePipeline" } + ] + }, + { + name: "setBindGroup", + args: [ + { name: "index", type: "uint32_t" }, + { name: "bindGroup", type: "BindGroup" }, + { name: "dynamicOffsetCount", "type": "size_t", "defaultAtomicValue": "0"}, + // { name: "dynamicOffsets", "type": "uint32_t*", "defaultAtomicValue": "nullptr"} + ], + implementation: `auto index = static_cast(arguments[0].getNumber()); + auto bindGroup = JsiBindGroup::fromValue(runtime, arguments[1]); + //auto dynamicOffsetCount = static_cast(arguments[2].getNumber()); + getObject()->SetBindGroup(index, *bindGroup, 0, nullptr); + return jsi::Value::undefined();` + }, + { + name: "dispatchWorkgroups", + args: [ + { name: "x", type: "uint32_t" }, + { name: "y", type: "uint32_t", optional: true, defaultAtomicValue: "1" }, + { name: "z", type: "uint32_t", optional: true, defaultAtomicValue: "1" } + ], + }, + { + name: "end", + args: [] + } + ] + }, { name: "CommandEncoder", methods: [ { name: "beginRenderPass", args: [{ name: "descriptor", type: "RenderPassDescriptor" }], returns: "RenderPassEncoder" }, - { name: "finish", args: [], returns: "CommandBuffer" } + { name: "finish", args: [], returns: "CommandBuffer" }, + { + name: "beginComputePass", + args: [{ name: "descriptor", type: "ComputePassDescriptor", optional: true }], + returns: "ComputePassEncoder", + implementation: ` + auto defaultDescriptor = new wgpu::ComputePassDescriptor(); + auto descriptor = + count > 0 ? JsiComputePassDescriptor::fromValue(runtime, arguments[0]) + : defaultDescriptor; + + auto ret = getObject()->BeginComputePass(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "beginComputePass returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret));` + }, + { + name: "copyBufferToBuffer", + args: [ + { name: "source", type: "Buffer" }, + { name: "sourceOffset", type: "uint32_t" }, + { name: "destination", type: "Buffer" }, + { name: "destinationOffset", type: "uint32_t" }, + { name: "size", type: "uint32_t" } + ], + } ] }, { @@ -216,7 +550,53 @@ export const model: JSIObject[] = [ name: "commandBuffers", type: "CommandBuffer[]", ctype: true - }] + }], + implementation: `std::vector commandBuffers; + auto jsiArray = arguments[0].asObject(runtime).asArray(runtime); + auto jsiArraySize = static_cast(jsiArray.size(runtime)); + for (int i = 0; i < jsiArraySize; i++) { + auto val = jsiArray.getValueAtIndex(runtime, i); + commandBuffers.push_back(*JsiCommandBuffer::fromValue(runtime, val)); + } + + getObject()->Submit(commandBuffers.size(), commandBuffers.data()); + return jsi::Value::undefined();` + }, + + { + name: "writeTexture", + args: [ + { + name: "destination", + type: "ImageCopyTexture" + }, + // { + // name: "data", + // type: "ArrayBuffer" + // }, + { + name: "dataLayout", + type: "TextureDataLayout" + }, + { + name: "size", + type: "Extent3D" + } + ], + implementation: ` auto destination = JsiImageCopyTexture::fromValue(runtime, arguments[0]); + if (!arguments[1].isObject()) { + throw jsi::JSError(runtime, "writeTexture: data must be an ArrayBuffer"); + } + if (!arguments[1].getObject(runtime).isArrayBuffer(runtime)) { + throw jsi::JSError(runtime, "Expected an ArrayBuffer"); + } + auto data = arguments[1].getObject(runtime).getArrayBuffer(runtime); + auto dataLayout = JsiTextureDataLayout::fromValue(runtime, arguments[2]); + auto size = JsiExtent3D::fromValue(runtime, arguments[3]); + + getObject()->WriteTexture(destination, data.data(runtime), data.size(runtime), dataLayout, size); + + return jsi::Value::undefined();` }, { name: "writeBuffer", @@ -230,10 +610,40 @@ export const model: JSIObject[] = [ auto buffer = JsiBuffer::fromValue(runtime, arguments[0]); auto offset = static_cast(arguments[1].getNumber()); auto data = arguments[2].getObject(runtime).getArrayBuffer(runtime); - auto size = static_cast(arguments[3].getNumber()); - getObject()->writeBuffer(*buffer, offset, data.data(runtime), size); + auto offset2 = count > 3 ? static_cast(arguments[3].getNumber()) : 0; + auto size = count > 4 ? static_cast(arguments[4].getNumber()) : buffer->GetSize(); + getObject()->WriteBuffer(*buffer, offset, data.data(runtime) + offset2, size); return jsi::Value::undefined(); `, + }, + { + name: "onSubmittedWorkDone", + args: [], + implementation: ` + auto object = getObject(); + auto instance = getContext()->getInstance(); + return RNJsi::JsiPromises::createPromiseAsJSIValue( + runtime, [object = std::move(object), + instance = std::move(instance)]( + jsi::Runtime &runtime, + std::shared_ptr promise) { + RNSkLogger::logToConsole("onSubmittedWorkDone start"); + auto callback = [](WGPUQueueWorkDoneStatus status, void *userdata) { + RNSkLogger::logToConsole("onSubmittedWorkDone callback status: " + + std::to_string(static_cast(status))); + auto promise = static_cast(userdata); + promise->resolve(jsi::Value::undefined()); + RNSkLogger::logToConsole("onSubmittedWorkDone end"); + }; + wgpu::QueueWorkDoneCallbackInfo callbackInfo = { + nullptr, wgpu::CallbackMode::WaitAnyOnly, callback, + promise.get()}; + wgpu::Future future = + object->OnSubmittedWorkDone(callbackInfo); + wgpu::FutureWaitInfo waitInfo = {future}; + instance.WaitAny(1, &waitInfo, UINT64_MAX); + }); + ` } ] }, @@ -242,18 +652,60 @@ export const model: JSIObject[] = [ }, { name: "RenderPipelineDescriptor", - defaultProperties: `object->multisample.count = 1; -object->multisample.mask = ~0u; -object->multisample.alphaToCoverageEnabled = false; -`, +// defaultProperties: `object->multisample.count = 1; +// object->multisample.mask = ~0u; +// object->multisample.alphaToCoverageEnabled = false; +// `, properties: [ {"name": "vertex", "type": "VertexState"}, {"name": "primitive", "type": "PrimitiveState"}, - {"name": "depthStencil", "type": "DepthStencilState", "optional": true, pointer: true}, + // {"name": "depthStencil", "type": "DepthStencilState", "optional": true, pointer: true}, {"name": "multisample", "type": "MultisampleState", "optional": true }, {"name": "fragment", "type": "FragmentState", "optional": true, pointer: true} ] }, + { + name: "ComputePipelineDescriptor", + properties: [ + {"name": "layout", "type": "PipelineLayout", "optional": true}, + {"name": "compute", "type": "ProgrammableStageDescriptor"} + ], + fromValueImpl: `static wgpu::ComputePipelineDescriptor *fromValue(jsi::Runtime &runtime, + const jsi::Value &raw) { +const auto &obj = raw.asObject(runtime); +if (obj.isHostObject(runtime)) { +return obj.asHostObject(runtime) +->getObject() +.get(); +} else { +auto object = new wgpu::ComputePipelineDescriptor(); + +// if (obj.hasProperty(runtime, "layout")) { +// auto layout = obj.getProperty(runtime, "layout"); + +// object->layout = *JsiPipelineLayout::fromValue(runtime, layout); +// } +if (obj.hasProperty(runtime, "compute")) { +auto compute = obj.getProperty(runtime, "compute"); + +object->compute = +*JsiProgrammableStageDescriptor::fromValue(runtime, compute); +} else { +throw jsi::JSError( +runtime, +"Missing mandatory prop compute in ComputePipelineDescriptor"); +} +return object; +} +}` + }, + { + name: "ProgrammableStageDescriptor", + properties: [ + {name: "module", type: "ShaderModule" }, + { name: "entryPoint", type: "string" } + ] + }, { name: "RenderPassEncoder", methods: [ @@ -268,19 +720,64 @@ object->multisample.alphaToCoverageEnabled = false; { name: "end", args: [], - } + }, + { + name: "pushDebugGroup", + args: [{ name: "label", type: "string" }] + }, + { name: "popDebugGroup", args: [] }, + { + name: "setBindGroup", + args: [ + { name: "index", type: "uint32_t" }, + { name: "bindGroup", type: "BindGroup" }, + { name: "dynamicOffsetCount", "type": "size_t", "defaultAtomicValue": "0"}, + // { name: "dynamicOffsets", "type": "uint32_t*", "defaultAtomicValue": "nullptr"} + ], + implementation: `auto index = static_cast(arguments[0].getNumber()); + auto bindGroup = JsiBindGroup::fromValue(runtime, arguments[1]); + //auto dynamicOffsetCount = static_cast(arguments[2].getNumber()); + getObject()->SetBindGroup(index, *bindGroup, 0, nullptr); + return jsi::Value::undefined();` + }, + { + name: "setVertexBuffer", + args: [ + { name: "slot", type: "uint32_t" }, + { name: "buffer", type: "Buffer" }, + {name: "offset", "type": "uint64_t"}, + {name: "size", "type": "uint64_t"} + ], + implementation: `auto slot = static_cast(arguments[0].getNumber()); + auto buffer = JsiBuffer::fromValue(runtime, arguments[1]); + auto offset = count > 2 ? static_cast(arguments[2].getNumber()) : 0; + auto size = count > 3 ? static_cast(arguments[3].getNumber()) : buffer->GetSize(); + + getObject()->SetVertexBuffer(slot, *buffer, offset, size); + return jsi::Value::undefined();` + }, ] }, { name: "RenderPassDescriptor", properties: [ - {"name": "colorAttachments", "type": "RenderPassColorAttachment[]"} + {"name": "colorAttachments", "type": "RenderPassColorAttachment[]"}, + // {"name": "depthStencilAttachment", "type": "RenderPassDepthStencilAttachment", "optional": true, pointer: true} + ] + }, + { + name: "RenderPassDepthStencilAttachment", + properties: [ + {"name": "view", "type": "TextureView"}, + {"name": "depthClearValue", "type": "uint32_t"}, + {"name": "depthLoadOp", "type": "LoadOp"}, + {"name": "depthStoreOp", "type": "StoreOp"} ] }, { name: "RenderPassColorAttachment", - defaultProperties: `object->resolveTarget = nullptr; -object->depthSlice = UINT32_MAX;`, +// defaultProperties: `object->resolveTarget = nullptr; +//object->depthSlice = UINT32_MAX;`, properties: [ {"name": "view", "type": "TextureView"}, {"name": "clearValue", "type": "Color"}, @@ -309,8 +806,8 @@ object->depthSlice = UINT32_MAX;`, }, { name: "ShaderModuleWGSLDescriptor", - defaultProperties: `object->chain.next = nullptr; -object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, + defaultProperties: ` +object->sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, properties: [ {"name": "code", "type": "string"} ] @@ -321,7 +818,29 @@ object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, { name: "Texture", methods: [ - { name: "createView", args: [], returns: "TextureView"} + { name: "createView", args: [ + { name: "descriptor", type: "TextureViewDescriptor", optional: true } + ], returns: "TextureView", + implementation: ` auto defaultDescriptor = nullptr; + auto descriptor = + count > 0 ? JsiTextureViewDescriptor::fromValue(runtime, arguments[0]) + : defaultDescriptor; + + auto ret = getObject()->CreateView(descriptor); + if (ret == nullptr) { + throw jsi::JSError(runtime, "createView returned null"); + } + return jsi::Object::createFromHostObject( + runtime, std::make_shared(getContext(), ret));`} + ] + }, + { + name: "TextureViewDescriptor", + properties: [ + {"name": "format", "type": "TextureFormat" , "optional": true}, + {"name": "dimension", "type": "TextureViewDimension", "optional": true}, + {"name": "baseMipLevel", "type": "uint32_t", "optional": true}, + {"name": "mipLevelCount", "type": "uint32_t", "optional": true} ] }, { @@ -338,11 +857,11 @@ object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, }, { name: "ColorTargetState", - defaultProperties: `object->writeMask = wgpu::ColorWriteMask::All;`, + // defaultProperties: `object->writeMask = wgpu::ColorWriteMask::All;`, properties: [ {"name": "format", "type": "TextureFormat"}, {"name": "blend", "type": "BlendState", "optional": true, pointer: true}, - {"name": "writeMask", "type": "uint32_t", "optional": true} + {"name": "writeMask", "type": "ColorWriteMask", "optional": true} ] }, { @@ -364,7 +883,24 @@ object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, name: "VertexState", properties: [ {"name": "module", "type": "ShaderModule"}, - {"name": "entryPoint", "type": "string" } + {"name": "entryPoint", "type": "string" }, + {"name": "buffers", "type": "VertexBufferLayout[]", "optional": true } + ] + }, + { + name: "VertexBufferLayout", + properties: [ + { name: "arrayStride", type: "uint64_t" }, + { name: "stepMode", type: "VertexStepMode", optional: true }, + { name: "attributes", type: "VertexAttribute[]"} + ] + }, + { + name: "VertexAttribute", + properties: [ + {"name": "shaderLocation", "type": "uint32_t"}, + {"name": "format", "type": "VertexFormat"}, + {"name": "offset", "type": "uint32_t"} ] }, { @@ -381,15 +917,15 @@ object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, name: "DepthStencilState", properties: [ {"name": "format", "type": "TextureFormat"}, - {"name": "depthWriteEnabled", "type": "bool", "optional": true, "default": "false"}, - {"name": "depthCompare", "type": "CompareFunction", "optional": true, "default": "undefined"}, + {"name": "depthWriteEnabled", "type": "bool", "optional": true,}, + {"name": "depthCompare", "type": "CompareFunction", "optional": true }, {"name": "stencilFront", "type": "StencilFaceState", "optional": true}, {"name": "stencilBack", "type": "StencilFaceState", "optional": true}, - {"name": "stencilReadMask", "type": "uint32_t", "optional": true, "default": "0xFFFFFFFF"}, - {"name": "stencilWriteMask", "type": "uint32_t", "optional": true, "default": "0xFFFFFFFF"}, - {"name": "depthBias", "type": "int32_t", "optional": true, "default": "0"}, - {"name": "depthBiasSlopeScale", "type": "float", "optional": true, "default": "0.0f"}, - {"name": "depthBiasClamp", "type": "float", "optional": true, "default": "0.0f" } + {"name": "stencilReadMask", "type": "uint32_t", "optional": true }, + {"name": "stencilWriteMask", "type": "uint32_t", "optional": true}, + {"name": "depthBias", "type": "int32_t", "optional": true, }, + {"name": "depthBiasSlopeScale", "type": "float", "optional": true, }, + {"name": "depthBiasClamp", "type": "float", "optional": true } ] }, { @@ -432,5 +968,23 @@ object->chain.sType = wgpu::SType::ShaderModuleWGSLDescriptor;`, { name: "mask", type: "uint32_t", optional: true }, { name: "alphaToCoverageEnabled", type: "bool", optional: true } ] + }, + { + name: "ComputePipeline", + methods: [ + { name: "getBindGroupLayout", args: [{ name: "index", type: "uint32_t" }], returns: "BindGroupLayout" } + ] + }, + { + name: "PipelineLayout", + }, + { + name: "PipelineLayoutDescriptor", + properties: [ + { name: "bindGroupLayouts", type: "BindGroupLayout[]"} + ] + }, + { + name: "Sampler" } ]; \ No newline at end of file diff --git a/scripts/generator/webgpu-bindings.ts b/scripts/generator/webgpu-bindings.ts index f2fb171cce..a748e00302 100644 --- a/scripts/generator/webgpu-bindings.ts +++ b/scripts/generator/webgpu-bindings.ts @@ -4,8 +4,10 @@ import { writeFileSync } from "fs"; import { generateObject } from "./generateObject"; import { model } from "./model"; import { enums, generateEnums } from "./enums"; +import { generateConstants } from "./constants"; writeFileSync(`package/cpp/wgpu/JsiEnums.h`, generateEnums(enums)); +writeFileSync(`package/cpp/wgpu/JsiConstants.h`, generateConstants()); model.forEach((object) => { const result = generateObject(object);