From cbc94a1e87671472adffa0fdec700bfe2625c3cd Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Sun, 14 Jan 2024 22:21:27 -0500 Subject: [PATCH] add back codegen stage (#3) * add back codegen stage --- .github/workflows/wheels.yml | 35 +- codegen/fetch_wgpu_bins.py | 57 +- codegen/generate.ts | 16 +- codegen/patches.ts | 2 +- packaging/fetch-native.py | 221 - packaging/wgpu_native.json | 10 - pyproject.toml | 5 +- webgoo/_build_ext.py | 1797 ------- webgoo/bindings.py | 8697 ---------------------------------- 9 files changed, 91 insertions(+), 10749 deletions(-) delete mode 100755 packaging/fetch-native.py delete mode 100644 packaging/wgpu_native.json delete mode 100644 webgoo/_build_ext.py delete mode 100644 webgoo/bindings.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6855a8a..a230115 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -6,25 +6,50 @@ on: pull_request: {} jobs: + codegen: + name: Run Codegen + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install Ruff + run: | + python -m pip install cffi ruff + - name: Run Codegen + run: | + python codegen/fetch_wgpu_bins.py + bun codegen/generate.ts + - uses: actions/upload-artifact@v3 + with: + name: codegen-${{ github.run_id }}-${{ github.run_number }} + path: ./webgoo/*.py + build_wheels: name: Build wheels on ${{ matrix.os }} + needs: codegen runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] - + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - name: Download binaries run: | - python -m pip install ruff requests python codegen/fetch_wgpu_bins.py - + - uses: actions/download-artifact@v3 + with: + name: codegen-${{ github.run_id }}-${{ github.run_number }} + path: webgoo/ - name: Build Wheels run: | python -m pip install cibuildwheel==2.16.2 python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl \ No newline at end of file diff --git a/codegen/fetch_wgpu_bins.py b/codegen/fetch_wgpu_bins.py index 8524a7f..b8f821e 100644 --- a/codegen/fetch_wgpu_bins.py +++ b/codegen/fetch_wgpu_bins.py @@ -1,18 +1,55 @@ -import os +import hashlib import shutil import zipfile from platform import uname - -import requests - - -def download_file(url, local_path): - resp = requests.get(url) - if resp.status_code == 404: +from typing import Optional +from urllib.request import urlopen + + +def fetch(url: str, sha256: Optional[str] = None) -> bytes: + """ + A simple standard-library only "fetch remote URL" function. + + Parameters + ------------ + url + Location of remote resource. + sha256 + The SHA256 hash of the resource once retrieved, + will raise a `ValueError` if the hash doesn't match. + + Returns + ------------- + data + Retrieved data. + """ + data = urlopen(url).read() + + if sha256 is not None: + hashed = hashlib.sha256(data).hexdigest() + if hashed != sha256: + raise ValueError("sha256 hash does not match!") + + return data + + +def download_file(url: str, local_path: str) -> None: + """ + Download a remote file and write it to the local file system. + + Parameters + ------------ + url + URL to download. + local_path + File location to write retrieved data. + """ + response = fetch(url) + if len(response) == 0: raise Exception(f"404: {url}") with open(local_path, "wb") as f: - f.write(resp.content) - print(f"Downloaded {os.path.getsize(local_path)} bytes -> {local_path}") + f.write(response) + print(f"Downloaded {len(response)} bytes -> {local_path}") class Lib: diff --git a/codegen/generate.ts b/codegen/generate.ts index c91ba92..aa60e11 100644 --- a/codegen/generate.ts +++ b/codegen/generate.ts @@ -176,7 +176,7 @@ class CFlags implements CType { return ` class ${this.pyName}: - def __init__(self, flags: ${pyUnion(`list[${etypename}]`, `int`, ftq)}): + def __init__(self, flags: ${pyUnion(`List[${etypename}]`, `int`, ftq)}): if isinstance(flags, list): self.value = sum(set(flags)) else: @@ -588,7 +588,7 @@ class ApiInfo { // assume this is a (count, ptr) combo const wrapperName = this.getListWrapper(next.ctype); const lname = quoted(wrapperName); - const maybeList = pyUnion(lname, `list[${next.ctype.pyName}]`); + const maybeList = pyUnion(lname, `List[${next.ctype.pyName}]`); pyArgs.push(`${next.name}: ${maybeList}`); staging.push(`if isinstance(${next.name}, list):`); staging.push(` ${next.name}_staged = ${wrapperName}(${next.name})`); @@ -697,7 +697,7 @@ class ArrayField implements CStructField { } argType(): string { - return pyUnion(this.listType(), `list[${quoted(this.ctype.pyName)}]`); + return pyUnion(this.listType(), `List[${quoted(this.ctype.pyName)}]`); } arg(): string { @@ -1121,7 +1121,7 @@ class ListWrapper implements Emittable { emit(): string { return ` class ${listName(this.ctype.pyName)}: - def __init__(self, items: list[${this.ctype.pyAnnotation(false, false)}]): + def __init__(self, items: List[${this.ctype.pyAnnotation(false, false)}]): self._count = len(items) self._ptr = _ffi_new('${this.ctype.cName}[]', self._count) for idx, item in enumerate(items): @@ -1320,15 +1320,17 @@ if __name__ == "__main__": # todo : this is platform specific, we should check the extension of path_compiled if sys.platform.startswith("linux"): subprocess.check_call(['patchelf', "--set-rpath", "$ORIGIN", path_compiled], cwd=cwd) + elif sys.platform.startswith("darwin"): + # on mac change the @rpath to a @loader_path + subprocess.check_call(['install_name_tool', "-change", "@rpath/libwgpu_native.dylib", "@loader_path/libwgpu_native.dylib", path_compiled], cwd=cwd) `; const pylibOutput = `# AUTOGENERATED from abc import ABC, abstractmethod -from collections.abc import Callable from enum import IntEnum -from typing import Any, Iterator, Optional, Union +from typing import Any, Iterator, Callable, Optional, Union, List from ._wgpu_native_cffi import ffi, lib @@ -1386,7 +1388,7 @@ class Chainable(ABC): ... class ChainedStruct: - def __init__(self, chain: list["Chainable"]): + def __init__(self, chain: List["Chainable"]): self.chain = chain if len(chain) == 0: self._cdata = ffi.NULL diff --git a/codegen/patches.ts b/codegen/patches.ts index f1741a1..fec5243 100644 --- a/codegen/patches.ts +++ b/codegen/patches.ts @@ -1,6 +1,6 @@ function listFeatures(raw_ffi_func: string): string[] { return [ - 'def enumerateFeatures(self) -> list["FeatureName"]:', + 'def enumerateFeatures(self) -> List["FeatureName"]:', ` # Hand-written because of idiosyncratic convention for using this function`, ` feature_count = lib.${raw_ffi_func}(self._cdata, ffi.NULL)`, ` feature_list = ffi.new("WGPUFeatureName[]", feature_count)`, diff --git a/packaging/fetch-native.py b/packaging/fetch-native.py deleted file mode 100755 index c3f6690..0000000 --- a/packaging/fetch-native.py +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/env python3 - -import json -import logging -import os -import sys -import tarfile -from fnmatch import fnmatch -from io import BytesIO -from platform import machine, system -from typing import Optional -from zipfile import ZipFile - -log = logging.getLogger("webgoo") -log.setLevel(logging.DEBUG) -log.addHandler(logging.StreamHandler(sys.stdout)) -_cwd = os.path.abspath(os.path.expanduser(os.path.dirname(__file__))) - - -def fetch(url: str, sha256: str) -> bytes: - """A simple standard-library only "fetch remote URL" function. - - Parameters - ---------- - url : str - Location of remote resource. - sha256: str - The SHA256 hash of the resource once retrieved, - wil raise a `ValueError` if the hash doesn't match. - - Returns - ------- - data : bytes - Retrieved data in memory with correct hash. - """ - import hashlib - from urllib.request import urlopen - - data = urlopen(url).read() - hashed = hashlib.sha256(data).hexdigest() - if hashed != sha256: - log.error(f"`{hashed}` != `{sha256}`") - raise ValueError("sha256 hash does not match!") - - return data - - -def extract(tar, member, path, chmod): - """Extract a single member from a tarfile to a path.""" - if os.path.isdir(path): - return - - if hasattr(tar, "extractfile"): - # a tarfile - data = tar.extractfile(member=member) - if not hasattr(data, "read"): - return - data = data.read() - else: - # ZipFile -_- - data = tar.read(member.filename) - - if len(data) == 0: - return - # make sure root path exists - os.makedirs(os.path.dirname(path), exist_ok=True) - with open(path, "wb") as f: - f.write(data) - if chmod is not None: - # python os.chmod takes an octal value - os.chmod(path, int(str(chmod), base=8)) - - -def handle_fetch( - url: str, - sha256: str, - target: str, - chmod: Optional[int] = None, - extract_skip: Optional[bool] = None, - extract_only: Optional[bool] = None, - filetype_routes: Optional[dict[str, Optional[str]]] = None, - strip_components: int = 0 -): - """A macro to fetch a remote resource (usually an executable) and - move it somewhere on the file system. - - Parameters - ---------- - url : str - A string with a remote resource. - sha256 : str - A hex string for the hash of the remote resource. - target : str - Target location on the local file system. - chmod : None or int. - Change permissions for extracted files. - extract_skip : None or iterable - Skip a certain member of the archive. - extract_only : None or str - Extract *only* a single file from the archive, - overrides `extract_skip`. - strip_components : int - Strip off this many components from the file path - in the archive, i.e. at `1`, `a/b/c` is extracted to `target/b/c` - """ - if ".." in target: - target = os.path.join(_cwd, target) - target = os.path.abspath(os.path.expanduser(target)) - - # get the raw bytes - log.debug(f"fetching: `{url}`") - raw = fetch(url=url, sha256=sha256) - - if len(raw) == 0: - raise ValueError(f"{url} is empty!") - - # if we have an archive that tar supports - if url.endswith((".tar.gz", ".tar.xz", ".tar.bz2", "zip")): - if url.endswith(".zip"): - tar = ZipFile(BytesIO(raw)) - members = tar.infolist() - else: - # mode needs to know what type of compression - mode = f'r:{url.split(".")[-1]}' - # get the archive - tar = tarfile.open(fileobj=BytesIO(raw), mode=mode) - members = tar.getmembers() - - if extract_skip is None: - extract_skip = [] - - for member in members: - if hasattr(member, "filename"): - name = member.filename - else: - name = member.name - - # final name after stripping components - name = "/".join(name.split("/")[strip_components:]) - - # if any of the skip patterns match continue - if any(fnmatch(name, p) for p in extract_skip): - log.debug(f"skipping: `{name}`") - continue - - if extract_only is None: - path = os.path.join(target, name) - log.debug(f"extracting: `{path}`") - extract(tar=tar, member=member, path=path, chmod=chmod) - else: - name = name.split("/")[-1] - if name == extract_only: - path = os.path.join(target, name) - log.debug(f"extracting `{path}`") - extract(tar=tar, member=member, path=path, chmod=chmod) - return - else: - # a single file - name = url.split("/")[-1].strip() - path = target - with open(path, "wb") as f: - f.write(raw) - - # apply chmod if requested - if chmod is not None: - # python os.chmod takes an octal value - os.chmod(path, int(str(chmod), base=8)) - - -def load_config(path: Optional[str] = None) -> list: - """Load a config file for embree download locations.""" - if path is None or len(path) == 0: - # use a default config file - path = os.path.join(_cwd, "wgpu_native.json") - with open(path) as f: - return json.load(f) - - -def is_current_platform(platform: str) -> bool: - """Check to see if a string platform identifier matches the current platform.""" - # 'linux', 'darwin', 'windows' - current = system().lower().strip() - if current.startswith("dar"): - return platform.startswith("dar") or platform.startswith("mac") - elif current.startswith("win"): - return platform.startswith("win") - elif current.startswith("lin"): - return platform.startswith("lin") - else: - raise ValueError(f"{current} ?= {platform}") - -def search(name: str): - """ - - """ - - current_machine = machine() - - for entry in load_config(): - print( entry) - if entry['name'] != name: - continue - if not is_current_platform(entry['platform']): - continue - if entry['machine'] != current_machine: - continue - - # pop the search fields - entry.pop('machine') - entry.pop('name') - entry.pop('platform') - - return entry - - raise ValueError(f'`{name}` not found!') - - - -if __name__ == "__main__": - handle_fetch(**search('wgpu-native')) - diff --git a/packaging/wgpu_native.json b/packaging/wgpu_native.json deleted file mode 100644 index 5c709d2..0000000 --- a/packaging/wgpu_native.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "name": "wgpu-native", - "platform": "linux", - "machine": "x86_64", - "sha256": "d683abcad4b834edc0fe5d09c5919758a21fc8ee11feaf7a0d05ecbfcaace0f8", - "target": "../webgoo/", - "url": "https://github.com/gfx-rs/wgpu-native/releases/download/v0.18.1.3/wgpu-linux-x86_64-release.zip" - } -] diff --git a/pyproject.toml b/pyproject.toml index 2d5dc49..ef7b397 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ webgoo = [ ] [tool.ruff] -target-version = "py311" +target-version = "py37" respect-gitignore = false # See https://github.com/charliermarsh/ruff#rules for error code definitions. select = [ @@ -68,3 +68,6 @@ before-build = "pip install cffi && cd webgoo && python _build_ext.py" # Skip 32-bit builds, musl, etc skip = ["*-win32", "*-manylinux_i686", "*musl*"] + +# just make sure the library imports for now +test-command = 'python -c "import webgoo"' diff --git a/webgoo/_build_ext.py b/webgoo/_build_ext.py deleted file mode 100644 index 8124489..0000000 --- a/webgoo/_build_ext.py +++ /dev/null @@ -1,1797 +0,0 @@ -# AUTOGENERATED -import os -import subprocess -import sys - -from cffi import FFI - -ffibuilder = FFI() - -CDEF = """// BSD 3-Clause License -// -// Copyright (c) 2019, "WebGPU native" developers -// All rights reserved. -// -// 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. - -typedef uint32_t WGPUFlags; -typedef uint32_t WGPUBool; - -typedef struct WGPUAdapterImpl* WGPUAdapter ; -typedef struct WGPUBindGroupImpl* WGPUBindGroup ; -typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout ; -typedef struct WGPUBufferImpl* WGPUBuffer ; -typedef struct WGPUCommandBufferImpl* WGPUCommandBuffer ; -typedef struct WGPUCommandEncoderImpl* WGPUCommandEncoder ; -typedef struct WGPUComputePassEncoderImpl* WGPUComputePassEncoder ; -typedef struct WGPUComputePipelineImpl* WGPUComputePipeline ; -typedef struct WGPUDeviceImpl* WGPUDevice ; -typedef struct WGPUInstanceImpl* WGPUInstance ; -typedef struct WGPUPipelineLayoutImpl* WGPUPipelineLayout ; -typedef struct WGPUQuerySetImpl* WGPUQuerySet ; -typedef struct WGPUQueueImpl* WGPUQueue ; -typedef struct WGPURenderBundleImpl* WGPURenderBundle ; -typedef struct WGPURenderBundleEncoderImpl* WGPURenderBundleEncoder ; -typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder ; -typedef struct WGPURenderPipelineImpl* WGPURenderPipeline ; -typedef struct WGPUSamplerImpl* WGPUSampler ; -typedef struct WGPUShaderModuleImpl* WGPUShaderModule ; -typedef struct WGPUSurfaceImpl* WGPUSurface ; -typedef struct WGPUTextureImpl* WGPUTexture ; -typedef struct WGPUTextureViewImpl* WGPUTextureView ; - -// Structure forward declarations -struct WGPUAdapterProperties; -struct WGPUBindGroupEntry; -struct WGPUBlendComponent; -struct WGPUBufferBindingLayout; -struct WGPUBufferDescriptor; -struct WGPUColor; -struct WGPUCommandBufferDescriptor; -struct WGPUCommandEncoderDescriptor; -struct WGPUCompilationMessage; -struct WGPUComputePassTimestampWrites; -struct WGPUConstantEntry; -struct WGPUExtent3D; -struct WGPUInstanceDescriptor; -struct WGPULimits; -struct WGPUMultisampleState; -struct WGPUOrigin3D; -struct WGPUPipelineLayoutDescriptor; -struct WGPUPrimitiveDepthClipControl; -struct WGPUPrimitiveState; -struct WGPUQuerySetDescriptor; -struct WGPUQueueDescriptor; -struct WGPURenderBundleDescriptor; -struct WGPURenderBundleEncoderDescriptor; -struct WGPURenderPassDepthStencilAttachment; -struct WGPURenderPassDescriptorMaxDrawCount; -struct WGPURenderPassTimestampWrites; -struct WGPURequestAdapterOptions; -struct WGPUSamplerBindingLayout; -struct WGPUSamplerDescriptor; -struct WGPUShaderModuleCompilationHint; -struct WGPUShaderModuleSPIRVDescriptor; -struct WGPUShaderModuleWGSLDescriptor; -struct WGPUStencilFaceState; -struct WGPUStorageTextureBindingLayout; -struct WGPUSurfaceCapabilities; -struct WGPUSurfaceConfiguration; -struct WGPUSurfaceDescriptor; -struct WGPUSurfaceDescriptorFromAndroidNativeWindow; -struct WGPUSurfaceDescriptorFromCanvasHTMLSelector; -struct WGPUSurfaceDescriptorFromMetalLayer; -struct WGPUSurfaceDescriptorFromWaylandSurface; -struct WGPUSurfaceDescriptorFromWindowsHWND; -struct WGPUSurfaceDescriptorFromXcbWindow; -struct WGPUSurfaceDescriptorFromXlibWindow; -struct WGPUSurfaceTexture; -struct WGPUTextureBindingLayout; -struct WGPUTextureDataLayout; -struct WGPUTextureViewDescriptor; -struct WGPUVertexAttribute; -struct WGPUBindGroupDescriptor; -struct WGPUBindGroupLayoutEntry; -struct WGPUBlendState; -struct WGPUCompilationInfo; -struct WGPUComputePassDescriptor; -struct WGPUDepthStencilState; -struct WGPUImageCopyBuffer; -struct WGPUImageCopyTexture; -struct WGPUProgrammableStageDescriptor; -struct WGPURenderPassColorAttachment; -struct WGPURequiredLimits; -struct WGPUShaderModuleDescriptor; -struct WGPUSupportedLimits; -struct WGPUTextureDescriptor; -struct WGPUVertexBufferLayout; -struct WGPUBindGroupLayoutDescriptor; -struct WGPUColorTargetState; -struct WGPUComputePipelineDescriptor; -struct WGPUDeviceDescriptor; -struct WGPURenderPassDescriptor; -struct WGPUVertexState; -struct WGPUFragmentState; -struct WGPURenderPipelineDescriptor; - -typedef enum WGPUAdapterType { - WGPUAdapterType_DiscreteGPU = 0x00000000, - WGPUAdapterType_IntegratedGPU = 0x00000001, - WGPUAdapterType_CPU = 0x00000002, - WGPUAdapterType_Unknown = 0x00000003, - WGPUAdapterType_Force32 = 0x7FFFFFFF -} WGPUAdapterType ; - -typedef enum WGPUAddressMode { - WGPUAddressMode_Repeat = 0x00000000, - WGPUAddressMode_MirrorRepeat = 0x00000001, - WGPUAddressMode_ClampToEdge = 0x00000002, - WGPUAddressMode_Force32 = 0x7FFFFFFF -} WGPUAddressMode ; - -typedef enum WGPUBackendType { - WGPUBackendType_Undefined = 0x00000000, - WGPUBackendType_Null = 0x00000001, - WGPUBackendType_WebGPU = 0x00000002, - WGPUBackendType_D3D11 = 0x00000003, - WGPUBackendType_D3D12 = 0x00000004, - WGPUBackendType_Metal = 0x00000005, - WGPUBackendType_Vulkan = 0x00000006, - WGPUBackendType_OpenGL = 0x00000007, - WGPUBackendType_OpenGLES = 0x00000008, - WGPUBackendType_Force32 = 0x7FFFFFFF -} WGPUBackendType ; - -typedef enum WGPUBlendFactor { - WGPUBlendFactor_Zero = 0x00000000, - WGPUBlendFactor_One = 0x00000001, - WGPUBlendFactor_Src = 0x00000002, - WGPUBlendFactor_OneMinusSrc = 0x00000003, - WGPUBlendFactor_SrcAlpha = 0x00000004, - WGPUBlendFactor_OneMinusSrcAlpha = 0x00000005, - WGPUBlendFactor_Dst = 0x00000006, - WGPUBlendFactor_OneMinusDst = 0x00000007, - WGPUBlendFactor_DstAlpha = 0x00000008, - WGPUBlendFactor_OneMinusDstAlpha = 0x00000009, - WGPUBlendFactor_SrcAlphaSaturated = 0x0000000A, - WGPUBlendFactor_Constant = 0x0000000B, - WGPUBlendFactor_OneMinusConstant = 0x0000000C, - WGPUBlendFactor_Force32 = 0x7FFFFFFF -} WGPUBlendFactor ; - -typedef enum WGPUBlendOperation { - WGPUBlendOperation_Add = 0x00000000, - WGPUBlendOperation_Subtract = 0x00000001, - WGPUBlendOperation_ReverseSubtract = 0x00000002, - WGPUBlendOperation_Min = 0x00000003, - WGPUBlendOperation_Max = 0x00000004, - WGPUBlendOperation_Force32 = 0x7FFFFFFF -} WGPUBlendOperation ; - -typedef enum WGPUBufferBindingType { - WGPUBufferBindingType_Undefined = 0x00000000, - WGPUBufferBindingType_Uniform = 0x00000001, - WGPUBufferBindingType_Storage = 0x00000002, - WGPUBufferBindingType_ReadOnlyStorage = 0x00000003, - WGPUBufferBindingType_Force32 = 0x7FFFFFFF -} WGPUBufferBindingType ; - -typedef enum WGPUBufferMapAsyncStatus { - WGPUBufferMapAsyncStatus_Success = 0x00000000, - WGPUBufferMapAsyncStatus_ValidationError = 0x00000001, - WGPUBufferMapAsyncStatus_Unknown = 0x00000002, - WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, - WGPUBufferMapAsyncStatus_DestroyedBeforeCallback = 0x00000004, - WGPUBufferMapAsyncStatus_UnmappedBeforeCallback = 0x00000005, - WGPUBufferMapAsyncStatus_MappingAlreadyPending = 0x00000006, - WGPUBufferMapAsyncStatus_OffsetOutOfRange = 0x00000007, - WGPUBufferMapAsyncStatus_SizeOutOfRange = 0x00000008, - WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUBufferMapAsyncStatus ; - -typedef enum WGPUBufferMapState { - WGPUBufferMapState_Unmapped = 0x00000000, - WGPUBufferMapState_Pending = 0x00000001, - WGPUBufferMapState_Mapped = 0x00000002, - WGPUBufferMapState_Force32 = 0x7FFFFFFF -} WGPUBufferMapState ; - -typedef enum WGPUCompareFunction { - WGPUCompareFunction_Undefined = 0x00000000, - WGPUCompareFunction_Never = 0x00000001, - WGPUCompareFunction_Less = 0x00000002, - WGPUCompareFunction_LessEqual = 0x00000003, - WGPUCompareFunction_Greater = 0x00000004, - WGPUCompareFunction_GreaterEqual = 0x00000005, - WGPUCompareFunction_Equal = 0x00000006, - WGPUCompareFunction_NotEqual = 0x00000007, - WGPUCompareFunction_Always = 0x00000008, - WGPUCompareFunction_Force32 = 0x7FFFFFFF -} WGPUCompareFunction ; - -typedef enum WGPUCompilationInfoRequestStatus { - WGPUCompilationInfoRequestStatus_Success = 0x00000000, - WGPUCompilationInfoRequestStatus_Error = 0x00000001, - WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, - WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF -} WGPUCompilationInfoRequestStatus ; - -typedef enum WGPUCompilationMessageType { - WGPUCompilationMessageType_Error = 0x00000000, - WGPUCompilationMessageType_Warning = 0x00000001, - WGPUCompilationMessageType_Info = 0x00000002, - WGPUCompilationMessageType_Force32 = 0x7FFFFFFF -} WGPUCompilationMessageType ; - -typedef enum WGPUCompositeAlphaMode { - WGPUCompositeAlphaMode_Auto = 0x00000000, - WGPUCompositeAlphaMode_Opaque = 0x00000001, - WGPUCompositeAlphaMode_Premultiplied = 0x00000002, - WGPUCompositeAlphaMode_Unpremultiplied = 0x00000003, - WGPUCompositeAlphaMode_Inherit = 0x00000004, - WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF -} WGPUCompositeAlphaMode ; - -typedef enum WGPUCreatePipelineAsyncStatus { - WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, - WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, - WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, - WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUCreatePipelineAsyncStatus ; - -typedef enum WGPUCullMode { - WGPUCullMode_None = 0x00000000, - WGPUCullMode_Front = 0x00000001, - WGPUCullMode_Back = 0x00000002, - WGPUCullMode_Force32 = 0x7FFFFFFF -} WGPUCullMode ; - -typedef enum WGPUDeviceLostReason { - WGPUDeviceLostReason_Undefined = 0x00000000, - WGPUDeviceLostReason_Destroyed = 0x00000001, - WGPUDeviceLostReason_Force32 = 0x7FFFFFFF -} WGPUDeviceLostReason ; - -typedef enum WGPUErrorFilter { - WGPUErrorFilter_Validation = 0x00000000, - WGPUErrorFilter_OutOfMemory = 0x00000001, - WGPUErrorFilter_Internal = 0x00000002, - WGPUErrorFilter_Force32 = 0x7FFFFFFF -} WGPUErrorFilter ; - -typedef enum WGPUErrorType { - WGPUErrorType_NoError = 0x00000000, - WGPUErrorType_Validation = 0x00000001, - WGPUErrorType_OutOfMemory = 0x00000002, - WGPUErrorType_Internal = 0x00000003, - WGPUErrorType_Unknown = 0x00000004, - WGPUErrorType_DeviceLost = 0x00000005, - WGPUErrorType_Force32 = 0x7FFFFFFF -} WGPUErrorType ; - -typedef enum WGPUFeatureName { - WGPUFeatureName_Undefined = 0x00000000, - WGPUFeatureName_DepthClipControl = 0x00000001, - WGPUFeatureName_Depth32FloatStencil8 = 0x00000002, - WGPUFeatureName_TimestampQuery = 0x00000003, - WGPUFeatureName_TextureCompressionBC = 0x00000004, - WGPUFeatureName_TextureCompressionETC2 = 0x00000005, - WGPUFeatureName_TextureCompressionASTC = 0x00000006, - WGPUFeatureName_IndirectFirstInstance = 0x00000007, - WGPUFeatureName_ShaderF16 = 0x00000008, - WGPUFeatureName_RG11B10UfloatRenderable = 0x00000009, - WGPUFeatureName_BGRA8UnormStorage = 0x0000000A, - WGPUFeatureName_Float32Filterable = 0x0000000B, - WGPUFeatureName_Force32 = 0x7FFFFFFF -} WGPUFeatureName ; - -typedef enum WGPUFilterMode { - WGPUFilterMode_Nearest = 0x00000000, - WGPUFilterMode_Linear = 0x00000001, - WGPUFilterMode_Force32 = 0x7FFFFFFF -} WGPUFilterMode ; - -typedef enum WGPUFrontFace { - WGPUFrontFace_CCW = 0x00000000, - WGPUFrontFace_CW = 0x00000001, - WGPUFrontFace_Force32 = 0x7FFFFFFF -} WGPUFrontFace ; - -typedef enum WGPUIndexFormat { - WGPUIndexFormat_Undefined = 0x00000000, - WGPUIndexFormat_Uint16 = 0x00000001, - WGPUIndexFormat_Uint32 = 0x00000002, - WGPUIndexFormat_Force32 = 0x7FFFFFFF -} WGPUIndexFormat ; - -typedef enum WGPULoadOp { - WGPULoadOp_Undefined = 0x00000000, - WGPULoadOp_Clear = 0x00000001, - WGPULoadOp_Load = 0x00000002, - WGPULoadOp_Force32 = 0x7FFFFFFF -} WGPULoadOp ; - -typedef enum WGPUMipmapFilterMode { - WGPUMipmapFilterMode_Nearest = 0x00000000, - WGPUMipmapFilterMode_Linear = 0x00000001, - WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF -} WGPUMipmapFilterMode ; - -typedef enum WGPUPowerPreference { - WGPUPowerPreference_Undefined = 0x00000000, - WGPUPowerPreference_LowPower = 0x00000001, - WGPUPowerPreference_HighPerformance = 0x00000002, - WGPUPowerPreference_Force32 = 0x7FFFFFFF -} WGPUPowerPreference ; - -typedef enum WGPUPresentMode { - WGPUPresentMode_Fifo = 0x00000000, - WGPUPresentMode_FifoRelaxed = 0x00000001, - WGPUPresentMode_Immediate = 0x00000002, - WGPUPresentMode_Mailbox = 0x00000003, - WGPUPresentMode_Force32 = 0x7FFFFFFF -} WGPUPresentMode ; - -typedef enum WGPUPrimitiveTopology { - WGPUPrimitiveTopology_PointList = 0x00000000, - WGPUPrimitiveTopology_LineList = 0x00000001, - WGPUPrimitiveTopology_LineStrip = 0x00000002, - WGPUPrimitiveTopology_TriangleList = 0x00000003, - WGPUPrimitiveTopology_TriangleStrip = 0x00000004, - WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF -} WGPUPrimitiveTopology ; - -typedef enum WGPUQueryType { - WGPUQueryType_Occlusion = 0x00000000, - WGPUQueryType_Timestamp = 0x00000001, - WGPUQueryType_Force32 = 0x7FFFFFFF -} WGPUQueryType ; - -typedef enum WGPUQueueWorkDoneStatus { - WGPUQueueWorkDoneStatus_Success = 0x00000000, - WGPUQueueWorkDoneStatus_Error = 0x00000001, - WGPUQueueWorkDoneStatus_Unknown = 0x00000002, - WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, - WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF -} WGPUQueueWorkDoneStatus ; - -typedef enum WGPURequestAdapterStatus { - WGPURequestAdapterStatus_Success = 0x00000000, - WGPURequestAdapterStatus_Unavailable = 0x00000001, - WGPURequestAdapterStatus_Error = 0x00000002, - WGPURequestAdapterStatus_Unknown = 0x00000003, - WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF -} WGPURequestAdapterStatus ; - -typedef enum WGPURequestDeviceStatus { - WGPURequestDeviceStatus_Success = 0x00000000, - WGPURequestDeviceStatus_Error = 0x00000001, - WGPURequestDeviceStatus_Unknown = 0x00000002, - WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF -} WGPURequestDeviceStatus ; - -typedef enum WGPUSType { - WGPUSType_Invalid = 0x00000000, - WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, - WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, - WGPUSType_SurfaceDescriptorFromXlibWindow = 0x00000003, - WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004, - WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, - WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, - WGPUSType_PrimitiveDepthClipControl = 0x00000007, - WGPUSType_SurfaceDescriptorFromWaylandSurface = 0x00000008, - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow = 0x00000009, - WGPUSType_SurfaceDescriptorFromXcbWindow = 0x0000000A, - WGPUSType_RenderPassDescriptorMaxDrawCount = 0x0000000F, - WGPUSType_Force32 = 0x7FFFFFFF -} WGPUSType ; - -typedef enum WGPUSamplerBindingType { - WGPUSamplerBindingType_Undefined = 0x00000000, - WGPUSamplerBindingType_Filtering = 0x00000001, - WGPUSamplerBindingType_NonFiltering = 0x00000002, - WGPUSamplerBindingType_Comparison = 0x00000003, - WGPUSamplerBindingType_Force32 = 0x7FFFFFFF -} WGPUSamplerBindingType ; - -typedef enum WGPUStencilOperation { - WGPUStencilOperation_Keep = 0x00000000, - WGPUStencilOperation_Zero = 0x00000001, - WGPUStencilOperation_Replace = 0x00000002, - WGPUStencilOperation_Invert = 0x00000003, - WGPUStencilOperation_IncrementClamp = 0x00000004, - WGPUStencilOperation_DecrementClamp = 0x00000005, - WGPUStencilOperation_IncrementWrap = 0x00000006, - WGPUStencilOperation_DecrementWrap = 0x00000007, - WGPUStencilOperation_Force32 = 0x7FFFFFFF -} WGPUStencilOperation ; - -typedef enum WGPUStorageTextureAccess { - WGPUStorageTextureAccess_Undefined = 0x00000000, - WGPUStorageTextureAccess_WriteOnly = 0x00000001, - WGPUStorageTextureAccess_Force32 = 0x7FFFFFFF -} WGPUStorageTextureAccess ; - -typedef enum WGPUStoreOp { - WGPUStoreOp_Undefined = 0x00000000, - WGPUStoreOp_Store = 0x00000001, - WGPUStoreOp_Discard = 0x00000002, - WGPUStoreOp_Force32 = 0x7FFFFFFF -} WGPUStoreOp ; - -typedef enum WGPUSurfaceGetCurrentTextureStatus { - WGPUSurfaceGetCurrentTextureStatus_Success = 0x00000000, - WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000001, - WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000002, - WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000003, - WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000004, - WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000005, - WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF -} WGPUSurfaceGetCurrentTextureStatus ; - -typedef enum WGPUTextureAspect { - WGPUTextureAspect_All = 0x00000000, - WGPUTextureAspect_StencilOnly = 0x00000001, - WGPUTextureAspect_DepthOnly = 0x00000002, - WGPUTextureAspect_Force32 = 0x7FFFFFFF -} WGPUTextureAspect ; - -typedef enum WGPUTextureDimension { - WGPUTextureDimension_1D = 0x00000000, - WGPUTextureDimension_2D = 0x00000001, - WGPUTextureDimension_3D = 0x00000002, - WGPUTextureDimension_Force32 = 0x7FFFFFFF -} WGPUTextureDimension ; - -typedef enum WGPUTextureFormat { - WGPUTextureFormat_Undefined = 0x00000000, - WGPUTextureFormat_R8Unorm = 0x00000001, - WGPUTextureFormat_R8Snorm = 0x00000002, - WGPUTextureFormat_R8Uint = 0x00000003, - WGPUTextureFormat_R8Sint = 0x00000004, - WGPUTextureFormat_R16Uint = 0x00000005, - WGPUTextureFormat_R16Sint = 0x00000006, - WGPUTextureFormat_R16Float = 0x00000007, - WGPUTextureFormat_RG8Unorm = 0x00000008, - WGPUTextureFormat_RG8Snorm = 0x00000009, - WGPUTextureFormat_RG8Uint = 0x0000000A, - WGPUTextureFormat_RG8Sint = 0x0000000B, - WGPUTextureFormat_R32Float = 0x0000000C, - WGPUTextureFormat_R32Uint = 0x0000000D, - WGPUTextureFormat_R32Sint = 0x0000000E, - WGPUTextureFormat_RG16Uint = 0x0000000F, - WGPUTextureFormat_RG16Sint = 0x00000010, - WGPUTextureFormat_RG16Float = 0x00000011, - WGPUTextureFormat_RGBA8Unorm = 0x00000012, - WGPUTextureFormat_RGBA8UnormSrgb = 0x00000013, - WGPUTextureFormat_RGBA8Snorm = 0x00000014, - WGPUTextureFormat_RGBA8Uint = 0x00000015, - WGPUTextureFormat_RGBA8Sint = 0x00000016, - WGPUTextureFormat_BGRA8Unorm = 0x00000017, - WGPUTextureFormat_BGRA8UnormSrgb = 0x00000018, - WGPUTextureFormat_RGB10A2Unorm = 0x00000019, - WGPUTextureFormat_RG11B10Ufloat = 0x0000001A, - WGPUTextureFormat_RGB9E5Ufloat = 0x0000001B, - WGPUTextureFormat_RG32Float = 0x0000001C, - WGPUTextureFormat_RG32Uint = 0x0000001D, - WGPUTextureFormat_RG32Sint = 0x0000001E, - WGPUTextureFormat_RGBA16Uint = 0x0000001F, - WGPUTextureFormat_RGBA16Sint = 0x00000020, - WGPUTextureFormat_RGBA16Float = 0x00000021, - WGPUTextureFormat_RGBA32Float = 0x00000022, - WGPUTextureFormat_RGBA32Uint = 0x00000023, - WGPUTextureFormat_RGBA32Sint = 0x00000024, - WGPUTextureFormat_Stencil8 = 0x00000025, - WGPUTextureFormat_Depth16Unorm = 0x00000026, - WGPUTextureFormat_Depth24Plus = 0x00000027, - WGPUTextureFormat_Depth24PlusStencil8 = 0x00000028, - WGPUTextureFormat_Depth32Float = 0x00000029, - WGPUTextureFormat_Depth32FloatStencil8 = 0x0000002A, - WGPUTextureFormat_BC1RGBAUnorm = 0x0000002B, - WGPUTextureFormat_BC1RGBAUnormSrgb = 0x0000002C, - WGPUTextureFormat_BC2RGBAUnorm = 0x0000002D, - WGPUTextureFormat_BC2RGBAUnormSrgb = 0x0000002E, - WGPUTextureFormat_BC3RGBAUnorm = 0x0000002F, - WGPUTextureFormat_BC3RGBAUnormSrgb = 0x00000030, - WGPUTextureFormat_BC4RUnorm = 0x00000031, - WGPUTextureFormat_BC4RSnorm = 0x00000032, - WGPUTextureFormat_BC5RGUnorm = 0x00000033, - WGPUTextureFormat_BC5RGSnorm = 0x00000034, - WGPUTextureFormat_BC6HRGBUfloat = 0x00000035, - WGPUTextureFormat_BC6HRGBFloat = 0x00000036, - WGPUTextureFormat_BC7RGBAUnorm = 0x00000037, - WGPUTextureFormat_BC7RGBAUnormSrgb = 0x00000038, - WGPUTextureFormat_ETC2RGB8Unorm = 0x00000039, - WGPUTextureFormat_ETC2RGB8UnormSrgb = 0x0000003A, - WGPUTextureFormat_ETC2RGB8A1Unorm = 0x0000003B, - WGPUTextureFormat_ETC2RGB8A1UnormSrgb = 0x0000003C, - WGPUTextureFormat_ETC2RGBA8Unorm = 0x0000003D, - WGPUTextureFormat_ETC2RGBA8UnormSrgb = 0x0000003E, - WGPUTextureFormat_EACR11Unorm = 0x0000003F, - WGPUTextureFormat_EACR11Snorm = 0x00000040, - WGPUTextureFormat_EACRG11Unorm = 0x00000041, - WGPUTextureFormat_EACRG11Snorm = 0x00000042, - WGPUTextureFormat_ASTC4x4Unorm = 0x00000043, - WGPUTextureFormat_ASTC4x4UnormSrgb = 0x00000044, - WGPUTextureFormat_ASTC5x4Unorm = 0x00000045, - WGPUTextureFormat_ASTC5x4UnormSrgb = 0x00000046, - WGPUTextureFormat_ASTC5x5Unorm = 0x00000047, - WGPUTextureFormat_ASTC5x5UnormSrgb = 0x00000048, - WGPUTextureFormat_ASTC6x5Unorm = 0x00000049, - WGPUTextureFormat_ASTC6x5UnormSrgb = 0x0000004A, - WGPUTextureFormat_ASTC6x6Unorm = 0x0000004B, - WGPUTextureFormat_ASTC6x6UnormSrgb = 0x0000004C, - WGPUTextureFormat_ASTC8x5Unorm = 0x0000004D, - WGPUTextureFormat_ASTC8x5UnormSrgb = 0x0000004E, - WGPUTextureFormat_ASTC8x6Unorm = 0x0000004F, - WGPUTextureFormat_ASTC8x6UnormSrgb = 0x00000050, - WGPUTextureFormat_ASTC8x8Unorm = 0x00000051, - WGPUTextureFormat_ASTC8x8UnormSrgb = 0x00000052, - WGPUTextureFormat_ASTC10x5Unorm = 0x00000053, - WGPUTextureFormat_ASTC10x5UnormSrgb = 0x00000054, - WGPUTextureFormat_ASTC10x6Unorm = 0x00000055, - WGPUTextureFormat_ASTC10x6UnormSrgb = 0x00000056, - WGPUTextureFormat_ASTC10x8Unorm = 0x00000057, - WGPUTextureFormat_ASTC10x8UnormSrgb = 0x00000058, - WGPUTextureFormat_ASTC10x10Unorm = 0x00000059, - WGPUTextureFormat_ASTC10x10UnormSrgb = 0x0000005A, - WGPUTextureFormat_ASTC12x10Unorm = 0x0000005B, - WGPUTextureFormat_ASTC12x10UnormSrgb = 0x0000005C, - WGPUTextureFormat_ASTC12x12Unorm = 0x0000005D, - WGPUTextureFormat_ASTC12x12UnormSrgb = 0x0000005E, - WGPUTextureFormat_Force32 = 0x7FFFFFFF -} WGPUTextureFormat ; - -typedef enum WGPUTextureSampleType { - WGPUTextureSampleType_Undefined = 0x00000000, - WGPUTextureSampleType_Float = 0x00000001, - WGPUTextureSampleType_UnfilterableFloat = 0x00000002, - WGPUTextureSampleType_Depth = 0x00000003, - WGPUTextureSampleType_Sint = 0x00000004, - WGPUTextureSampleType_Uint = 0x00000005, - WGPUTextureSampleType_Force32 = 0x7FFFFFFF -} WGPUTextureSampleType ; - -typedef enum WGPUTextureViewDimension { - WGPUTextureViewDimension_Undefined = 0x00000000, - WGPUTextureViewDimension_1D = 0x00000001, - WGPUTextureViewDimension_2D = 0x00000002, - WGPUTextureViewDimension_2DArray = 0x00000003, - WGPUTextureViewDimension_Cube = 0x00000004, - WGPUTextureViewDimension_CubeArray = 0x00000005, - WGPUTextureViewDimension_3D = 0x00000006, - WGPUTextureViewDimension_Force32 = 0x7FFFFFFF -} WGPUTextureViewDimension ; - -typedef enum WGPUVertexFormat { - WGPUVertexFormat_Undefined = 0x00000000, - WGPUVertexFormat_Uint8x2 = 0x00000001, - WGPUVertexFormat_Uint8x4 = 0x00000002, - WGPUVertexFormat_Sint8x2 = 0x00000003, - WGPUVertexFormat_Sint8x4 = 0x00000004, - WGPUVertexFormat_Unorm8x2 = 0x00000005, - WGPUVertexFormat_Unorm8x4 = 0x00000006, - WGPUVertexFormat_Snorm8x2 = 0x00000007, - WGPUVertexFormat_Snorm8x4 = 0x00000008, - WGPUVertexFormat_Uint16x2 = 0x00000009, - WGPUVertexFormat_Uint16x4 = 0x0000000A, - WGPUVertexFormat_Sint16x2 = 0x0000000B, - WGPUVertexFormat_Sint16x4 = 0x0000000C, - WGPUVertexFormat_Unorm16x2 = 0x0000000D, - WGPUVertexFormat_Unorm16x4 = 0x0000000E, - WGPUVertexFormat_Snorm16x2 = 0x0000000F, - WGPUVertexFormat_Snorm16x4 = 0x00000010, - WGPUVertexFormat_Float16x2 = 0x00000011, - WGPUVertexFormat_Float16x4 = 0x00000012, - WGPUVertexFormat_Float32 = 0x00000013, - WGPUVertexFormat_Float32x2 = 0x00000014, - WGPUVertexFormat_Float32x3 = 0x00000015, - WGPUVertexFormat_Float32x4 = 0x00000016, - WGPUVertexFormat_Uint32 = 0x00000017, - WGPUVertexFormat_Uint32x2 = 0x00000018, - WGPUVertexFormat_Uint32x3 = 0x00000019, - WGPUVertexFormat_Uint32x4 = 0x0000001A, - WGPUVertexFormat_Sint32 = 0x0000001B, - WGPUVertexFormat_Sint32x2 = 0x0000001C, - WGPUVertexFormat_Sint32x3 = 0x0000001D, - WGPUVertexFormat_Sint32x4 = 0x0000001E, - WGPUVertexFormat_Force32 = 0x7FFFFFFF -} WGPUVertexFormat ; - -typedef enum WGPUVertexStepMode { - WGPUVertexStepMode_Vertex = 0x00000000, - WGPUVertexStepMode_Instance = 0x00000001, - WGPUVertexStepMode_VertexBufferNotUsed = 0x00000002, - WGPUVertexStepMode_Force32 = 0x7FFFFFFF -} WGPUVertexStepMode ; - -typedef enum WGPUBufferUsage { - WGPUBufferUsage_None = 0x00000000, - WGPUBufferUsage_MapRead = 0x00000001, - WGPUBufferUsage_MapWrite = 0x00000002, - WGPUBufferUsage_CopySrc = 0x00000004, - WGPUBufferUsage_CopyDst = 0x00000008, - WGPUBufferUsage_Index = 0x00000010, - WGPUBufferUsage_Vertex = 0x00000020, - WGPUBufferUsage_Uniform = 0x00000040, - WGPUBufferUsage_Storage = 0x00000080, - WGPUBufferUsage_Indirect = 0x00000100, - WGPUBufferUsage_QueryResolve = 0x00000200, - WGPUBufferUsage_Force32 = 0x7FFFFFFF -} WGPUBufferUsage ; -typedef WGPUFlags WGPUBufferUsageFlags ; - -typedef enum WGPUColorWriteMask { - WGPUColorWriteMask_None = 0x00000000, - WGPUColorWriteMask_Red = 0x00000001, - WGPUColorWriteMask_Green = 0x00000002, - WGPUColorWriteMask_Blue = 0x00000004, - WGPUColorWriteMask_Alpha = 0x00000008, - WGPUColorWriteMask_All = 0x0000000F, - WGPUColorWriteMask_Force32 = 0x7FFFFFFF -} WGPUColorWriteMask ; -typedef WGPUFlags WGPUColorWriteMaskFlags ; - -typedef enum WGPUMapMode { - WGPUMapMode_None = 0x00000000, - WGPUMapMode_Read = 0x00000001, - WGPUMapMode_Write = 0x00000002, - WGPUMapMode_Force32 = 0x7FFFFFFF -} WGPUMapMode ; -typedef WGPUFlags WGPUMapModeFlags ; - -typedef enum WGPUShaderStage { - WGPUShaderStage_None = 0x00000000, - WGPUShaderStage_Vertex = 0x00000001, - WGPUShaderStage_Fragment = 0x00000002, - WGPUShaderStage_Compute = 0x00000004, - WGPUShaderStage_Force32 = 0x7FFFFFFF -} WGPUShaderStage ; -typedef WGPUFlags WGPUShaderStageFlags ; - -typedef enum WGPUTextureUsage { - WGPUTextureUsage_None = 0x00000000, - WGPUTextureUsage_CopySrc = 0x00000001, - WGPUTextureUsage_CopyDst = 0x00000002, - WGPUTextureUsage_TextureBinding = 0x00000004, - WGPUTextureUsage_StorageBinding = 0x00000008, - WGPUTextureUsage_RenderAttachment = 0x00000010, - WGPUTextureUsage_Force32 = 0x7FFFFFFF -} WGPUTextureUsage ; -typedef WGPUFlags WGPUTextureUsageFlags ; - -typedef void (*WGPUBufferMapCallback)(WGPUBufferMapAsyncStatus status, void * userdata) ; -typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, void * userdata) ; -typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, void * userdata) ; -typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, void * userdata) ; -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) ; -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) ; -typedef void (*WGPUProc)(void) ; -typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, void * userdata) ; -typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, void * userdata) ; -typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, void * userdata) ; - -typedef struct WGPUChainedStruct { - struct WGPUChainedStruct const * next; - WGPUSType sType; -} WGPUChainedStruct ; - -typedef struct WGPUChainedStructOut { - struct WGPUChainedStructOut * next; - WGPUSType sType; -} WGPUChainedStructOut ; - -typedef struct WGPUAdapterProperties { - WGPUChainedStructOut * nextInChain; - uint32_t vendorID; - char const * vendorName; - char const * architecture; - uint32_t deviceID; - char const * name; - char const * driverDescription; - WGPUAdapterType adapterType; - WGPUBackendType backendType; -} WGPUAdapterProperties ; - -typedef struct WGPUBindGroupEntry { - WGPUChainedStruct const * nextInChain; - uint32_t binding; - WGPUBuffer buffer; - uint64_t offset; - uint64_t size; - WGPUSampler sampler; - WGPUTextureView textureView; -} WGPUBindGroupEntry ; - -typedef struct WGPUBlendComponent { - WGPUBlendOperation operation; - WGPUBlendFactor srcFactor; - WGPUBlendFactor dstFactor; -} WGPUBlendComponent ; - -typedef struct WGPUBufferBindingLayout { - WGPUChainedStruct const * nextInChain; - WGPUBufferBindingType type; - WGPUBool hasDynamicOffset; - uint64_t minBindingSize; -} WGPUBufferBindingLayout ; - -typedef struct WGPUBufferDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUBufferUsageFlags usage; - uint64_t size; - WGPUBool mappedAtCreation; -} WGPUBufferDescriptor ; - -typedef struct WGPUColor { - double r; - double g; - double b; - double a; -} WGPUColor ; - -typedef struct WGPUCommandBufferDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; -} WGPUCommandBufferDescriptor ; - -typedef struct WGPUCommandEncoderDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; -} WGPUCommandEncoderDescriptor ; - -typedef struct WGPUCompilationMessage { - WGPUChainedStruct const * nextInChain; - char const * message; - WGPUCompilationMessageType type; - uint64_t lineNum; - uint64_t linePos; - uint64_t offset; - uint64_t length; - uint64_t utf16LinePos; - uint64_t utf16Offset; - uint64_t utf16Length; -} WGPUCompilationMessage ; - -typedef struct WGPUComputePassTimestampWrites { - WGPUQuerySet querySet; - uint32_t beginningOfPassWriteIndex; - uint32_t endOfPassWriteIndex; -} WGPUComputePassTimestampWrites ; - -typedef struct WGPUConstantEntry { - WGPUChainedStruct const * nextInChain; - char const * key; - double value; -} WGPUConstantEntry ; - -typedef struct WGPUExtent3D { - uint32_t width; - uint32_t height; - uint32_t depthOrArrayLayers; -} WGPUExtent3D ; - -typedef struct WGPUInstanceDescriptor { - WGPUChainedStruct const * nextInChain; -} WGPUInstanceDescriptor ; - -typedef struct WGPULimits { - uint32_t maxTextureDimension1D; - uint32_t maxTextureDimension2D; - uint32_t maxTextureDimension3D; - uint32_t maxTextureArrayLayers; - uint32_t maxBindGroups; - uint32_t maxBindGroupsPlusVertexBuffers; - uint32_t maxBindingsPerBindGroup; - uint32_t maxDynamicUniformBuffersPerPipelineLayout; - uint32_t maxDynamicStorageBuffersPerPipelineLayout; - uint32_t maxSampledTexturesPerShaderStage; - uint32_t maxSamplersPerShaderStage; - uint32_t maxStorageBuffersPerShaderStage; - uint32_t maxStorageTexturesPerShaderStage; - uint32_t maxUniformBuffersPerShaderStage; - uint64_t maxUniformBufferBindingSize; - uint64_t maxStorageBufferBindingSize; - uint32_t minUniformBufferOffsetAlignment; - uint32_t minStorageBufferOffsetAlignment; - uint32_t maxVertexBuffers; - uint64_t maxBufferSize; - uint32_t maxVertexAttributes; - uint32_t maxVertexBufferArrayStride; - uint32_t maxInterStageShaderComponents; - uint32_t maxInterStageShaderVariables; - uint32_t maxColorAttachments; - uint32_t maxColorAttachmentBytesPerSample; - uint32_t maxComputeWorkgroupStorageSize; - uint32_t maxComputeInvocationsPerWorkgroup; - uint32_t maxComputeWorkgroupSizeX; - uint32_t maxComputeWorkgroupSizeY; - uint32_t maxComputeWorkgroupSizeZ; - uint32_t maxComputeWorkgroupsPerDimension; -} WGPULimits ; - -typedef struct WGPUMultisampleState { - WGPUChainedStruct const * nextInChain; - uint32_t count; - uint32_t mask; - WGPUBool alphaToCoverageEnabled; -} WGPUMultisampleState ; - -typedef struct WGPUOrigin3D { - uint32_t x; - uint32_t y; - uint32_t z; -} WGPUOrigin3D ; - -typedef struct WGPUPipelineLayoutDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t bindGroupLayoutCount; - WGPUBindGroupLayout const * bindGroupLayouts; -} WGPUPipelineLayoutDescriptor ; - -// Can be chained in WGPUPrimitiveState -typedef struct WGPUPrimitiveDepthClipControl { - WGPUChainedStruct chain; - WGPUBool unclippedDepth; -} WGPUPrimitiveDepthClipControl ; - -typedef struct WGPUPrimitiveState { - WGPUChainedStruct const * nextInChain; - WGPUPrimitiveTopology topology; - WGPUIndexFormat stripIndexFormat; - WGPUFrontFace frontFace; - WGPUCullMode cullMode; -} WGPUPrimitiveState ; - -typedef struct WGPUQuerySetDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUQueryType type; - uint32_t count; -} WGPUQuerySetDescriptor ; - -typedef struct WGPUQueueDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; -} WGPUQueueDescriptor ; - -typedef struct WGPURenderBundleDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; -} WGPURenderBundleDescriptor ; - -typedef struct WGPURenderBundleEncoderDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t colorFormatCount; - WGPUTextureFormat const * colorFormats; - WGPUTextureFormat depthStencilFormat; - uint32_t sampleCount; - WGPUBool depthReadOnly; - WGPUBool stencilReadOnly; -} WGPURenderBundleEncoderDescriptor ; - -typedef struct WGPURenderPassDepthStencilAttachment { - WGPUTextureView view; - WGPULoadOp depthLoadOp; - WGPUStoreOp depthStoreOp; - float depthClearValue; - WGPUBool depthReadOnly; - WGPULoadOp stencilLoadOp; - WGPUStoreOp stencilStoreOp; - uint32_t stencilClearValue; - WGPUBool stencilReadOnly; -} WGPURenderPassDepthStencilAttachment ; - -// Can be chained in WGPURenderPassDescriptor -typedef struct WGPURenderPassDescriptorMaxDrawCount { - WGPUChainedStruct chain; - uint64_t maxDrawCount; -} WGPURenderPassDescriptorMaxDrawCount ; - -typedef struct WGPURenderPassTimestampWrites { - WGPUQuerySet querySet; - uint32_t beginningOfPassWriteIndex; - uint32_t endOfPassWriteIndex; -} WGPURenderPassTimestampWrites ; - -typedef struct WGPURequestAdapterOptions { - WGPUChainedStruct const * nextInChain; - WGPUSurface compatibleSurface; - WGPUPowerPreference powerPreference; - WGPUBackendType backendType; - WGPUBool forceFallbackAdapter; -} WGPURequestAdapterOptions ; - -typedef struct WGPUSamplerBindingLayout { - WGPUChainedStruct const * nextInChain; - WGPUSamplerBindingType type; -} WGPUSamplerBindingLayout ; - -typedef struct WGPUSamplerDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUAddressMode addressModeU; - WGPUAddressMode addressModeV; - WGPUAddressMode addressModeW; - WGPUFilterMode magFilter; - WGPUFilterMode minFilter; - WGPUMipmapFilterMode mipmapFilter; - float lodMinClamp; - float lodMaxClamp; - WGPUCompareFunction compare; - uint16_t maxAnisotropy; -} WGPUSamplerDescriptor ; - -typedef struct WGPUShaderModuleCompilationHint { - WGPUChainedStruct const * nextInChain; - char const * entryPoint; - WGPUPipelineLayout layout; -} WGPUShaderModuleCompilationHint ; - -// Can be chained in WGPUShaderModuleDescriptor -typedef struct WGPUShaderModuleSPIRVDescriptor { - WGPUChainedStruct chain; - uint32_t codeSize; - uint32_t const * code; -} WGPUShaderModuleSPIRVDescriptor ; - -// Can be chained in WGPUShaderModuleDescriptor -typedef struct WGPUShaderModuleWGSLDescriptor { - WGPUChainedStruct chain; - char const * code; -} WGPUShaderModuleWGSLDescriptor ; - -typedef struct WGPUStencilFaceState { - WGPUCompareFunction compare; - WGPUStencilOperation failOp; - WGPUStencilOperation depthFailOp; - WGPUStencilOperation passOp; -} WGPUStencilFaceState ; - -typedef struct WGPUStorageTextureBindingLayout { - WGPUChainedStruct const * nextInChain; - WGPUStorageTextureAccess access; - WGPUTextureFormat format; - WGPUTextureViewDimension viewDimension; -} WGPUStorageTextureBindingLayout ; - -typedef struct WGPUSurfaceCapabilities { - WGPUChainedStructOut * nextInChain; - size_t formatCount; - WGPUTextureFormat * formats; - size_t presentModeCount; - WGPUPresentMode * presentModes; - size_t alphaModeCount; - WGPUCompositeAlphaMode * alphaModes; -} WGPUSurfaceCapabilities ; - -typedef struct WGPUSurfaceConfiguration { - WGPUChainedStruct const * nextInChain; - WGPUDevice device; - WGPUTextureFormat format; - WGPUTextureUsageFlags usage; - size_t viewFormatCount; - WGPUTextureFormat const * viewFormats; - WGPUCompositeAlphaMode alphaMode; - uint32_t width; - uint32_t height; - WGPUPresentMode presentMode; -} WGPUSurfaceConfiguration ; - -typedef struct WGPUSurfaceDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; -} WGPUSurfaceDescriptor ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { - WGPUChainedStruct chain; - void * window; -} WGPUSurfaceDescriptorFromAndroidNativeWindow ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { - WGPUChainedStruct chain; - char const * selector; -} WGPUSurfaceDescriptorFromCanvasHTMLSelector ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromMetalLayer { - WGPUChainedStruct chain; - void * layer; -} WGPUSurfaceDescriptorFromMetalLayer ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromWaylandSurface { - WGPUChainedStruct chain; - void * display; - void * surface; -} WGPUSurfaceDescriptorFromWaylandSurface ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromWindowsHWND { - WGPUChainedStruct chain; - void * hinstance; - void * hwnd; -} WGPUSurfaceDescriptorFromWindowsHWND ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromXcbWindow { - WGPUChainedStruct chain; - void * connection; - uint32_t window; -} WGPUSurfaceDescriptorFromXcbWindow ; - -// Can be chained in WGPUSurfaceDescriptor -typedef struct WGPUSurfaceDescriptorFromXlibWindow { - WGPUChainedStruct chain; - void * display; - uint32_t window; -} WGPUSurfaceDescriptorFromXlibWindow ; - -typedef struct WGPUSurfaceTexture { - WGPUTexture texture; - WGPUBool suboptimal; - WGPUSurfaceGetCurrentTextureStatus status; -} WGPUSurfaceTexture ; - -typedef struct WGPUTextureBindingLayout { - WGPUChainedStruct const * nextInChain; - WGPUTextureSampleType sampleType; - WGPUTextureViewDimension viewDimension; - WGPUBool multisampled; -} WGPUTextureBindingLayout ; - -typedef struct WGPUTextureDataLayout { - WGPUChainedStruct const * nextInChain; - uint64_t offset; - uint32_t bytesPerRow; - uint32_t rowsPerImage; -} WGPUTextureDataLayout ; - -typedef struct WGPUTextureViewDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUTextureFormat format; - WGPUTextureViewDimension dimension; - uint32_t baseMipLevel; - uint32_t mipLevelCount; - uint32_t baseArrayLayer; - uint32_t arrayLayerCount; - WGPUTextureAspect aspect; -} WGPUTextureViewDescriptor ; - -typedef struct WGPUVertexAttribute { - WGPUVertexFormat format; - uint64_t offset; - uint32_t shaderLocation; -} WGPUVertexAttribute ; - -typedef struct WGPUBindGroupDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUBindGroupLayout layout; - size_t entryCount; - WGPUBindGroupEntry const * entries; -} WGPUBindGroupDescriptor ; - -typedef struct WGPUBindGroupLayoutEntry { - WGPUChainedStruct const * nextInChain; - uint32_t binding; - WGPUShaderStageFlags visibility; - WGPUBufferBindingLayout buffer; - WGPUSamplerBindingLayout sampler; - WGPUTextureBindingLayout texture; - WGPUStorageTextureBindingLayout storageTexture; -} WGPUBindGroupLayoutEntry ; - -typedef struct WGPUBlendState { - WGPUBlendComponent color; - WGPUBlendComponent alpha; -} WGPUBlendState ; - -typedef struct WGPUCompilationInfo { - WGPUChainedStruct const * nextInChain; - size_t messageCount; - WGPUCompilationMessage const * messages; -} WGPUCompilationInfo ; - -typedef struct WGPUComputePassDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUComputePassTimestampWrites const * timestampWrites; -} WGPUComputePassDescriptor ; - -typedef struct WGPUDepthStencilState { - WGPUChainedStruct const * nextInChain; - WGPUTextureFormat format; - WGPUBool depthWriteEnabled; - WGPUCompareFunction depthCompare; - WGPUStencilFaceState stencilFront; - WGPUStencilFaceState stencilBack; - uint32_t stencilReadMask; - uint32_t stencilWriteMask; - int32_t depthBias; - float depthBiasSlopeScale; - float depthBiasClamp; -} WGPUDepthStencilState ; - -typedef struct WGPUImageCopyBuffer { - WGPUChainedStruct const * nextInChain; - WGPUTextureDataLayout layout; - WGPUBuffer buffer; -} WGPUImageCopyBuffer ; - -typedef struct WGPUImageCopyTexture { - WGPUChainedStruct const * nextInChain; - WGPUTexture texture; - uint32_t mipLevel; - WGPUOrigin3D origin; - WGPUTextureAspect aspect; -} WGPUImageCopyTexture ; - -typedef struct WGPUProgrammableStageDescriptor { - WGPUChainedStruct const * nextInChain; - WGPUShaderModule module; - char const * entryPoint; - size_t constantCount; - WGPUConstantEntry const * constants; -} WGPUProgrammableStageDescriptor ; - -typedef struct WGPURenderPassColorAttachment { - WGPUChainedStruct const * nextInChain; - WGPUTextureView view; - WGPUTextureView resolveTarget; - WGPULoadOp loadOp; - WGPUStoreOp storeOp; - WGPUColor clearValue; -} WGPURenderPassColorAttachment ; - -typedef struct WGPURequiredLimits { - WGPUChainedStruct const * nextInChain; - WGPULimits limits; -} WGPURequiredLimits ; - -typedef struct WGPUShaderModuleDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t hintCount; - WGPUShaderModuleCompilationHint const * hints; -} WGPUShaderModuleDescriptor ; - -typedef struct WGPUSupportedLimits { - WGPUChainedStructOut * nextInChain; - WGPULimits limits; -} WGPUSupportedLimits ; - -typedef struct WGPUTextureDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUTextureUsageFlags usage; - WGPUTextureDimension dimension; - WGPUExtent3D size; - WGPUTextureFormat format; - uint32_t mipLevelCount; - uint32_t sampleCount; - size_t viewFormatCount; - WGPUTextureFormat const * viewFormats; -} WGPUTextureDescriptor ; - -typedef struct WGPUVertexBufferLayout { - uint64_t arrayStride; - WGPUVertexStepMode stepMode; - size_t attributeCount; - WGPUVertexAttribute const * attributes; -} WGPUVertexBufferLayout ; - -typedef struct WGPUBindGroupLayoutDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t entryCount; - WGPUBindGroupLayoutEntry const * entries; -} WGPUBindGroupLayoutDescriptor ; - -typedef struct WGPUColorTargetState { - WGPUChainedStruct const * nextInChain; - WGPUTextureFormat format; - WGPUBlendState const * blend; - WGPUColorWriteMaskFlags writeMask; -} WGPUColorTargetState ; - -typedef struct WGPUComputePipelineDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUPipelineLayout layout; - WGPUProgrammableStageDescriptor compute; -} WGPUComputePipelineDescriptor ; - -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t requiredFeatureCount; - WGPUFeatureName const * requiredFeatures; - WGPURequiredLimits const * requiredLimits; - WGPUQueueDescriptor defaultQueue; - WGPUDeviceLostCallback deviceLostCallback; - void * deviceLostUserdata; -} WGPUDeviceDescriptor ; - -typedef struct WGPURenderPassDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - size_t colorAttachmentCount; - WGPURenderPassColorAttachment const * colorAttachments; - WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; - WGPUQuerySet occlusionQuerySet; - WGPURenderPassTimestampWrites const * timestampWrites; -} WGPURenderPassDescriptor ; - -typedef struct WGPUVertexState { - WGPUChainedStruct const * nextInChain; - WGPUShaderModule module; - char const * entryPoint; - size_t constantCount; - WGPUConstantEntry const * constants; - size_t bufferCount; - WGPUVertexBufferLayout const * buffers; -} WGPUVertexState ; - -typedef struct WGPUFragmentState { - WGPUChainedStruct const * nextInChain; - WGPUShaderModule module; - char const * entryPoint; - size_t constantCount; - WGPUConstantEntry const * constants; - size_t targetCount; - WGPUColorTargetState const * targets; -} WGPUFragmentState ; - -typedef struct WGPURenderPipelineDescriptor { - WGPUChainedStruct const * nextInChain; - char const * label; - WGPUPipelineLayout layout; - WGPUVertexState vertex; - WGPUPrimitiveState primitive; - WGPUDepthStencilState const * depthStencil; - WGPUMultisampleState multisample; - WGPUFragmentState const * fragment; -} WGPURenderPipelineDescriptor ; - - WGPUInstance wgpuCreateInstance( WGPUInstanceDescriptor const * descriptor) ; - WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) ; - -// Methods of Adapter - size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) ; - WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) ; - void wgpuAdapterGetProperties(WGPUAdapter adapter, WGPUAdapterProperties * properties) ; - WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) ; - void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallback callback, void * userdata) ; - void wgpuAdapterReference(WGPUAdapter adapter) ; - void wgpuAdapterRelease(WGPUAdapter adapter) ; - -// Methods of BindGroup - void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) ; - void wgpuBindGroupReference(WGPUBindGroup bindGroup) ; - void wgpuBindGroupRelease(WGPUBindGroup bindGroup) ; - -// Methods of BindGroupLayout - void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) ; - void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) ; - void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) ; - -// Methods of Buffer - void wgpuBufferDestroy(WGPUBuffer buffer) ; - void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) ; - WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) ; - void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) ; - uint64_t wgpuBufferGetSize(WGPUBuffer buffer) ; - WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) ; - void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata) ; - void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) ; - void wgpuBufferUnmap(WGPUBuffer buffer) ; - void wgpuBufferReference(WGPUBuffer buffer) ; - void wgpuBufferRelease(WGPUBuffer buffer) ; - -// Methods of CommandBuffer - void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) ; - void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) ; - void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) ; - -// Methods of CommandEncoder - WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor) ; - WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) ; - void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) ; - void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) ; - void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) ; - void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) ; - void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) ; - WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor) ; - void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) ; - void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) ; - void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) ; - void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) ; - void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) ; - void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) ; - void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) ; - void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) ; - -// Methods of ComputePassEncoder - void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) ; - void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) ; - void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) ; - void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) ; - void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) ; - void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) ; - void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) ; - void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) ; - void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) ; - void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) ; - void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) ; - -// Methods of ComputePipeline - WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) ; - void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) ; - void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) ; - void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) ; - -// Methods of Device - WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) ; - WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) ; - WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) ; - WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor) ; - WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) ; - void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallback callback, void * userdata) ; - WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) ; - WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) ; - WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) ; - WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) ; - void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata) ; - WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor) ; - WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) ; - WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) ; - void wgpuDeviceDestroy(WGPUDevice device) ; - size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) ; - WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) ; - WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) ; - WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) ; - void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) ; - void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) ; - void wgpuDeviceSetLabel(WGPUDevice device, char const * label) ; - void wgpuDeviceSetUncapturedErrorCallback(WGPUDevice device, WGPUErrorCallback callback, void * userdata) ; - void wgpuDeviceReference(WGPUDevice device) ; - void wgpuDeviceRelease(WGPUDevice device) ; - -// Methods of Instance - WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) ; - void wgpuInstanceProcessEvents(WGPUInstance instance) ; - void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallback callback, void * userdata) ; - void wgpuInstanceReference(WGPUInstance instance) ; - void wgpuInstanceRelease(WGPUInstance instance) ; - -// Methods of PipelineLayout - void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) ; - void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) ; - void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) ; - -// Methods of QuerySet - void wgpuQuerySetDestroy(WGPUQuerySet querySet) ; - uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) ; - WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) ; - void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) ; - void wgpuQuerySetReference(WGPUQuerySet querySet) ; - void wgpuQuerySetRelease(WGPUQuerySet querySet) ; - -// Methods of Queue - void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallback callback, void * userdata) ; - void wgpuQueueSetLabel(WGPUQueue queue, char const * label) ; - void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) ; - void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) ; - void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) ; - void wgpuQueueReference(WGPUQueue queue) ; - void wgpuQueueRelease(WGPUQueue queue) ; - -// Methods of RenderBundle - void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) ; - void wgpuRenderBundleReference(WGPURenderBundle renderBundle) ; - void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) ; - -// Methods of RenderBundleEncoder - void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) ; - void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) ; - void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) ; - void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) ; - WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor) ; - void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) ; - void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) ; - void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) ; - void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) ; - void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) ; - void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) ; - void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) ; - void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) ; - void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) ; - void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) ; - -// Methods of RenderPassEncoder - void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) ; - void wgpuRenderPassEncoderDraw(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) ; - void wgpuRenderPassEncoderDrawIndexed(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) ; - void wgpuRenderPassEncoderDrawIndexedIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) ; - void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) ; - void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) ; - void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) ; - void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) ; - void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) ; - void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) ; - void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) ; - void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) ; - void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) ; - void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) ; - void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) ; - void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) ; - void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) ; - void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) ; - void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPUBuffer buffer, uint64_t offset, uint64_t size) ; - void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) ; - void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) ; - void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) ; - -// Methods of RenderPipeline - WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) ; - void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) ; - void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) ; - void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) ; - -// Methods of Sampler - void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) ; - void wgpuSamplerReference(WGPUSampler sampler) ; - void wgpuSamplerRelease(WGPUSampler sampler) ; - -// Methods of ShaderModule - void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) ; - void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) ; - void wgpuShaderModuleReference(WGPUShaderModule shaderModule) ; - void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) ; - -// Methods of Surface - void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * config) ; - void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) ; - void wgpuSurfaceGetCurrentTexture(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) ; - WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter) ; - void wgpuSurfacePresent(WGPUSurface surface) ; - void wgpuSurfaceUnconfigure(WGPUSurface surface) ; - void wgpuSurfaceReference(WGPUSurface surface) ; - void wgpuSurfaceRelease(WGPUSurface surface) ; - -// Methods of SurfaceCapabilities - void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities capabilities) ; - -// Methods of Texture - WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor) ; - void wgpuTextureDestroy(WGPUTexture texture) ; - uint32_t wgpuTextureGetDepthOrArrayLayers(WGPUTexture texture) ; - WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture) ; - WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) ; - uint32_t wgpuTextureGetHeight(WGPUTexture texture) ; - uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) ; - uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) ; - WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) ; - uint32_t wgpuTextureGetWidth(WGPUTexture texture) ; - void wgpuTextureSetLabel(WGPUTexture texture, char const * label) ; - void wgpuTextureReference(WGPUTexture texture) ; - void wgpuTextureRelease(WGPUTexture texture) ; - -// Methods of TextureView - void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) ; - void wgpuTextureViewReference(WGPUTextureView textureView) ; - void wgpuTextureViewRelease(WGPUTextureView textureView) ; - -typedef enum WGPUNativeSType { - // Start at 0003 since that's allocated range for wgpu-native - WGPUSType_DeviceExtras = 0x00030001, - WGPUSType_RequiredLimitsExtras = 0x00030002, - WGPUSType_PipelineLayoutExtras = 0x00030003, - WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, - WGPUSType_SupportedLimitsExtras = 0x00030005, - WGPUSType_InstanceExtras = 0x00030006, - WGPUSType_BindGroupEntryExtras = 0x00030007, - WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, - WGPUSType_QuerySetDescriptorExtras = 0x00030009, - WGPUNativeSType_Force32 = 0x7FFFFFFF -} WGPUNativeSType ; - -typedef enum WGPUNativeFeature { - WGPUNativeFeature_PushConstants = 0x00030001, - WGPUNativeFeature_TextureAdapterSpecificFormatFeatures = 0x00030002, - WGPUNativeFeature_MultiDrawIndirect = 0x00030003, - WGPUNativeFeature_MultiDrawIndirectCount = 0x00030004, - WGPUNativeFeature_VertexWritableStorage = 0x00030005, - WGPUNativeFeature_TextureBindingArray = 0x00030006, - WGPUNativeFeature_SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007, - WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, - WGPUNativeFeature_Force32 = 0x7FFFFFFF -} WGPUNativeFeature ; - -typedef enum WGPULogLevel { - WGPULogLevel_Off = 0x00000000, - WGPULogLevel_Error = 0x00000001, - WGPULogLevel_Warn = 0x00000002, - WGPULogLevel_Info = 0x00000003, - WGPULogLevel_Debug = 0x00000004, - WGPULogLevel_Trace = 0x00000005, - WGPULogLevel_Force32 = 0x7FFFFFFF -} WGPULogLevel ; - -typedef enum WGPUInstanceBackend { - WGPUInstanceBackend_All = 0x00000000, - WGPUInstanceBackend_Vulkan = 1 << 0, - WGPUInstanceBackend_GL = 1 << 1, - WGPUInstanceBackend_Metal = 1 << 2, - WGPUInstanceBackend_DX12 = 1 << 3, - WGPUInstanceBackend_DX11 = 1 << 4, - WGPUInstanceBackend_BrowserWebGPU = 1 << 5, - WGPUInstanceBackend_Force32 = 0x7FFFFFFF -} WGPUInstanceBackend ; -typedef WGPUFlags WGPUInstanceBackendFlags ; - -typedef enum WGPUInstanceFlag { - WGPUInstanceFlag_Default = 0x00000000, - WGPUInstanceFlag_Debug = 1 << 0, - WGPUInstanceFlag_Validation = 1 << 1, - WGPUInstanceFlag_DiscardHalLabels = 1 << 2, - WGPUInstanceFlag_Force32 = 0x7FFFFFFF -} WGPUInstanceFlag ; -typedef WGPUFlags WGPUInstanceFlags ; - -typedef enum WGPUDx12Compiler { - WGPUDx12Compiler_Undefined = 0x00000000, - WGPUDx12Compiler_Fxc = 0x00000001, - WGPUDx12Compiler_Dxc = 0x00000002, - WGPUDx12Compiler_Force32 = 0x7FFFFFFF -} WGPUDx12Compiler ; - -typedef enum WGPUGles3MinorVersion { - WGPUGles3MinorVersion_Automatic = 0x00000000, - WGPUGles3MinorVersion_Version0 = 0x00000001, - WGPUGles3MinorVersion_Version1 = 0x00000002, - WGPUGles3MinorVersion_Version2 = 0x00000003, - WGPUGles3MinorVersion_Force32 = 0x7FFFFFFF -} WGPUGles3MinorVersion ; - -typedef enum WGPUPipelineStatisticName { - WGPUPipelineStatisticName_VertexShaderInvocations = 0x00000000, - WGPUPipelineStatisticName_ClipperInvocations = 0x00000001, - WGPUPipelineStatisticName_ClipperPrimitivesOut = 0x00000002, - WGPUPipelineStatisticName_FragmentShaderInvocations = 0x00000003, - WGPUPipelineStatisticName_ComputeShaderInvocations = 0x00000004, - WGPUPipelineStatisticName_Force32 = 0x7FFFFFFF -} WGPUPipelineStatisticName ; - -typedef enum WGPUNativeQueryType { - WGPUNativeQueryType_PipelineStatistics = 0x00030000, - WGPUNativeQueryType_Force32 = 0x7FFFFFFF -} WGPUNativeQueryType ; - -typedef struct WGPUInstanceExtras { - WGPUChainedStruct chain; - WGPUInstanceBackendFlags backends; - WGPUInstanceFlags flags; - WGPUDx12Compiler dx12ShaderCompiler; - WGPUGles3MinorVersion gles3MinorVersion; - const char * dxilPath; - const char * dxcPath; -} WGPUInstanceExtras ; - -typedef struct WGPUDeviceExtras { - WGPUChainedStruct chain; - const char * tracePath; -} WGPUDeviceExtras ; - -typedef struct WGPUNativeLimits { - uint32_t maxPushConstantSize; - uint32_t maxNonSamplerBindings; -} WGPUNativeLimits ; - -typedef struct WGPURequiredLimitsExtras { - WGPUChainedStruct chain; - WGPUNativeLimits limits; -} WGPURequiredLimitsExtras ; - -typedef struct WGPUSupportedLimitsExtras { - WGPUChainedStructOut chain; - WGPUNativeLimits limits; -} WGPUSupportedLimitsExtras ; - -typedef struct WGPUPushConstantRange { - WGPUShaderStageFlags stages; - uint32_t start; - uint32_t end; -} WGPUPushConstantRange ; - -typedef struct WGPUPipelineLayoutExtras { - WGPUChainedStruct chain; - uint32_t pushConstantRangeCount; - WGPUPushConstantRange * pushConstantRanges; -} WGPUPipelineLayoutExtras ; - -typedef uint64_t WGPUSubmissionIndex; - -typedef struct WGPUWrappedSubmissionIndex { - WGPUQueue queue; - WGPUSubmissionIndex submissionIndex; -} WGPUWrappedSubmissionIndex ; - -typedef struct WGPUShaderDefine { - char const * name; - char const * value; -} WGPUShaderDefine ; - -typedef struct WGPUShaderModuleGLSLDescriptor { - WGPUChainedStruct chain; - WGPUShaderStage stage; - char const * code; - uint32_t defineCount; - WGPUShaderDefine * defines; -} WGPUShaderModuleGLSLDescriptor ; - -typedef struct WGPUStorageReport { - size_t numOccupied; - size_t numVacant; - size_t numError; - size_t elementSize; -} WGPUStorageReport ; - -typedef struct WGPUHubReport { - WGPUStorageReport adapters; - WGPUStorageReport devices; - WGPUStorageReport pipelineLayouts; - WGPUStorageReport shaderModules; - WGPUStorageReport bindGroupLayouts; - WGPUStorageReport bindGroups; - WGPUStorageReport commandBuffers; - WGPUStorageReport renderBundles; - WGPUStorageReport renderPipelines; - WGPUStorageReport computePipelines; - WGPUStorageReport querySets; - WGPUStorageReport buffers; - WGPUStorageReport textures; - WGPUStorageReport textureViews; - WGPUStorageReport samplers; -} WGPUHubReport ; - -typedef struct WGPUGlobalReport { - WGPUStorageReport surfaces; - WGPUBackendType backendType; - WGPUHubReport vulkan; - WGPUHubReport metal; - WGPUHubReport dx12; - WGPUHubReport dx11; - WGPUHubReport gl; -} WGPUGlobalReport ; - -typedef struct WGPUInstanceEnumerateAdapterOptions { - WGPUChainedStruct const * nextInChain; - WGPUInstanceBackendFlags backends; -} WGPUInstanceEnumerateAdapterOptions ; - -typedef struct WGPUBindGroupEntryExtras { - WGPUChainedStruct chain; - WGPUBuffer const * buffers; - size_t bufferCount; - WGPUSampler const * samplers; - size_t samplerCount; - WGPUTextureView const * textureViews; - size_t textureViewCount; -} WGPUBindGroupEntryExtras ; - -typedef struct WGPUBindGroupLayoutEntryExtras { - WGPUChainedStruct chain; - uint32_t count; -} WGPUBindGroupLayoutEntryExtras ; - -typedef struct WGPUQuerySetDescriptorExtras { - WGPUChainedStruct chain; - WGPUPipelineStatisticName const * pipelineStatistics; - size_t pipelineStatisticCount; -} WGPUQuerySetDescriptorExtras ; - -typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata) ; - - void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report) ; - size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters) ; - - WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) ; - -// Returns true if the queue is empty, or false if there are more queue submissions still in flight. - WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) ; - - void wgpuSetLogCallback(WGPULogCallback callback, void * userdata) ; - - void wgpuSetLogLevel(WGPULogLevel level) ; - - uint32_t wgpuGetVersion() ; - - void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void * const data) ; - - void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count) ; - void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count) ; - - void wgpuRenderPassEncoderMultiDrawIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count) ; - void wgpuRenderPassEncoderMultiDrawIndexedIndirectCount(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, WGPUBuffer count_buffer, uint64_t count_buffer_offset, uint32_t max_count) ; - - void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) ; - void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder) ; - void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) ; - void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder) ; - -extern "Python" void _raw_callback_BufferMapCallback(WGPUBufferMapAsyncStatus, void *); -extern "Python" void _raw_callback_CompilationInfoCallback(WGPUCompilationInfoRequestStatus, const WGPUCompilationInfo *, void *); -extern "Python" void _raw_callback_CreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, const char *, void *); -extern "Python" void _raw_callback_CreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, const char *, void *); -extern "Python" void _raw_callback_DeviceLostCallback(WGPUDeviceLostReason, const char *, void *); -extern "Python" void _raw_callback_ErrorCallback(WGPUErrorType, const char *, void *); -extern "Python" void _raw_callback_QueueWorkDoneCallback(WGPUQueueWorkDoneStatus, void *); -extern "Python" void _raw_callback_RequestAdapterCallback(WGPURequestAdapterStatus, WGPUAdapter, const char *, void *); -extern "Python" void _raw_callback_RequestDeviceCallback(WGPURequestDeviceStatus, WGPUDevice, const char *, void *); -extern "Python" void _raw_callback_ProcDeviceSetUncapturedErrorCallback(WGPUDevice, WGPUErrorCallback, void *); -extern "Python" void _raw_callback_LogCallback(WGPULogLevel, const char *, void *);""" -SOURCE = """ -#include "include/wgpu.h" -""" - -# get the current root directory we're running in -cwd = os.path.abspath(os.path.dirname(__file__)) - -ffibuilder.cdef(CDEF) -ffibuilder.set_source( - "_wgpu_native_cffi", SOURCE, libraries=["wgpu_native"], library_dirs=["."] -) - -if __name__ == "__main__": - # remove any orphaned build artifacts - outdir = cwd - [ - os.remove(os.path.join(cwd, name)) - for name in os.listdir(outdir) - if name.startswith("_wgpu_native_cffi.") - ] - - # build the library and save the full path to the built file - path_compiled: str = ffibuilder.compile(verbose=True) - - # patch the rpath so our CFFI library can find wgpu_native sitting next to it - # todo : this is platform specific, we should check the extension of path_compiled - if sys.platform.startswith("linux"): - subprocess.check_call( - ["patchelf", "--set-rpath", "$ORIGIN", path_compiled], cwd=cwd - ) diff --git a/webgoo/bindings.py b/webgoo/bindings.py deleted file mode 100644 index 39f633e..0000000 --- a/webgoo/bindings.py +++ /dev/null @@ -1,8697 +0,0 @@ -# AUTOGENERATED -from abc import ABC, abstractmethod -from collections.abc import Callable, Iterator -from enum import IntEnum -from typing import Any, Optional, Union - -from ._wgpu_native_cffi import ffi, lib - - -def funny_version_name() -> str: - return "aggressive-alpaca" - - -# make typing temporarily happy until I can figure out if there's -# a better way to have type information about CData fields -CData = Any - - -def _ffi_new(typespec: str, count: Optional[int] = None) -> CData: - return ffi.new(typespec, count) - - -def _ffi_init(typespec: str, initializer: Optional[Any]) -> CData: - if initializer is None: - return ffi.new(typespec) - else: - return initializer - - -def _ffi_deref(cdata): - if ffi.typeof(cdata).kind == "pointer": - return cdata[0] - else: - return cdata - - -def _ffi_unwrap_optional(val): - if val is None: - return ffi.NULL - else: - return val._cdata - - -def _ffi_unwrap_str(val: Optional[str]): - if val is None: - val = "" - return ffi.new("char[]", val.encode("utf8")) - - -def _ffi_string(val) -> str: - if val == ffi.NULL: - return "" - ret = ffi.string(val) - if isinstance(ret, bytes): - return ret.decode("utf8") - elif isinstance(ret, str): - return ret - else: - raise RuntimeError("IMPOSSIBLE") - - -def _cast_userdata(ud: CData) -> int: - return ffi.cast("int *", ud)[0] - - -class Chainable(ABC): - @property - @abstractmethod - def _chain(self) -> Any: - ... - - -class ChainedStruct: - def __init__(self, chain: list["Chainable"]): - self.chain = chain - if len(chain) == 0: - self._cdata = ffi.NULL - return - self._cdata = ffi.addressof(chain[0]._chain) - next_ptrs = [ffi.addressof(link._chain) for link in chain[1:]] + [ffi.NULL] - for idx, ptr in enumerate(next_ptrs): - chain[idx]._chain.next = ptr - - -# TODO: figure out a nicer way to generically handle this -# (because despite being layout-identical these two types -# are actually different!) -ChainedStructOut = ChainedStruct - - -class CBMap: - def __init__(self): - self.callbacks = {} - self.index = 0 - - def add(self, cb) -> int: - retidx = self.index - self.index += 1 - self.callbacks[retidx] = cb - return retidx - - def get(self, idx): - return self.callbacks.get(idx) - - def remove(self, idx): - if idx in self.callbacks: - del self.callbacks[idx] - - -class VoidPtr: - def __init__(self, data: CData, size: Optional[int] = None): - self._ptr = data - self._size = size - - def to_bytes(self) -> bytes: - return bytes(ffi.buffer(self._ptr, self._size)) - - -def cast_any_to_void(thing: Any) -> VoidPtr: - return VoidPtr(data=ffi.cast("void *", thing), size=0) - - -NULL_VOID_PTR = VoidPtr(data=ffi.NULL, size=0) - - -def getVersionStr() -> str: - version_int = getVersion() - a = (version_int >> 24) & 0xFF - b = (version_int >> 16) & 0xFF - c = (version_int >> 8) & 0xFF - d = (version_int >> 0) & 0xFF - return f"{a}.{b}.{c}.{d}" - - -# Basic types -class AdapterType(IntEnum): - DiscreteGPU = 0x00000000 - IntegratedGPU = 0x00000001 - CPU = 0x00000002 - Unknown = 0x00000003 - - -class AddressMode(IntEnum): - Repeat = 0x00000000 - MirrorRepeat = 0x00000001 - ClampToEdge = 0x00000002 - - -class BackendType(IntEnum): - Undefined = 0x00000000 - Null = 0x00000001 - WebGPU = 0x00000002 - D3D11 = 0x00000003 - D3D12 = 0x00000004 - Metal = 0x00000005 - Vulkan = 0x00000006 - OpenGL = 0x00000007 - OpenGLES = 0x00000008 - - -class BlendFactor(IntEnum): - Zero = 0x00000000 - One = 0x00000001 - Src = 0x00000002 - OneMinusSrc = 0x00000003 - SrcAlpha = 0x00000004 - OneMinusSrcAlpha = 0x00000005 - Dst = 0x00000006 - OneMinusDst = 0x00000007 - DstAlpha = 0x00000008 - OneMinusDstAlpha = 0x00000009 - SrcAlphaSaturated = 0x0000000A - Constant = 0x0000000B - OneMinusConstant = 0x0000000C - - -class BlendOperation(IntEnum): - Add = 0x00000000 - Subtract = 0x00000001 - ReverseSubtract = 0x00000002 - Min = 0x00000003 - Max = 0x00000004 - - -class BufferBindingType(IntEnum): - Undefined = 0x00000000 - Uniform = 0x00000001 - Storage = 0x00000002 - ReadOnlyStorage = 0x00000003 - - -class BufferMapAsyncStatus(IntEnum): - Success = 0x00000000 - ValidationError = 0x00000001 - Unknown = 0x00000002 - DeviceLost = 0x00000003 - DestroyedBeforeCallback = 0x00000004 - UnmappedBeforeCallback = 0x00000005 - MappingAlreadyPending = 0x00000006 - OffsetOutOfRange = 0x00000007 - SizeOutOfRange = 0x00000008 - - -class BufferMapState(IntEnum): - Unmapped = 0x00000000 - Pending = 0x00000001 - Mapped = 0x00000002 - - -class CompareFunction(IntEnum): - Undefined = 0x00000000 - Never = 0x00000001 - Less = 0x00000002 - LessEqual = 0x00000003 - Greater = 0x00000004 - GreaterEqual = 0x00000005 - Equal = 0x00000006 - NotEqual = 0x00000007 - Always = 0x00000008 - - -class CompilationInfoRequestStatus(IntEnum): - Success = 0x00000000 - Error = 0x00000001 - DeviceLost = 0x00000002 - Unknown = 0x00000003 - - -class CompilationMessageType(IntEnum): - Error = 0x00000000 - Warning = 0x00000001 - Info = 0x00000002 - - -class CompositeAlphaMode(IntEnum): - Auto = 0x00000000 - Opaque = 0x00000001 - Premultiplied = 0x00000002 - Unpremultiplied = 0x00000003 - Inherit = 0x00000004 - - -class CreatePipelineAsyncStatus(IntEnum): - Success = 0x00000000 - ValidationError = 0x00000001 - InternalError = 0x00000002 - DeviceLost = 0x00000003 - DeviceDestroyed = 0x00000004 - Unknown = 0x00000005 - - -class CullMode(IntEnum): - _None = 0x00000000 - Front = 0x00000001 - Back = 0x00000002 - - -class DeviceLostReason(IntEnum): - Undefined = 0x00000000 - Destroyed = 0x00000001 - - -class ErrorFilter(IntEnum): - Validation = 0x00000000 - OutOfMemory = 0x00000001 - Internal = 0x00000002 - - -class ErrorType(IntEnum): - NoError = 0x00000000 - Validation = 0x00000001 - OutOfMemory = 0x00000002 - Internal = 0x00000003 - Unknown = 0x00000004 - DeviceLost = 0x00000005 - - -class FeatureName(IntEnum): - Undefined = 0x00000000 - DepthClipControl = 0x00000001 - Depth32FloatStencil8 = 0x00000002 - TimestampQuery = 0x00000003 - TextureCompressionBC = 0x00000004 - TextureCompressionETC2 = 0x00000005 - TextureCompressionASTC = 0x00000006 - IndirectFirstInstance = 0x00000007 - ShaderF16 = 0x00000008 - RG11B10UfloatRenderable = 0x00000009 - BGRA8UnormStorage = 0x0000000A - Float32Filterable = 0x0000000B - PushConstants = 0x00030001 - TextureAdapterSpecificFormatFeatures = 0x00030002 - MultiDrawIndirect = 0x00030003 - MultiDrawIndirectCount = 0x00030004 - VertexWritableStorage = 0x00030005 - TextureBindingArray = 0x00030006 - SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007 - PipelineStatisticsQuery = 0x00030008 - - -class FilterMode(IntEnum): - Nearest = 0x00000000 - Linear = 0x00000001 - - -class FrontFace(IntEnum): - CCW = 0x00000000 - CW = 0x00000001 - - -class IndexFormat(IntEnum): - Undefined = 0x00000000 - Uint16 = 0x00000001 - Uint32 = 0x00000002 - - -class LoadOp(IntEnum): - Undefined = 0x00000000 - Clear = 0x00000001 - Load = 0x00000002 - - -class MipmapFilterMode(IntEnum): - Nearest = 0x00000000 - Linear = 0x00000001 - - -class PowerPreference(IntEnum): - Undefined = 0x00000000 - LowPower = 0x00000001 - HighPerformance = 0x00000002 - - -class PresentMode(IntEnum): - Fifo = 0x00000000 - FifoRelaxed = 0x00000001 - Immediate = 0x00000002 - Mailbox = 0x00000003 - - -class PrimitiveTopology(IntEnum): - PointList = 0x00000000 - LineList = 0x00000001 - LineStrip = 0x00000002 - TriangleList = 0x00000003 - TriangleStrip = 0x00000004 - - -class QueryType(IntEnum): - Occlusion = 0x00000000 - Timestamp = 0x00000001 - - -class QueueWorkDoneStatus(IntEnum): - Success = 0x00000000 - Error = 0x00000001 - Unknown = 0x00000002 - DeviceLost = 0x00000003 - - -class RequestAdapterStatus(IntEnum): - Success = 0x00000000 - Unavailable = 0x00000001 - Error = 0x00000002 - Unknown = 0x00000003 - - -class RequestDeviceStatus(IntEnum): - Success = 0x00000000 - Error = 0x00000001 - Unknown = 0x00000002 - - -class SType(IntEnum): - Invalid = 0x00000000 - SurfaceDescriptorFromMetalLayer = 0x00000001 - SurfaceDescriptorFromWindowsHWND = 0x00000002 - SurfaceDescriptorFromXlibWindow = 0x00000003 - SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004 - ShaderModuleSPIRVDescriptor = 0x00000005 - ShaderModuleWGSLDescriptor = 0x00000006 - PrimitiveDepthClipControl = 0x00000007 - SurfaceDescriptorFromWaylandSurface = 0x00000008 - SurfaceDescriptorFromAndroidNativeWindow = 0x00000009 - SurfaceDescriptorFromXcbWindow = 0x0000000A - RenderPassDescriptorMaxDrawCount = 0x0000000F - DeviceExtras = 0x00030001 - RequiredLimitsExtras = 0x00030002 - PipelineLayoutExtras = 0x00030003 - ShaderModuleGLSLDescriptor = 0x00030004 - SupportedLimitsExtras = 0x00030005 - InstanceExtras = 0x00030006 - BindGroupEntryExtras = 0x00030007 - BindGroupLayoutEntryExtras = 0x00030008 - QuerySetDescriptorExtras = 0x00030009 - - -class SamplerBindingType(IntEnum): - Undefined = 0x00000000 - Filtering = 0x00000001 - NonFiltering = 0x00000002 - Comparison = 0x00000003 - - -class StencilOperation(IntEnum): - Keep = 0x00000000 - Zero = 0x00000001 - Replace = 0x00000002 - Invert = 0x00000003 - IncrementClamp = 0x00000004 - DecrementClamp = 0x00000005 - IncrementWrap = 0x00000006 - DecrementWrap = 0x00000007 - - -class StorageTextureAccess(IntEnum): - Undefined = 0x00000000 - WriteOnly = 0x00000001 - - -class StoreOp(IntEnum): - Undefined = 0x00000000 - Store = 0x00000001 - Discard = 0x00000002 - - -class SurfaceGetCurrentTextureStatus(IntEnum): - Success = 0x00000000 - Timeout = 0x00000001 - Outdated = 0x00000002 - Lost = 0x00000003 - OutOfMemory = 0x00000004 - DeviceLost = 0x00000005 - - -class TextureAspect(IntEnum): - All = 0x00000000 - StencilOnly = 0x00000001 - DepthOnly = 0x00000002 - - -class TextureDimension(IntEnum): - _1D = 0x00000000 - _2D = 0x00000001 - _3D = 0x00000002 - - -class TextureFormat(IntEnum): - 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 - RGB10A2Unorm = 0x00000019 - RG11B10Ufloat = 0x0000001A - RGB9E5Ufloat = 0x0000001B - RG32Float = 0x0000001C - RG32Uint = 0x0000001D - RG32Sint = 0x0000001E - RGBA16Uint = 0x0000001F - RGBA16Sint = 0x00000020 - RGBA16Float = 0x00000021 - RGBA32Float = 0x00000022 - RGBA32Uint = 0x00000023 - RGBA32Sint = 0x00000024 - Stencil8 = 0x00000025 - Depth16Unorm = 0x00000026 - Depth24Plus = 0x00000027 - Depth24PlusStencil8 = 0x00000028 - Depth32Float = 0x00000029 - Depth32FloatStencil8 = 0x0000002A - BC1RGBAUnorm = 0x0000002B - BC1RGBAUnormSrgb = 0x0000002C - BC2RGBAUnorm = 0x0000002D - BC2RGBAUnormSrgb = 0x0000002E - BC3RGBAUnorm = 0x0000002F - BC3RGBAUnormSrgb = 0x00000030 - BC4RUnorm = 0x00000031 - BC4RSnorm = 0x00000032 - BC5RGUnorm = 0x00000033 - BC5RGSnorm = 0x00000034 - BC6HRGBUfloat = 0x00000035 - BC6HRGBFloat = 0x00000036 - BC7RGBAUnorm = 0x00000037 - BC7RGBAUnormSrgb = 0x00000038 - ETC2RGB8Unorm = 0x00000039 - ETC2RGB8UnormSrgb = 0x0000003A - ETC2RGB8A1Unorm = 0x0000003B - ETC2RGB8A1UnormSrgb = 0x0000003C - ETC2RGBA8Unorm = 0x0000003D - ETC2RGBA8UnormSrgb = 0x0000003E - EACR11Unorm = 0x0000003F - EACR11Snorm = 0x00000040 - EACRG11Unorm = 0x00000041 - EACRG11Snorm = 0x00000042 - ASTC4x4Unorm = 0x00000043 - ASTC4x4UnormSrgb = 0x00000044 - ASTC5x4Unorm = 0x00000045 - ASTC5x4UnormSrgb = 0x00000046 - ASTC5x5Unorm = 0x00000047 - ASTC5x5UnormSrgb = 0x00000048 - ASTC6x5Unorm = 0x00000049 - ASTC6x5UnormSrgb = 0x0000004A - ASTC6x6Unorm = 0x0000004B - ASTC6x6UnormSrgb = 0x0000004C - ASTC8x5Unorm = 0x0000004D - ASTC8x5UnormSrgb = 0x0000004E - ASTC8x6Unorm = 0x0000004F - ASTC8x6UnormSrgb = 0x00000050 - ASTC8x8Unorm = 0x00000051 - ASTC8x8UnormSrgb = 0x00000052 - ASTC10x5Unorm = 0x00000053 - ASTC10x5UnormSrgb = 0x00000054 - ASTC10x6Unorm = 0x00000055 - ASTC10x6UnormSrgb = 0x00000056 - ASTC10x8Unorm = 0x00000057 - ASTC10x8UnormSrgb = 0x00000058 - ASTC10x10Unorm = 0x00000059 - ASTC10x10UnormSrgb = 0x0000005A - ASTC12x10Unorm = 0x0000005B - ASTC12x10UnormSrgb = 0x0000005C - ASTC12x12Unorm = 0x0000005D - ASTC12x12UnormSrgb = 0x0000005E - - -class TextureSampleType(IntEnum): - Undefined = 0x00000000 - Float = 0x00000001 - UnfilterableFloat = 0x00000002 - Depth = 0x00000003 - Sint = 0x00000004 - Uint = 0x00000005 - - -class TextureViewDimension(IntEnum): - Undefined = 0x00000000 - _1D = 0x00000001 - _2D = 0x00000002 - _2DArray = 0x00000003 - Cube = 0x00000004 - CubeArray = 0x00000005 - _3D = 0x00000006 - - -class VertexFormat(IntEnum): - 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 - - -class VertexStepMode(IntEnum): - Vertex = 0x00000000 - Instance = 0x00000001 - VertexBufferNotUsed = 0x00000002 - - -class BufferUsage(IntEnum): - _None = 0x00000000 - MapRead = 0x00000001 - MapWrite = 0x00000002 - CopySrc = 0x00000004 - CopyDst = 0x00000008 - Index = 0x00000010 - Vertex = 0x00000020 - Uniform = 0x00000040 - Storage = 0x00000080 - Indirect = 0x00000100 - QueryResolve = 0x00000200 - - def __or__(self, rhs: "BufferUsage") -> "BufferUsageFlags": - return BufferUsageFlags(int(self) | int(rhs)) - - -class ColorWriteMask(IntEnum): - _None = 0x00000000 - Red = 0x00000001 - Green = 0x00000002 - Blue = 0x00000004 - Alpha = 0x00000008 - All = 0x0000000F - - def __or__(self, rhs: "ColorWriteMask") -> "ColorWriteMaskFlags": - return ColorWriteMaskFlags(int(self) | int(rhs)) - - -class MapMode(IntEnum): - _None = 0x00000000 - Read = 0x00000001 - Write = 0x00000002 - - def __or__(self, rhs: "MapMode") -> "MapModeFlags": - return MapModeFlags(int(self) | int(rhs)) - - -class ShaderStage(IntEnum): - _None = 0x00000000 - Vertex = 0x00000001 - Fragment = 0x00000002 - Compute = 0x00000004 - - def __or__(self, rhs: "ShaderStage") -> "ShaderStageFlags": - return ShaderStageFlags(int(self) | int(rhs)) - - -class TextureUsage(IntEnum): - _None = 0x00000000 - CopySrc = 0x00000001 - CopyDst = 0x00000002 - TextureBinding = 0x00000004 - StorageBinding = 0x00000008 - RenderAttachment = 0x00000010 - - def __or__(self, rhs: "TextureUsage") -> "TextureUsageFlags": - return TextureUsageFlags(int(self) | int(rhs)) - - -class LogLevel(IntEnum): - Off = 0x00000000 - Error = 0x00000001 - Warn = 0x00000002 - Info = 0x00000003 - Debug = 0x00000004 - Trace = 0x00000005 - - -class InstanceBackend(IntEnum): - All = 0x00000000 - Vulkan = 1 << 0 - GL = 1 << 1 - Metal = 1 << 2 - DX12 = 1 << 3 - DX11 = 1 << 4 - BrowserWebGPU = 1 << 5 - - def __or__(self, rhs: "InstanceBackend") -> "InstanceBackendFlags": - return InstanceBackendFlags(int(self) | int(rhs)) - - -class InstanceFlag(IntEnum): - Default = 0x00000000 - Debug = 1 << 0 - Validation = 1 << 1 - DiscardHalLabels = 1 << 2 - - def __or__(self, rhs: "InstanceFlag") -> "InstanceFlags": - return InstanceFlags(int(self) | int(rhs)) - - -class Dx12Compiler(IntEnum): - Undefined = 0x00000000 - Fxc = 0x00000001 - Dxc = 0x00000002 - - -class Gles3MinorVersion(IntEnum): - Automatic = 0x00000000 - Version0 = 0x00000001 - Version1 = 0x00000002 - Version2 = 0x00000003 - - -class PipelineStatisticName(IntEnum): - VertexShaderInvocations = 0x00000000 - ClipperInvocations = 0x00000001 - ClipperPrimitivesOut = 0x00000002 - FragmentShaderInvocations = 0x00000003 - ComputeShaderInvocations = 0x00000004 - - -class NativeQueryType(IntEnum): - PipelineStatistics = 0x00030000 - - -class BufferUsageFlags: - def __init__(self, flags: Union[list["BufferUsage"], int, "BufferUsageFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__(self, rhs: Union["BufferUsageFlags", "BufferUsage"]) -> "BufferUsageFlags": - return BufferUsageFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "BufferUsage") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["BufferUsage"]: - for v in BufferUsage: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("BufferUsage." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class ColorWriteMaskFlags: - def __init__(self, flags: Union[list["ColorWriteMask"], int, "ColorWriteMaskFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__( - self, rhs: Union["ColorWriteMaskFlags", "ColorWriteMask"] - ) -> "ColorWriteMaskFlags": - return ColorWriteMaskFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "ColorWriteMask") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["ColorWriteMask"]: - for v in ColorWriteMask: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("ColorWriteMask." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class MapModeFlags: - def __init__(self, flags: Union[list["MapMode"], int, "MapModeFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__(self, rhs: Union["MapModeFlags", "MapMode"]) -> "MapModeFlags": - return MapModeFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "MapMode") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["MapMode"]: - for v in MapMode: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("MapMode." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class ShaderStageFlags: - def __init__(self, flags: Union[list["ShaderStage"], int, "ShaderStageFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__(self, rhs: Union["ShaderStageFlags", "ShaderStage"]) -> "ShaderStageFlags": - return ShaderStageFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "ShaderStage") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["ShaderStage"]: - for v in ShaderStage: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("ShaderStage." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class TextureUsageFlags: - def __init__(self, flags: Union[list["TextureUsage"], int, "TextureUsageFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__( - self, rhs: Union["TextureUsageFlags", "TextureUsage"] - ) -> "TextureUsageFlags": - return TextureUsageFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "TextureUsage") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["TextureUsage"]: - for v in TextureUsage: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("TextureUsage." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class InstanceBackendFlags: - def __init__( - self, flags: Union[list["InstanceBackend"], int, "InstanceBackendFlags"] - ): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__( - self, rhs: Union["InstanceBackendFlags", "InstanceBackend"] - ) -> "InstanceBackendFlags": - return InstanceBackendFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "InstanceBackend") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["InstanceBackend"]: - for v in InstanceBackend: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("InstanceBackend." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class InstanceFlags: - def __init__(self, flags: Union[list["InstanceFlag"], int, "InstanceFlags"]): - if isinstance(flags, list): - self.value = sum(set(flags)) - else: - self.value = int(flags) - - def __or__(self, rhs: Union["InstanceFlags", "InstanceFlag"]) -> "InstanceFlags": - return InstanceFlags(int(self) | int(rhs)) - - def __int__(self) -> int: - return self.value - - def __contains__(self, flag: "InstanceFlag") -> bool: - return self.value & int(flag) > 0 - - def __iter__(self) -> Iterator["InstanceFlag"]: - for v in InstanceFlag: - if self.value & int(v) > 0: - yield v - - def __str__(self) -> str: - return " | ".join("InstanceFlag." + v.name for v in self) - - def __repr__(self) -> str: - return str(self) - - -class Adapter: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuAdapterRelease) - if add_ref: - lib.wgpuAdapterReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Adapter") - - def enumerateFeatures(self) -> list["FeatureName"]: - # Hand-written because of idiosyncratic convention for using this function - feature_count = lib.wgpuAdapterEnumerateFeatures(self._cdata, ffi.NULL) - feature_list = ffi.new("WGPUFeatureName[]", feature_count) - lib.wgpuAdapterEnumerateFeatures(self._cdata, feature_list) - return [FeatureName(feature_list[idx]) for idx in range(feature_count)] - - def getLimits(self, limits: "SupportedLimits") -> bool: - return lib.wgpuAdapterGetLimits(self._cdata, limits._cdata) - - def getProperties(self, properties: "AdapterProperties") -> None: - return lib.wgpuAdapterGetProperties(self._cdata, properties._cdata) - - def hasFeature(self, feature: "FeatureName") -> bool: - return lib.wgpuAdapterHasFeature(self._cdata, int(feature)) - - def requestDevice( - self, descriptor: Optional["DeviceDescriptor"], callback: "RequestDeviceCallback" - ) -> None: - return lib.wgpuAdapterRequestDevice( - self._cdata, - _ffi_unwrap_optional(descriptor), - callback._ptr, - callback._userdata, - ) - - def _reference(self) -> None: - return lib.wgpuAdapterReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuAdapterRelease(self._cdata) - - -class BindGroup: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuBindGroupRelease) - if add_ref: - lib.wgpuBindGroupReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for BindGroup") - - def setLabel(self, label: str) -> None: - return lib.wgpuBindGroupSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuBindGroupReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuBindGroupRelease(self._cdata) - - -class BindGroupLayout: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuBindGroupLayoutRelease) - if add_ref: - lib.wgpuBindGroupLayoutReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for BindGroupLayout") - - def setLabel(self, label: str) -> None: - return lib.wgpuBindGroupLayoutSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuBindGroupLayoutReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuBindGroupLayoutRelease(self._cdata) - - -class Buffer: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuBufferRelease) - if add_ref: - lib.wgpuBufferReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Buffer") - - def destroy(self) -> None: - return lib.wgpuBufferDestroy(self._cdata) - - def getConstMappedRange(self, offset: int, size: int) -> VoidPtr: - return VoidPtr(lib.wgpuBufferGetConstMappedRange(self._cdata, offset, size), size) - - def getMapState(self) -> "BufferMapState": - return BufferMapState(lib.wgpuBufferGetMapState(self._cdata)) - - def getMappedRange(self, offset: int, size: int) -> VoidPtr: - return VoidPtr(lib.wgpuBufferGetMappedRange(self._cdata, offset, size), size) - - def getSize(self) -> int: - return lib.wgpuBufferGetSize(self._cdata) - - def getUsage(self) -> "BufferUsageFlags": - return BufferUsageFlags(lib.wgpuBufferGetUsage(self._cdata)) - - def mapAsync( - self, - mode: Union["MapModeFlags", "MapMode"], - offset: int, - size: int, - callback: "BufferMapCallback", - ) -> None: - return lib.wgpuBufferMapAsync( - self._cdata, int(mode), offset, size, callback._ptr, callback._userdata - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuBufferSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def unmap(self) -> None: - return lib.wgpuBufferUnmap(self._cdata) - - def _reference(self) -> None: - return lib.wgpuBufferReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuBufferRelease(self._cdata) - - -class CommandBuffer: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuCommandBufferRelease) - if add_ref: - lib.wgpuCommandBufferReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for CommandBuffer") - - def setLabel(self, label: str) -> None: - return lib.wgpuCommandBufferSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuCommandBufferReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuCommandBufferRelease(self._cdata) - - -class CommandEncoder: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuCommandEncoderRelease) - if add_ref: - lib.wgpuCommandEncoderReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for CommandEncoder") - - def beginComputePassFromDesc( - self, descriptor: Optional["ComputePassDescriptor"] - ) -> "ComputePassEncoder": - return ComputePassEncoder( - lib.wgpuCommandEncoderBeginComputePass( - self._cdata, _ffi_unwrap_optional(descriptor) - ), - add_ref=False, - ) - - def beginComputePass( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - timestampWrites: Optional["ComputePassTimestampWrites"] = None, - ) -> "ComputePassEncoder": - return self.beginComputePassFromDesc( - computePassDescriptor( - nextInChain=nextInChain, label=label, timestampWrites=timestampWrites - ) - ) - - def beginRenderPassFromDesc( - self, descriptor: "RenderPassDescriptor" - ) -> "RenderPassEncoder": - return RenderPassEncoder( - lib.wgpuCommandEncoderBeginRenderPass(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def beginRenderPass( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - colorAttachments: Union[ - "RenderPassColorAttachmentList", list["RenderPassColorAttachment"] - ], - depthStencilAttachment: Optional["RenderPassDepthStencilAttachment"] = None, - occlusionQuerySet: Optional["QuerySet"] = None, - timestampWrites: Optional["RenderPassTimestampWrites"] = None, - ) -> "RenderPassEncoder": - return self.beginRenderPassFromDesc( - renderPassDescriptor( - nextInChain=nextInChain, - label=label, - colorAttachments=colorAttachments, - depthStencilAttachment=depthStencilAttachment, - occlusionQuerySet=occlusionQuerySet, - timestampWrites=timestampWrites, - ) - ) - - def clearBuffer(self, buffer: "Buffer", offset: int, size: int) -> None: - return lib.wgpuCommandEncoderClearBuffer(self._cdata, buffer._cdata, offset, size) - - def copyBufferToBuffer( - self, - source: "Buffer", - sourceOffset: int, - destination: "Buffer", - destinationOffset: int, - size: int, - ) -> None: - return lib.wgpuCommandEncoderCopyBufferToBuffer( - self._cdata, - source._cdata, - sourceOffset, - destination._cdata, - destinationOffset, - size, - ) - - def copyBufferToTexture( - self, - source: "ImageCopyBuffer", - destination: "ImageCopyTexture", - copySize: "Extent3D", - ) -> None: - return lib.wgpuCommandEncoderCopyBufferToTexture( - self._cdata, source._cdata, destination._cdata, copySize._cdata - ) - - def copyTextureToBuffer( - self, - source: "ImageCopyTexture", - destination: "ImageCopyBuffer", - copySize: "Extent3D", - ) -> None: - return lib.wgpuCommandEncoderCopyTextureToBuffer( - self._cdata, source._cdata, destination._cdata, copySize._cdata - ) - - def copyTextureToTexture( - self, - source: "ImageCopyTexture", - destination: "ImageCopyTexture", - copySize: "Extent3D", - ) -> None: - return lib.wgpuCommandEncoderCopyTextureToTexture( - self._cdata, source._cdata, destination._cdata, copySize._cdata - ) - - def finishFromDesc( - self, descriptor: Optional["CommandBufferDescriptor"] - ) -> "CommandBuffer": - return CommandBuffer( - lib.wgpuCommandEncoderFinish(self._cdata, _ffi_unwrap_optional(descriptor)), - add_ref=False, - ) - - def finish( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - ) -> "CommandBuffer": - return self.finishFromDesc( - commandBufferDescriptor(nextInChain=nextInChain, label=label) - ) - - def insertDebugMarker(self, markerLabel: str) -> None: - return lib.wgpuCommandEncoderInsertDebugMarker( - self._cdata, _ffi_unwrap_str(markerLabel) - ) - - def popDebugGroup(self) -> None: - return lib.wgpuCommandEncoderPopDebugGroup(self._cdata) - - def pushDebugGroup(self, groupLabel: str) -> None: - return lib.wgpuCommandEncoderPushDebugGroup( - self._cdata, _ffi_unwrap_str(groupLabel) - ) - - def resolveQuerySet( - self, - querySet: "QuerySet", - firstQuery: int, - queryCount: int, - destination: "Buffer", - destinationOffset: int, - ) -> None: - return lib.wgpuCommandEncoderResolveQuerySet( - self._cdata, - querySet._cdata, - firstQuery, - queryCount, - destination._cdata, - destinationOffset, - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuCommandEncoderSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def writeTimestamp(self, querySet: "QuerySet", queryIndex: int) -> None: - return lib.wgpuCommandEncoderWriteTimestamp( - self._cdata, querySet._cdata, queryIndex - ) - - def _reference(self) -> None: - return lib.wgpuCommandEncoderReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuCommandEncoderRelease(self._cdata) - - -class ComputePassEncoder: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuComputePassEncoderRelease) - if add_ref: - lib.wgpuComputePassEncoderReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for ComputePassEncoder") - - def dispatchWorkgroups( - self, workgroupCountX: int, workgroupCountY: int, workgroupCountZ: int - ) -> None: - return lib.wgpuComputePassEncoderDispatchWorkgroups( - self._cdata, workgroupCountX, workgroupCountY, workgroupCountZ - ) - - def dispatchWorkgroupsIndirect( - self, indirectBuffer: "Buffer", indirectOffset: int - ) -> None: - return lib.wgpuComputePassEncoderDispatchWorkgroupsIndirect( - self._cdata, indirectBuffer._cdata, indirectOffset - ) - - def end(self) -> None: - return lib.wgpuComputePassEncoderEnd(self._cdata) - - def insertDebugMarker(self, markerLabel: str) -> None: - return lib.wgpuComputePassEncoderInsertDebugMarker( - self._cdata, _ffi_unwrap_str(markerLabel) - ) - - def popDebugGroup(self) -> None: - return lib.wgpuComputePassEncoderPopDebugGroup(self._cdata) - - def pushDebugGroup(self, groupLabel: str) -> None: - return lib.wgpuComputePassEncoderPushDebugGroup( - self._cdata, _ffi_unwrap_str(groupLabel) - ) - - def setBindGroup( - self, - groupIndex: int, - group: Optional["BindGroup"], - dynamicOffsets: Union["IntList", list[int]], - ) -> None: - if isinstance(dynamicOffsets, list): - dynamicOffsets_staged = IntList(dynamicOffsets) - else: - dynamicOffsets_staged = dynamicOffsets - return lib.wgpuComputePassEncoderSetBindGroup( - self._cdata, - groupIndex, - _ffi_unwrap_optional(group), - dynamicOffsets_staged._count, - dynamicOffsets_staged._ptr, - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuComputePassEncoderSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def setPipeline(self, pipeline: "ComputePipeline") -> None: - return lib.wgpuComputePassEncoderSetPipeline(self._cdata, pipeline._cdata) - - def _reference(self) -> None: - return lib.wgpuComputePassEncoderReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuComputePassEncoderRelease(self._cdata) - - def beginPipelineStatisticsQuery(self, querySet: "QuerySet", queryIndex: int) -> None: - return lib.wgpuComputePassEncoderBeginPipelineStatisticsQuery( - self._cdata, querySet._cdata, queryIndex - ) - - def endPipelineStatisticsQuery(self) -> None: - return lib.wgpuComputePassEncoderEndPipelineStatisticsQuery(self._cdata) - - -class ComputePipeline: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuComputePipelineRelease) - if add_ref: - lib.wgpuComputePipelineReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for ComputePipeline") - - def getBindGroupLayout(self, groupIndex: int) -> "BindGroupLayout": - return BindGroupLayout( - lib.wgpuComputePipelineGetBindGroupLayout(self._cdata, groupIndex), - add_ref=False, - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuComputePipelineSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuComputePipelineReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuComputePipelineRelease(self._cdata) - - -class Device: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuDeviceRelease) - if add_ref: - lib.wgpuDeviceReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Device") - - # wgpuGetProcAddress is marked as a MISBEHAVED FUNCTION: - # Untyped function pointer return. - - def createBindGroupFromDesc(self, descriptor: "BindGroupDescriptor") -> "BindGroup": - return BindGroup( - lib.wgpuDeviceCreateBindGroup(self._cdata, descriptor._cdata), add_ref=False - ) - - def createBindGroup( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: "BindGroupLayout", - entries: Union["BindGroupEntryList", list["BindGroupEntry"]], - ) -> "BindGroup": - return self.createBindGroupFromDesc( - bindGroupDescriptor( - nextInChain=nextInChain, label=label, layout=layout, entries=entries - ) - ) - - def createBindGroupLayoutFromDesc( - self, descriptor: "BindGroupLayoutDescriptor" - ) -> "BindGroupLayout": - return BindGroupLayout( - lib.wgpuDeviceCreateBindGroupLayout(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createBindGroupLayout( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - entries: Union["BindGroupLayoutEntryList", list["BindGroupLayoutEntry"]], - ) -> "BindGroupLayout": - return self.createBindGroupLayoutFromDesc( - bindGroupLayoutDescriptor( - nextInChain=nextInChain, label=label, entries=entries - ) - ) - - def createBufferFromDesc(self, descriptor: "BufferDescriptor") -> "Buffer": - return Buffer( - lib.wgpuDeviceCreateBuffer(self._cdata, descriptor._cdata), add_ref=False - ) - - def createBuffer( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - usage: Union["BufferUsageFlags", "BufferUsage"], - size: int, - mappedAtCreation: bool = False, - ) -> "Buffer": - return self.createBufferFromDesc( - bufferDescriptor( - nextInChain=nextInChain, - label=label, - usage=usage, - size=size, - mappedAtCreation=mappedAtCreation, - ) - ) - - def createCommandEncoderFromDesc( - self, descriptor: Optional["CommandEncoderDescriptor"] - ) -> "CommandEncoder": - return CommandEncoder( - lib.wgpuDeviceCreateCommandEncoder( - self._cdata, _ffi_unwrap_optional(descriptor) - ), - add_ref=False, - ) - - def createCommandEncoder( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - ) -> "CommandEncoder": - return self.createCommandEncoderFromDesc( - commandEncoderDescriptor(nextInChain=nextInChain, label=label) - ) - - def createComputePipelineFromDesc( - self, descriptor: "ComputePipelineDescriptor" - ) -> "ComputePipeline": - return ComputePipeline( - lib.wgpuDeviceCreateComputePipeline(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createComputePipeline( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: Optional["PipelineLayout"] = None, - compute: "ProgrammableStageDescriptor", - ) -> "ComputePipeline": - return self.createComputePipelineFromDesc( - computePipelineDescriptor( - nextInChain=nextInChain, label=label, layout=layout, compute=compute - ) - ) - - def createComputePipelineAsync( - self, - descriptor: "ComputePipelineDescriptor", - callback: "CreateComputePipelineAsyncCallback", - ) -> None: - return lib.wgpuDeviceCreateComputePipelineAsync( - self._cdata, descriptor._cdata, callback._ptr, callback._userdata - ) - - def createPipelineLayoutFromDesc( - self, descriptor: "PipelineLayoutDescriptor" - ) -> "PipelineLayout": - return PipelineLayout( - lib.wgpuDeviceCreatePipelineLayout(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createPipelineLayout( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - bindGroupLayouts: Union["BindGroupLayoutList", list["BindGroupLayout"]], - ) -> "PipelineLayout": - return self.createPipelineLayoutFromDesc( - pipelineLayoutDescriptor( - nextInChain=nextInChain, label=label, bindGroupLayouts=bindGroupLayouts - ) - ) - - def createQuerySetFromDesc(self, descriptor: "QuerySetDescriptor") -> "QuerySet": - return QuerySet( - lib.wgpuDeviceCreateQuerySet(self._cdata, descriptor._cdata), add_ref=False - ) - - def createQuerySet( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - type: "QueryType", - count: int, - ) -> "QuerySet": - return self.createQuerySetFromDesc( - querySetDescriptor( - nextInChain=nextInChain, label=label, type=type, count=count - ) - ) - - def createRenderBundleEncoderFromDesc( - self, descriptor: "RenderBundleEncoderDescriptor" - ) -> "RenderBundleEncoder": - return RenderBundleEncoder( - lib.wgpuDeviceCreateRenderBundleEncoder(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createRenderBundleEncoder( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - colorFormats: Union["TextureFormatList", list["TextureFormat"]], - depthStencilFormat: "TextureFormat", - sampleCount: int, - depthReadOnly: bool = False, - stencilReadOnly: bool = False, - ) -> "RenderBundleEncoder": - return self.createRenderBundleEncoderFromDesc( - renderBundleEncoderDescriptor( - nextInChain=nextInChain, - label=label, - colorFormats=colorFormats, - depthStencilFormat=depthStencilFormat, - sampleCount=sampleCount, - depthReadOnly=depthReadOnly, - stencilReadOnly=stencilReadOnly, - ) - ) - - def createRenderPipelineFromDesc( - self, descriptor: "RenderPipelineDescriptor" - ) -> "RenderPipeline": - return RenderPipeline( - lib.wgpuDeviceCreateRenderPipeline(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createRenderPipeline( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: Optional["PipelineLayout"] = None, - vertex: "VertexState", - primitive: "PrimitiveState", - depthStencil: Optional["DepthStencilState"] = None, - multisample: "MultisampleState", - fragment: Optional["FragmentState"] = None, - ) -> "RenderPipeline": - return self.createRenderPipelineFromDesc( - renderPipelineDescriptor( - nextInChain=nextInChain, - label=label, - layout=layout, - vertex=vertex, - primitive=primitive, - depthStencil=depthStencil, - multisample=multisample, - fragment=fragment, - ) - ) - - def createRenderPipelineAsync( - self, - descriptor: "RenderPipelineDescriptor", - callback: "CreateRenderPipelineAsyncCallback", - ) -> None: - return lib.wgpuDeviceCreateRenderPipelineAsync( - self._cdata, descriptor._cdata, callback._ptr, callback._userdata - ) - - def createSamplerFromDesc( - self, descriptor: Optional["SamplerDescriptor"] - ) -> "Sampler": - return Sampler( - lib.wgpuDeviceCreateSampler(self._cdata, _ffi_unwrap_optional(descriptor)), - add_ref=False, - ) - - def createSampler( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - addressModeU: "AddressMode" = AddressMode.ClampToEdge, - addressModeV: "AddressMode" = AddressMode.ClampToEdge, - addressModeW: "AddressMode" = AddressMode.ClampToEdge, - magFilter: "FilterMode" = FilterMode.Nearest, - minFilter: "FilterMode" = FilterMode.Nearest, - mipmapFilter: "MipmapFilterMode" = MipmapFilterMode.Nearest, - lodMinClamp: float = 0, - lodMaxClamp: float = 32, - compare: "CompareFunction", - maxAnisotropy: int = 1, - ) -> "Sampler": - return self.createSamplerFromDesc( - samplerDescriptor( - nextInChain=nextInChain, - label=label, - addressModeU=addressModeU, - addressModeV=addressModeV, - addressModeW=addressModeW, - magFilter=magFilter, - minFilter=minFilter, - mipmapFilter=mipmapFilter, - lodMinClamp=lodMinClamp, - lodMaxClamp=lodMaxClamp, - compare=compare, - maxAnisotropy=maxAnisotropy, - ) - ) - - def createShaderModuleFromDesc( - self, descriptor: "ShaderModuleDescriptor" - ) -> "ShaderModule": - return ShaderModule( - lib.wgpuDeviceCreateShaderModule(self._cdata, descriptor._cdata), - add_ref=False, - ) - - def createShaderModule( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - hints: Union[ - "ShaderModuleCompilationHintList", list["ShaderModuleCompilationHint"] - ], - ) -> "ShaderModule": - return self.createShaderModuleFromDesc( - shaderModuleDescriptor(nextInChain=nextInChain, label=label, hints=hints) - ) - - def createTextureFromDesc(self, descriptor: "TextureDescriptor") -> "Texture": - return Texture( - lib.wgpuDeviceCreateTexture(self._cdata, descriptor._cdata), add_ref=False - ) - - def createTexture( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - usage: Union["TextureUsageFlags", "TextureUsage"], - dimension: "TextureDimension" = TextureDimension._2D, - size: "Extent3D", - format: "TextureFormat", - mipLevelCount: int = 1, - sampleCount: int = 1, - viewFormats: Union["TextureFormatList", list["TextureFormat"]], - ) -> "Texture": - return self.createTextureFromDesc( - textureDescriptor( - nextInChain=nextInChain, - label=label, - usage=usage, - dimension=dimension, - size=size, - format=format, - mipLevelCount=mipLevelCount, - sampleCount=sampleCount, - viewFormats=viewFormats, - ) - ) - - def destroy(self) -> None: - return lib.wgpuDeviceDestroy(self._cdata) - - def enumerateFeatures(self) -> list["FeatureName"]: - # Hand-written because of idiosyncratic convention for using this function - feature_count = lib.wgpuDeviceEnumerateFeatures(self._cdata, ffi.NULL) - feature_list = ffi.new("WGPUFeatureName[]", feature_count) - lib.wgpuDeviceEnumerateFeatures(self._cdata, feature_list) - return [FeatureName(feature_list[idx]) for idx in range(feature_count)] - - def getLimits(self, limits: "SupportedLimits") -> bool: - return lib.wgpuDeviceGetLimits(self._cdata, limits._cdata) - - def getQueue(self) -> "Queue": - return Queue(lib.wgpuDeviceGetQueue(self._cdata), add_ref=False) - - def hasFeature(self, feature: "FeatureName") -> bool: - return lib.wgpuDeviceHasFeature(self._cdata, int(feature)) - - def popErrorScope(self, callback: "ErrorCallback") -> None: - return lib.wgpuDevicePopErrorScope(self._cdata, callback._ptr, callback._userdata) - - def pushErrorScope(self, filter: "ErrorFilter") -> None: - return lib.wgpuDevicePushErrorScope(self._cdata, int(filter)) - - def setLabel(self, label: str) -> None: - return lib.wgpuDeviceSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def setUncapturedErrorCallback(self, callback: "ErrorCallback") -> None: - return lib.wgpuDeviceSetUncapturedErrorCallback( - self._cdata, callback._ptr, callback._userdata - ) - - def _reference(self) -> None: - return lib.wgpuDeviceReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuDeviceRelease(self._cdata) - - def poll( - self, wait: bool, wrappedSubmissionIndex: Optional["WrappedSubmissionIndex"] - ) -> bool: - return lib.wgpuDevicePoll( - self._cdata, wait, _ffi_unwrap_optional(wrappedSubmissionIndex) - ) - - -class Instance: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuInstanceRelease) - if add_ref: - lib.wgpuInstanceReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Instance") - - def createSurfaceFromDesc(self, descriptor: "SurfaceDescriptor") -> "Surface": - return Surface( - lib.wgpuInstanceCreateSurface(self._cdata, descriptor._cdata), add_ref=False - ) - - def createSurface( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - ) -> "Surface": - return self.createSurfaceFromDesc( - surfaceDescriptor(nextInChain=nextInChain, label=label) - ) - - def processEvents(self) -> None: - return lib.wgpuInstanceProcessEvents(self._cdata) - - def requestAdapter( - self, - options: Optional["RequestAdapterOptions"], - callback: "RequestAdapterCallback", - ) -> None: - return lib.wgpuInstanceRequestAdapter( - self._cdata, _ffi_unwrap_optional(options), callback._ptr, callback._userdata - ) - - def _reference(self) -> None: - return lib.wgpuInstanceReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuInstanceRelease(self._cdata) - - def generateReport(self, report: "GlobalReport") -> None: - return lib.wgpuGenerateReport(self._cdata, report._cdata) - - def enumerateAdapters( - self, options: "InstanceEnumerateAdapterOptions", adapters: "Adapter" - ) -> int: - return lib.wgpuInstanceEnumerateAdapters( - self._cdata, options._cdata, adapters._cdata - ) - - -class PipelineLayout: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuPipelineLayoutRelease) - if add_ref: - lib.wgpuPipelineLayoutReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for PipelineLayout") - - def setLabel(self, label: str) -> None: - return lib.wgpuPipelineLayoutSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuPipelineLayoutReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuPipelineLayoutRelease(self._cdata) - - -class QuerySet: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuQuerySetRelease) - if add_ref: - lib.wgpuQuerySetReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for QuerySet") - - def destroy(self) -> None: - return lib.wgpuQuerySetDestroy(self._cdata) - - def getCount(self) -> int: - return lib.wgpuQuerySetGetCount(self._cdata) - - def getType(self) -> "QueryType": - return QueryType(lib.wgpuQuerySetGetType(self._cdata)) - - def setLabel(self, label: str) -> None: - return lib.wgpuQuerySetSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuQuerySetReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuQuerySetRelease(self._cdata) - - -class Queue: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuQueueRelease) - if add_ref: - lib.wgpuQueueReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Queue") - - def onSubmittedWorkDone(self, callback: "QueueWorkDoneCallback") -> None: - return lib.wgpuQueueOnSubmittedWorkDone( - self._cdata, callback._ptr, callback._userdata - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuQueueSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def submit(self, commands: Union["CommandBufferList", list[CommandBuffer]]) -> None: - if isinstance(commands, list): - commands_staged = CommandBufferList(commands) - else: - commands_staged = commands - return lib.wgpuQueueSubmit( - self._cdata, commands_staged._count, commands_staged._ptr - ) - - def writeBuffer(self, buffer: "Buffer", bufferOffset: int, data: VoidPtr) -> None: - return lib.wgpuQueueWriteBuffer( - self._cdata, buffer._cdata, bufferOffset, data._ptr, data._size - ) - - def writeTexture( - self, - destination: "ImageCopyTexture", - data: VoidPtr, - dataLayout: "TextureDataLayout", - writeSize: "Extent3D", - ) -> None: - return lib.wgpuQueueWriteTexture( - self._cdata, - destination._cdata, - data._ptr, - data._size, - dataLayout._cdata, - writeSize._cdata, - ) - - def _reference(self) -> None: - return lib.wgpuQueueReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuQueueRelease(self._cdata) - - def submitForIndex( - self, commands: Union["CommandBufferList", list[CommandBuffer]] - ) -> int: - if isinstance(commands, list): - commands_staged = CommandBufferList(commands) - else: - commands_staged = commands - return lib.wgpuQueueSubmitForIndex( - self._cdata, commands_staged._count, commands_staged._ptr - ) - - -class RenderBundle: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuRenderBundleRelease) - if add_ref: - lib.wgpuRenderBundleReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for RenderBundle") - - def setLabel(self, label: str) -> None: - return lib.wgpuRenderBundleSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuRenderBundleReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuRenderBundleRelease(self._cdata) - - -class RenderBundleEncoder: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuRenderBundleEncoderRelease) - if add_ref: - lib.wgpuRenderBundleEncoderReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for RenderBundleEncoder") - - def draw( - self, vertexCount: int, instanceCount: int, firstVertex: int, firstInstance: int - ) -> None: - return lib.wgpuRenderBundleEncoderDraw( - self._cdata, vertexCount, instanceCount, firstVertex, firstInstance - ) - - def drawIndexed( - self, - indexCount: int, - instanceCount: int, - firstIndex: int, - baseVertex: int, - firstInstance: int, - ) -> None: - return lib.wgpuRenderBundleEncoderDrawIndexed( - self._cdata, indexCount, instanceCount, firstIndex, baseVertex, firstInstance - ) - - def drawIndexedIndirect(self, indirectBuffer: "Buffer", indirectOffset: int) -> None: - return lib.wgpuRenderBundleEncoderDrawIndexedIndirect( - self._cdata, indirectBuffer._cdata, indirectOffset - ) - - def drawIndirect(self, indirectBuffer: "Buffer", indirectOffset: int) -> None: - return lib.wgpuRenderBundleEncoderDrawIndirect( - self._cdata, indirectBuffer._cdata, indirectOffset - ) - - def finishFromDesc( - self, descriptor: Optional["RenderBundleDescriptor"] - ) -> "RenderBundle": - return RenderBundle( - lib.wgpuRenderBundleEncoderFinish( - self._cdata, _ffi_unwrap_optional(descriptor) - ), - add_ref=False, - ) - - def finish( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - ) -> "RenderBundle": - return self.finishFromDesc( - renderBundleDescriptor(nextInChain=nextInChain, label=label) - ) - - def insertDebugMarker(self, markerLabel: str) -> None: - return lib.wgpuRenderBundleEncoderInsertDebugMarker( - self._cdata, _ffi_unwrap_str(markerLabel) - ) - - def popDebugGroup(self) -> None: - return lib.wgpuRenderBundleEncoderPopDebugGroup(self._cdata) - - def pushDebugGroup(self, groupLabel: str) -> None: - return lib.wgpuRenderBundleEncoderPushDebugGroup( - self._cdata, _ffi_unwrap_str(groupLabel) - ) - - def setBindGroup( - self, - groupIndex: int, - group: Optional["BindGroup"], - dynamicOffsets: Union["IntList", list[int]], - ) -> None: - if isinstance(dynamicOffsets, list): - dynamicOffsets_staged = IntList(dynamicOffsets) - else: - dynamicOffsets_staged = dynamicOffsets - return lib.wgpuRenderBundleEncoderSetBindGroup( - self._cdata, - groupIndex, - _ffi_unwrap_optional(group), - dynamicOffsets_staged._count, - dynamicOffsets_staged._ptr, - ) - - def setIndexBuffer( - self, buffer: "Buffer", format: "IndexFormat", offset: int, size: int - ) -> None: - return lib.wgpuRenderBundleEncoderSetIndexBuffer( - self._cdata, buffer._cdata, int(format), offset, size - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuRenderBundleEncoderSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def setPipeline(self, pipeline: "RenderPipeline") -> None: - return lib.wgpuRenderBundleEncoderSetPipeline(self._cdata, pipeline._cdata) - - def setVertexBuffer( - self, slot: int, buffer: Optional["Buffer"], offset: int, size: int - ) -> None: - return lib.wgpuRenderBundleEncoderSetVertexBuffer( - self._cdata, slot, _ffi_unwrap_optional(buffer), offset, size - ) - - def _reference(self) -> None: - return lib.wgpuRenderBundleEncoderReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuRenderBundleEncoderRelease(self._cdata) - - -class RenderPassEncoder: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuRenderPassEncoderRelease) - if add_ref: - lib.wgpuRenderPassEncoderReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for RenderPassEncoder") - - def beginOcclusionQuery(self, queryIndex: int) -> None: - return lib.wgpuRenderPassEncoderBeginOcclusionQuery(self._cdata, queryIndex) - - def draw( - self, vertexCount: int, instanceCount: int, firstVertex: int, firstInstance: int - ) -> None: - return lib.wgpuRenderPassEncoderDraw( - self._cdata, vertexCount, instanceCount, firstVertex, firstInstance - ) - - def drawIndexed( - self, - indexCount: int, - instanceCount: int, - firstIndex: int, - baseVertex: int, - firstInstance: int, - ) -> None: - return lib.wgpuRenderPassEncoderDrawIndexed( - self._cdata, indexCount, instanceCount, firstIndex, baseVertex, firstInstance - ) - - def drawIndexedIndirect(self, indirectBuffer: "Buffer", indirectOffset: int) -> None: - return lib.wgpuRenderPassEncoderDrawIndexedIndirect( - self._cdata, indirectBuffer._cdata, indirectOffset - ) - - def drawIndirect(self, indirectBuffer: "Buffer", indirectOffset: int) -> None: - return lib.wgpuRenderPassEncoderDrawIndirect( - self._cdata, indirectBuffer._cdata, indirectOffset - ) - - def end(self) -> None: - return lib.wgpuRenderPassEncoderEnd(self._cdata) - - def endOcclusionQuery(self) -> None: - return lib.wgpuRenderPassEncoderEndOcclusionQuery(self._cdata) - - def executeBundles( - self, bundles: Union["RenderBundleList", list[RenderBundle]] - ) -> None: - if isinstance(bundles, list): - bundles_staged = RenderBundleList(bundles) - else: - bundles_staged = bundles - return lib.wgpuRenderPassEncoderExecuteBundles( - self._cdata, bundles_staged._count, bundles_staged._ptr - ) - - def insertDebugMarker(self, markerLabel: str) -> None: - return lib.wgpuRenderPassEncoderInsertDebugMarker( - self._cdata, _ffi_unwrap_str(markerLabel) - ) - - def popDebugGroup(self) -> None: - return lib.wgpuRenderPassEncoderPopDebugGroup(self._cdata) - - def pushDebugGroup(self, groupLabel: str) -> None: - return lib.wgpuRenderPassEncoderPushDebugGroup( - self._cdata, _ffi_unwrap_str(groupLabel) - ) - - def setBindGroup( - self, - groupIndex: int, - group: Optional["BindGroup"], - dynamicOffsets: Union["IntList", list[int]], - ) -> None: - if isinstance(dynamicOffsets, list): - dynamicOffsets_staged = IntList(dynamicOffsets) - else: - dynamicOffsets_staged = dynamicOffsets - return lib.wgpuRenderPassEncoderSetBindGroup( - self._cdata, - groupIndex, - _ffi_unwrap_optional(group), - dynamicOffsets_staged._count, - dynamicOffsets_staged._ptr, - ) - - def setBlendConstant(self, color: "Color") -> None: - return lib.wgpuRenderPassEncoderSetBlendConstant(self._cdata, color._cdata) - - def setIndexBuffer( - self, buffer: "Buffer", format: "IndexFormat", offset: int, size: int - ) -> None: - return lib.wgpuRenderPassEncoderSetIndexBuffer( - self._cdata, buffer._cdata, int(format), offset, size - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuRenderPassEncoderSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def setPipeline(self, pipeline: "RenderPipeline") -> None: - return lib.wgpuRenderPassEncoderSetPipeline(self._cdata, pipeline._cdata) - - def setScissorRect(self, x: int, y: int, width: int, height: int) -> None: - return lib.wgpuRenderPassEncoderSetScissorRect(self._cdata, x, y, width, height) - - def setStencilReference(self, reference: int) -> None: - return lib.wgpuRenderPassEncoderSetStencilReference(self._cdata, reference) - - def setVertexBuffer( - self, slot: int, buffer: Optional["Buffer"], offset: int, size: int - ) -> None: - return lib.wgpuRenderPassEncoderSetVertexBuffer( - self._cdata, slot, _ffi_unwrap_optional(buffer), offset, size - ) - - def setViewport( - self, - x: float, - y: float, - width: float, - height: float, - minDepth: float, - maxDepth: float, - ) -> None: - return lib.wgpuRenderPassEncoderSetViewport( - self._cdata, x, y, width, height, minDepth, maxDepth - ) - - def _reference(self) -> None: - return lib.wgpuRenderPassEncoderReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuRenderPassEncoderRelease(self._cdata) - - def setPushConstants( - self, - stages: Union["ShaderStageFlags", "ShaderStage"], - offset: int, - sizeBytes: int, - data: VoidPtr, - ) -> None: - return lib.wgpuRenderPassEncoderSetPushConstants( - self._cdata, int(stages), offset, sizeBytes, data._ptr - ) - - def multiDrawIndirect(self, buffer: "Buffer", offset: int, count: int) -> None: - return lib.wgpuRenderPassEncoderMultiDrawIndirect( - self._cdata, buffer._cdata, offset, count - ) - - def multiDrawIndexedIndirect(self, buffer: "Buffer", offset: int, count: int) -> None: - return lib.wgpuRenderPassEncoderMultiDrawIndexedIndirect( - self._cdata, buffer._cdata, offset, count - ) - - def multiDrawIndirectCount( - self, - buffer: "Buffer", - offset: int, - count_buffer: "Buffer", - count_buffer_offset: int, - max_count: int, - ) -> None: - return lib.wgpuRenderPassEncoderMultiDrawIndirectCount( - self._cdata, - buffer._cdata, - offset, - count_buffer._cdata, - count_buffer_offset, - max_count, - ) - - def multiDrawIndexedIndirectCount( - self, - buffer: "Buffer", - offset: int, - count_buffer: "Buffer", - count_buffer_offset: int, - max_count: int, - ) -> None: - return lib.wgpuRenderPassEncoderMultiDrawIndexedIndirectCount( - self._cdata, - buffer._cdata, - offset, - count_buffer._cdata, - count_buffer_offset, - max_count, - ) - - def beginPipelineStatisticsQuery(self, querySet: "QuerySet", queryIndex: int) -> None: - return lib.wgpuRenderPassEncoderBeginPipelineStatisticsQuery( - self._cdata, querySet._cdata, queryIndex - ) - - def endPipelineStatisticsQuery(self) -> None: - return lib.wgpuRenderPassEncoderEndPipelineStatisticsQuery(self._cdata) - - -class RenderPipeline: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuRenderPipelineRelease) - if add_ref: - lib.wgpuRenderPipelineReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for RenderPipeline") - - def getBindGroupLayout(self, groupIndex: int) -> "BindGroupLayout": - return BindGroupLayout( - lib.wgpuRenderPipelineGetBindGroupLayout(self._cdata, groupIndex), - add_ref=False, - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuRenderPipelineSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuRenderPipelineReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuRenderPipelineRelease(self._cdata) - - -class Sampler: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuSamplerRelease) - if add_ref: - lib.wgpuSamplerReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Sampler") - - def setLabel(self, label: str) -> None: - return lib.wgpuSamplerSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuSamplerReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuSamplerRelease(self._cdata) - - -class ShaderModule: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuShaderModuleRelease) - if add_ref: - lib.wgpuShaderModuleReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for ShaderModule") - - def getCompilationInfo(self, callback: "CompilationInfoCallback") -> None: - return lib.wgpuShaderModuleGetCompilationInfo( - self._cdata, callback._ptr, callback._userdata - ) - - def setLabel(self, label: str) -> None: - return lib.wgpuShaderModuleSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuShaderModuleReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuShaderModuleRelease(self._cdata) - - -class Surface: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuSurfaceRelease) - if add_ref: - lib.wgpuSurfaceReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Surface") - - def configure(self, config: "SurfaceConfiguration") -> None: - return lib.wgpuSurfaceConfigure(self._cdata, config._cdata) - - def getCapabilities( - self, adapter: "Adapter", capabilities: "SurfaceCapabilities" - ) -> None: - return lib.wgpuSurfaceGetCapabilities( - self._cdata, adapter._cdata, capabilities._cdata - ) - - def getCurrentTexture(self, surfaceTexture: "SurfaceTexture") -> None: - return lib.wgpuSurfaceGetCurrentTexture(self._cdata, surfaceTexture._cdata) - - def getPreferredFormat(self, adapter: "Adapter") -> "TextureFormat": - return TextureFormat( - lib.wgpuSurfaceGetPreferredFormat(self._cdata, adapter._cdata) - ) - - def present(self) -> None: - return lib.wgpuSurfacePresent(self._cdata) - - def unconfigure(self) -> None: - return lib.wgpuSurfaceUnconfigure(self._cdata) - - def _reference(self) -> None: - return lib.wgpuSurfaceReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuSurfaceRelease(self._cdata) - - -class Texture: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuTextureRelease) - if add_ref: - lib.wgpuTextureReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for Texture") - - def createViewFromDesc( - self, descriptor: Optional["TextureViewDescriptor"] - ) -> "TextureView": - return TextureView( - lib.wgpuTextureCreateView(self._cdata, _ffi_unwrap_optional(descriptor)), - add_ref=False, - ) - - def createView( - self, - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - format: "TextureFormat", - dimension: "TextureViewDimension", - baseMipLevel: int = 0, - mipLevelCount: int, - baseArrayLayer: int = 0, - arrayLayerCount: int, - aspect: "TextureAspect" = TextureAspect.All, - ) -> "TextureView": - return self.createViewFromDesc( - textureViewDescriptor( - nextInChain=nextInChain, - label=label, - format=format, - dimension=dimension, - baseMipLevel=baseMipLevel, - mipLevelCount=mipLevelCount, - baseArrayLayer=baseArrayLayer, - arrayLayerCount=arrayLayerCount, - aspect=aspect, - ) - ) - - def destroy(self) -> None: - return lib.wgpuTextureDestroy(self._cdata) - - def getDepthOrArrayLayers(self) -> int: - return lib.wgpuTextureGetDepthOrArrayLayers(self._cdata) - - def getDimension(self) -> "TextureDimension": - return TextureDimension(lib.wgpuTextureGetDimension(self._cdata)) - - def getFormat(self) -> "TextureFormat": - return TextureFormat(lib.wgpuTextureGetFormat(self._cdata)) - - def getHeight(self) -> int: - return lib.wgpuTextureGetHeight(self._cdata) - - def getMipLevelCount(self) -> int: - return lib.wgpuTextureGetMipLevelCount(self._cdata) - - def getSampleCount(self) -> int: - return lib.wgpuTextureGetSampleCount(self._cdata) - - def getUsage(self) -> "TextureUsageFlags": - return TextureUsageFlags(lib.wgpuTextureGetUsage(self._cdata)) - - def getWidth(self) -> int: - return lib.wgpuTextureGetWidth(self._cdata) - - def setLabel(self, label: str) -> None: - return lib.wgpuTextureSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuTextureReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuTextureRelease(self._cdata) - - -class TextureView: - def __init__(self, cdata: CData, add_ref=False): - if cdata != ffi.NULL: - self._cdata = ffi.gc(cdata, lib.wgpuTextureViewRelease) - if add_ref: - lib.wgpuTextureViewReference(self._cdata) - else: - self._cdata = ffi.NULL - - def release(self): - if self._cdata == ffi.NULL: - return - ffi.release(self._cdata) - self._cdata = ffi.NULL - - def is_valid(self): - return self._cdata != ffi.NULL - - def assert_valid(self): - if not self.is_valid(): - raise RuntimeError("Valid assertion failed for TextureView") - - def setLabel(self, label: str) -> None: - return lib.wgpuTextureViewSetLabel(self._cdata, _ffi_unwrap_str(label)) - - def _reference(self) -> None: - return lib.wgpuTextureViewReference(self._cdata) - - def _release(self) -> None: - return lib.wgpuTextureViewRelease(self._cdata) - - -# ChainedStruct is specially defined elsewhere -# ChainedStructOut is specially defined elsewhere - - -class AdapterProperties: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUAdapterProperties *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStructOut"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStructOut"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def vendorID(self) -> int: - return self._cdata.vendorID - - @vendorID.setter - def vendorID(self, v: int): - self._cdata.vendorID = v - - @property - def vendorName(self) -> str: - return _ffi_string(self._cdata.vendorName) - - @vendorName.setter - def vendorName(self, v: str): - self._vendorName = v - self._store_vendorName = _ffi_unwrap_str(v) - self._cdata.vendorName = self._store_vendorName - - @property - def architecture(self) -> str: - return _ffi_string(self._cdata.architecture) - - @architecture.setter - def architecture(self, v: str): - self._architecture = v - self._store_architecture = _ffi_unwrap_str(v) - self._cdata.architecture = self._store_architecture - - @property - def deviceID(self) -> int: - return self._cdata.deviceID - - @deviceID.setter - def deviceID(self, v: int): - self._cdata.deviceID = v - - @property - def name(self) -> str: - return _ffi_string(self._cdata.name) - - @name.setter - def name(self, v: str): - self._name = v - self._store_name = _ffi_unwrap_str(v) - self._cdata.name = self._store_name - - @property - def driverDescription(self) -> str: - return _ffi_string(self._cdata.driverDescription) - - @driverDescription.setter - def driverDescription(self, v: str): - self._driverDescription = v - self._store_driverDescription = _ffi_unwrap_str(v) - self._cdata.driverDescription = self._store_driverDescription - - @property - def adapterType(self) -> "AdapterType": - return AdapterType(self._cdata.adapterType) - - @adapterType.setter - def adapterType(self, v: "AdapterType"): - self._cdata.adapterType = int(v) - - @property - def backendType(self) -> "BackendType": - return BackendType(self._cdata.backendType) - - @backendType.setter - def backendType(self, v: "BackendType"): - self._cdata.backendType = int(v) - - -def adapterProperties( - *, - nextInChain: Optional["ChainedStructOut"] = None, - vendorID: int, - vendorName: str, - architecture: str, - deviceID: int, - name: str, - driverDescription: str, - adapterType: "AdapterType", - backendType: "BackendType", -) -> AdapterProperties: - ret = AdapterProperties(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.vendorID = vendorID - ret.vendorName = vendorName - ret.architecture = architecture - ret.deviceID = deviceID - ret.name = name - ret.driverDescription = driverDescription - ret.adapterType = adapterType - ret.backendType = backendType - return ret - - -class BindGroupEntry: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupEntry *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def binding(self) -> int: - return self._cdata.binding - - @binding.setter - def binding(self, v: int): - self._cdata.binding = v - - @property - def buffer(self) -> Optional["Buffer"]: - return Buffer(self._cdata.buffer, add_ref=True) - - @buffer.setter - def buffer(self, v: Optional["Buffer"]): - self._buffer = v - if v is None: - self._cdata.buffer = ffi.NULL - else: - self._cdata.buffer = v._cdata - - @property - def offset(self) -> int: - return self._cdata.offset - - @offset.setter - def offset(self, v: int): - self._cdata.offset = v - - @property - def size(self) -> int: - return self._cdata.size - - @size.setter - def size(self, v: int): - self._cdata.size = v - - @property - def sampler(self) -> Optional["Sampler"]: - return Sampler(self._cdata.sampler, add_ref=True) - - @sampler.setter - def sampler(self, v: Optional["Sampler"]): - self._sampler = v - if v is None: - self._cdata.sampler = ffi.NULL - else: - self._cdata.sampler = v._cdata - - @property - def textureView(self) -> Optional["TextureView"]: - return TextureView(self._cdata.textureView, add_ref=True) - - @textureView.setter - def textureView(self, v: Optional["TextureView"]): - self._textureView = v - if v is None: - self._cdata.textureView = ffi.NULL - else: - self._cdata.textureView = v._cdata - - -def bindGroupEntry( - *, - nextInChain: Optional["ChainedStruct"] = None, - binding: int, - buffer: Optional["Buffer"] = None, - offset: int, - size: int, - sampler: Optional["Sampler"] = None, - textureView: Optional["TextureView"] = None, -) -> BindGroupEntry: - ret = BindGroupEntry(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.binding = binding - ret.buffer = buffer - ret.offset = offset - ret.size = size - ret.sampler = sampler - ret.textureView = textureView - return ret - - -class BlendComponent: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBlendComponent *", cdata) - - @property - def operation(self) -> "BlendOperation": - return BlendOperation(self._cdata.operation) - - @operation.setter - def operation(self, v: "BlendOperation"): - self._cdata.operation = int(v) - - @property - def srcFactor(self) -> "BlendFactor": - return BlendFactor(self._cdata.srcFactor) - - @srcFactor.setter - def srcFactor(self, v: "BlendFactor"): - self._cdata.srcFactor = int(v) - - @property - def dstFactor(self) -> "BlendFactor": - return BlendFactor(self._cdata.dstFactor) - - @dstFactor.setter - def dstFactor(self, v: "BlendFactor"): - self._cdata.dstFactor = int(v) - - -def blendComponent( - *, - operation: "BlendOperation" = BlendOperation.Add, - srcFactor: "BlendFactor" = BlendFactor.One, - dstFactor: "BlendFactor" = BlendFactor.Zero, -) -> BlendComponent: - ret = BlendComponent(cdata=None, parent=None) - ret.operation = operation - ret.srcFactor = srcFactor - ret.dstFactor = dstFactor - return ret - - -class BufferBindingLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBufferBindingLayout *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def type(self) -> "BufferBindingType": - return BufferBindingType(self._cdata.type) - - @type.setter - def type(self, v: "BufferBindingType"): - self._cdata.type = int(v) - - @property - def hasDynamicOffset(self) -> bool: - return self._cdata.hasDynamicOffset - - @hasDynamicOffset.setter - def hasDynamicOffset(self, v: bool): - self._cdata.hasDynamicOffset = v - - @property - def minBindingSize(self) -> int: - return self._cdata.minBindingSize - - @minBindingSize.setter - def minBindingSize(self, v: int): - self._cdata.minBindingSize = v - - -def bufferBindingLayout( - *, - nextInChain: Optional["ChainedStruct"] = None, - type: "BufferBindingType", - hasDynamicOffset: bool, - minBindingSize: int, -) -> BufferBindingLayout: - ret = BufferBindingLayout(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.type = type - ret.hasDynamicOffset = hasDynamicOffset - ret.minBindingSize = minBindingSize - return ret - - -class BufferDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBufferDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def usage(self) -> "BufferUsageFlags": - return BufferUsageFlags(self._cdata.usage) - - @usage.setter - def usage(self, v: Union["BufferUsageFlags", "BufferUsage"]): - self._cdata.usage = int(v) - - @property - def size(self) -> int: - return self._cdata.size - - @size.setter - def size(self, v: int): - self._cdata.size = v - - @property - def mappedAtCreation(self) -> bool: - return self._cdata.mappedAtCreation - - @mappedAtCreation.setter - def mappedAtCreation(self, v: bool): - self._cdata.mappedAtCreation = v - - -def bufferDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - usage: Union["BufferUsageFlags", "BufferUsage"], - size: int, - mappedAtCreation: bool = False, -) -> BufferDescriptor: - ret = BufferDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.usage = usage - ret.size = size - ret.mappedAtCreation = mappedAtCreation - return ret - - -class Color: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUColor *", cdata) - - @property - def r(self) -> float: - return self._cdata.r - - @r.setter - def r(self, v: float): - self._cdata.r = v - - @property - def g(self) -> float: - return self._cdata.g - - @g.setter - def g(self, v: float): - self._cdata.g = v - - @property - def b(self) -> float: - return self._cdata.b - - @b.setter - def b(self, v: float): - self._cdata.b = v - - @property - def a(self) -> float: - return self._cdata.a - - @a.setter - def a(self, v: float): - self._cdata.a = v - - -def color(*, r: float, g: float, b: float, a: float) -> Color: - ret = Color(cdata=None, parent=None) - ret.r = r - ret.g = g - ret.b = b - ret.a = a - return ret - - -class CommandBufferDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUCommandBufferDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - -def commandBufferDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None, label: Optional[str] = None -) -> CommandBufferDescriptor: - ret = CommandBufferDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - return ret - - -class CommandEncoderDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUCommandEncoderDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - -def commandEncoderDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None, label: Optional[str] = None -) -> CommandEncoderDescriptor: - ret = CommandEncoderDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - return ret - - -class CompilationMessage: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUCompilationMessage *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def message(self) -> Optional[str]: - return _ffi_string(self._cdata.message) - - @message.setter - def message(self, v: Optional[str]): - self._message = v - if v is None: - self._cdata.message = ffi.NULL - else: - self._store_message = _ffi_unwrap_str(v) - self._cdata.message = self._store_message - - @property - def type(self) -> "CompilationMessageType": - return CompilationMessageType(self._cdata.type) - - @type.setter - def type(self, v: "CompilationMessageType"): - self._cdata.type = int(v) - - @property - def lineNum(self) -> int: - return self._cdata.lineNum - - @lineNum.setter - def lineNum(self, v: int): - self._cdata.lineNum = v - - @property - def linePos(self) -> int: - return self._cdata.linePos - - @linePos.setter - def linePos(self, v: int): - self._cdata.linePos = v - - @property - def offset(self) -> int: - return self._cdata.offset - - @offset.setter - def offset(self, v: int): - self._cdata.offset = v - - @property - def length(self) -> int: - return self._cdata.length - - @length.setter - def length(self, v: int): - self._cdata.length = v - - @property - def utf16LinePos(self) -> int: - return self._cdata.utf16LinePos - - @utf16LinePos.setter - def utf16LinePos(self, v: int): - self._cdata.utf16LinePos = v - - @property - def utf16Offset(self) -> int: - return self._cdata.utf16Offset - - @utf16Offset.setter - def utf16Offset(self, v: int): - self._cdata.utf16Offset = v - - @property - def utf16Length(self) -> int: - return self._cdata.utf16Length - - @utf16Length.setter - def utf16Length(self, v: int): - self._cdata.utf16Length = v - - -def compilationMessage( - *, - nextInChain: Optional["ChainedStruct"] = None, - message: Optional[str] = None, - type: "CompilationMessageType", - lineNum: int, - linePos: int, - offset: int, - length: int, - utf16LinePos: int, - utf16Offset: int, - utf16Length: int, -) -> CompilationMessage: - ret = CompilationMessage(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.message = message - ret.type = type - ret.lineNum = lineNum - ret.linePos = linePos - ret.offset = offset - ret.length = length - ret.utf16LinePos = utf16LinePos - ret.utf16Offset = utf16Offset - ret.utf16Length = utf16Length - return ret - - -class ComputePassTimestampWrites: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUComputePassTimestampWrites *", cdata) - - @property - def querySet(self) -> "QuerySet": - return QuerySet(self._cdata.querySet, add_ref=True) - - @querySet.setter - def querySet(self, v: "QuerySet"): - self._querySet = v - self._cdata.querySet = v._cdata - - @property - def beginningOfPassWriteIndex(self) -> int: - return self._cdata.beginningOfPassWriteIndex - - @beginningOfPassWriteIndex.setter - def beginningOfPassWriteIndex(self, v: int): - self._cdata.beginningOfPassWriteIndex = v - - @property - def endOfPassWriteIndex(self) -> int: - return self._cdata.endOfPassWriteIndex - - @endOfPassWriteIndex.setter - def endOfPassWriteIndex(self, v: int): - self._cdata.endOfPassWriteIndex = v - - -def computePassTimestampWrites( - *, querySet: "QuerySet", beginningOfPassWriteIndex: int, endOfPassWriteIndex: int -) -> ComputePassTimestampWrites: - ret = ComputePassTimestampWrites(cdata=None, parent=None) - ret.querySet = querySet - ret.beginningOfPassWriteIndex = beginningOfPassWriteIndex - ret.endOfPassWriteIndex = endOfPassWriteIndex - return ret - - -class ConstantEntry: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUConstantEntry *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def key(self) -> str: - return _ffi_string(self._cdata.key) - - @key.setter - def key(self, v: str): - self._key = v - self._store_key = _ffi_unwrap_str(v) - self._cdata.key = self._store_key - - @property - def value(self) -> float: - return self._cdata.value - - @value.setter - def value(self, v: float): - self._cdata.value = v - - -def constantEntry( - *, nextInChain: Optional["ChainedStruct"] = None, key: str, value: float -) -> ConstantEntry: - ret = ConstantEntry(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.key = key - ret.value = value - return ret - - -class Extent3D: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUExtent3D *", cdata) - - @property - def width(self) -> int: - return self._cdata.width - - @width.setter - def width(self, v: int): - self._cdata.width = v - - @property - def height(self) -> int: - return self._cdata.height - - @height.setter - def height(self, v: int): - self._cdata.height = v - - @property - def depthOrArrayLayers(self) -> int: - return self._cdata.depthOrArrayLayers - - @depthOrArrayLayers.setter - def depthOrArrayLayers(self, v: int): - self._cdata.depthOrArrayLayers = v - - -def extent3D(*, width: int, height: int, depthOrArrayLayers: int) -> Extent3D: - ret = Extent3D(cdata=None, parent=None) - ret.width = width - ret.height = height - ret.depthOrArrayLayers = depthOrArrayLayers - return ret - - -class InstanceDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUInstanceDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - -def instanceDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None -) -> InstanceDescriptor: - ret = InstanceDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - return ret - - -class Limits: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPULimits *", cdata) - - @property - def maxTextureDimension1D(self) -> int: - return self._cdata.maxTextureDimension1D - - @maxTextureDimension1D.setter - def maxTextureDimension1D(self, v: int): - self._cdata.maxTextureDimension1D = v - - @property - def maxTextureDimension2D(self) -> int: - return self._cdata.maxTextureDimension2D - - @maxTextureDimension2D.setter - def maxTextureDimension2D(self, v: int): - self._cdata.maxTextureDimension2D = v - - @property - def maxTextureDimension3D(self) -> int: - return self._cdata.maxTextureDimension3D - - @maxTextureDimension3D.setter - def maxTextureDimension3D(self, v: int): - self._cdata.maxTextureDimension3D = v - - @property - def maxTextureArrayLayers(self) -> int: - return self._cdata.maxTextureArrayLayers - - @maxTextureArrayLayers.setter - def maxTextureArrayLayers(self, v: int): - self._cdata.maxTextureArrayLayers = v - - @property - def maxBindGroups(self) -> int: - return self._cdata.maxBindGroups - - @maxBindGroups.setter - def maxBindGroups(self, v: int): - self._cdata.maxBindGroups = v - - @property - def maxBindGroupsPlusVertexBuffers(self) -> int: - return self._cdata.maxBindGroupsPlusVertexBuffers - - @maxBindGroupsPlusVertexBuffers.setter - def maxBindGroupsPlusVertexBuffers(self, v: int): - self._cdata.maxBindGroupsPlusVertexBuffers = v - - @property - def maxBindingsPerBindGroup(self) -> int: - return self._cdata.maxBindingsPerBindGroup - - @maxBindingsPerBindGroup.setter - def maxBindingsPerBindGroup(self, v: int): - self._cdata.maxBindingsPerBindGroup = v - - @property - def maxDynamicUniformBuffersPerPipelineLayout(self) -> int: - return self._cdata.maxDynamicUniformBuffersPerPipelineLayout - - @maxDynamicUniformBuffersPerPipelineLayout.setter - def maxDynamicUniformBuffersPerPipelineLayout(self, v: int): - self._cdata.maxDynamicUniformBuffersPerPipelineLayout = v - - @property - def maxDynamicStorageBuffersPerPipelineLayout(self) -> int: - return self._cdata.maxDynamicStorageBuffersPerPipelineLayout - - @maxDynamicStorageBuffersPerPipelineLayout.setter - def maxDynamicStorageBuffersPerPipelineLayout(self, v: int): - self._cdata.maxDynamicStorageBuffersPerPipelineLayout = v - - @property - def maxSampledTexturesPerShaderStage(self) -> int: - return self._cdata.maxSampledTexturesPerShaderStage - - @maxSampledTexturesPerShaderStage.setter - def maxSampledTexturesPerShaderStage(self, v: int): - self._cdata.maxSampledTexturesPerShaderStage = v - - @property - def maxSamplersPerShaderStage(self) -> int: - return self._cdata.maxSamplersPerShaderStage - - @maxSamplersPerShaderStage.setter - def maxSamplersPerShaderStage(self, v: int): - self._cdata.maxSamplersPerShaderStage = v - - @property - def maxStorageBuffersPerShaderStage(self) -> int: - return self._cdata.maxStorageBuffersPerShaderStage - - @maxStorageBuffersPerShaderStage.setter - def maxStorageBuffersPerShaderStage(self, v: int): - self._cdata.maxStorageBuffersPerShaderStage = v - - @property - def maxStorageTexturesPerShaderStage(self) -> int: - return self._cdata.maxStorageTexturesPerShaderStage - - @maxStorageTexturesPerShaderStage.setter - def maxStorageTexturesPerShaderStage(self, v: int): - self._cdata.maxStorageTexturesPerShaderStage = v - - @property - def maxUniformBuffersPerShaderStage(self) -> int: - return self._cdata.maxUniformBuffersPerShaderStage - - @maxUniformBuffersPerShaderStage.setter - def maxUniformBuffersPerShaderStage(self, v: int): - self._cdata.maxUniformBuffersPerShaderStage = v - - @property - def maxUniformBufferBindingSize(self) -> int: - return self._cdata.maxUniformBufferBindingSize - - @maxUniformBufferBindingSize.setter - def maxUniformBufferBindingSize(self, v: int): - self._cdata.maxUniformBufferBindingSize = v - - @property - def maxStorageBufferBindingSize(self) -> int: - return self._cdata.maxStorageBufferBindingSize - - @maxStorageBufferBindingSize.setter - def maxStorageBufferBindingSize(self, v: int): - self._cdata.maxStorageBufferBindingSize = v - - @property - def minUniformBufferOffsetAlignment(self) -> int: - return self._cdata.minUniformBufferOffsetAlignment - - @minUniformBufferOffsetAlignment.setter - def minUniformBufferOffsetAlignment(self, v: int): - self._cdata.minUniformBufferOffsetAlignment = v - - @property - def minStorageBufferOffsetAlignment(self) -> int: - return self._cdata.minStorageBufferOffsetAlignment - - @minStorageBufferOffsetAlignment.setter - def minStorageBufferOffsetAlignment(self, v: int): - self._cdata.minStorageBufferOffsetAlignment = v - - @property - def maxVertexBuffers(self) -> int: - return self._cdata.maxVertexBuffers - - @maxVertexBuffers.setter - def maxVertexBuffers(self, v: int): - self._cdata.maxVertexBuffers = v - - @property - def maxBufferSize(self) -> int: - return self._cdata.maxBufferSize - - @maxBufferSize.setter - def maxBufferSize(self, v: int): - self._cdata.maxBufferSize = v - - @property - def maxVertexAttributes(self) -> int: - return self._cdata.maxVertexAttributes - - @maxVertexAttributes.setter - def maxVertexAttributes(self, v: int): - self._cdata.maxVertexAttributes = v - - @property - def maxVertexBufferArrayStride(self) -> int: - return self._cdata.maxVertexBufferArrayStride - - @maxVertexBufferArrayStride.setter - def maxVertexBufferArrayStride(self, v: int): - self._cdata.maxVertexBufferArrayStride = v - - @property - def maxInterStageShaderComponents(self) -> int: - return self._cdata.maxInterStageShaderComponents - - @maxInterStageShaderComponents.setter - def maxInterStageShaderComponents(self, v: int): - self._cdata.maxInterStageShaderComponents = v - - @property - def maxInterStageShaderVariables(self) -> int: - return self._cdata.maxInterStageShaderVariables - - @maxInterStageShaderVariables.setter - def maxInterStageShaderVariables(self, v: int): - self._cdata.maxInterStageShaderVariables = v - - @property - def maxColorAttachments(self) -> int: - return self._cdata.maxColorAttachments - - @maxColorAttachments.setter - def maxColorAttachments(self, v: int): - self._cdata.maxColorAttachments = v - - @property - def maxColorAttachmentBytesPerSample(self) -> int: - return self._cdata.maxColorAttachmentBytesPerSample - - @maxColorAttachmentBytesPerSample.setter - def maxColorAttachmentBytesPerSample(self, v: int): - self._cdata.maxColorAttachmentBytesPerSample = v - - @property - def maxComputeWorkgroupStorageSize(self) -> int: - return self._cdata.maxComputeWorkgroupStorageSize - - @maxComputeWorkgroupStorageSize.setter - def maxComputeWorkgroupStorageSize(self, v: int): - self._cdata.maxComputeWorkgroupStorageSize = v - - @property - def maxComputeInvocationsPerWorkgroup(self) -> int: - return self._cdata.maxComputeInvocationsPerWorkgroup - - @maxComputeInvocationsPerWorkgroup.setter - def maxComputeInvocationsPerWorkgroup(self, v: int): - self._cdata.maxComputeInvocationsPerWorkgroup = v - - @property - def maxComputeWorkgroupSizeX(self) -> int: - return self._cdata.maxComputeWorkgroupSizeX - - @maxComputeWorkgroupSizeX.setter - def maxComputeWorkgroupSizeX(self, v: int): - self._cdata.maxComputeWorkgroupSizeX = v - - @property - def maxComputeWorkgroupSizeY(self) -> int: - return self._cdata.maxComputeWorkgroupSizeY - - @maxComputeWorkgroupSizeY.setter - def maxComputeWorkgroupSizeY(self, v: int): - self._cdata.maxComputeWorkgroupSizeY = v - - @property - def maxComputeWorkgroupSizeZ(self) -> int: - return self._cdata.maxComputeWorkgroupSizeZ - - @maxComputeWorkgroupSizeZ.setter - def maxComputeWorkgroupSizeZ(self, v: int): - self._cdata.maxComputeWorkgroupSizeZ = v - - @property - def maxComputeWorkgroupsPerDimension(self) -> int: - return self._cdata.maxComputeWorkgroupsPerDimension - - @maxComputeWorkgroupsPerDimension.setter - def maxComputeWorkgroupsPerDimension(self, v: int): - self._cdata.maxComputeWorkgroupsPerDimension = v - - -def limits( - *, - maxTextureDimension1D: int, - maxTextureDimension2D: int, - maxTextureDimension3D: int, - maxTextureArrayLayers: int, - maxBindGroups: int, - maxBindGroupsPlusVertexBuffers: int, - maxBindingsPerBindGroup: int, - maxDynamicUniformBuffersPerPipelineLayout: int, - maxDynamicStorageBuffersPerPipelineLayout: int, - maxSampledTexturesPerShaderStage: int, - maxSamplersPerShaderStage: int, - maxStorageBuffersPerShaderStage: int, - maxStorageTexturesPerShaderStage: int, - maxUniformBuffersPerShaderStage: int, - maxUniformBufferBindingSize: int, - maxStorageBufferBindingSize: int, - minUniformBufferOffsetAlignment: int, - minStorageBufferOffsetAlignment: int, - maxVertexBuffers: int, - maxBufferSize: int, - maxVertexAttributes: int, - maxVertexBufferArrayStride: int, - maxInterStageShaderComponents: int, - maxInterStageShaderVariables: int, - maxColorAttachments: int, - maxColorAttachmentBytesPerSample: int, - maxComputeWorkgroupStorageSize: int, - maxComputeInvocationsPerWorkgroup: int, - maxComputeWorkgroupSizeX: int, - maxComputeWorkgroupSizeY: int, - maxComputeWorkgroupSizeZ: int, - maxComputeWorkgroupsPerDimension: int, -) -> Limits: - ret = Limits(cdata=None, parent=None) - ret.maxTextureDimension1D = maxTextureDimension1D - ret.maxTextureDimension2D = maxTextureDimension2D - ret.maxTextureDimension3D = maxTextureDimension3D - ret.maxTextureArrayLayers = maxTextureArrayLayers - ret.maxBindGroups = maxBindGroups - ret.maxBindGroupsPlusVertexBuffers = maxBindGroupsPlusVertexBuffers - ret.maxBindingsPerBindGroup = maxBindingsPerBindGroup - ret.maxDynamicUniformBuffersPerPipelineLayout = ( - maxDynamicUniformBuffersPerPipelineLayout - ) - ret.maxDynamicStorageBuffersPerPipelineLayout = ( - maxDynamicStorageBuffersPerPipelineLayout - ) - ret.maxSampledTexturesPerShaderStage = maxSampledTexturesPerShaderStage - ret.maxSamplersPerShaderStage = maxSamplersPerShaderStage - ret.maxStorageBuffersPerShaderStage = maxStorageBuffersPerShaderStage - ret.maxStorageTexturesPerShaderStage = maxStorageTexturesPerShaderStage - ret.maxUniformBuffersPerShaderStage = maxUniformBuffersPerShaderStage - ret.maxUniformBufferBindingSize = maxUniformBufferBindingSize - ret.maxStorageBufferBindingSize = maxStorageBufferBindingSize - ret.minUniformBufferOffsetAlignment = minUniformBufferOffsetAlignment - ret.minStorageBufferOffsetAlignment = minStorageBufferOffsetAlignment - ret.maxVertexBuffers = maxVertexBuffers - ret.maxBufferSize = maxBufferSize - ret.maxVertexAttributes = maxVertexAttributes - ret.maxVertexBufferArrayStride = maxVertexBufferArrayStride - ret.maxInterStageShaderComponents = maxInterStageShaderComponents - ret.maxInterStageShaderVariables = maxInterStageShaderVariables - ret.maxColorAttachments = maxColorAttachments - ret.maxColorAttachmentBytesPerSample = maxColorAttachmentBytesPerSample - ret.maxComputeWorkgroupStorageSize = maxComputeWorkgroupStorageSize - ret.maxComputeInvocationsPerWorkgroup = maxComputeInvocationsPerWorkgroup - ret.maxComputeWorkgroupSizeX = maxComputeWorkgroupSizeX - ret.maxComputeWorkgroupSizeY = maxComputeWorkgroupSizeY - ret.maxComputeWorkgroupSizeZ = maxComputeWorkgroupSizeZ - ret.maxComputeWorkgroupsPerDimension = maxComputeWorkgroupsPerDimension - return ret - - -class MultisampleState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUMultisampleState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def count(self) -> int: - return self._cdata.count - - @count.setter - def count(self, v: int): - self._cdata.count = v - - @property - def mask(self) -> int: - return self._cdata.mask - - @mask.setter - def mask(self, v: int): - self._cdata.mask = v - - @property - def alphaToCoverageEnabled(self) -> bool: - return self._cdata.alphaToCoverageEnabled - - @alphaToCoverageEnabled.setter - def alphaToCoverageEnabled(self, v: bool): - self._cdata.alphaToCoverageEnabled = v - - -def multisampleState( - *, - nextInChain: Optional["ChainedStruct"] = None, - count: int = 1, - mask: int = 0xFFFFFFFF, - alphaToCoverageEnabled: bool = False, -) -> MultisampleState: - ret = MultisampleState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.count = count - ret.mask = mask - ret.alphaToCoverageEnabled = alphaToCoverageEnabled - return ret - - -class Origin3D: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUOrigin3D *", cdata) - - @property - def x(self) -> int: - return self._cdata.x - - @x.setter - def x(self, v: int): - self._cdata.x = v - - @property - def y(self) -> int: - return self._cdata.y - - @y.setter - def y(self, v: int): - self._cdata.y = v - - @property - def z(self) -> int: - return self._cdata.z - - @z.setter - def z(self, v: int): - self._cdata.z = v - - -def origin3D(*, x: int, y: int, z: int) -> Origin3D: - ret = Origin3D(cdata=None, parent=None) - ret.x = x - ret.y = y - ret.z = z - return ret - - -class PipelineLayoutDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUPipelineLayoutDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def bindGroupLayouts(self) -> "BindGroupLayoutList": - return self._bindGroupLayouts - - @bindGroupLayouts.setter - def bindGroupLayouts(self, v: Union["BindGroupLayoutList", list["BindGroupLayout"]]): - if isinstance(v, list): - v2 = BindGroupLayoutList(v) - else: - v2 = v - self._bindGroupLayouts = v2 - self._cdata.bindGroupLayoutCount = v2._count - self._cdata.bindGroupLayouts = v2._ptr - - -def pipelineLayoutDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - bindGroupLayouts: Union["BindGroupLayoutList", list["BindGroupLayout"]], -) -> PipelineLayoutDescriptor: - ret = PipelineLayoutDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.bindGroupLayouts = bindGroupLayouts - return ret - - -class PrimitiveDepthClipControl(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUPrimitiveDepthClipControl *", cdata) - self._cdata.chain.sType = SType.PrimitiveDepthClipControl - - @property - def unclippedDepth(self) -> bool: - return self._cdata.unclippedDepth - - @unclippedDepth.setter - def unclippedDepth(self, v: bool): - self._cdata.unclippedDepth = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def primitiveDepthClipControl(*, unclippedDepth: bool) -> PrimitiveDepthClipControl: - ret = PrimitiveDepthClipControl(cdata=None, parent=None) - ret.unclippedDepth = unclippedDepth - return ret - - -class PrimitiveState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUPrimitiveState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def topology(self) -> "PrimitiveTopology": - return PrimitiveTopology(self._cdata.topology) - - @topology.setter - def topology(self, v: "PrimitiveTopology"): - self._cdata.topology = int(v) - - @property - def stripIndexFormat(self) -> "IndexFormat": - return IndexFormat(self._cdata.stripIndexFormat) - - @stripIndexFormat.setter - def stripIndexFormat(self, v: "IndexFormat"): - self._cdata.stripIndexFormat = int(v) - - @property - def frontFace(self) -> "FrontFace": - return FrontFace(self._cdata.frontFace) - - @frontFace.setter - def frontFace(self, v: "FrontFace"): - self._cdata.frontFace = int(v) - - @property - def cullMode(self) -> "CullMode": - return CullMode(self._cdata.cullMode) - - @cullMode.setter - def cullMode(self, v: "CullMode"): - self._cdata.cullMode = int(v) - - -def primitiveState( - *, - nextInChain: Optional["ChainedStruct"] = None, - topology: "PrimitiveTopology" = PrimitiveTopology.TriangleList, - stripIndexFormat: "IndexFormat", - frontFace: "FrontFace" = FrontFace.CCW, - cullMode: "CullMode" = CullMode._None, -) -> PrimitiveState: - ret = PrimitiveState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.topology = topology - ret.stripIndexFormat = stripIndexFormat - ret.frontFace = frontFace - ret.cullMode = cullMode - return ret - - -class QuerySetDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUQuerySetDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def type(self) -> "QueryType": - return QueryType(self._cdata.type) - - @type.setter - def type(self, v: "QueryType"): - self._cdata.type = int(v) - - @property - def count(self) -> int: - return self._cdata.count - - @count.setter - def count(self, v: int): - self._cdata.count = v - - -def querySetDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - type: "QueryType", - count: int, -) -> QuerySetDescriptor: - ret = QuerySetDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.type = type - ret.count = count - return ret - - -class QueueDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUQueueDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - -def queueDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None, label: Optional[str] = None -) -> QueueDescriptor: - ret = QueueDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - return ret - - -class RenderBundleDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderBundleDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - -def renderBundleDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None, label: Optional[str] = None -) -> RenderBundleDescriptor: - ret = RenderBundleDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - return ret - - -class RenderBundleEncoderDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderBundleEncoderDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def colorFormats(self) -> "TextureFormatList": - return self._colorFormats - - @colorFormats.setter - def colorFormats(self, v: Union["TextureFormatList", list["TextureFormat"]]): - if isinstance(v, list): - v2 = TextureFormatList(v) - else: - v2 = v - self._colorFormats = v2 - self._cdata.colorFormatCount = v2._count - self._cdata.colorFormats = v2._ptr - - @property - def depthStencilFormat(self) -> "TextureFormat": - return TextureFormat(self._cdata.depthStencilFormat) - - @depthStencilFormat.setter - def depthStencilFormat(self, v: "TextureFormat"): - self._cdata.depthStencilFormat = int(v) - - @property - def sampleCount(self) -> int: - return self._cdata.sampleCount - - @sampleCount.setter - def sampleCount(self, v: int): - self._cdata.sampleCount = v - - @property - def depthReadOnly(self) -> bool: - return self._cdata.depthReadOnly - - @depthReadOnly.setter - def depthReadOnly(self, v: bool): - self._cdata.depthReadOnly = v - - @property - def stencilReadOnly(self) -> bool: - return self._cdata.stencilReadOnly - - @stencilReadOnly.setter - def stencilReadOnly(self, v: bool): - self._cdata.stencilReadOnly = v - - -def renderBundleEncoderDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - colorFormats: Union["TextureFormatList", list["TextureFormat"]], - depthStencilFormat: "TextureFormat", - sampleCount: int, - depthReadOnly: bool = False, - stencilReadOnly: bool = False, -) -> RenderBundleEncoderDescriptor: - ret = RenderBundleEncoderDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.colorFormats = colorFormats - ret.depthStencilFormat = depthStencilFormat - ret.sampleCount = sampleCount - ret.depthReadOnly = depthReadOnly - ret.stencilReadOnly = stencilReadOnly - return ret - - -class RenderPassDepthStencilAttachment: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPassDepthStencilAttachment *", cdata) - - @property - def view(self) -> "TextureView": - return TextureView(self._cdata.view, add_ref=True) - - @view.setter - def view(self, v: "TextureView"): - self._view = v - self._cdata.view = v._cdata - - @property - def depthLoadOp(self) -> "LoadOp": - return LoadOp(self._cdata.depthLoadOp) - - @depthLoadOp.setter - def depthLoadOp(self, v: "LoadOp"): - self._cdata.depthLoadOp = int(v) - - @property - def depthStoreOp(self) -> "StoreOp": - return StoreOp(self._cdata.depthStoreOp) - - @depthStoreOp.setter - def depthStoreOp(self, v: "StoreOp"): - self._cdata.depthStoreOp = int(v) - - @property - def depthClearValue(self) -> float: - return self._cdata.depthClearValue - - @depthClearValue.setter - def depthClearValue(self, v: float): - self._cdata.depthClearValue = v - - @property - def depthReadOnly(self) -> bool: - return self._cdata.depthReadOnly - - @depthReadOnly.setter - def depthReadOnly(self, v: bool): - self._cdata.depthReadOnly = v - - @property - def stencilLoadOp(self) -> "LoadOp": - return LoadOp(self._cdata.stencilLoadOp) - - @stencilLoadOp.setter - def stencilLoadOp(self, v: "LoadOp"): - self._cdata.stencilLoadOp = int(v) - - @property - def stencilStoreOp(self) -> "StoreOp": - return StoreOp(self._cdata.stencilStoreOp) - - @stencilStoreOp.setter - def stencilStoreOp(self, v: "StoreOp"): - self._cdata.stencilStoreOp = int(v) - - @property - def stencilClearValue(self) -> int: - return self._cdata.stencilClearValue - - @stencilClearValue.setter - def stencilClearValue(self, v: int): - self._cdata.stencilClearValue = v - - @property - def stencilReadOnly(self) -> bool: - return self._cdata.stencilReadOnly - - @stencilReadOnly.setter - def stencilReadOnly(self, v: bool): - self._cdata.stencilReadOnly = v - - -def renderPassDepthStencilAttachment( - *, - view: "TextureView", - depthLoadOp: "LoadOp", - depthStoreOp: "StoreOp", - depthClearValue: float, - depthReadOnly: bool = False, - stencilLoadOp: "LoadOp", - stencilStoreOp: "StoreOp", - stencilClearValue: int = 0, - stencilReadOnly: bool = False, -) -> RenderPassDepthStencilAttachment: - ret = RenderPassDepthStencilAttachment(cdata=None, parent=None) - ret.view = view - ret.depthLoadOp = depthLoadOp - ret.depthStoreOp = depthStoreOp - ret.depthClearValue = depthClearValue - ret.depthReadOnly = depthReadOnly - ret.stencilLoadOp = stencilLoadOp - ret.stencilStoreOp = stencilStoreOp - ret.stencilClearValue = stencilClearValue - ret.stencilReadOnly = stencilReadOnly - return ret - - -class RenderPassDescriptorMaxDrawCount(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPassDescriptorMaxDrawCount *", cdata) - self._cdata.chain.sType = SType.RenderPassDescriptorMaxDrawCount - - @property - def maxDrawCount(self) -> int: - return self._cdata.maxDrawCount - - @maxDrawCount.setter - def maxDrawCount(self, v: int): - self._cdata.maxDrawCount = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def renderPassDescriptorMaxDrawCount( - *, maxDrawCount: int -) -> RenderPassDescriptorMaxDrawCount: - ret = RenderPassDescriptorMaxDrawCount(cdata=None, parent=None) - ret.maxDrawCount = maxDrawCount - return ret - - -class RenderPassTimestampWrites: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPassTimestampWrites *", cdata) - - @property - def querySet(self) -> "QuerySet": - return QuerySet(self._cdata.querySet, add_ref=True) - - @querySet.setter - def querySet(self, v: "QuerySet"): - self._querySet = v - self._cdata.querySet = v._cdata - - @property - def beginningOfPassWriteIndex(self) -> int: - return self._cdata.beginningOfPassWriteIndex - - @beginningOfPassWriteIndex.setter - def beginningOfPassWriteIndex(self, v: int): - self._cdata.beginningOfPassWriteIndex = v - - @property - def endOfPassWriteIndex(self) -> int: - return self._cdata.endOfPassWriteIndex - - @endOfPassWriteIndex.setter - def endOfPassWriteIndex(self, v: int): - self._cdata.endOfPassWriteIndex = v - - -def renderPassTimestampWrites( - *, querySet: "QuerySet", beginningOfPassWriteIndex: int, endOfPassWriteIndex: int -) -> RenderPassTimestampWrites: - ret = RenderPassTimestampWrites(cdata=None, parent=None) - ret.querySet = querySet - ret.beginningOfPassWriteIndex = beginningOfPassWriteIndex - ret.endOfPassWriteIndex = endOfPassWriteIndex - return ret - - -class RequestAdapterOptions: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURequestAdapterOptions *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def compatibleSurface(self) -> Optional["Surface"]: - return Surface(self._cdata.compatibleSurface, add_ref=True) - - @compatibleSurface.setter - def compatibleSurface(self, v: Optional["Surface"]): - self._compatibleSurface = v - if v is None: - self._cdata.compatibleSurface = ffi.NULL - else: - self._cdata.compatibleSurface = v._cdata - - @property - def powerPreference(self) -> "PowerPreference": - return PowerPreference(self._cdata.powerPreference) - - @powerPreference.setter - def powerPreference(self, v: "PowerPreference"): - self._cdata.powerPreference = int(v) - - @property - def backendType(self) -> "BackendType": - return BackendType(self._cdata.backendType) - - @backendType.setter - def backendType(self, v: "BackendType"): - self._cdata.backendType = int(v) - - @property - def forceFallbackAdapter(self) -> bool: - return self._cdata.forceFallbackAdapter - - @forceFallbackAdapter.setter - def forceFallbackAdapter(self, v: bool): - self._cdata.forceFallbackAdapter = v - - -def requestAdapterOptions( - *, - nextInChain: Optional["ChainedStruct"] = None, - compatibleSurface: Optional["Surface"] = None, - powerPreference: "PowerPreference", - backendType: "BackendType", - forceFallbackAdapter: bool = False, -) -> RequestAdapterOptions: - ret = RequestAdapterOptions(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.compatibleSurface = compatibleSurface - ret.powerPreference = powerPreference - ret.backendType = backendType - ret.forceFallbackAdapter = forceFallbackAdapter - return ret - - -class SamplerBindingLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSamplerBindingLayout *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def type(self) -> "SamplerBindingType": - return SamplerBindingType(self._cdata.type) - - @type.setter - def type(self, v: "SamplerBindingType"): - self._cdata.type = int(v) - - -def samplerBindingLayout( - *, nextInChain: Optional["ChainedStruct"] = None, type: "SamplerBindingType" -) -> SamplerBindingLayout: - ret = SamplerBindingLayout(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.type = type - return ret - - -class SamplerDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSamplerDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def addressModeU(self) -> "AddressMode": - return AddressMode(self._cdata.addressModeU) - - @addressModeU.setter - def addressModeU(self, v: "AddressMode"): - self._cdata.addressModeU = int(v) - - @property - def addressModeV(self) -> "AddressMode": - return AddressMode(self._cdata.addressModeV) - - @addressModeV.setter - def addressModeV(self, v: "AddressMode"): - self._cdata.addressModeV = int(v) - - @property - def addressModeW(self) -> "AddressMode": - return AddressMode(self._cdata.addressModeW) - - @addressModeW.setter - def addressModeW(self, v: "AddressMode"): - self._cdata.addressModeW = int(v) - - @property - def magFilter(self) -> "FilterMode": - return FilterMode(self._cdata.magFilter) - - @magFilter.setter - def magFilter(self, v: "FilterMode"): - self._cdata.magFilter = int(v) - - @property - def minFilter(self) -> "FilterMode": - return FilterMode(self._cdata.minFilter) - - @minFilter.setter - def minFilter(self, v: "FilterMode"): - self._cdata.minFilter = int(v) - - @property - def mipmapFilter(self) -> "MipmapFilterMode": - return MipmapFilterMode(self._cdata.mipmapFilter) - - @mipmapFilter.setter - def mipmapFilter(self, v: "MipmapFilterMode"): - self._cdata.mipmapFilter = int(v) - - @property - def lodMinClamp(self) -> float: - return self._cdata.lodMinClamp - - @lodMinClamp.setter - def lodMinClamp(self, v: float): - self._cdata.lodMinClamp = v - - @property - def lodMaxClamp(self) -> float: - return self._cdata.lodMaxClamp - - @lodMaxClamp.setter - def lodMaxClamp(self, v: float): - self._cdata.lodMaxClamp = v - - @property - def compare(self) -> "CompareFunction": - return CompareFunction(self._cdata.compare) - - @compare.setter - def compare(self, v: "CompareFunction"): - self._cdata.compare = int(v) - - @property - def maxAnisotropy(self) -> int: - return self._cdata.maxAnisotropy - - @maxAnisotropy.setter - def maxAnisotropy(self, v: int): - self._cdata.maxAnisotropy = v - - -def samplerDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - addressModeU: "AddressMode" = AddressMode.ClampToEdge, - addressModeV: "AddressMode" = AddressMode.ClampToEdge, - addressModeW: "AddressMode" = AddressMode.ClampToEdge, - magFilter: "FilterMode" = FilterMode.Nearest, - minFilter: "FilterMode" = FilterMode.Nearest, - mipmapFilter: "MipmapFilterMode" = MipmapFilterMode.Nearest, - lodMinClamp: float = 0, - lodMaxClamp: float = 32, - compare: "CompareFunction", - maxAnisotropy: int = 1, -) -> SamplerDescriptor: - ret = SamplerDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.addressModeU = addressModeU - ret.addressModeV = addressModeV - ret.addressModeW = addressModeW - ret.magFilter = magFilter - ret.minFilter = minFilter - ret.mipmapFilter = mipmapFilter - ret.lodMinClamp = lodMinClamp - ret.lodMaxClamp = lodMaxClamp - ret.compare = compare - ret.maxAnisotropy = maxAnisotropy - return ret - - -class ShaderModuleCompilationHint: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderModuleCompilationHint *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def entryPoint(self) -> str: - return _ffi_string(self._cdata.entryPoint) - - @entryPoint.setter - def entryPoint(self, v: str): - self._entryPoint = v - self._store_entryPoint = _ffi_unwrap_str(v) - self._cdata.entryPoint = self._store_entryPoint - - @property - def layout(self) -> "PipelineLayout": - return PipelineLayout(self._cdata.layout, add_ref=True) - - @layout.setter - def layout(self, v: "PipelineLayout"): - self._layout = v - self._cdata.layout = v._cdata - - -def shaderModuleCompilationHint( - *, - nextInChain: Optional["ChainedStruct"] = None, - entryPoint: str, - layout: "PipelineLayout", -) -> ShaderModuleCompilationHint: - ret = ShaderModuleCompilationHint(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.entryPoint = entryPoint - ret.layout = layout - return ret - - -class ShaderModuleSPIRVDescriptor(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderModuleSPIRVDescriptor *", cdata) - self._cdata.chain.sType = SType.ShaderModuleSPIRVDescriptor - - @property - def codeSize(self) -> int: - return self._cdata.codeSize - - @codeSize.setter - def codeSize(self, v: int): - self._cdata.codeSize = v - - @property - def code(self) -> int: - return self._code - - @code.setter - def code(self, v: int): - self._code = v - self._cdata.code = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def shaderModuleSPIRVDescriptor( - *, codeSize: int, code: int -) -> ShaderModuleSPIRVDescriptor: - ret = ShaderModuleSPIRVDescriptor(cdata=None, parent=None) - ret.codeSize = codeSize - ret.code = code - return ret - - -class ShaderModuleWGSLDescriptor(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderModuleWGSLDescriptor *", cdata) - self._cdata.chain.sType = SType.ShaderModuleWGSLDescriptor - - @property - def code(self) -> str: - return _ffi_string(self._cdata.code) - - @code.setter - def code(self, v: str): - self._code = v - self._store_code = _ffi_unwrap_str(v) - self._cdata.code = self._store_code - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def shaderModuleWGSLDescriptor(*, code: str) -> ShaderModuleWGSLDescriptor: - ret = ShaderModuleWGSLDescriptor(cdata=None, parent=None) - ret.code = code - return ret - - -class StencilFaceState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUStencilFaceState *", cdata) - - @property - def compare(self) -> "CompareFunction": - return CompareFunction(self._cdata.compare) - - @compare.setter - def compare(self, v: "CompareFunction"): - self._cdata.compare = int(v) - - @property - def failOp(self) -> "StencilOperation": - return StencilOperation(self._cdata.failOp) - - @failOp.setter - def failOp(self, v: "StencilOperation"): - self._cdata.failOp = int(v) - - @property - def depthFailOp(self) -> "StencilOperation": - return StencilOperation(self._cdata.depthFailOp) - - @depthFailOp.setter - def depthFailOp(self, v: "StencilOperation"): - self._cdata.depthFailOp = int(v) - - @property - def passOp(self) -> "StencilOperation": - return StencilOperation(self._cdata.passOp) - - @passOp.setter - def passOp(self, v: "StencilOperation"): - self._cdata.passOp = int(v) - - -def stencilFaceState( - *, - compare: "CompareFunction" = CompareFunction.Always, - failOp: "StencilOperation" = StencilOperation.Keep, - depthFailOp: "StencilOperation" = StencilOperation.Keep, - passOp: "StencilOperation" = StencilOperation.Keep, -) -> StencilFaceState: - ret = StencilFaceState(cdata=None, parent=None) - ret.compare = compare - ret.failOp = failOp - ret.depthFailOp = depthFailOp - ret.passOp = passOp - return ret - - -class StorageTextureBindingLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUStorageTextureBindingLayout *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def access(self) -> "StorageTextureAccess": - return StorageTextureAccess(self._cdata.access) - - @access.setter - def access(self, v: "StorageTextureAccess"): - self._cdata.access = int(v) - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def viewDimension(self) -> "TextureViewDimension": - return TextureViewDimension(self._cdata.viewDimension) - - @viewDimension.setter - def viewDimension(self, v: "TextureViewDimension"): - self._cdata.viewDimension = int(v) - - -def storageTextureBindingLayout( - *, - nextInChain: Optional["ChainedStruct"] = None, - access: "StorageTextureAccess", - format: "TextureFormat", - viewDimension: "TextureViewDimension", -) -> StorageTextureBindingLayout: - ret = StorageTextureBindingLayout(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.access = access - ret.format = format - ret.viewDimension = viewDimension - return ret - - -class SurfaceCapabilities: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceCapabilities *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStructOut"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStructOut"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def formats(self) -> "TextureFormatList": - return self._formats - - @formats.setter - def formats(self, v: Union["TextureFormatList", list["TextureFormat"]]): - if isinstance(v, list): - v2 = TextureFormatList(v) - else: - v2 = v - self._formats = v2 - self._cdata.formatCount = v2._count - self._cdata.formats = v2._ptr - - @property - def presentModes(self) -> "PresentModeList": - return self._presentModes - - @presentModes.setter - def presentModes(self, v: Union["PresentModeList", list["PresentMode"]]): - if isinstance(v, list): - v2 = PresentModeList(v) - else: - v2 = v - self._presentModes = v2 - self._cdata.presentModeCount = v2._count - self._cdata.presentModes = v2._ptr - - @property - def alphaModes(self) -> "CompositeAlphaModeList": - return self._alphaModes - - @alphaModes.setter - def alphaModes(self, v: Union["CompositeAlphaModeList", list["CompositeAlphaMode"]]): - if isinstance(v, list): - v2 = CompositeAlphaModeList(v) - else: - v2 = v - self._alphaModes = v2 - self._cdata.alphaModeCount = v2._count - self._cdata.alphaModes = v2._ptr - - -def surfaceCapabilities( - *, - nextInChain: Optional["ChainedStructOut"] = None, - formats: Union["TextureFormatList", list["TextureFormat"]], - presentModes: Union["PresentModeList", list["PresentMode"]], - alphaModes: Union["CompositeAlphaModeList", list["CompositeAlphaMode"]], -) -> SurfaceCapabilities: - ret = SurfaceCapabilities(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.formats = formats - ret.presentModes = presentModes - ret.alphaModes = alphaModes - return ret - - -class SurfaceConfiguration: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceConfiguration *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def device(self) -> "Device": - return Device(self._cdata.device, add_ref=True) - - @device.setter - def device(self, v: "Device"): - self._device = v - self._cdata.device = v._cdata - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def usage(self) -> "TextureUsageFlags": - return TextureUsageFlags(self._cdata.usage) - - @usage.setter - def usage(self, v: Union["TextureUsageFlags", "TextureUsage"]): - self._cdata.usage = int(v) - - @property - def viewFormats(self) -> "TextureFormatList": - return self._viewFormats - - @viewFormats.setter - def viewFormats(self, v: Union["TextureFormatList", list["TextureFormat"]]): - if isinstance(v, list): - v2 = TextureFormatList(v) - else: - v2 = v - self._viewFormats = v2 - self._cdata.viewFormatCount = v2._count - self._cdata.viewFormats = v2._ptr - - @property - def alphaMode(self) -> "CompositeAlphaMode": - return CompositeAlphaMode(self._cdata.alphaMode) - - @alphaMode.setter - def alphaMode(self, v: "CompositeAlphaMode"): - self._cdata.alphaMode = int(v) - - @property - def width(self) -> int: - return self._cdata.width - - @width.setter - def width(self, v: int): - self._cdata.width = v - - @property - def height(self) -> int: - return self._cdata.height - - @height.setter - def height(self, v: int): - self._cdata.height = v - - @property - def presentMode(self) -> "PresentMode": - return PresentMode(self._cdata.presentMode) - - @presentMode.setter - def presentMode(self, v: "PresentMode"): - self._cdata.presentMode = int(v) - - -def surfaceConfiguration( - *, - nextInChain: Optional["ChainedStruct"] = None, - device: "Device", - format: "TextureFormat", - usage: Union["TextureUsageFlags", "TextureUsage"], - viewFormats: Union["TextureFormatList", list["TextureFormat"]], - alphaMode: "CompositeAlphaMode", - width: int, - height: int, - presentMode: "PresentMode", -) -> SurfaceConfiguration: - ret = SurfaceConfiguration(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.device = device - ret.format = format - ret.usage = usage - ret.viewFormats = viewFormats - ret.alphaMode = alphaMode - ret.width = width - ret.height = height - ret.presentMode = presentMode - return ret - - -class SurfaceDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - -def surfaceDescriptor( - *, nextInChain: Optional["ChainedStruct"] = None, label: Optional[str] = None -) -> SurfaceDescriptor: - ret = SurfaceDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - return ret - - -class SurfaceDescriptorFromAndroidNativeWindow(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromAndroidNativeWindow *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromAndroidNativeWindow - - @property - def window(self) -> VoidPtr: - return self._window - - @window.setter - def window(self, v: VoidPtr): - self._window = v - self._cdata.window = v._ptr - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromAndroidNativeWindow( - *, window: VoidPtr -) -> SurfaceDescriptorFromAndroidNativeWindow: - ret = SurfaceDescriptorFromAndroidNativeWindow(cdata=None, parent=None) - ret.window = window - return ret - - -class SurfaceDescriptorFromCanvasHTMLSelector(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromCanvasHTMLSelector *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromCanvasHTMLSelector - - @property - def selector(self) -> str: - return _ffi_string(self._cdata.selector) - - @selector.setter - def selector(self, v: str): - self._selector = v - self._store_selector = _ffi_unwrap_str(v) - self._cdata.selector = self._store_selector - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromCanvasHTMLSelector( - *, selector: str -) -> SurfaceDescriptorFromCanvasHTMLSelector: - ret = SurfaceDescriptorFromCanvasHTMLSelector(cdata=None, parent=None) - ret.selector = selector - return ret - - -class SurfaceDescriptorFromMetalLayer(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromMetalLayer *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromMetalLayer - - @property - def layer(self) -> VoidPtr: - return self._layer - - @layer.setter - def layer(self, v: VoidPtr): - self._layer = v - self._cdata.layer = v._ptr - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromMetalLayer(*, layer: VoidPtr) -> SurfaceDescriptorFromMetalLayer: - ret = SurfaceDescriptorFromMetalLayer(cdata=None, parent=None) - ret.layer = layer - return ret - - -class SurfaceDescriptorFromWaylandSurface(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromWaylandSurface *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromWaylandSurface - - @property - def display(self) -> VoidPtr: - return self._display - - @display.setter - def display(self, v: VoidPtr): - self._display = v - self._cdata.display = v._ptr - - @property - def surface(self) -> VoidPtr: - return self._surface - - @surface.setter - def surface(self, v: VoidPtr): - self._surface = v - self._cdata.surface = v._ptr - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromWaylandSurface( - *, display: VoidPtr, surface: VoidPtr -) -> SurfaceDescriptorFromWaylandSurface: - ret = SurfaceDescriptorFromWaylandSurface(cdata=None, parent=None) - ret.display = display - ret.surface = surface - return ret - - -class SurfaceDescriptorFromWindowsHWND(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromWindowsHWND *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromWindowsHWND - - @property - def hinstance(self) -> VoidPtr: - return self._hinstance - - @hinstance.setter - def hinstance(self, v: VoidPtr): - self._hinstance = v - self._cdata.hinstance = v._ptr - - @property - def hwnd(self) -> VoidPtr: - return self._hwnd - - @hwnd.setter - def hwnd(self, v: VoidPtr): - self._hwnd = v - self._cdata.hwnd = v._ptr - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromWindowsHWND( - *, hinstance: VoidPtr, hwnd: VoidPtr -) -> SurfaceDescriptorFromWindowsHWND: - ret = SurfaceDescriptorFromWindowsHWND(cdata=None, parent=None) - ret.hinstance = hinstance - ret.hwnd = hwnd - return ret - - -class SurfaceDescriptorFromXcbWindow(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromXcbWindow *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromXcbWindow - - @property - def connection(self) -> VoidPtr: - return self._connection - - @connection.setter - def connection(self, v: VoidPtr): - self._connection = v - self._cdata.connection = v._ptr - - @property - def window(self) -> int: - return self._cdata.window - - @window.setter - def window(self, v: int): - self._cdata.window = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromXcbWindow( - *, connection: VoidPtr, window: int -) -> SurfaceDescriptorFromXcbWindow: - ret = SurfaceDescriptorFromXcbWindow(cdata=None, parent=None) - ret.connection = connection - ret.window = window - return ret - - -class SurfaceDescriptorFromXlibWindow(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceDescriptorFromXlibWindow *", cdata) - self._cdata.chain.sType = SType.SurfaceDescriptorFromXlibWindow - - @property - def display(self) -> VoidPtr: - return self._display - - @display.setter - def display(self, v: VoidPtr): - self._display = v - self._cdata.display = v._ptr - - @property - def window(self) -> int: - return self._cdata.window - - @window.setter - def window(self, v: int): - self._cdata.window = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def surfaceDescriptorFromXlibWindow( - *, display: VoidPtr, window: int -) -> SurfaceDescriptorFromXlibWindow: - ret = SurfaceDescriptorFromXlibWindow(cdata=None, parent=None) - ret.display = display - ret.window = window - return ret - - -class SurfaceTexture: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSurfaceTexture *", cdata) - - @property - def texture(self) -> "Texture": - return Texture(self._cdata.texture, add_ref=True) - - @texture.setter - def texture(self, v: "Texture"): - self._texture = v - self._cdata.texture = v._cdata - - @property - def suboptimal(self) -> bool: - return self._cdata.suboptimal - - @suboptimal.setter - def suboptimal(self, v: bool): - self._cdata.suboptimal = v - - @property - def status(self) -> "SurfaceGetCurrentTextureStatus": - return SurfaceGetCurrentTextureStatus(self._cdata.status) - - @status.setter - def status(self, v: "SurfaceGetCurrentTextureStatus"): - self._cdata.status = int(v) - - -def surfaceTexture( - *, texture: "Texture", suboptimal: bool, status: "SurfaceGetCurrentTextureStatus" -) -> SurfaceTexture: - ret = SurfaceTexture(cdata=None, parent=None) - ret.texture = texture - ret.suboptimal = suboptimal - ret.status = status - return ret - - -class TextureBindingLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUTextureBindingLayout *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def sampleType(self) -> "TextureSampleType": - return TextureSampleType(self._cdata.sampleType) - - @sampleType.setter - def sampleType(self, v: "TextureSampleType"): - self._cdata.sampleType = int(v) - - @property - def viewDimension(self) -> "TextureViewDimension": - return TextureViewDimension(self._cdata.viewDimension) - - @viewDimension.setter - def viewDimension(self, v: "TextureViewDimension"): - self._cdata.viewDimension = int(v) - - @property - def multisampled(self) -> bool: - return self._cdata.multisampled - - @multisampled.setter - def multisampled(self, v: bool): - self._cdata.multisampled = v - - -def textureBindingLayout( - *, - nextInChain: Optional["ChainedStruct"] = None, - sampleType: "TextureSampleType", - viewDimension: "TextureViewDimension", - multisampled: bool, -) -> TextureBindingLayout: - ret = TextureBindingLayout(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.sampleType = sampleType - ret.viewDimension = viewDimension - ret.multisampled = multisampled - return ret - - -class TextureDataLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUTextureDataLayout *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def offset(self) -> int: - return self._cdata.offset - - @offset.setter - def offset(self, v: int): - self._cdata.offset = v - - @property - def bytesPerRow(self) -> int: - return self._cdata.bytesPerRow - - @bytesPerRow.setter - def bytesPerRow(self, v: int): - self._cdata.bytesPerRow = v - - @property - def rowsPerImage(self) -> int: - return self._cdata.rowsPerImage - - @rowsPerImage.setter - def rowsPerImage(self, v: int): - self._cdata.rowsPerImage = v - - -def textureDataLayout( - *, - nextInChain: Optional["ChainedStruct"] = None, - offset: int, - bytesPerRow: int, - rowsPerImage: int, -) -> TextureDataLayout: - ret = TextureDataLayout(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.offset = offset - ret.bytesPerRow = bytesPerRow - ret.rowsPerImage = rowsPerImage - return ret - - -class TextureViewDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUTextureViewDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def dimension(self) -> "TextureViewDimension": - return TextureViewDimension(self._cdata.dimension) - - @dimension.setter - def dimension(self, v: "TextureViewDimension"): - self._cdata.dimension = int(v) - - @property - def baseMipLevel(self) -> int: - return self._cdata.baseMipLevel - - @baseMipLevel.setter - def baseMipLevel(self, v: int): - self._cdata.baseMipLevel = v - - @property - def mipLevelCount(self) -> int: - return self._cdata.mipLevelCount - - @mipLevelCount.setter - def mipLevelCount(self, v: int): - self._cdata.mipLevelCount = v - - @property - def baseArrayLayer(self) -> int: - return self._cdata.baseArrayLayer - - @baseArrayLayer.setter - def baseArrayLayer(self, v: int): - self._cdata.baseArrayLayer = v - - @property - def arrayLayerCount(self) -> int: - return self._cdata.arrayLayerCount - - @arrayLayerCount.setter - def arrayLayerCount(self, v: int): - self._cdata.arrayLayerCount = v - - @property - def aspect(self) -> "TextureAspect": - return TextureAspect(self._cdata.aspect) - - @aspect.setter - def aspect(self, v: "TextureAspect"): - self._cdata.aspect = int(v) - - -def textureViewDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - format: "TextureFormat", - dimension: "TextureViewDimension", - baseMipLevel: int = 0, - mipLevelCount: int, - baseArrayLayer: int = 0, - arrayLayerCount: int, - aspect: "TextureAspect" = TextureAspect.All, -) -> TextureViewDescriptor: - ret = TextureViewDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.format = format - ret.dimension = dimension - ret.baseMipLevel = baseMipLevel - ret.mipLevelCount = mipLevelCount - ret.baseArrayLayer = baseArrayLayer - ret.arrayLayerCount = arrayLayerCount - ret.aspect = aspect - return ret - - -class VertexAttribute: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUVertexAttribute *", cdata) - - @property - def format(self) -> "VertexFormat": - return VertexFormat(self._cdata.format) - - @format.setter - def format(self, v: "VertexFormat"): - self._cdata.format = int(v) - - @property - def offset(self) -> int: - return self._cdata.offset - - @offset.setter - def offset(self, v: int): - self._cdata.offset = v - - @property - def shaderLocation(self) -> int: - return self._cdata.shaderLocation - - @shaderLocation.setter - def shaderLocation(self, v: int): - self._cdata.shaderLocation = v - - -def vertexAttribute( - *, format: "VertexFormat", offset: int, shaderLocation: int -) -> VertexAttribute: - ret = VertexAttribute(cdata=None, parent=None) - ret.format = format - ret.offset = offset - ret.shaderLocation = shaderLocation - return ret - - -class BindGroupDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def layout(self) -> "BindGroupLayout": - return BindGroupLayout(self._cdata.layout, add_ref=True) - - @layout.setter - def layout(self, v: "BindGroupLayout"): - self._layout = v - self._cdata.layout = v._cdata - - @property - def entries(self) -> "BindGroupEntryList": - return self._entries - - @entries.setter - def entries(self, v: Union["BindGroupEntryList", list["BindGroupEntry"]]): - if isinstance(v, list): - v2 = BindGroupEntryList(v) - else: - v2 = v - self._entries = v2 - self._cdata.entryCount = v2._count - self._cdata.entries = v2._ptr - - -def bindGroupDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: "BindGroupLayout", - entries: Union["BindGroupEntryList", list["BindGroupEntry"]], -) -> BindGroupDescriptor: - ret = BindGroupDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.layout = layout - ret.entries = entries - return ret - - -class BindGroupLayoutEntry: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupLayoutEntry *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def binding(self) -> int: - return self._cdata.binding - - @binding.setter - def binding(self, v: int): - self._cdata.binding = v - - @property - def visibility(self) -> "ShaderStageFlags": - return ShaderStageFlags(self._cdata.visibility) - - @visibility.setter - def visibility(self, v: Union["ShaderStageFlags", "ShaderStage"]): - self._cdata.visibility = int(v) - - @property - def buffer(self) -> "BufferBindingLayout": - return BufferBindingLayout(cdata=self._cdata.buffer, parent=self) - - @buffer.setter - def buffer(self, v: "BufferBindingLayout"): - self._cdata.buffer = _ffi_deref(v._cdata) - - @property - def sampler(self) -> "SamplerBindingLayout": - return SamplerBindingLayout(cdata=self._cdata.sampler, parent=self) - - @sampler.setter - def sampler(self, v: "SamplerBindingLayout"): - self._cdata.sampler = _ffi_deref(v._cdata) - - @property - def texture(self) -> "TextureBindingLayout": - return TextureBindingLayout(cdata=self._cdata.texture, parent=self) - - @texture.setter - def texture(self, v: "TextureBindingLayout"): - self._cdata.texture = _ffi_deref(v._cdata) - - @property - def storageTexture(self) -> "StorageTextureBindingLayout": - return StorageTextureBindingLayout(cdata=self._cdata.storageTexture, parent=self) - - @storageTexture.setter - def storageTexture(self, v: "StorageTextureBindingLayout"): - self._cdata.storageTexture = _ffi_deref(v._cdata) - - -def bindGroupLayoutEntry( - *, - nextInChain: Optional["ChainedStruct"] = None, - binding: int, - visibility: Union["ShaderStageFlags", "ShaderStage"], - buffer: "BufferBindingLayout", - sampler: "SamplerBindingLayout", - texture: "TextureBindingLayout", - storageTexture: "StorageTextureBindingLayout", -) -> BindGroupLayoutEntry: - ret = BindGroupLayoutEntry(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.binding = binding - ret.visibility = visibility - ret.buffer = buffer - ret.sampler = sampler - ret.texture = texture - ret.storageTexture = storageTexture - return ret - - -class BlendState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBlendState *", cdata) - - @property - def color(self) -> "BlendComponent": - return BlendComponent(cdata=self._cdata.color, parent=self) - - @color.setter - def color(self, v: "BlendComponent"): - self._cdata.color = _ffi_deref(v._cdata) - - @property - def alpha(self) -> "BlendComponent": - return BlendComponent(cdata=self._cdata.alpha, parent=self) - - @alpha.setter - def alpha(self, v: "BlendComponent"): - self._cdata.alpha = _ffi_deref(v._cdata) - - -def blendState(*, color: "BlendComponent", alpha: "BlendComponent") -> BlendState: - ret = BlendState(cdata=None, parent=None) - ret.color = color - ret.alpha = alpha - return ret - - -class CompilationInfo: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUCompilationInfo *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def messages(self) -> "CompilationMessageList": - return self._messages - - @messages.setter - def messages(self, v: Union["CompilationMessageList", list["CompilationMessage"]]): - if isinstance(v, list): - v2 = CompilationMessageList(v) - else: - v2 = v - self._messages = v2 - self._cdata.messageCount = v2._count - self._cdata.messages = v2._ptr - - -def compilationInfo( - *, - nextInChain: Optional["ChainedStruct"] = None, - messages: Union["CompilationMessageList", list["CompilationMessage"]], -) -> CompilationInfo: - ret = CompilationInfo(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.messages = messages - return ret - - -class ComputePassDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUComputePassDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def timestampWrites(self) -> Optional["ComputePassTimestampWrites"]: - return ComputePassTimestampWrites(cdata=self._cdata.timestampWrites, parent=self) - - @timestampWrites.setter - def timestampWrites(self, v: Optional["ComputePassTimestampWrites"]): - self._timestampWrites = v - if v is None: - self._cdata.timestampWrites = ffi.NULL - else: - self._cdata.timestampWrites = v._cdata - - -def computePassDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - timestampWrites: Optional["ComputePassTimestampWrites"] = None, -) -> ComputePassDescriptor: - ret = ComputePassDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.timestampWrites = timestampWrites - return ret - - -class DepthStencilState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUDepthStencilState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def depthWriteEnabled(self) -> bool: - return self._cdata.depthWriteEnabled - - @depthWriteEnabled.setter - def depthWriteEnabled(self, v: bool): - self._cdata.depthWriteEnabled = v - - @property - def depthCompare(self) -> "CompareFunction": - return CompareFunction(self._cdata.depthCompare) - - @depthCompare.setter - def depthCompare(self, v: "CompareFunction"): - self._cdata.depthCompare = int(v) - - @property - def stencilFront(self) -> "StencilFaceState": - return StencilFaceState(cdata=self._cdata.stencilFront, parent=self) - - @stencilFront.setter - def stencilFront(self, v: "StencilFaceState"): - self._cdata.stencilFront = _ffi_deref(v._cdata) - - @property - def stencilBack(self) -> "StencilFaceState": - return StencilFaceState(cdata=self._cdata.stencilBack, parent=self) - - @stencilBack.setter - def stencilBack(self, v: "StencilFaceState"): - self._cdata.stencilBack = _ffi_deref(v._cdata) - - @property - def stencilReadMask(self) -> int: - return self._cdata.stencilReadMask - - @stencilReadMask.setter - def stencilReadMask(self, v: int): - self._cdata.stencilReadMask = v - - @property - def stencilWriteMask(self) -> int: - return self._cdata.stencilWriteMask - - @stencilWriteMask.setter - def stencilWriteMask(self, v: int): - self._cdata.stencilWriteMask = v - - @property - def depthBias(self) -> int: - return self._cdata.depthBias - - @depthBias.setter - def depthBias(self, v: int): - self._cdata.depthBias = v - - @property - def depthBiasSlopeScale(self) -> float: - return self._cdata.depthBiasSlopeScale - - @depthBiasSlopeScale.setter - def depthBiasSlopeScale(self, v: float): - self._cdata.depthBiasSlopeScale = v - - @property - def depthBiasClamp(self) -> float: - return self._cdata.depthBiasClamp - - @depthBiasClamp.setter - def depthBiasClamp(self, v: float): - self._cdata.depthBiasClamp = v - - -def depthStencilState( - *, - nextInChain: Optional["ChainedStruct"] = None, - format: "TextureFormat", - depthWriteEnabled: bool, - depthCompare: "CompareFunction", - stencilFront: "StencilFaceState", - stencilBack: "StencilFaceState", - stencilReadMask: int = 0xFFFFFFFF, - stencilWriteMask: int = 0xFFFFFFFF, - depthBias: int = 0, - depthBiasSlopeScale: float = 0, - depthBiasClamp: float = 0, -) -> DepthStencilState: - ret = DepthStencilState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.format = format - ret.depthWriteEnabled = depthWriteEnabled - ret.depthCompare = depthCompare - ret.stencilFront = stencilFront - ret.stencilBack = stencilBack - ret.stencilReadMask = stencilReadMask - ret.stencilWriteMask = stencilWriteMask - ret.depthBias = depthBias - ret.depthBiasSlopeScale = depthBiasSlopeScale - ret.depthBiasClamp = depthBiasClamp - return ret - - -class ImageCopyBuffer: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUImageCopyBuffer *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def layout(self) -> "TextureDataLayout": - return TextureDataLayout(cdata=self._cdata.layout, parent=self) - - @layout.setter - def layout(self, v: "TextureDataLayout"): - self._cdata.layout = _ffi_deref(v._cdata) - - @property - def buffer(self) -> "Buffer": - return Buffer(self._cdata.buffer, add_ref=True) - - @buffer.setter - def buffer(self, v: "Buffer"): - self._buffer = v - self._cdata.buffer = v._cdata - - -def imageCopyBuffer( - *, - nextInChain: Optional["ChainedStruct"] = None, - layout: "TextureDataLayout", - buffer: "Buffer", -) -> ImageCopyBuffer: - ret = ImageCopyBuffer(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.layout = layout - ret.buffer = buffer - return ret - - -class ImageCopyTexture: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUImageCopyTexture *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def texture(self) -> "Texture": - return Texture(self._cdata.texture, add_ref=True) - - @texture.setter - def texture(self, v: "Texture"): - self._texture = v - self._cdata.texture = v._cdata - - @property - def mipLevel(self) -> int: - return self._cdata.mipLevel - - @mipLevel.setter - def mipLevel(self, v: int): - self._cdata.mipLevel = v - - @property - def origin(self) -> "Origin3D": - return Origin3D(cdata=self._cdata.origin, parent=self) - - @origin.setter - def origin(self, v: "Origin3D"): - self._cdata.origin = _ffi_deref(v._cdata) - - @property - def aspect(self) -> "TextureAspect": - return TextureAspect(self._cdata.aspect) - - @aspect.setter - def aspect(self, v: "TextureAspect"): - self._cdata.aspect = int(v) - - -def imageCopyTexture( - *, - nextInChain: Optional["ChainedStruct"] = None, - texture: "Texture", - mipLevel: int, - origin: "Origin3D", - aspect: "TextureAspect", -) -> ImageCopyTexture: - ret = ImageCopyTexture(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.texture = texture - ret.mipLevel = mipLevel - ret.origin = origin - ret.aspect = aspect - return ret - - -class ProgrammableStageDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUProgrammableStageDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def module(self) -> "ShaderModule": - return ShaderModule(self._cdata.module, add_ref=True) - - @module.setter - def module(self, v: "ShaderModule"): - self._module = v - self._cdata.module = v._cdata - - @property - def entryPoint(self) -> str: - return _ffi_string(self._cdata.entryPoint) - - @entryPoint.setter - def entryPoint(self, v: str): - self._entryPoint = v - self._store_entryPoint = _ffi_unwrap_str(v) - self._cdata.entryPoint = self._store_entryPoint - - @property - def constants(self) -> "ConstantEntryList": - return self._constants - - @constants.setter - def constants(self, v: Union["ConstantEntryList", list["ConstantEntry"]]): - if isinstance(v, list): - v2 = ConstantEntryList(v) - else: - v2 = v - self._constants = v2 - self._cdata.constantCount = v2._count - self._cdata.constants = v2._ptr - - -def programmableStageDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - module: "ShaderModule", - entryPoint: str, - constants: Union["ConstantEntryList", list["ConstantEntry"]], -) -> ProgrammableStageDescriptor: - ret = ProgrammableStageDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.module = module - ret.entryPoint = entryPoint - ret.constants = constants - return ret - - -class RenderPassColorAttachment: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPassColorAttachment *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def view(self) -> Optional["TextureView"]: - return TextureView(self._cdata.view, add_ref=True) - - @view.setter - def view(self, v: Optional["TextureView"]): - self._view = v - if v is None: - self._cdata.view = ffi.NULL - else: - self._cdata.view = v._cdata - - @property - def resolveTarget(self) -> Optional["TextureView"]: - return TextureView(self._cdata.resolveTarget, add_ref=True) - - @resolveTarget.setter - def resolveTarget(self, v: Optional["TextureView"]): - self._resolveTarget = v - if v is None: - self._cdata.resolveTarget = ffi.NULL - else: - self._cdata.resolveTarget = v._cdata - - @property - def loadOp(self) -> "LoadOp": - return LoadOp(self._cdata.loadOp) - - @loadOp.setter - def loadOp(self, v: "LoadOp"): - self._cdata.loadOp = int(v) - - @property - def storeOp(self) -> "StoreOp": - return StoreOp(self._cdata.storeOp) - - @storeOp.setter - def storeOp(self, v: "StoreOp"): - self._cdata.storeOp = int(v) - - @property - def clearValue(self) -> "Color": - return Color(cdata=self._cdata.clearValue, parent=self) - - @clearValue.setter - def clearValue(self, v: "Color"): - self._cdata.clearValue = _ffi_deref(v._cdata) - - -def renderPassColorAttachment( - *, - nextInChain: Optional["ChainedStruct"] = None, - view: Optional["TextureView"] = None, - resolveTarget: Optional["TextureView"] = None, - loadOp: "LoadOp", - storeOp: "StoreOp", - clearValue: "Color", -) -> RenderPassColorAttachment: - ret = RenderPassColorAttachment(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.view = view - ret.resolveTarget = resolveTarget - ret.loadOp = loadOp - ret.storeOp = storeOp - ret.clearValue = clearValue - return ret - - -class RequiredLimits: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURequiredLimits *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def limits(self) -> "Limits": - return Limits(cdata=self._cdata.limits, parent=self) - - @limits.setter - def limits(self, v: "Limits"): - self._cdata.limits = _ffi_deref(v._cdata) - - -def requiredLimits( - *, nextInChain: Optional["ChainedStruct"] = None, limits: "Limits" -) -> RequiredLimits: - ret = RequiredLimits(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.limits = limits - return ret - - -class ShaderModuleDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderModuleDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def hints(self) -> "ShaderModuleCompilationHintList": - return self._hints - - @hints.setter - def hints( - self, - v: Union["ShaderModuleCompilationHintList", list["ShaderModuleCompilationHint"]], - ): - if isinstance(v, list): - v2 = ShaderModuleCompilationHintList(v) - else: - v2 = v - self._hints = v2 - self._cdata.hintCount = v2._count - self._cdata.hints = v2._ptr - - -def shaderModuleDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - hints: Union["ShaderModuleCompilationHintList", list["ShaderModuleCompilationHint"]], -) -> ShaderModuleDescriptor: - ret = ShaderModuleDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.hints = hints - return ret - - -class SupportedLimits: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSupportedLimits *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStructOut"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStructOut"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def limits(self) -> "Limits": - return Limits(cdata=self._cdata.limits, parent=self) - - @limits.setter - def limits(self, v: "Limits"): - self._cdata.limits = _ffi_deref(v._cdata) - - -def supportedLimits( - *, nextInChain: Optional["ChainedStructOut"] = None, limits: "Limits" -) -> SupportedLimits: - ret = SupportedLimits(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.limits = limits - return ret - - -class TextureDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUTextureDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def usage(self) -> "TextureUsageFlags": - return TextureUsageFlags(self._cdata.usage) - - @usage.setter - def usage(self, v: Union["TextureUsageFlags", "TextureUsage"]): - self._cdata.usage = int(v) - - @property - def dimension(self) -> "TextureDimension": - return TextureDimension(self._cdata.dimension) - - @dimension.setter - def dimension(self, v: "TextureDimension"): - self._cdata.dimension = int(v) - - @property - def size(self) -> "Extent3D": - return Extent3D(cdata=self._cdata.size, parent=self) - - @size.setter - def size(self, v: "Extent3D"): - self._cdata.size = _ffi_deref(v._cdata) - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def mipLevelCount(self) -> int: - return self._cdata.mipLevelCount - - @mipLevelCount.setter - def mipLevelCount(self, v: int): - self._cdata.mipLevelCount = v - - @property - def sampleCount(self) -> int: - return self._cdata.sampleCount - - @sampleCount.setter - def sampleCount(self, v: int): - self._cdata.sampleCount = v - - @property - def viewFormats(self) -> "TextureFormatList": - return self._viewFormats - - @viewFormats.setter - def viewFormats(self, v: Union["TextureFormatList", list["TextureFormat"]]): - if isinstance(v, list): - v2 = TextureFormatList(v) - else: - v2 = v - self._viewFormats = v2 - self._cdata.viewFormatCount = v2._count - self._cdata.viewFormats = v2._ptr - - -def textureDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - usage: Union["TextureUsageFlags", "TextureUsage"], - dimension: "TextureDimension" = TextureDimension._2D, - size: "Extent3D", - format: "TextureFormat", - mipLevelCount: int = 1, - sampleCount: int = 1, - viewFormats: Union["TextureFormatList", list["TextureFormat"]], -) -> TextureDescriptor: - ret = TextureDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.usage = usage - ret.dimension = dimension - ret.size = size - ret.format = format - ret.mipLevelCount = mipLevelCount - ret.sampleCount = sampleCount - ret.viewFormats = viewFormats - return ret - - -class VertexBufferLayout: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUVertexBufferLayout *", cdata) - - @property - def arrayStride(self) -> int: - return self._cdata.arrayStride - - @arrayStride.setter - def arrayStride(self, v: int): - self._cdata.arrayStride = v - - @property - def stepMode(self) -> "VertexStepMode": - return VertexStepMode(self._cdata.stepMode) - - @stepMode.setter - def stepMode(self, v: "VertexStepMode"): - self._cdata.stepMode = int(v) - - @property - def attributes(self) -> "VertexAttributeList": - return self._attributes - - @attributes.setter - def attributes(self, v: Union["VertexAttributeList", list["VertexAttribute"]]): - if isinstance(v, list): - v2 = VertexAttributeList(v) - else: - v2 = v - self._attributes = v2 - self._cdata.attributeCount = v2._count - self._cdata.attributes = v2._ptr - - -def vertexBufferLayout( - *, - arrayStride: int, - stepMode: "VertexStepMode" = VertexStepMode.Vertex, - attributes: Union["VertexAttributeList", list["VertexAttribute"]], -) -> VertexBufferLayout: - ret = VertexBufferLayout(cdata=None, parent=None) - ret.arrayStride = arrayStride - ret.stepMode = stepMode - ret.attributes = attributes - return ret - - -class BindGroupLayoutDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupLayoutDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def entries(self) -> "BindGroupLayoutEntryList": - return self._entries - - @entries.setter - def entries(self, v: Union["BindGroupLayoutEntryList", list["BindGroupLayoutEntry"]]): - if isinstance(v, list): - v2 = BindGroupLayoutEntryList(v) - else: - v2 = v - self._entries = v2 - self._cdata.entryCount = v2._count - self._cdata.entries = v2._ptr - - -def bindGroupLayoutDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - entries: Union["BindGroupLayoutEntryList", list["BindGroupLayoutEntry"]], -) -> BindGroupLayoutDescriptor: - ret = BindGroupLayoutDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.entries = entries - return ret - - -class ColorTargetState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUColorTargetState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def format(self) -> "TextureFormat": - return TextureFormat(self._cdata.format) - - @format.setter - def format(self, v: "TextureFormat"): - self._cdata.format = int(v) - - @property - def blend(self) -> Optional["BlendState"]: - return BlendState(cdata=self._cdata.blend, parent=self) - - @blend.setter - def blend(self, v: Optional["BlendState"]): - self._blend = v - if v is None: - self._cdata.blend = ffi.NULL - else: - self._cdata.blend = v._cdata - - @property - def writeMask(self) -> "ColorWriteMaskFlags": - return ColorWriteMaskFlags(self._cdata.writeMask) - - @writeMask.setter - def writeMask(self, v: Union["ColorWriteMaskFlags", "ColorWriteMask"]): - self._cdata.writeMask = int(v) - - -def colorTargetState( - *, - nextInChain: Optional["ChainedStruct"] = None, - format: "TextureFormat", - blend: Optional["BlendState"] = None, - writeMask: Union["ColorWriteMaskFlags", "ColorWriteMask"], -) -> ColorTargetState: - ret = ColorTargetState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.format = format - ret.blend = blend - ret.writeMask = writeMask - return ret - - -class ComputePipelineDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUComputePipelineDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def layout(self) -> Optional["PipelineLayout"]: - return PipelineLayout(self._cdata.layout, add_ref=True) - - @layout.setter - def layout(self, v: Optional["PipelineLayout"]): - self._layout = v - if v is None: - self._cdata.layout = ffi.NULL - else: - self._cdata.layout = v._cdata - - @property - def compute(self) -> "ProgrammableStageDescriptor": - return ProgrammableStageDescriptor(cdata=self._cdata.compute, parent=self) - - @compute.setter - def compute(self, v: "ProgrammableStageDescriptor"): - self._cdata.compute = _ffi_deref(v._cdata) - - -def computePipelineDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: Optional["PipelineLayout"] = None, - compute: "ProgrammableStageDescriptor", -) -> ComputePipelineDescriptor: - ret = ComputePipelineDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.layout = layout - ret.compute = compute - return ret - - -class DeviceDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUDeviceDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def requiredFeatures(self) -> "FeatureNameList": - return self._requiredFeatures - - @requiredFeatures.setter - def requiredFeatures(self, v: Union["FeatureNameList", list["FeatureName"]]): - if isinstance(v, list): - v2 = FeatureNameList(v) - else: - v2 = v - self._requiredFeatures = v2 - self._cdata.requiredFeatureCount = v2._count - self._cdata.requiredFeatures = v2._ptr - - @property - def requiredLimits(self) -> Optional["RequiredLimits"]: - return RequiredLimits(cdata=self._cdata.requiredLimits, parent=self) - - @requiredLimits.setter - def requiredLimits(self, v: Optional["RequiredLimits"]): - self._requiredLimits = v - if v is None: - self._cdata.requiredLimits = ffi.NULL - else: - self._cdata.requiredLimits = v._cdata - - @property - def defaultQueue(self) -> "QueueDescriptor": - return QueueDescriptor(cdata=self._cdata.defaultQueue, parent=self) - - @defaultQueue.setter - def defaultQueue(self, v: "QueueDescriptor"): - self._cdata.defaultQueue = _ffi_deref(v._cdata) - - @property - def deviceLostCallback(self) -> "DeviceLostCallback": - return self._deviceLostCallback - - @deviceLostCallback.setter - def deviceLostCallback(self, v: "DeviceLostCallback"): - self._deviceLostCallback = v - self._cdata.deviceLostCallback = v._ptr - self._cdata.deviceLostUserdata = v._userdata - - -def deviceDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - requiredFeatures: Union["FeatureNameList", list["FeatureName"]], - requiredLimits: Optional["RequiredLimits"] = None, - defaultQueue: "QueueDescriptor", - deviceLostCallback: "DeviceLostCallback", -) -> DeviceDescriptor: - ret = DeviceDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.requiredFeatures = requiredFeatures - ret.requiredLimits = requiredLimits - ret.defaultQueue = defaultQueue - ret.deviceLostCallback = deviceLostCallback - return ret - - -class RenderPassDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPassDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def colorAttachments(self) -> "RenderPassColorAttachmentList": - return self._colorAttachments - - @colorAttachments.setter - def colorAttachments( - self, v: Union["RenderPassColorAttachmentList", list["RenderPassColorAttachment"]] - ): - if isinstance(v, list): - v2 = RenderPassColorAttachmentList(v) - else: - v2 = v - self._colorAttachments = v2 - self._cdata.colorAttachmentCount = v2._count - self._cdata.colorAttachments = v2._ptr - - @property - def depthStencilAttachment(self) -> Optional["RenderPassDepthStencilAttachment"]: - return RenderPassDepthStencilAttachment( - cdata=self._cdata.depthStencilAttachment, parent=self - ) - - @depthStencilAttachment.setter - def depthStencilAttachment(self, v: Optional["RenderPassDepthStencilAttachment"]): - self._depthStencilAttachment = v - if v is None: - self._cdata.depthStencilAttachment = ffi.NULL - else: - self._cdata.depthStencilAttachment = v._cdata - - @property - def occlusionQuerySet(self) -> Optional["QuerySet"]: - return QuerySet(self._cdata.occlusionQuerySet, add_ref=True) - - @occlusionQuerySet.setter - def occlusionQuerySet(self, v: Optional["QuerySet"]): - self._occlusionQuerySet = v - if v is None: - self._cdata.occlusionQuerySet = ffi.NULL - else: - self._cdata.occlusionQuerySet = v._cdata - - @property - def timestampWrites(self) -> Optional["RenderPassTimestampWrites"]: - return RenderPassTimestampWrites(cdata=self._cdata.timestampWrites, parent=self) - - @timestampWrites.setter - def timestampWrites(self, v: Optional["RenderPassTimestampWrites"]): - self._timestampWrites = v - if v is None: - self._cdata.timestampWrites = ffi.NULL - else: - self._cdata.timestampWrites = v._cdata - - -def renderPassDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - colorAttachments: Union[ - "RenderPassColorAttachmentList", list["RenderPassColorAttachment"] - ], - depthStencilAttachment: Optional["RenderPassDepthStencilAttachment"] = None, - occlusionQuerySet: Optional["QuerySet"] = None, - timestampWrites: Optional["RenderPassTimestampWrites"] = None, -) -> RenderPassDescriptor: - ret = RenderPassDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.colorAttachments = colorAttachments - ret.depthStencilAttachment = depthStencilAttachment - ret.occlusionQuerySet = occlusionQuerySet - ret.timestampWrites = timestampWrites - return ret - - -class VertexState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUVertexState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def module(self) -> "ShaderModule": - return ShaderModule(self._cdata.module, add_ref=True) - - @module.setter - def module(self, v: "ShaderModule"): - self._module = v - self._cdata.module = v._cdata - - @property - def entryPoint(self) -> str: - return _ffi_string(self._cdata.entryPoint) - - @entryPoint.setter - def entryPoint(self, v: str): - self._entryPoint = v - self._store_entryPoint = _ffi_unwrap_str(v) - self._cdata.entryPoint = self._store_entryPoint - - @property - def constants(self) -> "ConstantEntryList": - return self._constants - - @constants.setter - def constants(self, v: Union["ConstantEntryList", list["ConstantEntry"]]): - if isinstance(v, list): - v2 = ConstantEntryList(v) - else: - v2 = v - self._constants = v2 - self._cdata.constantCount = v2._count - self._cdata.constants = v2._ptr - - @property - def buffers(self) -> "VertexBufferLayoutList": - return self._buffers - - @buffers.setter - def buffers(self, v: Union["VertexBufferLayoutList", list["VertexBufferLayout"]]): - if isinstance(v, list): - v2 = VertexBufferLayoutList(v) - else: - v2 = v - self._buffers = v2 - self._cdata.bufferCount = v2._count - self._cdata.buffers = v2._ptr - - -def vertexState( - *, - nextInChain: Optional["ChainedStruct"] = None, - module: "ShaderModule", - entryPoint: str, - constants: Union["ConstantEntryList", list["ConstantEntry"]], - buffers: Union["VertexBufferLayoutList", list["VertexBufferLayout"]], -) -> VertexState: - ret = VertexState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.module = module - ret.entryPoint = entryPoint - ret.constants = constants - ret.buffers = buffers - return ret - - -class FragmentState: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUFragmentState *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def module(self) -> "ShaderModule": - return ShaderModule(self._cdata.module, add_ref=True) - - @module.setter - def module(self, v: "ShaderModule"): - self._module = v - self._cdata.module = v._cdata - - @property - def entryPoint(self) -> str: - return _ffi_string(self._cdata.entryPoint) - - @entryPoint.setter - def entryPoint(self, v: str): - self._entryPoint = v - self._store_entryPoint = _ffi_unwrap_str(v) - self._cdata.entryPoint = self._store_entryPoint - - @property - def constants(self) -> "ConstantEntryList": - return self._constants - - @constants.setter - def constants(self, v: Union["ConstantEntryList", list["ConstantEntry"]]): - if isinstance(v, list): - v2 = ConstantEntryList(v) - else: - v2 = v - self._constants = v2 - self._cdata.constantCount = v2._count - self._cdata.constants = v2._ptr - - @property - def targets(self) -> "ColorTargetStateList": - return self._targets - - @targets.setter - def targets(self, v: Union["ColorTargetStateList", list["ColorTargetState"]]): - if isinstance(v, list): - v2 = ColorTargetStateList(v) - else: - v2 = v - self._targets = v2 - self._cdata.targetCount = v2._count - self._cdata.targets = v2._ptr - - -def fragmentState( - *, - nextInChain: Optional["ChainedStruct"] = None, - module: "ShaderModule", - entryPoint: str, - constants: Union["ConstantEntryList", list["ConstantEntry"]], - targets: Union["ColorTargetStateList", list["ColorTargetState"]], -) -> FragmentState: - ret = FragmentState(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.module = module - ret.entryPoint = entryPoint - ret.constants = constants - ret.targets = targets - return ret - - -class RenderPipelineDescriptor: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURenderPipelineDescriptor *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def label(self) -> Optional[str]: - return _ffi_string(self._cdata.label) - - @label.setter - def label(self, v: Optional[str]): - self._label = v - if v is None: - self._cdata.label = ffi.NULL - else: - self._store_label = _ffi_unwrap_str(v) - self._cdata.label = self._store_label - - @property - def layout(self) -> Optional["PipelineLayout"]: - return PipelineLayout(self._cdata.layout, add_ref=True) - - @layout.setter - def layout(self, v: Optional["PipelineLayout"]): - self._layout = v - if v is None: - self._cdata.layout = ffi.NULL - else: - self._cdata.layout = v._cdata - - @property - def vertex(self) -> "VertexState": - return VertexState(cdata=self._cdata.vertex, parent=self) - - @vertex.setter - def vertex(self, v: "VertexState"): - self._cdata.vertex = _ffi_deref(v._cdata) - - @property - def primitive(self) -> "PrimitiveState": - return PrimitiveState(cdata=self._cdata.primitive, parent=self) - - @primitive.setter - def primitive(self, v: "PrimitiveState"): - self._cdata.primitive = _ffi_deref(v._cdata) - - @property - def depthStencil(self) -> Optional["DepthStencilState"]: - return DepthStencilState(cdata=self._cdata.depthStencil, parent=self) - - @depthStencil.setter - def depthStencil(self, v: Optional["DepthStencilState"]): - self._depthStencil = v - if v is None: - self._cdata.depthStencil = ffi.NULL - else: - self._cdata.depthStencil = v._cdata - - @property - def multisample(self) -> "MultisampleState": - return MultisampleState(cdata=self._cdata.multisample, parent=self) - - @multisample.setter - def multisample(self, v: "MultisampleState"): - self._cdata.multisample = _ffi_deref(v._cdata) - - @property - def fragment(self) -> Optional["FragmentState"]: - return FragmentState(cdata=self._cdata.fragment, parent=self) - - @fragment.setter - def fragment(self, v: Optional["FragmentState"]): - self._fragment = v - if v is None: - self._cdata.fragment = ffi.NULL - else: - self._cdata.fragment = v._cdata - - -def renderPipelineDescriptor( - *, - nextInChain: Optional["ChainedStruct"] = None, - label: Optional[str] = None, - layout: Optional["PipelineLayout"] = None, - vertex: "VertexState", - primitive: "PrimitiveState", - depthStencil: Optional["DepthStencilState"] = None, - multisample: "MultisampleState", - fragment: Optional["FragmentState"] = None, -) -> RenderPipelineDescriptor: - ret = RenderPipelineDescriptor(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.label = label - ret.layout = layout - ret.vertex = vertex - ret.primitive = primitive - ret.depthStencil = depthStencil - ret.multisample = multisample - ret.fragment = fragment - return ret - - -class InstanceExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUInstanceExtras *", cdata) - self._cdata.chain.sType = SType.InstanceExtras - - @property - def backends(self) -> "InstanceBackendFlags": - return InstanceBackendFlags(self._cdata.backends) - - @backends.setter - def backends(self, v: Union["InstanceBackendFlags", "InstanceBackend"]): - self._cdata.backends = int(v) - - @property - def flags(self) -> "InstanceFlags": - return InstanceFlags(self._cdata.flags) - - @flags.setter - def flags(self, v: Union["InstanceFlags", "InstanceFlag"]): - self._cdata.flags = int(v) - - @property - def dx12ShaderCompiler(self) -> "Dx12Compiler": - return Dx12Compiler(self._cdata.dx12ShaderCompiler) - - @dx12ShaderCompiler.setter - def dx12ShaderCompiler(self, v: "Dx12Compiler"): - self._cdata.dx12ShaderCompiler = int(v) - - @property - def gles3MinorVersion(self) -> "Gles3MinorVersion": - return Gles3MinorVersion(self._cdata.gles3MinorVersion) - - @gles3MinorVersion.setter - def gles3MinorVersion(self, v: "Gles3MinorVersion"): - self._cdata.gles3MinorVersion = int(v) - - @property - def dxilPath(self) -> str: - return _ffi_string(self._cdata.dxilPath) - - @dxilPath.setter - def dxilPath(self, v: str): - self._dxilPath = v - self._store_dxilPath = _ffi_unwrap_str(v) - self._cdata.dxilPath = self._store_dxilPath - - @property - def dxcPath(self) -> str: - return _ffi_string(self._cdata.dxcPath) - - @dxcPath.setter - def dxcPath(self, v: str): - self._dxcPath = v - self._store_dxcPath = _ffi_unwrap_str(v) - self._cdata.dxcPath = self._store_dxcPath - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def instanceExtras( - *, - backends: Union["InstanceBackendFlags", "InstanceBackend"], - flags: Union["InstanceFlags", "InstanceFlag"], - dx12ShaderCompiler: "Dx12Compiler", - gles3MinorVersion: "Gles3MinorVersion", - dxilPath: str, - dxcPath: str, -) -> InstanceExtras: - ret = InstanceExtras(cdata=None, parent=None) - ret.backends = backends - ret.flags = flags - ret.dx12ShaderCompiler = dx12ShaderCompiler - ret.gles3MinorVersion = gles3MinorVersion - ret.dxilPath = dxilPath - ret.dxcPath = dxcPath - return ret - - -class DeviceExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUDeviceExtras *", cdata) - self._cdata.chain.sType = SType.DeviceExtras - - @property - def tracePath(self) -> str: - return _ffi_string(self._cdata.tracePath) - - @tracePath.setter - def tracePath(self, v: str): - self._tracePath = v - self._store_tracePath = _ffi_unwrap_str(v) - self._cdata.tracePath = self._store_tracePath - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def deviceExtras(*, tracePath: str) -> DeviceExtras: - ret = DeviceExtras(cdata=None, parent=None) - ret.tracePath = tracePath - return ret - - -class NativeLimits: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUNativeLimits *", cdata) - - @property - def maxPushConstantSize(self) -> int: - return self._cdata.maxPushConstantSize - - @maxPushConstantSize.setter - def maxPushConstantSize(self, v: int): - self._cdata.maxPushConstantSize = v - - @property - def maxNonSamplerBindings(self) -> int: - return self._cdata.maxNonSamplerBindings - - @maxNonSamplerBindings.setter - def maxNonSamplerBindings(self, v: int): - self._cdata.maxNonSamplerBindings = v - - -def nativeLimits(*, maxPushConstantSize: int, maxNonSamplerBindings: int) -> NativeLimits: - ret = NativeLimits(cdata=None, parent=None) - ret.maxPushConstantSize = maxPushConstantSize - ret.maxNonSamplerBindings = maxNonSamplerBindings - return ret - - -class RequiredLimitsExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPURequiredLimitsExtras *", cdata) - self._cdata.chain.sType = SType.RequiredLimitsExtras - - @property - def limits(self) -> "NativeLimits": - return NativeLimits(cdata=self._cdata.limits, parent=self) - - @limits.setter - def limits(self, v: "NativeLimits"): - self._cdata.limits = _ffi_deref(v._cdata) - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def requiredLimitsExtras(*, limits: "NativeLimits") -> RequiredLimitsExtras: - ret = RequiredLimitsExtras(cdata=None, parent=None) - ret.limits = limits - return ret - - -class SupportedLimitsExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUSupportedLimitsExtras *", cdata) - self._cdata.chain.sType = SType.SupportedLimitsExtras - - @property - def limits(self) -> "NativeLimits": - return NativeLimits(cdata=self._cdata.limits, parent=self) - - @limits.setter - def limits(self, v: "NativeLimits"): - self._cdata.limits = _ffi_deref(v._cdata) - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def supportedLimitsExtras(*, limits: "NativeLimits") -> SupportedLimitsExtras: - ret = SupportedLimitsExtras(cdata=None, parent=None) - ret.limits = limits - return ret - - -class PushConstantRange: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUPushConstantRange *", cdata) - - @property - def stages(self) -> "ShaderStageFlags": - return ShaderStageFlags(self._cdata.stages) - - @stages.setter - def stages(self, v: Union["ShaderStageFlags", "ShaderStage"]): - self._cdata.stages = int(v) - - @property - def start(self) -> int: - return self._cdata.start - - @start.setter - def start(self, v: int): - self._cdata.start = v - - @property - def end(self) -> int: - return self._cdata.end - - @end.setter - def end(self, v: int): - self._cdata.end = v - - -def pushConstantRange( - *, stages: Union["ShaderStageFlags", "ShaderStage"], start: int, end: int -) -> PushConstantRange: - ret = PushConstantRange(cdata=None, parent=None) - ret.stages = stages - ret.start = start - ret.end = end - return ret - - -class PipelineLayoutExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUPipelineLayoutExtras *", cdata) - self._cdata.chain.sType = SType.PipelineLayoutExtras - - @property - def pushConstantRangeCount(self) -> int: - return self._cdata.pushConstantRangeCount - - @pushConstantRangeCount.setter - def pushConstantRangeCount(self, v: int): - self._cdata.pushConstantRangeCount = v - - @property - def pushConstantRanges(self) -> "PushConstantRange": - return PushConstantRange(cdata=self._cdata.pushConstantRanges, parent=self) - - @pushConstantRanges.setter - def pushConstantRanges(self, v: "PushConstantRange"): - self._pushConstantRanges = v - self._cdata.pushConstantRanges = v._cdata - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def pipelineLayoutExtras( - *, pushConstantRangeCount: int, pushConstantRanges: "PushConstantRange" -) -> PipelineLayoutExtras: - ret = PipelineLayoutExtras(cdata=None, parent=None) - ret.pushConstantRangeCount = pushConstantRangeCount - ret.pushConstantRanges = pushConstantRanges - return ret - - -class WrappedSubmissionIndex: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUWrappedSubmissionIndex *", cdata) - - @property - def queue(self) -> "Queue": - return Queue(self._cdata.queue, add_ref=True) - - @queue.setter - def queue(self, v: "Queue"): - self._queue = v - self._cdata.queue = v._cdata - - @property - def submissionIndex(self) -> int: - return self._cdata.submissionIndex - - @submissionIndex.setter - def submissionIndex(self, v: int): - self._cdata.submissionIndex = v - - -def wrappedSubmissionIndex( - *, queue: "Queue", submissionIndex: int -) -> WrappedSubmissionIndex: - ret = WrappedSubmissionIndex(cdata=None, parent=None) - ret.queue = queue - ret.submissionIndex = submissionIndex - return ret - - -class ShaderDefine: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderDefine *", cdata) - - @property - def name(self) -> str: - return _ffi_string(self._cdata.name) - - @name.setter - def name(self, v: str): - self._name = v - self._store_name = _ffi_unwrap_str(v) - self._cdata.name = self._store_name - - @property - def value(self) -> str: - return _ffi_string(self._cdata.value) - - @value.setter - def value(self, v: str): - self._value = v - self._store_value = _ffi_unwrap_str(v) - self._cdata.value = self._store_value - - -def shaderDefine(*, name: str, value: str) -> ShaderDefine: - ret = ShaderDefine(cdata=None, parent=None) - ret.name = name - ret.value = value - return ret - - -class ShaderModuleGLSLDescriptor(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUShaderModuleGLSLDescriptor *", cdata) - self._cdata.chain.sType = SType.ShaderModuleGLSLDescriptor - - @property - def stage(self) -> "ShaderStage": - return ShaderStage(self._cdata.stage) - - @stage.setter - def stage(self, v: "ShaderStage"): - self._cdata.stage = int(v) - - @property - def code(self) -> str: - return _ffi_string(self._cdata.code) - - @code.setter - def code(self, v: str): - self._code = v - self._store_code = _ffi_unwrap_str(v) - self._cdata.code = self._store_code - - @property - def defineCount(self) -> int: - return self._cdata.defineCount - - @defineCount.setter - def defineCount(self, v: int): - self._cdata.defineCount = v - - @property - def defines(self) -> "ShaderDefine": - return ShaderDefine(cdata=self._cdata.defines, parent=self) - - @defines.setter - def defines(self, v: "ShaderDefine"): - self._defines = v - self._cdata.defines = v._cdata - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def shaderModuleGLSLDescriptor( - *, stage: "ShaderStage", code: str, defineCount: int, defines: "ShaderDefine" -) -> ShaderModuleGLSLDescriptor: - ret = ShaderModuleGLSLDescriptor(cdata=None, parent=None) - ret.stage = stage - ret.code = code - ret.defineCount = defineCount - ret.defines = defines - return ret - - -class StorageReport: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUStorageReport *", cdata) - - @property - def numOccupied(self) -> int: - return self._cdata.numOccupied - - @numOccupied.setter - def numOccupied(self, v: int): - self._cdata.numOccupied = v - - @property - def numVacant(self) -> int: - return self._cdata.numVacant - - @numVacant.setter - def numVacant(self, v: int): - self._cdata.numVacant = v - - @property - def numError(self) -> int: - return self._cdata.numError - - @numError.setter - def numError(self, v: int): - self._cdata.numError = v - - @property - def elementSize(self) -> int: - return self._cdata.elementSize - - @elementSize.setter - def elementSize(self, v: int): - self._cdata.elementSize = v - - -def storageReport( - *, numOccupied: int, numVacant: int, numError: int, elementSize: int -) -> StorageReport: - ret = StorageReport(cdata=None, parent=None) - ret.numOccupied = numOccupied - ret.numVacant = numVacant - ret.numError = numError - ret.elementSize = elementSize - return ret - - -class HubReport: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUHubReport *", cdata) - - @property - def adapters(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.adapters, parent=self) - - @adapters.setter - def adapters(self, v: "StorageReport"): - self._cdata.adapters = _ffi_deref(v._cdata) - - @property - def devices(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.devices, parent=self) - - @devices.setter - def devices(self, v: "StorageReport"): - self._cdata.devices = _ffi_deref(v._cdata) - - @property - def pipelineLayouts(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.pipelineLayouts, parent=self) - - @pipelineLayouts.setter - def pipelineLayouts(self, v: "StorageReport"): - self._cdata.pipelineLayouts = _ffi_deref(v._cdata) - - @property - def shaderModules(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.shaderModules, parent=self) - - @shaderModules.setter - def shaderModules(self, v: "StorageReport"): - self._cdata.shaderModules = _ffi_deref(v._cdata) - - @property - def bindGroupLayouts(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.bindGroupLayouts, parent=self) - - @bindGroupLayouts.setter - def bindGroupLayouts(self, v: "StorageReport"): - self._cdata.bindGroupLayouts = _ffi_deref(v._cdata) - - @property - def bindGroups(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.bindGroups, parent=self) - - @bindGroups.setter - def bindGroups(self, v: "StorageReport"): - self._cdata.bindGroups = _ffi_deref(v._cdata) - - @property - def commandBuffers(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.commandBuffers, parent=self) - - @commandBuffers.setter - def commandBuffers(self, v: "StorageReport"): - self._cdata.commandBuffers = _ffi_deref(v._cdata) - - @property - def renderBundles(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.renderBundles, parent=self) - - @renderBundles.setter - def renderBundles(self, v: "StorageReport"): - self._cdata.renderBundles = _ffi_deref(v._cdata) - - @property - def renderPipelines(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.renderPipelines, parent=self) - - @renderPipelines.setter - def renderPipelines(self, v: "StorageReport"): - self._cdata.renderPipelines = _ffi_deref(v._cdata) - - @property - def computePipelines(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.computePipelines, parent=self) - - @computePipelines.setter - def computePipelines(self, v: "StorageReport"): - self._cdata.computePipelines = _ffi_deref(v._cdata) - - @property - def querySets(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.querySets, parent=self) - - @querySets.setter - def querySets(self, v: "StorageReport"): - self._cdata.querySets = _ffi_deref(v._cdata) - - @property - def buffers(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.buffers, parent=self) - - @buffers.setter - def buffers(self, v: "StorageReport"): - self._cdata.buffers = _ffi_deref(v._cdata) - - @property - def textures(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.textures, parent=self) - - @textures.setter - def textures(self, v: "StorageReport"): - self._cdata.textures = _ffi_deref(v._cdata) - - @property - def textureViews(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.textureViews, parent=self) - - @textureViews.setter - def textureViews(self, v: "StorageReport"): - self._cdata.textureViews = _ffi_deref(v._cdata) - - @property - def samplers(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.samplers, parent=self) - - @samplers.setter - def samplers(self, v: "StorageReport"): - self._cdata.samplers = _ffi_deref(v._cdata) - - -def hubReport( - *, - adapters: "StorageReport", - devices: "StorageReport", - pipelineLayouts: "StorageReport", - shaderModules: "StorageReport", - bindGroupLayouts: "StorageReport", - bindGroups: "StorageReport", - commandBuffers: "StorageReport", - renderBundles: "StorageReport", - renderPipelines: "StorageReport", - computePipelines: "StorageReport", - querySets: "StorageReport", - buffers: "StorageReport", - textures: "StorageReport", - textureViews: "StorageReport", - samplers: "StorageReport", -) -> HubReport: - ret = HubReport(cdata=None, parent=None) - ret.adapters = adapters - ret.devices = devices - ret.pipelineLayouts = pipelineLayouts - ret.shaderModules = shaderModules - ret.bindGroupLayouts = bindGroupLayouts - ret.bindGroups = bindGroups - ret.commandBuffers = commandBuffers - ret.renderBundles = renderBundles - ret.renderPipelines = renderPipelines - ret.computePipelines = computePipelines - ret.querySets = querySets - ret.buffers = buffers - ret.textures = textures - ret.textureViews = textureViews - ret.samplers = samplers - return ret - - -class GlobalReport: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUGlobalReport *", cdata) - - @property - def surfaces(self) -> "StorageReport": - return StorageReport(cdata=self._cdata.surfaces, parent=self) - - @surfaces.setter - def surfaces(self, v: "StorageReport"): - self._cdata.surfaces = _ffi_deref(v._cdata) - - @property - def backendType(self) -> "BackendType": - return BackendType(self._cdata.backendType) - - @backendType.setter - def backendType(self, v: "BackendType"): - self._cdata.backendType = int(v) - - @property - def vulkan(self) -> "HubReport": - return HubReport(cdata=self._cdata.vulkan, parent=self) - - @vulkan.setter - def vulkan(self, v: "HubReport"): - self._cdata.vulkan = _ffi_deref(v._cdata) - - @property - def metal(self) -> "HubReport": - return HubReport(cdata=self._cdata.metal, parent=self) - - @metal.setter - def metal(self, v: "HubReport"): - self._cdata.metal = _ffi_deref(v._cdata) - - @property - def dx12(self) -> "HubReport": - return HubReport(cdata=self._cdata.dx12, parent=self) - - @dx12.setter - def dx12(self, v: "HubReport"): - self._cdata.dx12 = _ffi_deref(v._cdata) - - @property - def dx11(self) -> "HubReport": - return HubReport(cdata=self._cdata.dx11, parent=self) - - @dx11.setter - def dx11(self, v: "HubReport"): - self._cdata.dx11 = _ffi_deref(v._cdata) - - @property - def gl(self) -> "HubReport": - return HubReport(cdata=self._cdata.gl, parent=self) - - @gl.setter - def gl(self, v: "HubReport"): - self._cdata.gl = _ffi_deref(v._cdata) - - -def globalReport( - *, - surfaces: "StorageReport", - backendType: "BackendType", - vulkan: "HubReport", - metal: "HubReport", - dx12: "HubReport", - dx11: "HubReport", - gl: "HubReport", -) -> GlobalReport: - ret = GlobalReport(cdata=None, parent=None) - ret.surfaces = surfaces - ret.backendType = backendType - ret.vulkan = vulkan - ret.metal = metal - ret.dx12 = dx12 - ret.dx11 = dx11 - ret.gl = gl - return ret - - -class InstanceEnumerateAdapterOptions: - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUInstanceEnumerateAdapterOptions *", cdata) - - @property - def nextInChain(self) -> Optional["ChainedStruct"]: - return self._nextInChain - - @nextInChain.setter - def nextInChain(self, v: Optional["ChainedStruct"]): - self._nextInChain = v - if v is None: - self._cdata.nextInChain = ffi.NULL - else: - self._cdata.nextInChain = v._cdata - - @property - def backends(self) -> "InstanceBackendFlags": - return InstanceBackendFlags(self._cdata.backends) - - @backends.setter - def backends(self, v: Union["InstanceBackendFlags", "InstanceBackend"]): - self._cdata.backends = int(v) - - -def instanceEnumerateAdapterOptions( - *, - nextInChain: Optional["ChainedStruct"] = None, - backends: Union["InstanceBackendFlags", "InstanceBackend"], -) -> InstanceEnumerateAdapterOptions: - ret = InstanceEnumerateAdapterOptions(cdata=None, parent=None) - ret.nextInChain = nextInChain - ret.backends = backends - return ret - - -class BindGroupEntryExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupEntryExtras *", cdata) - self._cdata.chain.sType = SType.BindGroupEntryExtras - - @property - def buffers(self) -> "Buffer": - return Buffer(self._cdata.buffers, add_ref=True) - - @buffers.setter - def buffers(self, v: "Buffer"): - self._buffers = v - self._cdata.buffers = v._cdata - - @property - def samplers(self) -> "SamplerList": - return self._samplers - - @samplers.setter - def samplers(self, v: Union["SamplerList", list["Sampler"]]): - if isinstance(v, list): - v2 = SamplerList(v) - else: - v2 = v - self._samplers = v2 - self._cdata.bufferCount = v2._count - self._cdata.samplers = v2._ptr - - @property - def textureViews(self) -> "TextureViewList": - return self._textureViews - - @textureViews.setter - def textureViews(self, v: Union["TextureViewList", list["TextureView"]]): - if isinstance(v, list): - v2 = TextureViewList(v) - else: - v2 = v - self._textureViews = v2 - self._cdata.samplerCount = v2._count - self._cdata.textureViews = v2._ptr - - @property - def textureViewCount(self) -> int: - return self._cdata.textureViewCount - - @textureViewCount.setter - def textureViewCount(self, v: int): - self._cdata.textureViewCount = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def bindGroupEntryExtras( - *, - buffers: "Buffer", - samplers: Union["SamplerList", list["Sampler"]], - textureViews: Union["TextureViewList", list["TextureView"]], - textureViewCount: int, -) -> BindGroupEntryExtras: - ret = BindGroupEntryExtras(cdata=None, parent=None) - ret.buffers = buffers - ret.samplers = samplers - ret.textureViews = textureViews - ret.textureViewCount = textureViewCount - return ret - - -class BindGroupLayoutEntryExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUBindGroupLayoutEntryExtras *", cdata) - self._cdata.chain.sType = SType.BindGroupLayoutEntryExtras - - @property - def count(self) -> int: - return self._cdata.count - - @count.setter - def count(self, v: int): - self._cdata.count = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def bindGroupLayoutEntryExtras(*, count: int) -> BindGroupLayoutEntryExtras: - ret = BindGroupLayoutEntryExtras(cdata=None, parent=None) - ret.count = count - return ret - - -class QuerySetDescriptorExtras(Chainable): - def __init__(self, *, cdata: Optional[CData] = None, parent: Optional[Any] = None): - self._parent = parent - self._cdata = _ffi_init("WGPUQuerySetDescriptorExtras *", cdata) - self._cdata.chain.sType = SType.QuerySetDescriptorExtras - - @property - def pipelineStatistics(self) -> "PipelineStatisticName": - return self._pipelineStatistics - - @pipelineStatistics.setter - def pipelineStatistics(self, v: "PipelineStatisticName"): - self._pipelineStatistics = v - self._cdata.pipelineStatistics = int(v) - - @property - def pipelineStatisticCount(self) -> int: - return self._cdata.pipelineStatisticCount - - @pipelineStatisticCount.setter - def pipelineStatisticCount(self, v: int): - self._cdata.pipelineStatisticCount = v - - @property - def _chain(self) -> Any: - return self._cdata.chain - - -def querySetDescriptorExtras( - *, pipelineStatistics: "PipelineStatisticName", pipelineStatisticCount: int -) -> QuerySetDescriptorExtras: - ret = QuerySetDescriptorExtras(cdata=None, parent=None) - ret.pipelineStatistics = pipelineStatistics - ret.pipelineStatisticCount = pipelineStatisticCount - return ret - - -# Loose functions -def createInstanceFromDesc(descriptor: Optional["InstanceDescriptor"]) -> "Instance": - return Instance( - lib.wgpuCreateInstance(_ffi_unwrap_optional(descriptor)), add_ref=False - ) - - -def createInstance(*, nextInChain: Optional["ChainedStruct"] = None) -> "Instance": - return createInstanceFromDesc(instanceDescriptor(nextInChain=nextInChain)) - - -def surfaceCapabilitiesFreeMembers(capabilities: "SurfaceCapabilities") -> None: - return lib.wgpuSurfaceCapabilitiesFreeMembers(_ffi_deref(capabilities._cdata)) - - -def setLogCallback(callback: "LogCallback") -> None: - return lib.wgpuSetLogCallback(callback._ptr, callback._userdata) - - -def setLogLevel(level: "LogLevel") -> None: - return lib.wgpuSetLogLevel(int(level)) - - -def getVersion() -> int: - return lib.wgpuGetVersion() - - -# Util wrapper types - -_callback_map_BufferMapCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_BufferMapCallback(status, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_BufferMapCallback.get(idx) - if cb is not None: - cb(BufferMapAsyncStatus(status)) - - -class BufferMapCallback: - def __init__(self, callback: Callable[["BufferMapAsyncStatus"], None]): - self.index = _callback_map_BufferMapCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_BufferMapCallback - - def remove(self): - _callback_map_BufferMapCallback.remove(self.index) - - -_callback_map_CompilationInfoCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_CompilationInfoCallback(status, compilationInfo, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_CompilationInfoCallback.get(idx) - if cb is not None: - cb( - CompilationInfoRequestStatus(status), - CompilationInfo(cdata=compilationInfo, parent=None), - ) - - -class CompilationInfoCallback: - def __init__( - self, - callback: Callable[["CompilationInfoRequestStatus", "CompilationInfo"], None], - ): - self.index = _callback_map_CompilationInfoCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_CompilationInfoCallback - - def remove(self): - _callback_map_CompilationInfoCallback.remove(self.index) - - -_callback_map_CreateComputePipelineAsyncCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_CreateComputePipelineAsyncCallback(status, pipeline, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_CreateComputePipelineAsyncCallback.get(idx) - if cb is not None: - cb( - CreatePipelineAsyncStatus(status), - ComputePipeline(pipeline, add_ref=False), - _ffi_string(message), - ) - - -class CreateComputePipelineAsyncCallback: - def __init__( - self, - callback: Callable[["CreatePipelineAsyncStatus", "ComputePipeline", str], None], - ): - self.index = _callback_map_CreateComputePipelineAsyncCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_CreateComputePipelineAsyncCallback - - def remove(self): - _callback_map_CreateComputePipelineAsyncCallback.remove(self.index) - - -_callback_map_CreateRenderPipelineAsyncCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_CreateRenderPipelineAsyncCallback(status, pipeline, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_CreateRenderPipelineAsyncCallback.get(idx) - if cb is not None: - cb( - CreatePipelineAsyncStatus(status), - RenderPipeline(pipeline, add_ref=False), - _ffi_string(message), - ) - - -class CreateRenderPipelineAsyncCallback: - def __init__( - self, - callback: Callable[["CreatePipelineAsyncStatus", "RenderPipeline", str], None], - ): - self.index = _callback_map_CreateRenderPipelineAsyncCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_CreateRenderPipelineAsyncCallback - - def remove(self): - _callback_map_CreateRenderPipelineAsyncCallback.remove(self.index) - - -_callback_map_DeviceLostCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_DeviceLostCallback(reason, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_DeviceLostCallback.get(idx) - if cb is not None: - cb(DeviceLostReason(reason), _ffi_string(message)) - - -class DeviceLostCallback: - def __init__(self, callback: Callable[["DeviceLostReason", str], None]): - self.index = _callback_map_DeviceLostCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_DeviceLostCallback - - def remove(self): - _callback_map_DeviceLostCallback.remove(self.index) - - -_callback_map_ErrorCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_ErrorCallback(type, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_ErrorCallback.get(idx) - if cb is not None: - cb(ErrorType(type), _ffi_string(message)) - - -class ErrorCallback: - def __init__(self, callback: Callable[["ErrorType", str], None]): - self.index = _callback_map_ErrorCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_ErrorCallback - - def remove(self): - _callback_map_ErrorCallback.remove(self.index) - - -_callback_map_QueueWorkDoneCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_QueueWorkDoneCallback(status, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_QueueWorkDoneCallback.get(idx) - if cb is not None: - cb(QueueWorkDoneStatus(status)) - - -class QueueWorkDoneCallback: - def __init__(self, callback: Callable[["QueueWorkDoneStatus"], None]): - self.index = _callback_map_QueueWorkDoneCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_QueueWorkDoneCallback - - def remove(self): - _callback_map_QueueWorkDoneCallback.remove(self.index) - - -_callback_map_RequestAdapterCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_RequestAdapterCallback(status, adapter, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_RequestAdapterCallback.get(idx) - if cb is not None: - cb( - RequestAdapterStatus(status), - Adapter(adapter, add_ref=False), - _ffi_string(message), - ) - - -class RequestAdapterCallback: - def __init__( - self, callback: Callable[["RequestAdapterStatus", "Adapter", str], None] - ): - self.index = _callback_map_RequestAdapterCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_RequestAdapterCallback - - def remove(self): - _callback_map_RequestAdapterCallback.remove(self.index) - - -_callback_map_RequestDeviceCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_RequestDeviceCallback(status, device, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_RequestDeviceCallback.get(idx) - if cb is not None: - cb( - RequestDeviceStatus(status), - Device(device, add_ref=False), - _ffi_string(message), - ) - - -class RequestDeviceCallback: - def __init__(self, callback: Callable[["RequestDeviceStatus", "Device", str], None]): - self.index = _callback_map_RequestDeviceCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_RequestDeviceCallback - - def remove(self): - _callback_map_RequestDeviceCallback.remove(self.index) - - -_callback_map_ProcDeviceSetUncapturedErrorCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_ProcDeviceSetUncapturedErrorCallback(device, callback, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_ProcDeviceSetUncapturedErrorCallback.get(idx) - if cb is not None: - cb(Device(device, add_ref=False), callback) - - -class ProcDeviceSetUncapturedErrorCallback: - def __init__(self, callback: Callable[["Device", "ErrorCallback"], None]): - self.index = _callback_map_ProcDeviceSetUncapturedErrorCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_ProcDeviceSetUncapturedErrorCallback - - def remove(self): - _callback_map_ProcDeviceSetUncapturedErrorCallback.remove(self.index) - - -_callback_map_LogCallback = CBMap() - - -@ffi.def_extern() -def _raw_callback_LogCallback(level, message, userdata): - idx = _cast_userdata(userdata) - cb = _callback_map_LogCallback.get(idx) - if cb is not None: - cb(LogLevel(level), _ffi_string(message)) - - -class LogCallback: - def __init__(self, callback: Callable[["LogLevel", str], None]): - self.index = _callback_map_LogCallback.add(callback) - self._userdata = _ffi_new("int[]", 1) - self._userdata[0] = self.index - self._ptr = lib._raw_callback_LogCallback - - def remove(self): - _callback_map_LogCallback.remove(self.index) - - -class BindGroupLayoutList: - def __init__(self, items: list["BindGroupLayout"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUBindGroupLayout[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item._cdata - - -class TextureFormatList: - def __init__(self, items: list["TextureFormat"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUTextureFormat[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = int(item) - - -class PresentModeList: - def __init__(self, items: list["PresentMode"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUPresentMode[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = int(item) - - -class CompositeAlphaModeList: - def __init__(self, items: list["CompositeAlphaMode"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUCompositeAlphaMode[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = int(item) - - -class BindGroupEntryList: - def __init__(self, items: list["BindGroupEntry"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUBindGroupEntry[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class CompilationMessageList: - def __init__(self, items: list["CompilationMessage"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUCompilationMessage[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class ConstantEntryList: - def __init__(self, items: list["ConstantEntry"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUConstantEntry[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class ShaderModuleCompilationHintList: - def __init__(self, items: list["ShaderModuleCompilationHint"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUShaderModuleCompilationHint[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class VertexAttributeList: - def __init__(self, items: list["VertexAttribute"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUVertexAttribute[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class BindGroupLayoutEntryList: - def __init__(self, items: list["BindGroupLayoutEntry"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUBindGroupLayoutEntry[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class FeatureNameList: - def __init__(self, items: list["FeatureName"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUFeatureName[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = int(item) - - -class RenderPassColorAttachmentList: - def __init__(self, items: list["RenderPassColorAttachment"]): - self._count = len(items) - self._ptr = _ffi_new("WGPURenderPassColorAttachment[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class VertexBufferLayoutList: - def __init__(self, items: list["VertexBufferLayout"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUVertexBufferLayout[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class ColorTargetStateList: - def __init__(self, items: list["ColorTargetState"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUColorTargetState[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = _ffi_deref(item._cdata) - - -class SamplerList: - def __init__(self, items: list["Sampler"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUSampler[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item._cdata - - -class TextureViewList: - def __init__(self, items: list["TextureView"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUTextureView[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item._cdata - - -class IntList: - def __init__(self, items: list[int]): - self._count = len(items) - self._ptr = _ffi_new("uint32_t[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item - - -class CommandBufferList: - def __init__(self, items: list["CommandBuffer"]): - self._count = len(items) - self._ptr = _ffi_new("WGPUCommandBuffer[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item._cdata - - -class RenderBundleList: - def __init__(self, items: list["RenderBundle"]): - self._count = len(items) - self._ptr = _ffi_new("WGPURenderBundle[]", self._count) - for idx, item in enumerate(items): - self._ptr[idx] = item._cdata