From 70a82981a266b6b731d4f98cab17f5c9c6b813cf Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 14 Oct 2026 11:55:02 +0200 Subject: [PATCH 01/10] WIP new way to generate the code/api --- apigen/README.md | 131 + apigen/__init__.py | 4 + apigen/__main__.py | 40 + apigen/apigen_utils.py | 310 ++ apigen/definitions/diff_backend_pyodide.toml | 4 + apigen/definitions/diff_backend_wgpu.toml | 5 + apigen/definitions/diff_base.toml | 15 + apigen/definitions/docs_ai.toml | 2277 ++++++++++++ apigen/definitions/docs_dev.toml | 3 + apigen/definitions/docs_ts.toml | 1400 +++++++ apigen/definitions/index.d.ts | 3420 ++++++++++++++++++ apigen/definitions/webgpu.idl | 1383 +++++++ apigen/definitions/wgpu_api.toml | 1190 ++++++ apigen/definitions/wgpu_api_web.toml | 1217 +++++++ apigen/definitions/wgpu_docs.toml | 2413 ++++++++++++ apigen/download.py | 40 + apigen/parse_idl.py | 609 ++++ apigen/parse_ts.py | 332 ++ apigen/tests/test_structures.py | 14 + apigen/unite.py | 158 + apigen/write_flags_enums_structs.py | 83 + 21 files changed, 15048 insertions(+) create mode 100644 apigen/README.md create mode 100644 apigen/__init__.py create mode 100644 apigen/__main__.py create mode 100644 apigen/apigen_utils.py create mode 100644 apigen/definitions/diff_backend_pyodide.toml create mode 100644 apigen/definitions/diff_backend_wgpu.toml create mode 100644 apigen/definitions/diff_base.toml create mode 100644 apigen/definitions/docs_ai.toml create mode 100644 apigen/definitions/docs_dev.toml create mode 100644 apigen/definitions/docs_ts.toml create mode 100644 apigen/definitions/index.d.ts create mode 100644 apigen/definitions/webgpu.idl create mode 100644 apigen/definitions/wgpu_api.toml create mode 100644 apigen/definitions/wgpu_api_web.toml create mode 100644 apigen/definitions/wgpu_docs.toml create mode 100644 apigen/download.py create mode 100644 apigen/parse_idl.py create mode 100644 apigen/parse_ts.py create mode 100644 apigen/tests/test_structures.py create mode 100644 apigen/unite.py create mode 100644 apigen/write_flags_enums_structs.py diff --git a/apigen/README.md b/apigen/README.md new file mode 100644 index 00000000..cbf2f8e5 --- /dev/null +++ b/apigen/README.md @@ -0,0 +1,131 @@ +## The API format structure + +The API is stored in a "json-able" data structure that can be easily loaded and manipulated. +This allows generating an API definition that is precise and sort of human readable, plus +we can easily combine multiple structures, e.g. diff definitions, backend-specific additions, +and docs from multiple sources. + +The structure has some two dozen leaf nodes: +``` +flags.SomeFlag.doc : str +flags.SomeFlag.fields.SOME_FIELD.doc : str +flags.SomeFlag.fields.SOME_FIELD.value : int + +enums.SomeEnum.doc : str +enums.SomeEnum.fields.some_field.doc : str +enums.SomeEnum.fields.some_field.value : str + +structs.SomeStruct.doc : str +structs.SomeStruct.fields.some_field.doc : str +structs.SomeStruct.fields.some_field.type : str +structs.SomeStruct.fields.some_field.default : str +structs.SomeStruct.fields.some_field.required : bool + +classes.GPUSomeClass.doc : str +classes.GPUSomeClass.bases : list[str] + +classes.GPUSomeClass.properties.some_prop.doc : str +classes.GPUSomeClass.properties.some_prop.type : str + +classes.GPUSomeClass.methods.some_method.doc : str +classes.GPUSomeClass.methods.some_method.returns.doc : str +classes.GPUSomeClass.methods.some_method.returns.type : str +classes.GPUSomeClass.methods.some_method.args.some_arg.doc : str +classes.GPUSomeClass.methods.some_method.args.some_arg.type : str +classes.GPUSomeClass.methods.some_method.args.some_arg.default : str +classes.GPUSomeClass.methods.some_method.args.some_arg.required : bool +``` + +As a structure, this looks a bit look this: + +``` +flags = { + + SomeFlag: { + doc = "" + fields = { + SOME_FIELD = { + doc = "" + value = 1 + } + ... + } + } + ... +} + + +enums = { + + SomeEnum: { + doc = "" + fields = { + some_field = { + doc = "" + value = "some-field" + } + ... + } + } + ... +} + + +structs = { + + SomeStruct: { + doc = "" + fields = { + some_field = { + doc = "" + type = "int" + default = "0" + required = False + } + ... + } + } + ... +} + + +classes = { + + GPUSomeClass = { + doc = "" + bases = ["GPUObject"] + properties = { + some_prop = { + doc = "" + type = "int" + } + ... + } + methods = { + some_method = { + doc = "" + returns = { + doc = "" + type = "None" + } + args = { + some_arg { + doc = "" + type = "" + default = "" + required = True + } + ... + } + } + ... + } + + } + ... +} + +``` + +We could have used JSON to store these data formats, but we use TOML +because it makes it more readable and the use of sections allows for more concise definitions. diff --git a/apigen/__init__.py b/apigen/__init__.py new file mode 100644 index 00000000..c88ad595 --- /dev/null +++ b/apigen/__init__.py @@ -0,0 +1,4 @@ +""" Code to generate the wgpu-py API. +""" +from .download import download_idl +from .parse_idl import parse_idl_to_toml diff --git a/apigen/__main__.py b/apigen/__main__.py new file mode 100644 index 00000000..6b76b0a1 --- /dev/null +++ b/apigen/__main__.py @@ -0,0 +1,40 @@ +""" +The entrypoint / script to apply automatic patches to the code. +See README.md for more information. +""" + +import os +import sys +from argparse import ArgumentParser + + +parser = ArgumentParser(description="Run code generation and patching.") + +parser.add_argument( + "--download-idl", + action="store_true", + dest="download_idl", + help="Download the latest webgpu.idl", +) + + +# Little trick to allow running this file as a script +sys.path.insert(0, os.path.abspath(os.path.join(__file__, "..", ".."))) + + +from apigen import download_idl + + +if __name__ == "__main__": + args = parser.parse_args() + if args.download_idl: + print("Hey") + download_idl() + elif False: + pass + # main(do_api=args.api, do_wgpu_native=args.wgpu_native, do_js=args.js) + # main() + # file_cache.write_changed_files_to_disk() + else: + parser.print_help() + sys.exit(0) diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py new file mode 100644 index 00000000..9322faf4 --- /dev/null +++ b/apigen/apigen_utils.py @@ -0,0 +1,310 @@ +import sys +import tomllib +import subprocess +from pathlib import Path + + +DEFINITIONS_DIR = Path(__file__).parent.absolute() / "definitions" +ROOT_DIR = Path(__file__).parents[1].absolute() + + +def read_file(*fname): + """Read a file from disk using the relative filename. Line endings are normalized.""" + filename = ROOT_DIR.joinpath(*fname) + with open(filename, "rb") as f: + return ( + f.read() + .decode() + .replace("\r\n", "\n") + .replace("\r", "\n") + .replace("\\\n", "") # Macros escaping a newline + ) + + +def write_file(text:str, *fname): + """Write the given text to disk, using the relative filename. Line endings are matched to what's used for __init__.py.""" + filename = ROOT_DIR.joinpath(*fname) + if not text.endswith("\n"): + text = text + "\n" + with open(filename, "wb") as f: + f.write(text.replace("\n", LE).encode()) + + +def _get_line_endings(text): + """Detect whether the line endings in use is CR LF or CRLF.""" + # Count how many line ending chars there are + crlf_count = text.count("\r\n") + lf_count = text.count("\n") - crlf_count + cr_count = text.count("\r") - crlf_count + assert lf_count + cr_count + crlf_count >= 4 + # Check what's used the most, or whether it's a combination. + if lf_count > cr_count and lf_count > crlf_count: + return "\n" + elif cr_count > lf_count and cr_count > crlf_count: + return "\r" + else: + return "\r\n" + +LE = _get_line_endings((ROOT_DIR / 'apigen' / "__init__.py").read_bytes().decode()) + + +def to_snake_case(name, separator="_"): + """Convert a name from camelCase to snake_case. Names that already are + snake_case remain the same. + """ + name2 = "" + for c in name: + c2 = c.lower() + if c2 != c and len(name2) > 0: + prev = name2[-1] + if c2 == "d" and prev in "123": + name2 = name2[:-1] + separator + prev + elif prev != separator: + name2 += separator + name2 += c2 + return name2 + + +def dict_deep_merge(a:dict, b:dict, allow_add: bool=True) -> dict: + """Return a new dict: b merged into a, recursing into nested dicts.""" + result = dict(a) + for key, val in b.items(): + if isinstance(val, dict): + if key in result and isinstance(result[key], dict): + if "diff" in val: + assert val['diff'] == "REMOVE" + result.pop(key, None) + else: + result[key] = dict_deep_merge(result[key], val, allow_add) + elif allow_add: + result[key] = val + else: + result[key] = val + + return result + + +class FormatError(Exception): + pass + + +def format_code(src, singleline=False): + """Format the given src string. If singleline is True, all function + signatures become single-line, so they can be parsed and updated. + """ + line_length = 320 if singleline else 88 + cmd = [ + sys.executable, + "-m", + "ruff", + "format", + "--line-length", + str(line_length), + "--no-cache", + "--stdin-filename", + "tmp.py", + ] + + p = subprocess.run(cmd, input=src.encode(), capture_output=True) + + if p.returncode: + stdout = p.stdout.decode(errors="ignore") + stderr = p.stderr.decode(errors="ignore") + raise FormatError( + f"Could not format source ({p.returncode}).\n\nstdout: " + + stdout + + "\n\nstderr: " + + stderr + ) + else: + result = p.stdout.decode(errors="ignore") + + # Make defs single-line. You'd think that setting the line length + # to a very high number would do the trick, but it does not. + if singleline: + result = _make_sigs_singline(result) + + return result + + +def indent(text: str, indent=4) -> str: + text = text.strip() + lines = [] + for line in text.split("\n"): + lines.append(" " * indent + line.rstrip()) + lines.append("") + return "\n".join(lines) + + +def read_definition_file(fname: str) -> dict: + """Read a TOML API definition file and check that the structure is correct. + Returns the structure as a dict. + """ + source = read_file("apigen", "definitions", fname) + structure = tomllib.loads(source) + + diff_actions = ("REMOVE", ) + + # The code below is just a tedious traversing of the structure that checks each leaf node. + + for section, section_dict in structure.items(): + assert section in ("flags", "enums", "structs", "classes") + assert isinstance(section_dict, dict) + + if section == "flags": + for flag_name, flag_dict in structure[section].items(): + assert "_" not in flag_name + for flag_attr_key, flag_attr_value in flag_dict.items(): + if flag_attr_key == "doc": + assert isinstance(flag_attr_value, str) + elif flag_attr_key == "diff": + assert flag_attr_value in diff_actions + elif flag_attr_key == "fields": + assert isinstance(flag_attr_value, dict) + for field_name, field_dict in flag_attr_value.items(): + assert field_name.upper() == field_name + assert isinstance(field_dict, dict) + for field_dict_key, field_dict_val in field_dict.items(): + if field_dict_key == "doc": + assert isinstance(field_dict_val, str) + elif field_dict_key == "diff": + assert field_dict_val in diff_actions + elif field_dict_key == "value": + assert isinstance(field_dict_val, int) + else: + raise RuntimeError(f"Invalid flag field dict key {field_dict_key!r}") + else: + raise RuntimeError(f"Invalid flag attr {flag_attr_key!r}") + + if section == "enums": + for enum_name, enum_dict in structure[section].items(): + assert "_" not in enum_name + for enum_attr_key, enum_attr_value in enum_dict.items(): + if enum_attr_key == "doc": + assert isinstance(enum_attr_value, str) + elif enum_attr_key == "diff": + assert enum_attr_value in diff_actions + elif enum_attr_key == "fields": + assert isinstance(enum_attr_value, dict) + for field_name, field_dict in enum_attr_value.items(): + assert field_name.lower() == field_name + assert isinstance(field_dict, dict) + for field_dict_key, field_dict_val in field_dict.items(): + if field_dict_key == "doc": + assert isinstance(field_dict_val, str) + elif field_dict_key == "diff": + assert field_dict_val in diff_actions + elif field_dict_key == "value": + assert isinstance(field_dict_val, str) + assert field_dict_val == enum_name_to_value(field_name) + else: + raise RuntimeError(f"Invalid enum field dict key {field_dict_key!r}") + else: + raise RuntimeError(f"Invalid enum attr {enum_attr_key!r}") + + if section == "structs": + for struct_name, struct_dict in structure[section].items(): + assert "_" not in struct_name + for struct_attr_key, struct_attr_value in struct_dict.items(): + if struct_attr_key == "doc": + assert isinstance(struct_attr_value, str) + elif struct_attr_key == "diff": + assert struct_attr_value in diff_actions + elif struct_attr_key == "fields": + assert isinstance(struct_attr_value, dict) + for field_name, field_dict in struct_attr_value.items(): + assert field_name.lower() == field_name + assert isinstance(field_dict, dict) + for field_dict_key, field_dict_val in field_dict.items(): + if field_dict_key == "doc": + assert isinstance(field_dict_val, str) + elif field_dict_key == "diff": + assert field_dict_val in diff_actions + elif field_dict_key == "type": + assert isinstance(field_dict_val, str) + elif field_dict_key == "default": + assert isinstance(field_dict_val, str) + elif field_dict_key == "required": + assert isinstance(field_dict_val, bool) + else: + raise RuntimeError(f"Invalid struct field dict key {field_dict_key!r}") + else: + raise RuntimeError(f"Invalid struct attr {struct_attr_key!r}") + + + if section == "classes": + for class_name, class_dict in structure[section].items(): + assert "_" not in class_name + for class_attr_key, class_attr_value in class_dict.items(): + if class_attr_key == "doc": + assert isinstance(class_attr_value, str) + elif class_attr_key == "diff": + assert class_attr_value in diff_actions + elif class_attr_key == "bases": + assert isinstance(class_attr_value, list) + assert all(isinstance(x, str) for x in class_attr_value) + elif class_attr_key == "properties": + assert isinstance(class_attr_value, dict) + for prop_name, prop_dict in class_attr_value.items(): + assert prop_name.lower() == prop_name + assert isinstance(prop_dict, dict) + for prop_dict_key, prop_dict_val in prop_dict.items(): + if prop_dict_key == "doc": + assert isinstance(prop_dict_val, str) + elif prop_dict_key == "diff": + assert prop_dict_val in diff_actions + elif prop_dict_key == "type": + assert isinstance(prop_dict_val, str) + else: + raise RuntimeError(f"Invalid property dict key {prop_dict_key!r}") + elif class_attr_key == "methods": + assert isinstance(class_attr_value, dict) + for method_name, method_dict in class_attr_value.items(): + assert method_name.lower() == method_name + assert isinstance(method_dict, dict) + for method_dict_key, method_dict_val in method_dict.items(): + if method_dict_key == "doc": + assert isinstance(method_dict_val, str) + elif method_dict_key == "diff": + assert method_dict_val in diff_actions + elif method_dict_key == "returns": + assert isinstance(method_dict_val, dict) + for return_dict_key, return_dict_val in method_dict_val.items(): + if return_dict_key == "doc": + assert isinstance(return_dict_val, str) + elif return_dict_key == "type": + assert isinstance(return_dict_val, str) + else: + raise RuntimeError(f"Invalid method returns dict key {return_dict_key!r}") + elif method_dict_key == "args": + assert isinstance(method_dict_val, dict) + for arg_name, arg_dict in method_dict_val.items(): + assert arg_name.lower() == arg_name + assert isinstance(arg_dict, dict) + for arg_dict_key, arg_dict_val in arg_dict.items(): + if arg_dict_key == "doc": + assert isinstance(arg_dict_val, str) + elif arg_dict_key == "diff": + assert arg_dict_val in diff_actions + elif arg_dict_key == "type": + assert isinstance(arg_dict_val, str) + elif arg_dict_key == "default": + assert isinstance(arg_dict_val, str) + elif arg_dict_key == "required": + assert isinstance(arg_dict_val, bool) + else: + raise RuntimeError(f"Invalid method arg dict key {arg_dict_key!r}") + else: + raise RuntimeError(f"Invalid method dict key {method_dict_key!r}") + else: + raise RuntimeError(f"Invalid class attr {class_attr_key!r}") + + return structure + + +def enum_name_to_value(name): + parts = name.split("_") + for i in range(len(parts)): + if parts[i] in ("d1", "d2", "d3"): + parts[i] = parts[i][::-1] + return "-".join(parts) diff --git a/apigen/definitions/diff_backend_pyodide.toml b/apigen/definitions/diff_backend_pyodide.toml new file mode 100644 index 00000000..a0b482f9 --- /dev/null +++ b/apigen/definitions/diff_backend_pyodide.toml @@ -0,0 +1,4 @@ +# diff_backend_pyodide.toml +# +# Defines how the Pyodide API differs from the base API. +# We could use this to bring back e.g. external textures. diff --git a/apigen/definitions/diff_backend_wgpu.toml b/apigen/definitions/diff_backend_wgpu.toml new file mode 100644 index 00000000..d7f65257 --- /dev/null +++ b/apigen/definitions/diff_backend_wgpu.toml @@ -0,0 +1,5 @@ +# diff_backend_wgpu.toml +# +# Defines how the native/desktop API differs from the base API. +# Code that uses any of these cannot run on the web. Therefore we make this extra API +# explicit by using a suffix for everything that is added. diff --git a/apigen/definitions/diff_base.toml b/apigen/definitions/diff_base.toml new file mode 100644 index 00000000..ee0f3641 --- /dev/null +++ b/apigen/definitions/diff_base.toml @@ -0,0 +1,15 @@ +# diff_base.toml +# +# Defines how our wgpu-py base API differs from the web-api (the one derived from webgpu.idl). +# We mostly *remove* things that we cannot replicate on desktop. So that we can an API surface that is the +# intersection of what we can use on desktop and web. + +# Remove things related to external textures +[classes] +GPUQueue.methods.copy_external_image_to_texture = {diff="REMOVE"} +GPUDevice.methods.import_external_texture = {diff="REMOVE"} +[structs] +ExternalTextureBindingLayout = {diff="REMOVE"} +CopyExternalImageDestInfo = {diff="REMOVE"} +CopyExternalImageSourceInfo = {diff="REMOVE"} +BindGroupLayoutEntry.fields.external_texture = {diff="REMOVE"} diff --git a/apigen/definitions/docs_ai.toml b/apigen/definitions/docs_ai.toml new file mode 100644 index 00000000..353daf73 --- /dev/null +++ b/apigen/definitions/docs_ai.toml @@ -0,0 +1,2277 @@ +# docs_ai.toml +# +# Documentation for the base wgpu API, generated by Claude Sonnet 5.5 at 13-10-2026. +# +# Cross-reference conventions used in these docs: +# - Classes are referred to by name, e.g. GPUBuffer. +# - Flags, enums and structs use a prefix, e.g. flags.BufferUsage, enums.TextureFormat, structs.BufferDescriptor. +# - Fields and arguments are referred to like "the usage field of structs.BufferDescriptor" +# or "the mode argument of the GPUBuffer.map_async() method". + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[flags] + +[flags.BufferUsage] +doc = """ +Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator. + +The usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards. +Using a buffer in a way that was not declared here results in a validation error. +""" +fields.MAP_READ.doc = "The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST." +fields.MAP_WRITE.doc = "The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC." +fields.COPY_SRC.doc = "The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer()." +fields.COPY_DST.doc = "The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer()." +fields.INDEX.doc = "The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer()." +fields.VERTEX.doc = "The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer()." +fields.UNIFORM.doc = "The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform." +fields.STORAGE.doc = "The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage." +fields.INDIRECT.doc = "The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect()." +fields.QUERY_RESOLVE.doc = "The buffer can be the destination of GPUCommandEncoder.resolve_query_set()." + +[flags.MapMode] +doc = """ +Bit flags that specify whether a buffer is mapped for reading or writing. + +Used in the mode argument of the GPUBuffer.map_async() method. The mode must match the +flags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE. +""" +fields.READ.doc = "Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ." +fields.WRITE.doc = "Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE." + +[flags.TextureUsage] +doc = """ +Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator. + +The usage is set when creating the texture (see the usage field of structs.TextureDescriptor). +Texture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor). +""" +fields.COPY_SRC.doc = "The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer()." +fields.COPY_DST.doc = "The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture()." +fields.TEXTURE_BINDING.doc = "The texture can be bound for sampling in a shader, see structs.TextureBindingLayout." +fields.STORAGE_BINDING.doc = "The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout." +fields.RENDER_ATTACHMENT.doc = "The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor." +fields.TRANSIENT_ATTACHMENT.doc = "The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard." + +[flags.ShaderStage] +doc = """ +Bit flags that specify in which shader stages a resource is visible. + +Used in the visibility field of structs.BindGroupLayoutEntry. +""" +fields.VERTEX.doc = "The vertex shader stage." +fields.FRAGMENT.doc = "The fragment shader stage." +fields.COMPUTE.doc = "The compute shader stage." + +[flags.ColorWrite] +doc = """ +Bit flags that specify which color channels of a render target are written to. + +Used in the write_mask field of structs.ColorTargetState. +""" +fields.RED.doc = "Write the red channel." +fields.GREEN.doc = "Write the green channel." +fields.BLUE.doc = "Write the blue channel." +fields.ALPHA.doc = "Write the alpha channel." +fields.ALL.doc = "Write all channels (RED, GREEN, BLUE and ALPHA)." + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[enums] + +[enums.PowerPreference] +doc = """ +Hint for which kind of adapter to select. + +Used in the power_preference field of structs.RequestAdapterOptions. This is only a hint; +the implementation may ignore it. +""" +fields.low_power.doc = "Prefer an adapter that uses little power, e.g. an integrated GPU." +fields.high_performance.doc = "Prefer an adapter with the highest performance, e.g. a discrete GPU." + +[enums.FeatureName] +doc = """ +Names of optional features that an adapter may support and a device may request. + +Available features can be inspected via the features property of GPUAdapter. Features +are enabled by listing them in the required_features field of structs.DeviceDescriptor. +The features of the device are available via the features property of GPUDevice. +""" +fields.core_features_and_limits.doc = "Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode)." +fields.depth_clip_control.doc = "Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState." +fields.depth32float_stencil8.doc = "Enables enums.TextureFormat.depth32float_stencil8." +fields.texture_compression_bc.doc = "Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm." +fields.texture_compression_bc_sliced_d3.doc = "Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_bc." +fields.texture_compression_etc2.doc = "Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm." +fields.texture_compression_astc.doc = "Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm." +fields.texture_compression_astc_sliced_d3.doc = "Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_astc." +fields.timestamp_query.doc = "Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites." +fields.indirect_first_instance.doc = "Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect()." +fields.shader_f16.doc = "Allows the use of the f16 type in WGSL shaders (the enable f16 directive)." +fields.rg11b10ufloat_renderable.doc = "Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling." +fields.bgra8unorm_storage.doc = "Allows enums.TextureFormat.bgra8unorm to be used as a storage texture." +fields.float32_filterable.doc = "Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler." +fields.float32_blendable.doc = "Allows 32-bit float color attachments to be used with blending." +fields.clip_distances.doc = "Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes." +fields.dual_source_blending.doc = "Allows blending with a second fragment shader output, see enums.BlendFactor.src1." +fields.subgroups.doc = "Allows the use of subgroup operations in WGSL shaders." +fields.texture_formats_tier1.doc = "Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats." +fields.texture_formats_tier2.doc = "Enables further texture format capabilities, such as read-write storage access for more formats. Requires texture_formats_tier1." +fields.primitive_index.doc = "Allows the primitive_index built-in in WGSL fragment shaders." +fields.texture_component_swizzle.doc = "Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor." + +[enums.BufferMapState] +doc = """ +The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer. +""" +fields.unmapped.doc = "The buffer is not mapped; it can be used by the GPU." +fields.pending.doc = "A GPUBuffer.map_async() call is in progress but has not yet completed." +fields.mapped.doc = "The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range()." + +[enums.TextureDimension] +doc = """ +The dimensionality of a GPUTexture. + +Used in the dimension field of structs.TextureDescriptor. +""" +fields.d1.doc = "A one-dimensional texture, with only a width." +fields.d2.doc = "A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers)." +fields.d3.doc = "A three-dimensional (volume) texture, with width, height and depth." + +[enums.TextureViewDimension] +doc = """ +The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader. + +Used in the dimension field of structs.TextureViewDescriptor and the view_dimension field of +structs.TextureBindingLayout and structs.StorageTextureBindingLayout. +""" +fields.d1.doc = "A one-dimensional view; corresponds to texture_1d in WGSL." +fields.d2.doc = "A two-dimensional view of a single layer; corresponds to texture_2d in WGSL." +fields.d2_array.doc = "A view of an array of 2D layers; corresponds to texture_2d_array in WGSL." +fields.cube.doc = "A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL." +fields.cube_array.doc = "A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL." +fields.d3.doc = "A three-dimensional view; corresponds to texture_3d in WGSL." + +[enums.TextureAspect] +doc = """ +Which aspect (part) of a texture a view or copy operation refers to. + +This is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects. +""" +fields.all.doc = "All available aspects of the texture format." +fields.stencil_only.doc = "Only the stencil aspect of a depth-stencil format." +fields.depth_only.doc = "Only the depth aspect of a depth-stencil format." + +[enums.TextureFormat] +doc = """ +The pixel format of a GPUTexture. + +Names are of the form: channels, bit size per channel, and a type suffix. +The suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1), +uint/sint = unsigned/signed integer, float = floating point, and srgb = the color +is stored in sRGB and automatically converted to linear when sampled (and back when written). +Some formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage). +""" +fields.r8unorm.doc = "One channel (red), 8-bit unsigned normalized." +fields.r8snorm.doc = "One channel (red), 8-bit signed normalized." +fields.r8uint.doc = "One channel (red), 8-bit unsigned integer." +fields.r8sint.doc = "One channel (red), 8-bit signed integer." +fields.r16unorm.doc = "One channel (red), 16-bit unsigned normalized. Requires feature texture_formats_tier1." +fields.r16snorm.doc = "One channel (red), 16-bit signed normalized. Requires feature texture_formats_tier1." +fields.r16uint.doc = "One channel (red), 16-bit unsigned integer." +fields.r16sint.doc = "One channel (red), 16-bit signed integer." +fields.r16float.doc = "One channel (red), 16-bit floating point." +fields.rg8unorm.doc = "Two channels (red, green), 8-bit unsigned normalized each." +fields.rg8snorm.doc = "Two channels (red, green), 8-bit signed normalized each." +fields.rg8uint.doc = "Two channels (red, green), 8-bit unsigned integer each." +fields.rg8sint.doc = "Two channels (red, green), 8-bit signed integer each." +fields.r32uint.doc = "One channel (red), 32-bit unsigned integer." +fields.r32sint.doc = "One channel (red), 32-bit signed integer." +fields.r32float.doc = "One channel (red), 32-bit floating point." +fields.rg16unorm.doc = "Two channels (red, green), 16-bit unsigned normalized each. Requires feature texture_formats_tier1." +fields.rg16snorm.doc = "Two channels (red, green), 16-bit signed normalized each. Requires feature texture_formats_tier1." +fields.rg16uint.doc = "Two channels (red, green), 16-bit unsigned integer each." +fields.rg16sint.doc = "Two channels (red, green), 16-bit signed integer each." +fields.rg16float.doc = "Two channels (red, green), 16-bit floating point each." +fields.rgba8unorm.doc = "Four channels (red, green, blue, alpha), 8-bit unsigned normalized each." +fields.rgba8unorm_srgb.doc = "Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels." +fields.rgba8snorm.doc = "Four channels (RGBA), 8-bit signed normalized each." +fields.rgba8uint.doc = "Four channels (RGBA), 8-bit unsigned integer each." +fields.rgba8sint.doc = "Four channels (RGBA), 8-bit signed integer each." +fields.bgra8unorm.doc = "Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format()." +fields.bgra8unorm_srgb.doc = "Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels." +fields.rgb9e5ufloat.doc = "Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable." +fields.rgb10a2uint.doc = "Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha." +fields.rgb10a2unorm.doc = "Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha." +fields.rg11b10ufloat.doc = "Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with feature rg11b10ufloat_renderable." +fields.rg32uint.doc = "Two channels (red, green), 32-bit unsigned integer each." +fields.rg32sint.doc = "Two channels (red, green), 32-bit signed integer each." +fields.rg32float.doc = "Two channels (red, green), 32-bit floating point each." +fields.rgba16unorm.doc = "Four channels (RGBA), 16-bit unsigned normalized each. Requires feature texture_formats_tier1." +fields.rgba16snorm.doc = "Four channels (RGBA), 16-bit signed normalized each. Requires feature texture_formats_tier1." +fields.rgba16uint.doc = "Four channels (RGBA), 16-bit unsigned integer each." +fields.rgba16sint.doc = "Four channels (RGBA), 16-bit signed integer each." +fields.rgba16float.doc = "Four channels (RGBA), 16-bit floating point each." +fields.rgba32uint.doc = "Four channels (RGBA), 32-bit unsigned integer each." +fields.rgba32sint.doc = "Four channels (RGBA), 32-bit signed integer each." +fields.rgba32float.doc = "Four channels (RGBA), 32-bit floating point each." +fields.stencil8.doc = "A stencil-only format with 8 bits per pixel." +fields.depth16unorm.doc = "A depth-only format with 16-bit unsigned normalized depth." +fields.depth24plus.doc = "A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer." +fields.depth24plus_stencil8.doc = "A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer." +fields.depth32float.doc = "A depth-only format with 32-bit floating point depth." +fields.depth32float_stencil8.doc = "A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires feature depth32float_stencil8." +fields.bc1_rgba_unorm.doc = "BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires feature texture_compression_bc." +fields.bc1_rgba_unorm_srgb.doc = "BC1 (DXT1) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." +fields.bc2_rgba_unorm.doc = "BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc." +fields.bc2_rgba_unorm_srgb.doc = "BC2 (DXT3) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." +fields.bc3_rgba_unorm.doc = "BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc." +fields.bc3_rgba_unorm_srgb.doc = "BC3 (DXT5) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." +fields.bc4_r_unorm.doc = "BC4 compressed single channel, unsigned normalized. Requires feature texture_compression_bc." +fields.bc4_r_snorm.doc = "BC4 compressed single channel, signed normalized. Requires feature texture_compression_bc." +fields.bc5_rg_unorm.doc = "BC5 compressed two channels, unsigned normalized. Requires feature texture_compression_bc." +fields.bc5_rg_snorm.doc = "BC5 compressed two channels, signed normalized. Requires feature texture_compression_bc." +fields.bc6h_rgb_ufloat.doc = "BC6H compressed HDR RGB, unsigned float. Requires feature texture_compression_bc." +fields.bc6h_rgb_float.doc = "BC6H compressed HDR RGB, signed float. Requires feature texture_compression_bc." +fields.bc7_rgba_unorm.doc = "BC7 compressed RGBA, unsigned normalized. Requires feature texture_compression_bc." +fields.bc7_rgba_unorm_srgb.doc = "BC7 compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." +fields.etc2_rgb8unorm.doc = "ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2." +fields.etc2_rgb8unorm_srgb.doc = "ETC2 compressed RGB with sRGB encoding. Requires feature texture_compression_etc2." +fields.etc2_rgb8a1unorm.doc = "ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires feature texture_compression_etc2." +fields.etc2_rgb8a1unorm_srgb.doc = "ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires feature texture_compression_etc2." +fields.etc2_rgba8unorm.doc = "ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2." +fields.etc2_rgba8unorm_srgb.doc = "ETC2 compressed RGBA with sRGB encoding. Requires feature texture_compression_etc2." +fields.eac_r11unorm.doc = "EAC compressed single channel, 11-bit unsigned normalized. Requires feature texture_compression_etc2." +fields.eac_r11snorm.doc = "EAC compressed single channel, 11-bit signed normalized. Requires feature texture_compression_etc2." +fields.eac_rg11unorm.doc = "EAC compressed two channels, 11-bit unsigned normalized each. Requires feature texture_compression_etc2." +fields.eac_rg11snorm.doc = "EAC compressed two channels, 11-bit signed normalized each. Requires feature texture_compression_etc2." +fields.astc_4x4_unorm.doc = "ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_4x4_unorm_srgb.doc = "ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_5x4_unorm.doc = "ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_5x4_unorm_srgb.doc = "ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_5x5_unorm.doc = "ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_5x5_unorm_srgb.doc = "ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_6x5_unorm.doc = "ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_6x5_unorm_srgb.doc = "ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_6x6_unorm.doc = "ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_6x6_unorm_srgb.doc = "ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_8x5_unorm.doc = "ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_8x5_unorm_srgb.doc = "ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_8x6_unorm.doc = "ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_8x6_unorm_srgb.doc = "ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_8x8_unorm.doc = "ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_8x8_unorm_srgb.doc = "ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_10x5_unorm.doc = "ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_10x5_unorm_srgb.doc = "ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_10x6_unorm.doc = "ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_10x6_unorm_srgb.doc = "ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_10x8_unorm.doc = "ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_10x8_unorm_srgb.doc = "ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_10x10_unorm.doc = "ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_10x10_unorm_srgb.doc = "ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_12x10_unorm.doc = "ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_12x10_unorm_srgb.doc = "ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires feature texture_compression_astc." +fields.astc_12x12_unorm.doc = "ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires feature texture_compression_astc." +fields.astc_12x12_unorm_srgb.doc = "ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires feature texture_compression_astc." + +[enums.AddressMode] +doc = """ +How a sampler handles texture coordinates outside the 0..1 range, per axis. + +Used in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor. +""" +fields.clamp_to_edge.doc = "Coordinates are clamped to the range 0..1, so the edge texels are repeated." +fields.repeat.doc = "The texture tiles: only the fractional part of the coordinate is used." +fields.mirror_repeat.doc = "The texture tiles, but is mirrored every other repetition." + +[enums.FilterMode] +doc = """ +How a sampler filters texels when a texture is magnified or minified. + +Used in the mag_filter and min_filter fields of structs.SamplerDescriptor. +""" +fields.nearest.doc = "Use the value of the nearest texel." +fields.linear.doc = "Linearly interpolate between the nearest texels." + +[enums.MipmapFilterMode] +doc = """ +How a sampler filters between mip levels. + +Used in the mipmap_filter field of structs.SamplerDescriptor. +""" +fields.nearest.doc = "Use the nearest mip level." +fields.linear.doc = "Linearly interpolate between the two nearest mip levels." + +[enums.CompareFunction] +doc = """ +A comparison function, used for depth testing, stencil testing and comparison samplers. + +The comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to +the existing value. If the comparison is true, the test passes. +""" +fields.never.doc = "The comparison never passes." +fields.less.doc = "Passes if the new value is less than the existing value." +fields.equal.doc = "Passes if the new value is equal to the existing value." +fields.less_equal.doc = "Passes if the new value is less than or equal to the existing value." +fields.greater.doc = "Passes if the new value is greater than the existing value." +fields.not_equal.doc = "Passes if the new value is not equal to the existing value." +fields.greater_equal.doc = "Passes if the new value is greater than or equal to the existing value." +fields.always.doc = "The comparison always passes." + +[enums.BufferBindingType] +doc = """ +The type of a buffer binding in a bind group layout. + +Used in the type field of structs.BufferBindingLayout. +""" +fields.uniform.doc = "A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM." +fields.storage.doc = "A read-write storage buffer. Requires flags.BufferUsage.STORAGE." +fields.read_only_storage.doc = "A read-only storage buffer. Requires flags.BufferUsage.STORAGE." + +[enums.SamplerBindingType] +doc = """ +The type of a sampler binding in a bind group layout. + +Used in the type field of structs.SamplerBindingLayout. +""" +fields.filtering.doc = "A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float." +fields.non_filtering.doc = "A sampler that only uses nearest filtering. Can be used with any float texture." +fields.comparison.doc = "A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor)." + +[enums.TextureSampleType] +doc = """ +The type of values that is returned when sampling a texture in a shader. + +Used in the sample_type field of structs.TextureBindingLayout. +""" +fields.float.doc = "Floating point values; the texture can be sampled with a filtering sampler." +fields.unfilterable_float.doc = "Floating point values, but the texture cannot be filtered (e.g. 32-bit float without the float32_filterable feature)." +fields.depth.doc = "Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler." +fields.sint.doc = "Signed integer values." +fields.uint.doc = "Unsigned integer values." + +[enums.StorageTextureAccess] +doc = """ +How a storage texture can be accessed by a shader. + +Used in the access field of structs.StorageTextureBindingLayout. +""" +fields.write_only.doc = "The shader can only write to the texture." +fields.read_only.doc = "The shader can only read from the texture." +fields.read_write.doc = "The shader can both read from and write to the texture." + +[enums.CompilationMessageType] +doc = """ +The severity of a GPUCompilationMessage. +""" +fields.error.doc = "An error; the shader module is invalid." +fields.warning.doc = "A warning; the shader module is valid but something may be wrong." +fields.info.doc = "An informational message." + +[enums.PipelineErrorReason] +doc = """ +The reason for a GPUPipelineError. + +Available via the reason property of GPUPipelineError. +""" +fields.validation.doc = "The pipeline failed validation, e.g. because of an invalid descriptor or shader." +fields.internal.doc = "An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend." + +[enums.AutoLayoutMode] +doc = """ +Indicates that a pipeline layout should be derived automatically from the shader code. + +Used as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor. +The resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout(). +""" +fields.auto.doc = "Derive the pipeline layout from the shader." + +[enums.PrimitiveTopology] +doc = """ +How vertices are assembled into primitives. + +Used in the topology field of structs.PrimitiveState. +""" +fields.point_list.doc = "Each vertex defines a point." +fields.line_list.doc = "Each pair of vertices defines a separate line." +fields.line_strip.doc = "Each vertex after the first defines a line to the previous vertex." +fields.triangle_list.doc = "Each triple of vertices defines a separate triangle." +fields.triangle_strip.doc = "Each vertex after the first two defines a triangle with the previous two vertices." + +[enums.FrontFace] +doc = """ +Defines which winding order of a triangle is considered front-facing. + +Used in the front_face field of structs.PrimitiveState. +""" +fields.ccw.doc = "Triangles with counter-clockwise vertices (in framebuffer space) are front-facing." +fields.cw.doc = "Triangles with clockwise vertices (in framebuffer space) are front-facing." + +[enums.CullMode] +doc = """ +Defines which faces of triangles are culled (not drawn). + +Used in the cull_mode field of structs.PrimitiveState. +""" +fields.none.doc = "No faces are culled." +fields.front.doc = "Front-facing triangles are culled." +fields.back.doc = "Back-facing triangles are culled." + +[enums.BlendFactor] +doc = """ +A factor that is multiplied with the source or destination color or alpha in blending. + +Used in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions, +src is the output of the fragment shader and dst is the existing value in the render target. +""" +fields.zero.doc = "Factor 0." +fields.one.doc = "Factor 1." +fields.src.doc = "The source color, per component." +fields.one_minus_src.doc = "One minus the source color, per component." +fields.src_alpha.doc = "The source alpha." +fields.one_minus_src_alpha.doc = "One minus the source alpha." +fields.dst.doc = "The destination color, per component." +fields.one_minus_dst.doc = "One minus the destination color, per component." +fields.dst_alpha.doc = "The destination alpha." +fields.one_minus_dst_alpha.doc = "One minus the destination alpha." +fields.src_alpha_saturated.doc = "The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha." +fields.constant.doc = "The blend constant color, see GPURenderPassEncoder.set_blend_constant()." +fields.one_minus_constant.doc = "One minus the blend constant color." +fields.src1.doc = "The second source color output of the fragment shader. Requires feature dual_source_blending." +fields.one_minus_src1.doc = "One minus the second source color. Requires feature dual_source_blending." +fields.src1_alpha.doc = "The second source alpha. Requires feature dual_source_blending." +fields.one_minus_src1_alpha.doc = "One minus the second source alpha. Requires feature dual_source_blending." + +[enums.BlendOperation] +doc = """ +The operation used to combine the scaled source and destination values in blending. + +Used in the operation field of structs.BlendComponent. +""" +fields.add.doc = "Result is source plus destination." +fields.subtract.doc = "Result is source minus destination." +fields.reverse_subtract.doc = "Result is destination minus source." +fields.min.doc = "Result is the minimum of source and destination (blend factors are ignored)." +fields.max.doc = "Result is the maximum of source and destination (blend factors are ignored)." + +[enums.StencilOperation] +doc = """ +The operation performed on the stencil buffer value after a stencil or depth test. + +Used in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState. +""" +fields.keep.doc = "Keep the current stencil value." +fields.zero.doc = "Set the stencil value to zero." +fields.replace.doc = "Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference()." +fields.invert.doc = "Bitwise invert the current stencil value." +fields.increment_clamp.doc = "Increment the stencil value, clamping to the maximum." +fields.decrement_clamp.doc = "Decrement the stencil value, clamping to zero." +fields.increment_wrap.doc = "Increment the stencil value, wrapping to zero on overflow." +fields.decrement_wrap.doc = "Decrement the stencil value, wrapping to the maximum on underflow." + +[enums.IndexFormat] +doc = """ +The data type of the indices in an index buffer. + +Used in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method +and the strip_index_format field of structs.PrimitiveState. +""" +fields.uint16.doc = "Indices are 16-bit unsigned integers." +fields.uint32.doc = "Indices are 32-bit unsigned integers." + +[enums.VertexFormat] +doc = """ +The format of a vertex attribute in a vertex buffer. + +Used in the format field of structs.VertexAttribute. The name consists of the component type and +bit size, optionally followed by xN for the number of components. The shader sees the data as +float (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components. +""" +fields.uint8.doc = "One 8-bit unsigned integer." +fields.uint8x2.doc = "Two 8-bit unsigned integers." +fields.uint8x4.doc = "Four 8-bit unsigned integers." +fields.sint8.doc = "One 8-bit signed integer." +fields.sint8x2.doc = "Two 8-bit signed integers." +fields.sint8x4.doc = "Four 8-bit signed integers." +fields.unorm8.doc = "One 8-bit unsigned normalized value (0..1)." +fields.unorm8x2.doc = "Two 8-bit unsigned normalized values (0..1)." +fields.unorm8x4.doc = "Four 8-bit unsigned normalized values (0..1)." +fields.snorm8.doc = "One 8-bit signed normalized value (-1..1)." +fields.snorm8x2.doc = "Two 8-bit signed normalized values (-1..1)." +fields.snorm8x4.doc = "Four 8-bit signed normalized values (-1..1)." +fields.uint16.doc = "One 16-bit unsigned integer." +fields.uint16x2.doc = "Two 16-bit unsigned integers." +fields.uint16x4.doc = "Four 16-bit unsigned integers." +fields.sint16.doc = "One 16-bit signed integer." +fields.sint16x2.doc = "Two 16-bit signed integers." +fields.sint16x4.doc = "Four 16-bit signed integers." +fields.unorm16.doc = "One 16-bit unsigned normalized value (0..1)." +fields.unorm16x2.doc = "Two 16-bit unsigned normalized values (0..1)." +fields.unorm16x4.doc = "Four 16-bit unsigned normalized values (0..1)." +fields.snorm16.doc = "One 16-bit signed normalized value (-1..1)." +fields.snorm16x2.doc = "Two 16-bit signed normalized values (-1..1)." +fields.snorm16x4.doc = "Four 16-bit signed normalized values (-1..1)." +fields.float16.doc = "One 16-bit float." +fields.float16x2.doc = "Two 16-bit floats." +fields.float16x4.doc = "Four 16-bit floats." +fields.float32.doc = "One 32-bit float." +fields.float32x2.doc = "Two 32-bit floats." +fields.float32x3.doc = "Three 32-bit floats." +fields.float32x4.doc = "Four 32-bit floats." +fields.uint32.doc = "One 32-bit unsigned integer." +fields.uint32x2.doc = "Two 32-bit unsigned integers." +fields.uint32x3.doc = "Three 32-bit unsigned integers." +fields.uint32x4.doc = "Four 32-bit unsigned integers." +fields.sint32.doc = "One 32-bit signed integer." +fields.sint32x2.doc = "Two 32-bit signed integers." +fields.sint32x3.doc = "Three 32-bit signed integers." +fields.sint32x4.doc = "Four 32-bit signed integers." +fields.unorm10_10_10_2.doc = "A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float." +fields.unorm8x4_bgra.doc = "Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order." + +[enums.VertexStepMode] +doc = """ +How often a vertex buffer is advanced. + +Used in the step_mode field of structs.VertexBufferLayout. +""" +fields.vertex.doc = "The buffer is advanced for each vertex." +fields.instance.doc = "The buffer is advanced for each instance." + +[enums.LoadOp] +doc = """ +What happens to the contents of an attachment at the start of a render pass. + +Used in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. +""" +fields.load.doc = "Keep the existing contents of the attachment." +fields.clear.doc = "Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment)." + +[enums.StoreOp] +doc = """ +What happens to the contents of an attachment at the end of a render pass. + +Used in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. +""" +fields.store.doc = "Store the results of the render pass in the attachment." +fields.discard.doc = "Discard the results; the contents of the attachment become undefined (zero-initialized when next used)." + +[enums.QueryType] +doc = """ +The type of queries in a GPUQuerySet. + +Used in the type field of structs.QuerySetDescriptor. +""" +fields.occlusion.doc = "Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query()." +fields.timestamp.doc = "Timestamp queries record GPU timestamps. Requires feature timestamp_query." + +[enums.CanvasAlphaMode] +doc = """ +How the alpha channel of a canvas texture is interpreted when compositing with the page or window. + +Used in the alpha_mode field of structs.CanvasConfiguration. +""" +fields.opaque.doc = "The alpha channel is ignored and the canvas is treated as fully opaque." +fields.premultiplied.doc = "The color channels are expected to be premultiplied by the alpha channel." + +[enums.CanvasToneMappingMode] +doc = """ +How the content of a canvas is tone mapped when displayed. + +Used in the mode field of structs.CanvasToneMapping. +""" +fields.standard.doc = "Color values are clamped to the standard dynamic range (SDR) of the display." +fields.extended.doc = "Color values may exceed the SDR range, up to the dynamic range of the display (HDR)." + +[enums.DeviceLostReason] +doc = """ +The reason a GPUDevice was lost. + +Available via the reason property of GPUDeviceLostInfo. +""" +fields.unknown.doc = "The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal." +fields.destroyed.doc = "The device was lost because GPUDevice.destroy() was called." + +[enums.ErrorFilter] +doc = """ +The type of error that is captured by an error scope. + +Used in the filter argument of the GPUDevice.push_error_scope() method. +""" +fields.validation.doc = "Captures GPUValidationError errors, which signal incorrect API usage." +fields.out_of_memory.doc = "Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation." +fields.internal.doc = "Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits)." + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[structs] + +[structs.RequestAdapterOptions] +doc = """ +Options for requesting an adapter. + +Used as the options argument of the GPU.request_adapter() method. +""" +fields.feature_level.doc = "The feature level to request: 'core' (default) or 'compatibility', a more limited level supported by more (older) hardware." +fields.power_preference.doc = "Hint for the kind of adapter to select, see enums.PowerPreference." +fields.force_fallback_adapter.doc = "If true, only a fallback adapter (e.g. a software renderer) is returned, or no adapter if there is none." +fields.xr_compatible.doc = "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." + +[structs.DeviceDescriptor] +doc = """ +Descriptor for requesting a device. + +Used as the descriptor argument of the GPUAdapter.request_device() method. +""" +fields.label.doc = "A human-readable label for the device, used in debugging and error messages." +fields.required_features.doc = "A list of enums.FeatureName that the device must support. Requesting an unsupported feature fails." +fields.required_limits.doc = "A mapping of limit names to the values the device requires. Must not be better than what the adapter supports. Unspecified limits get their default value." +fields.default_queue.doc = "A structs.QueueDescriptor with options for the default queue of the device." + +[structs.BufferDescriptor] +doc = """ +Descriptor for creating a GPUBuffer. + +Used as the descriptor argument of the GPUDevice.create_buffer() method. +""" +fields.label.doc = "A human-readable label for the buffer, used in debugging and error messages." +fields.size.doc = "The size of the buffer in bytes." +fields.usage.doc = "The allowed usages of the buffer, a combination of flags.BufferUsage." +fields.mapped_at_creation.doc = "If true, the buffer is created in a mapped state so it can be filled right away using GPUBuffer.get_mapped_range(). The size must then be a multiple of 4." + +[structs.TextureDescriptor] +doc = """ +Descriptor for creating a GPUTexture. + +Used as the descriptor argument of the GPUDevice.create_texture() method. +""" +fields.label.doc = "A human-readable label for the texture, used in debugging and error messages." +fields.size.doc = "The size of the texture as a structs.Extent3D, or a tuple of (width, height, depth_or_array_layers). Height and depth default to 1." +fields.mip_level_count.doc = "The number of mip levels. Defaults to 1." +fields.sample_count.doc = "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." +fields.dimension.doc = "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." +fields.format.doc = "The pixel format of the texture, see enums.TextureFormat." +fields.usage.doc = "The allowed usages of the texture, a combination of flags.TextureUsage." +fields.view_formats.doc = "Additional enums.TextureFormat values that views of this texture may use. Formats that differ only in sRGB-ness from the texture format are allowed." +fields.texture_binding_view_dimension.doc = "Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding." + +[structs.TextureViewDescriptor] +doc = """ +Descriptor for creating a GPUTextureView. + +Used as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields +get a default derived from the texture, so by default the view covers the whole texture. +""" +fields.label.doc = "A human-readable label for the texture view, used in debugging and error messages." +fields.format.doc = "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." +fields.dimension.doc = "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." +fields.usage.doc = "The usages the view will be used for, a subset of the usage of the texture (see flags.TextureUsage). Defaults to all usages of the texture." +fields.aspect.doc = "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." +fields.base_mip_level.doc = "The first mip level accessible via the view. Defaults to 0." +fields.mip_level_count.doc = "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." +fields.base_array_layer.doc = "The first array layer accessible via the view. Defaults to 0." +fields.array_layer_count.doc = "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." +fields.swizzle.doc = "A string of four characters (default 'rgba') that defines how the components of the view are mapped, e.g. 'bgra'. Allowed characters are r, g, b, a, 0 and 1. Requires feature texture_component_swizzle." + +[structs.ExternalTextureDescriptor] +doc = """ +Descriptor for importing an external texture, such as a video frame. + +Used as the descriptor argument of the GPUDevice.import_external_texture() method. +""" +fields.label.doc = "A human-readable label for the external texture, used in debugging and error messages." +fields.source.doc = "The source of the image data, e.g. a video element or video frame. Only meaningful in browser environments." +fields.color_space.doc = "The color space of the source image, e.g. 'srgb'. Defaults to 'srgb'." + +[structs.SamplerDescriptor] +doc = """ +Descriptor for creating a GPUSampler. + +Used as the descriptor argument of the GPUDevice.create_sampler() method. +""" +fields.label.doc = "A human-readable label for the sampler, used in debugging and error messages." +fields.address_mode_u.doc = "How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge." +fields.address_mode_v.doc = "How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge." +fields.address_mode_w.doc = "How to handle texture coordinates outside 0..1 along the w (z) axis, see enums.AddressMode. Defaults to clamp_to_edge." +fields.mag_filter.doc = "The filter used when the texture is magnified, see enums.FilterMode. Defaults to nearest." +fields.min_filter.doc = "The filter used when the texture is minified, see enums.FilterMode. Defaults to nearest." +fields.mipmap_filter.doc = "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." +fields.lod_min_clamp.doc = "The minimum level of detail used when sampling. Defaults to 0." +fields.lod_max_clamp.doc = "The maximum level of detail used when sampling. Defaults to 32." +fields.compare.doc = "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures." +fields.max_anisotropy.doc = "The maximum anisotropic filtering level, from 1 (default, disabled) to 16. Values above 1 require all filters to be linear." + +[structs.BindGroupLayoutDescriptor] +doc = """ +Descriptor for creating a GPUBindGroupLayout. + +Used as the descriptor argument of the GPUDevice.create_bind_group_layout() method. +""" +fields.label.doc = "A human-readable label for the bind group layout, used in debugging and error messages." +fields.entries.doc = "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." + +[structs.BindGroupLayoutEntry] +doc = """ +Describes a single binding in a bind group layout. + +Exactly one of buffer, sampler, texture, storage_texture and external_texture must be set, +which determines the type of resource that is bound. +""" +fields.binding.doc = "The binding number, matching the @binding attribute in the shader." +fields.visibility.doc = "The shader stages in which the resource is visible, a combination of flags.ShaderStage." +fields.buffer.doc = "If set, a structs.BufferBindingLayout: the entry is a buffer binding." +fields.sampler.doc = "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." +fields.texture.doc = "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." +fields.storage_texture.doc = "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." +fields.external_texture.doc = "If set, a structs.ExternalTextureBindingLayout: the entry is an external texture binding." + +[structs.BufferBindingLayout] +doc = """ +Describes the layout of a buffer binding. + +Used in the buffer field of structs.BindGroupLayoutEntry. +""" +fields.type.doc = "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." +fields.has_dynamic_offset.doc = "If true, an offset can be given in GPUBindingCommandsMixin.set_bind_group() when binding. Defaults to false." +fields.min_binding_size.doc = "The minimum size in bytes of a buffer bound to this entry. Defaults to 0, in which case the size is checked at draw/dispatch time." + +[structs.SamplerBindingLayout] +doc = """ +Describes the layout of a sampler binding. + +Used in the sampler field of structs.BindGroupLayoutEntry. +""" +fields.type.doc = "The type of sampler binding, see enums.SamplerBindingType. Defaults to filtering." + +[structs.TextureBindingLayout] +doc = """ +Describes the layout of a sampled texture binding. + +Used in the texture field of structs.BindGroupLayoutEntry. +""" +fields.sample_type.doc = "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." +fields.view_dimension.doc = "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." +fields.multisampled.doc = "If true, the bound texture must be multisampled. Defaults to false." + +[structs.StorageTextureBindingLayout] +doc = """ +Describes the layout of a storage texture binding. + +Used in the storage_texture field of structs.BindGroupLayoutEntry. +""" +fields.access.doc = "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." +fields.format.doc = "The enums.TextureFormat that the bound texture view must have." +fields.view_dimension.doc = "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." + +[structs.ExternalTextureBindingLayout] +doc = """ +Describes the layout of an external texture binding. + +Used in the external_texture field of structs.BindGroupLayoutEntry. It has no fields. +""" + +[structs.BindGroupDescriptor] +doc = """ +Descriptor for creating a GPUBindGroup. + +Used as the descriptor argument of the GPUDevice.create_bind_group() method. +""" +fields.label.doc = "A human-readable label for the bind group, used in debugging and error messages." +fields.layout.doc = "The GPUBindGroupLayout that this bind group conforms to." +fields.entries.doc = "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." + +[structs.BindGroupEntry] +doc = """ +A single resource binding in a bind group. + +Used in the entries field of structs.BindGroupDescriptor. +""" +fields.binding.doc = "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." +fields.resource.doc = "The resource to bind: a GPUSampler, a GPUTextureView, a structs.BufferBinding, or a GPUBuffer (which binds the whole buffer)." + +[structs.BufferBinding] +doc = """ +Describes a range of a GPUBuffer to bind. + +Can be used as the resource field of structs.BindGroupEntry. +""" +fields.buffer.doc = "The GPUBuffer to bind." +fields.offset.doc = "The offset in bytes into the buffer where the binding starts. Defaults to 0." +fields.size.doc = "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." + +[structs.PipelineLayoutDescriptor] +doc = """ +Descriptor for creating a GPUPipelineLayout. + +Used as the descriptor argument of the GPUDevice.create_pipeline_layout() method. +""" +fields.label.doc = "A human-readable label for the pipeline layout, used in debugging and error messages." +fields.bind_group_layouts.doc = "A list of GPUBindGroupLayout objects, one for each bind group index (set) used by the pipeline." +fields.immediate_size.doc = "The size in bytes of the immediate data (small data set with GPUBindingCommandsMixin.set_immediates()). Defaults to 0." + +[structs.ShaderModuleDescriptor] +doc = """ +Descriptor for creating a GPUShaderModule. + +Used as the descriptor argument of the GPUDevice.create_shader_module() method. +""" +fields.label.doc = "A human-readable label for the shader module, used in debugging and error messages." +fields.code.doc = "The shader source code, in WGSL." +fields.compilation_hints.doc = "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile the shader early." + +[structs.ShaderModuleCompilationHint] +doc = """ +A hint for the compilation of a shader module. + +Used in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only +affect performance, not behavior. +""" +fields.entry_point.doc = "The name of the shader entry point that the hint applies to." +fields.layout.doc = "The GPUPipelineLayout (or enums.AutoLayoutMode.auto) that the entry point will be used with." + +[structs.PipelineErrorInit] +doc = """ +Initialization options for a GPUPipelineError. + +Used as the options argument of the GPUPipelineError constructor. +""" +fields.reason.doc = "The reason for the error, see enums.PipelineErrorReason." + +[structs.ProgrammableStage] +doc = """ +Describes a programmable (shader) stage of a pipeline. + +This is the base for structs.VertexState, structs.FragmentState and the compute field of +structs.ComputePipelineDescriptor. +""" +fields.module.doc = "The GPUShaderModule containing the shader code." +fields.entry_point.doc = "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." +fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." + +[structs.ComputePipelineDescriptor] +doc = """ +Descriptor for creating a GPUComputePipeline. + +Used as the descriptor argument of the GPUDevice.create_compute_pipeline() method. +""" +fields.label.doc = "A human-readable label for the pipeline, used in debugging and error messages." +fields.layout.doc = "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader." +fields.compute.doc = "A structs.ProgrammableStage describing the compute shader." + +[structs.RenderPipelineDescriptor] +doc = """ +Descriptor for creating a GPURenderPipeline. + +Used as the descriptor argument of the GPUDevice.create_render_pipeline() method. +""" +fields.label.doc = "A human-readable label for the pipeline, used in debugging and error messages." +fields.layout.doc = "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shaders." +fields.vertex.doc = "A structs.VertexState describing the vertex shader and vertex buffers." +fields.primitive.doc = "A structs.PrimitiveState describing how primitives are assembled and rasterized." +fields.depth_stencil.doc = "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." +fields.multisample.doc = "A structs.MultisampleState describing multisampling." +fields.fragment.doc = "An optional structs.FragmentState describing the fragment shader and render targets." + +[structs.PrimitiveState] +doc = """ +Describes how a render pipeline assembles and rasterizes primitives. + +Used in the primitive field of structs.RenderPipelineDescriptor. +""" +fields.topology.doc = "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." +fields.strip_index_format.doc = "The enums.IndexFormat of the index buffer. Required for strip topologies when drawing with indices." +fields.front_face.doc = "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." +fields.cull_mode.doc = "Which faces to cull, see enums.CullMode. Defaults to none." +fields.unclipped_depth.doc = "If true, primitives are not clipped by the near and far planes. Requires feature depth_clip_control." + +[structs.MultisampleState] +doc = """ +Describes the multisampling of a render pipeline. + +Used in the multisample field of structs.RenderPipelineDescriptor. +""" +fields.count.doc = "The number of samples per pixel. Must be 1 or 4, and match the attachments. Defaults to 1." +fields.mask.doc = "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." +fields.alpha_to_coverage_enabled.doc = "If true, the alpha output of the fragment shader is used to generate a coverage mask. Defaults to false." + +[structs.FragmentState] +doc = """ +Describes the fragment shader stage and render targets of a render pipeline. + +Used in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. +""" +fields.module.doc = "The GPUShaderModule containing the fragment shader code." +fields.entry_point.doc = "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." +fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." +fields.targets.doc = "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." + +[structs.ColorTargetState] +doc = """ +Describes a color render target of a render pipeline. + +Used in the targets field of structs.FragmentState. +""" +fields.format.doc = "The enums.TextureFormat of the color attachment." +fields.blend.doc = "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." +fields.write_mask.doc = "Which channels are written, a combination of flags.ColorWrite. Defaults to ALL." + +[structs.BlendState] +doc = """ +Describes how blending is performed for a color target. + +Used in the blend field of structs.ColorTargetState. +""" +fields.color.doc = "A structs.BlendComponent for the color (RGB) channels." +fields.alpha.doc = "A structs.BlendComponent for the alpha channel." + +[structs.BlendComponent] +doc = """ +Describes how the blending of a single component (color or alpha) is performed. + +The result is: operation(src * src_factor, dst * dst_factor). +""" +fields.operation.doc = "The enums.BlendOperation used to combine the scaled values. Defaults to add." +fields.src_factor.doc = "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." +fields.dst_factor.doc = "The enums.BlendFactor applied to the destination (existing target value). Defaults to zero." + +[structs.DepthStencilState] +doc = """ +Describes the depth and stencil state of a render pipeline. + +Used in the depth_stencil field of structs.RenderPipelineDescriptor. +""" +fields.format.doc = "The depth-stencil enums.TextureFormat of the attachment." +fields.depth_write_enabled.doc = "If true, depth values of fragments that pass the depth test are written to the attachment." +fields.depth_compare.doc = "The enums.CompareFunction used for the depth test." +fields.stencil_front.doc = "A structs.StencilFaceState for front-facing primitives." +fields.stencil_back.doc = "A structs.StencilFaceState for back-facing primitives." +fields.stencil_read_mask.doc = "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." +fields.stencil_write_mask.doc = "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." +fields.depth_bias.doc = "A constant depth value added to each fragment. Defaults to 0." +fields.depth_bias_slope_scale.doc = "A depth bias that scales with the slope of the primitive. Defaults to 0." +fields.depth_bias_clamp.doc = "The maximum (or minimum, if negative) depth bias of a fragment. Defaults to 0." + +[structs.StencilFaceState] +doc = """ +Describes the stencil operations for one face (front or back) of primitives. + +Used in the stencil_front and stencil_back fields of structs.DepthStencilState. +""" +fields.compare.doc = "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." +fields.fail_op.doc = "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." +fields.depth_fail_op.doc = "The enums.StencilOperation performed if the stencil test passes but the depth test fails. Defaults to keep." +fields.pass_op.doc = "The enums.StencilOperation performed if both the stencil and depth tests pass. Defaults to keep." + +[structs.VertexState] +doc = """ +Describes the vertex shader stage and vertex buffers of a render pipeline. + +Used in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. +""" +fields.module.doc = "The GPUShaderModule containing the vertex shader code." +fields.entry_point.doc = "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." +fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." +fields.buffers.doc = "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." + +[structs.VertexBufferLayout] +doc = """ +Describes the layout of a vertex buffer. + +Used in the buffers field of structs.VertexState. +""" +fields.array_stride.doc = "The stride in bytes between consecutive elements in the buffer." +fields.step_mode.doc = "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." +fields.attributes.doc = "A list of structs.VertexAttribute describing the attributes in each element." + +[structs.VertexAttribute] +doc = """ +Describes a single vertex attribute within a vertex buffer. + +Used in the attributes field of structs.VertexBufferLayout. +""" +fields.format.doc = "The enums.VertexFormat of the attribute." +fields.offset.doc = "The offset in bytes of the attribute from the start of an element in the buffer." +fields.shader_location.doc = "The location number of the attribute in the vertex shader (the @location attribute)." + +[structs.TexelCopyBufferLayout] +doc = """ +Describes the layout of texel data in a buffer or in a block of memory. + +Used as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo. +""" +fields.offset.doc = "The offset in bytes into the data where the texel data starts. Defaults to 0." +fields.bytes_per_row.doc = "The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256 for buffer copies." +fields.rows_per_image.doc = "The number of rows per image (layer or slice). Required if there is more than one image." + +[structs.TexelCopyBufferInfo] +doc = """ +Describes a buffer and the layout of texel data in it. + +Used as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer(). +Extends structs.TexelCopyBufferLayout. +""" +fields.offset.doc = "The offset in bytes into the buffer where the texel data starts. Defaults to 0." +fields.bytes_per_row.doc = "The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256." +fields.rows_per_image.doc = "The number of rows per image (layer or slice). Required if there is more than one image." +fields.buffer.doc = "The GPUBuffer that contains (or will contain) the texel data." + +[structs.TexelCopyTextureInfo] +doc = """ +Describes a texture and the part of it that is the source or destination of a copy. + +Used in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(), +GPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture(). +""" +fields.texture.doc = "The GPUTexture to copy to or from." +fields.mip_level.doc = "The mip level to copy to or from. Defaults to 0." +fields.origin.doc = "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." +fields.aspect.doc = "Which aspect of the texture to copy, see enums.TextureAspect. Defaults to all." + +[structs.CopyExternalImageDestInfo] +doc = """ +Describes the destination texture of GPUQueue.copy_external_image_to_texture(). + +Extends structs.TexelCopyTextureInfo with color space information. +""" +fields.texture.doc = "The GPUTexture to copy to." +fields.mip_level.doc = "The mip level to copy to. Defaults to 0." +fields.origin.doc = "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." +fields.aspect.doc = "Which aspect of the texture to copy to, see enums.TextureAspect. Defaults to all." +fields.color_space.doc = "The color space to encode the copied image data in, e.g. 'srgb'. Defaults to 'srgb'." +fields.premultiplied_alpha.doc = "If true, the color channels are premultiplied by the alpha channel when written. Defaults to false." + +[structs.CopyExternalImageSourceInfo] +doc = """ +Describes the source of GPUQueue.copy_external_image_to_texture(). + +Used as the source argument of that method. +""" +fields.source.doc = "The image source, e.g. an image, canvas or video frame. Only meaningful in browser environments (in Python, e.g. an array or PIL image may be supported)." +fields.origin.doc = "The origin in the source image to start copying from, as a structs.Origin2D or a tuple (x, y). Defaults to (0, 0)." +fields.flip_y.doc = "If true, the source image is flipped vertically before copying. Defaults to false." + +[structs.CommandBufferDescriptor] +doc = """ +Descriptor for a GPUCommandBuffer. + +Used as the descriptor argument of the GPUCommandEncoder.finish() method. +""" +fields.label.doc = "A human-readable label for the command buffer, used in debugging and error messages." + +[structs.CommandEncoderDescriptor] +doc = """ +Descriptor for creating a GPUCommandEncoder. + +Used as the descriptor argument of the GPUDevice.create_command_encoder() method. +""" +fields.label.doc = "A human-readable label for the command encoder, used in debugging and error messages." + +[structs.ComputePassTimestampWrites] +doc = """ +Describes where to write timestamps for a compute pass. + +Used in the timestamp_writes field of structs.ComputePassDescriptor. Requires feature timestamp_query. +""" +fields.query_set.doc = "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." +fields.beginning_of_pass_write_index.doc = "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." +fields.end_of_pass_write_index.doc = "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." + +[structs.ComputePassDescriptor] +doc = """ +Descriptor for beginning a compute pass. + +Used as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method. +""" +fields.label.doc = "A human-readable label for the compute pass, used in debugging and error messages." +fields.timestamp_writes.doc = "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." + +[structs.RenderPassTimestampWrites] +doc = """ +Describes where to write timestamps for a render pass. + +Used in the timestamp_writes field of structs.RenderPassDescriptor. Requires feature timestamp_query. +""" +fields.query_set.doc = "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." +fields.beginning_of_pass_write_index.doc = "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." +fields.end_of_pass_write_index.doc = "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." + +[structs.RenderPassDescriptor] +doc = """ +Descriptor for beginning a render pass. + +Used as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method. +""" +fields.label.doc = "A human-readable label for the render pass, used in debugging and error messages." +fields.color_attachments.doc = "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to." +fields.depth_stencil_attachment.doc = "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." +fields.occlusion_query_set.doc = "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." +fields.timestamp_writes.doc = "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." +fields.max_draw_count.doc = "The maximum number of draw calls that will be done in the pass, used as a hint for the implementation. Defaults to 50000000." + +[structs.RenderPassColorAttachment] +doc = """ +Describes a color attachment of a render pass. + +Used in the color_attachments field of structs.RenderPassDescriptor. +""" +fields.view.doc = "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." +fields.depth_slice.doc = "For 3D textures, the index of the depth slice to render to." +fields.resolve_target.doc = "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." +fields.clear_value.doc = "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." +fields.load_op.doc = "What to do with the existing contents at the start of the pass, see enums.LoadOp." +fields.store_op.doc = "What to do with the results at the end of the pass, see enums.StoreOp." + +[structs.RenderPassDepthStencilAttachment] +doc = """ +Describes the depth-stencil attachment of a render pass. + +Used in the depth_stencil_attachment field of structs.RenderPassDescriptor. +""" +fields.view.doc = "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." +fields.depth_clear_value.doc = "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." +fields.depth_load_op.doc = "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." +fields.depth_store_op.doc = "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." +fields.depth_read_only.doc = "If true, the depth aspect is read-only in the pass (it is not written to). Defaults to false." +fields.stencil_clear_value.doc = "The value to clear the stencil aspect to if stencil_load_op is clear. Defaults to 0." +fields.stencil_load_op.doc = "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." +fields.stencil_store_op.doc = "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." +fields.stencil_read_only.doc = "If true, the stencil aspect is read-only in the pass (it is not written to). Defaults to false." + +[structs.RenderPassLayout] +doc = """ +Describes the attachment formats of a render pass or render bundle. + +This is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with +passes (or bundles) whose layout is compatible with the pipeline. +""" +fields.label.doc = "A human-readable label, used in debugging and error messages." +fields.color_formats.doc = "A list of enums.TextureFormat (or None for unused slots) of the color attachments." +fields.depth_stencil_format.doc = "The enums.TextureFormat of the depth-stencil attachment, if any." +fields.sample_count.doc = "The number of samples per pixel of the attachments. Defaults to 1." + +[structs.RenderBundleDescriptor] +doc = """ +Descriptor for a GPURenderBundle. + +Used as the descriptor argument of the GPURenderBundleEncoder.finish() method. +""" +fields.label.doc = "A human-readable label for the render bundle, used in debugging and error messages." + +[structs.RenderBundleEncoderDescriptor] +doc = """ +Descriptor for creating a GPURenderBundleEncoder. + +Used as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method. +Extends structs.RenderPassLayout. +""" +fields.label.doc = "A human-readable label for the render bundle encoder, used in debugging and error messages." +fields.color_formats.doc = "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." +fields.depth_stencil_format.doc = "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." +fields.sample_count.doc = "The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1." +fields.depth_read_only.doc = "If true, the bundle does not write to the depth aspect. Defaults to false." +fields.stencil_read_only.doc = "If true, the bundle does not write to the stencil aspect. Defaults to false." + +[structs.QueueDescriptor] +doc = """ +Descriptor for a GPUQueue. + +Used in the default_queue field of structs.DeviceDescriptor. +""" +fields.label.doc = "A human-readable label for the queue, used in debugging and error messages." + +[structs.QuerySetDescriptor] +doc = """ +Descriptor for creating a GPUQuerySet. + +Used as the descriptor argument of the GPUDevice.create_query_set() method. +""" +fields.label.doc = "A human-readable label for the query set, used in debugging and error messages." +fields.type.doc = "The type of queries in the set, see enums.QueryType." +fields.count.doc = "The number of queries in the set." + +[structs.CanvasToneMapping] +doc = """ +Describes the tone mapping of a canvas. + +Used in the tone_mapping field of structs.CanvasConfiguration. +""" +fields.mode.doc = "The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard." + +[structs.CanvasConfiguration] +doc = """ +Configuration for a GPUCanvasContext. + +Used as the configuration argument of the GPUCanvasContext.configure() method. +""" +fields.device.doc = "The GPUDevice that the canvas textures will be used with." +fields.format.doc = "The enums.TextureFormat of the canvas textures. Use GPU.get_preferred_canvas_format() for the best choice." +fields.usage.doc = "The allowed usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT." +fields.view_formats.doc = "Additional enums.TextureFormat values that views of the canvas texture may use." +fields.color_space.doc = "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." +fields.tone_mapping.doc = "A structs.CanvasToneMapping that describes how the canvas content is tone mapped." +fields.alpha_mode.doc = "How the alpha channel of the canvas is interpreted, see enums.CanvasAlphaMode. Defaults to opaque." + +[structs.UncapturedErrorEventInit] +doc = """ +Initialization data for an uncaptured error event. + +The event is passed to the callback set via the onuncapturederror property of GPUDevice. +""" +fields.error.doc = "The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope." + +[structs.Color] +doc = """ +An RGBA color with floating point components. + +Can also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment. +""" +fields.r.doc = "The red component." +fields.g.doc = "The green component." +fields.b.doc = "The blue component." +fields.a.doc = "The alpha component." + +[structs.Origin2D] +doc = """ +A 2D origin (offset) in a texture or image, in texels. + +Can also be given as a tuple (x, y). +""" +fields.x.doc = "The x coordinate (horizontal). Defaults to 0." +fields.y.doc = "The y coordinate (vertical). Defaults to 0." + +[structs.Origin3D] +doc = """ +A 3D origin (offset) in a texture, in texels. + +Can also be given as a tuple (x, y, z). +""" +fields.x.doc = "The x coordinate (horizontal). Defaults to 0." +fields.y.doc = "The y coordinate (vertical). Defaults to 0." +fields.z.doc = "The z coordinate (depth, or array layer). Defaults to 0." + +[structs.Extent3D] +doc = """ +A 3D size (extent) of a texture, in texels. + +Can also be given as a tuple (width, height, depth_or_array_layers). +""" +fields.width.doc = "The width of the extent." +fields.height.doc = "The height of the extent. Defaults to 1." +fields.depth_or_array_layers.doc = "The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1." + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[classes] + +[classes.GPUObjectBase] +doc = """ +The base class of all GPU objects. + +It provides the label property that is shared by all objects in the API. +""" +properties.label.doc = "A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it." +[classes.GPUObjectBase.methods] + +[classes.GPUAdapterInfo] +doc = """ +Information about a physical adapter (GPU). + +An instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice. +The values are strings that are possibly empty if the information is not available. +""" +properties.vendor.doc = "The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'." +properties.architecture.doc = "The name of the family or class of GPUs the adapter belongs to." +properties.device.doc = "A vendor-specific identifier of the adapter." +properties.description.doc = "A human-readable description of the adapter, e.g. the name of the GPU." +properties.subgroup_min_size.doc = "The minimum supported subgroup size of the adapter." +properties.subgroup_max_size.doc = "The maximum supported subgroup size of the adapter." +properties.is_fallback_adapter.doc = "Whether this is a fallback adapter, e.g. a software renderer." +[classes.GPUAdapterInfo.methods] + +[classes.GPU] +doc = """ +The entry point of the API. + +It is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu. +""" +properties.wgsl_language_features.doc = "The set of WGSL language features that are supported by the implementation." +[classes.GPU.methods] +[classes.GPU.methods.request_adapter] +doc = """ +Request a GPUAdapter, which represents a physical GPU (or a software equivalent). + +The adapter can be used to inspect the capabilities (features and limits) of the GPU, +and to request a GPUDevice. If no suitable adapter is available, None is returned. +""" +returns.doc = "A GPUAdapter, or None if no suitable adapter was found." +args.options.doc = "A structs.RequestAdapterOptions with options for selecting the adapter." +[classes.GPU.methods.get_preferred_canvas_format] +doc = """ +Get the preferred texture format for presenting to a canvas. + +Using this format for the format field of structs.CanvasConfiguration avoids a conversion when presenting. +""" +returns.doc = "An enums.TextureFormat, either rgba8unorm or bgra8unorm." + +[classes.GPUAdapter] +doc = """ +Represents a physical GPU (or a software implementation of one). + +An adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice, +which is used to do actual work. Adapters are obtained via GPU.request_adapter(). +""" +properties.features.doc = "The set of enums.FeatureName that the adapter supports." +properties.limits.doc = "A mapping of limit names to the maximum values supported by the adapter." +properties.info.doc = "A GPUAdapterInfo with information about the adapter." +[classes.GPUAdapter.methods] +[classes.GPUAdapter.methods.request_device] +doc = """ +Request a GPUDevice from the adapter. + +The device is the main object used to create resources and to submit work. An adapter can +only provide a single device; if it was already used, or if the requested features or limits +are not supported, the request fails. +""" +returns.doc = "A GPUDevice." +args.descriptor.doc = "A structs.DeviceDescriptor with the required features and limits." + +[classes.GPUDevice] +doc = """ +The main object that is used to create GPU resources and to submit work. + +A device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue +(the queue property) which is used to submit work to the GPU. Most resources +(buffers, textures, pipelines, etc.) are created using the create_* methods of the device. +""" +properties.features.doc = "The set of enums.FeatureName that are enabled on the device." +properties.limits.doc = "A mapping of limit names to the values that are in effect for the device." +properties.adapter_info.doc = "A GPUAdapterInfo with information about the adapter that this device was created from." +properties.queue.doc = "The default GPUQueue of the device." +properties.lost.doc = "A promise or future that resolves to a GPUDeviceLostInfo when the device is lost." +properties.onuncapturederror.doc = "A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope." +[classes.GPUDevice.methods] +[classes.GPUDevice.methods.destroy] +doc = """ +Destroy the device and release its resources. + +The device is lost with the reason enums.DeviceLostReason.destroyed. All resources created by the device become unusable. +""" +returns.doc = "None." +[classes.GPUDevice.methods.create_buffer] +doc = """ +Create a GPUBuffer, a block of memory that can be used by the GPU. + +Data can be written to the buffer using GPUQueue.write_buffer(), copy commands, or by mapping it (see GPUBuffer.map_async()). +""" +returns.doc = "A GPUBuffer." +args.descriptor.doc = "A structs.BufferDescriptor describing the buffer." +[classes.GPUDevice.methods.create_texture] +doc = """ +Create a GPUTexture, an image resource (1D, 2D or 3D) that can be sampled or rendered to. + +Textures are not accessed directly by shaders; use GPUTexture.create_view() to obtain a GPUTextureView. +""" +returns.doc = "A GPUTexture." +args.descriptor.doc = "A structs.TextureDescriptor describing the texture." +[classes.GPUDevice.methods.create_sampler] +doc = """ +Create a GPUSampler, which defines how a texture is sampled (filtering and addressing) in a shader. +""" +returns.doc = "A GPUSampler." +args.descriptor.doc = "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." +[classes.GPUDevice.methods.import_external_texture] +doc = """ +Import an external image source, such as a video frame, as a texture that can be sampled in a shader. + +The resulting object is only valid for a short time (until the end of the current frame/task), after which it must be re-imported. +This is mostly relevant in browser environments. +""" +returns.doc = "A GPUExternalTexture." +args.descriptor.doc = "A structs.ExternalTextureDescriptor describing the source." +[classes.GPUDevice.methods.create_bind_group_layout] +doc = """ +Create a GPUBindGroupLayout, which describes the types and visibility of the resources in a bind group. + +A bind group layout is used in create_bind_group() and create_pipeline_layout(). +""" +returns.doc = "A GPUBindGroupLayout." +args.descriptor.doc = "A structs.BindGroupLayoutDescriptor describing the entries of the layout." +[classes.GPUDevice.methods.create_pipeline_layout] +doc = """ +Create a GPUPipelineLayout, which describes all bind groups (and immediate data) used by a pipeline. +""" +returns.doc = "A GPUPipelineLayout." +args.descriptor.doc = "A structs.PipelineLayoutDescriptor describing the bind group layouts." +[classes.GPUDevice.methods.create_bind_group] +doc = """ +Create a GPUBindGroup, which binds actual resources (buffers, textures, samplers) to the slots described by a layout. + +Bind groups are set on a pass encoder with GPUBindingCommandsMixin.set_bind_group(). +""" +returns.doc = "A GPUBindGroup." +args.descriptor.doc = "A structs.BindGroupDescriptor with the layout and the resources to bind." +[classes.GPUDevice.methods.create_shader_module] +doc = """ +Create a GPUShaderModule from shader source code (WGSL). + +Compilation errors do not raise immediately; use GPUShaderModule.get_compilation_info() to inspect messages, +or use error scopes (see push_error_scope()). +""" +returns.doc = "A GPUShaderModule." +args.descriptor.doc = "A structs.ShaderModuleDescriptor containing the shader code." +[classes.GPUDevice.methods.create_compute_pipeline] +doc = """ +Create a GPUComputePipeline, which describes a compute shader and its resources. + +Shader compilation may happen synchronously; use create_compute_pipeline_async() to avoid blocking. +""" +returns.doc = "A GPUComputePipeline." +args.descriptor.doc = "A structs.ComputePipelineDescriptor describing the pipeline." +[classes.GPUDevice.methods.create_render_pipeline] +doc = """ +Create a GPURenderPipeline, which describes the full state of the graphics pipeline: shaders, vertex layout, rasterization, depth/stencil, blending and render targets. + +Shader compilation may happen synchronously; use create_render_pipeline_async() to avoid blocking. +""" +returns.doc = "A GPURenderPipeline." +args.descriptor.doc = "A structs.RenderPipelineDescriptor describing the pipeline." +[classes.GPUDevice.methods.create_compute_pipeline_async] +doc = """ +Asynchronous version of create_compute_pipeline(). + +The pipeline is created without blocking. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device. +""" +returns.doc = "A GPUComputePipeline (awaitable)." +args.descriptor.doc = "A structs.ComputePipelineDescriptor describing the pipeline." +[classes.GPUDevice.methods.create_render_pipeline_async] +doc = """ +Asynchronous version of create_render_pipeline(). + +The pipeline is created without blocking. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device. +""" +returns.doc = "A GPURenderPipeline (awaitable)." +args.descriptor.doc = "A structs.RenderPipelineDescriptor describing the pipeline." +[classes.GPUDevice.methods.create_command_encoder] +doc = """ +Create a GPUCommandEncoder, used to record GPU commands (passes and copies). + +Finish the encoder with GPUCommandEncoder.finish() and submit the result with GPUQueue.submit(). +""" +returns.doc = "A GPUCommandEncoder." +args.descriptor.doc = "A structs.CommandEncoderDescriptor. Optional." +[classes.GPUDevice.methods.create_render_bundle_encoder] +doc = """ +Create a GPURenderBundleEncoder, used to pre-record a sequence of render commands that can be replayed in many render passes. + +The attachment formats given in the descriptor determine in which render passes the resulting bundle can be used. +""" +returns.doc = "A GPURenderBundleEncoder." +args.descriptor.doc = "A structs.RenderBundleEncoderDescriptor describing the attachment formats." +[classes.GPUDevice.methods.create_query_set] +doc = """ +Create a GPUQuerySet, a set of queries that hold e.g. occlusion or timestamp results. + +Results are written during passes and can be retrieved with GPUCommandEncoder.resolve_query_set(). +""" +returns.doc = "A GPUQuerySet." +args.descriptor.doc = "A structs.QuerySetDescriptor describing the type and count of queries." +[classes.GPUDevice.methods.push_error_scope] +doc = """ +Push a new error scope onto the device's error scope stack. + +While the scope is active, errors of the given type that are generated by operations on this device are +captured by the scope (instead of triggering the onuncapturederror callback). Retrieve them with pop_error_scope(). +""" +returns.doc = "None." +args.filter.doc = "The type of error to capture, see enums.ErrorFilter." +[classes.GPUDevice.methods.pop_error_scope] +doc = """ +Pop the most recent error scope from the stack and return the first error it captured. + +Errors are only reported once all operations in the scope have been processed. +""" +returns.doc = "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." + +[classes.GPUBuffer] +doc = """ +A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage. + +Buffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or +copy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the +buffer cannot be used by the GPU while it is mapped. +""" +properties.size.doc = "The size of the buffer in bytes." +properties.usage.doc = "The usage of the buffer, a combination of flags.BufferUsage." +properties.map_state.doc = "The current mapping state of the buffer, see enums.BufferMapState." +[classes.GPUBuffer.methods] +[classes.GPUBuffer.methods.map_async] +doc = """ +Map (a part of) the buffer so its memory can be accessed by the CPU. + +The returned promise or future resolves when the buffer is mapped. Once mapped, use get_mapped_range() +to access the data, and call unmap() when done to give the buffer back to the GPU. +""" +returns.doc = "None (awaitable); resolves when the buffer is mapped." +args.mode.doc = "Whether to map for reading or writing, see flags.MapMode." +args.offset.doc = "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." +args.size.doc = "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." +[classes.GPUBuffer.methods.get_mapped_range] +doc = """ +Get a view on the memory of a mapped part of the buffer. + +The buffer must be mapped (see map_async() or the mapped_at_creation field of structs.BufferDescriptor). +The returned memory becomes invalid when the buffer is unmapped. +""" +returns.doc = "A writable memory view (e.g. a memoryview) on the mapped range." +args.offset.doc = "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." +args.size.doc = "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." +[classes.GPUBuffer.methods.unmap] +doc = """ +Unmap the buffer, making any mapped memory invalid, and handing the buffer back to the GPU. + +If the buffer was mapped for writing, the written data becomes visible to the GPU. +""" +returns.doc = "None." +[classes.GPUBuffer.methods.destroy] +doc = """ +Destroy the buffer and free its memory. + +The buffer can no longer be used. Calling this multiple times is allowed. +""" +returns.doc = "None." + +[classes.GPUTexture] +doc = """ +An image resource of one, two or three dimensions, optionally with mip levels and array layers. + +Textures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render +attachment, create a GPUTextureView with create_view(). +""" +properties.width.doc = "The width of the texture in texels." +properties.height.doc = "The height of the texture in texels." +properties.depth_or_array_layers.doc = "The depth (for 3D textures) or the number of array layers of the texture." +properties.mip_level_count.doc = "The number of mip levels of the texture." +properties.sample_count.doc = "The number of samples per pixel of the texture (1 unless multisampled)." +properties.dimension.doc = "The dimensionality of the texture, see enums.TextureDimension." +properties.format.doc = "The pixel format of the texture, see enums.TextureFormat." +properties.usage.doc = "The allowed usages of the texture, a combination of flags.TextureUsage." +properties.texture_binding_view_dimension.doc = "Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding." +[classes.GPUTexture.methods] +[classes.GPUTexture.methods.create_view] +doc = """ +Create a GPUTextureView, a specific view of (part of) the texture. + +The view is what gets bound to shaders or used as a render attachment. +""" +returns.doc = "A GPUTextureView." +args.descriptor.doc = "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." +[classes.GPUTexture.methods.destroy] +doc = """ +Destroy the texture and free its memory. + +The texture can no longer be used. Calling this multiple times is allowed. +""" +returns.doc = "None." + +[classes.GPUTextureView] +doc = """ +A view on (a part of) a GPUTexture. + +Texture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry) +and as render pass attachments (see structs.RenderPassColorAttachment). +""" +[classes.GPUTextureView.methods] + +[classes.GPUSampler] +doc = """ +Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture. + +Samplers are created with GPUDevice.create_sampler(). +""" +[classes.GPUSampler.methods] + +[classes.GPUBindGroupLayout] +doc = """ +Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup. + +Bind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline +via GPUPipelineBase.get_bind_group_layout(). +""" +[classes.GPUBindGroupLayout.methods] + +[classes.GPUBindGroup] +doc = """ +A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout. + +Bind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group(). +""" +[classes.GPUBindGroup.methods] + +[classes.GPUPipelineLayout] +doc = """ +Describes the bind group layouts (and immediate data size) that a pipeline uses. + +Pipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto. +""" +[classes.GPUPipelineLayout.methods] + +[classes.GPUShaderModule] +doc = """ +A compiled piece of shader code (WGSL), containing one or more entry points. + +Shader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage). +""" +[classes.GPUShaderModule.methods] +[classes.GPUShaderModule.methods.get_compilation_info] +doc = """ +Get diagnostic messages (errors, warnings, info) produced when compiling the shader. +""" +returns.doc = "A GPUCompilationInfo (awaitable) with the list of messages." + +[classes.GPUCompilationMessage] +doc = """ +A single diagnostic message produced when compiling a shader module. + +The messages are available via the messages property of GPUCompilationInfo. +""" +properties.message.doc = "The human-readable text of the message." +properties.type.doc = "The severity of the message, see enums.CompilationMessageType." +properties.line_num.doc = "The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line." +properties.line_pos.doc = "The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position." +properties.offset.doc = "The offset in the shader code (in UTF-16 code units) that the message refers to." +properties.length.doc = "The length (in UTF-16 code units) of the span in the shader code that the message refers to." +[classes.GPUCompilationMessage.methods] + +[classes.GPUCompilationInfo] +doc = """ +The diagnostic messages produced when compiling a shader module. + +Obtained from GPUShaderModule.get_compilation_info(). +""" +properties.messages.doc = "A list of GPUCompilationMessage objects." +[classes.GPUCompilationInfo.methods] + +[classes.GPUPipelineError] +doc = """ +The error that is raised when asynchronous pipeline creation fails. + +Raised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async(). +""" +properties.reason.doc = "The reason for the failure, see enums.PipelineErrorReason." +[classes.GPUPipelineError.methods] +[classes.GPUPipelineError.methods.constructor] +doc = """ +Create a GPUPipelineError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = "A GPUPipelineError." +args.message.doc = "The human-readable error message." +args.options.doc = "A structs.PipelineErrorInit with the reason of the error." + +[classes.GPUPipelineBase] +doc = """ +The base class for GPUComputePipeline and GPURenderPipeline. + +It provides access to the bind group layouts of the pipeline. +""" +[classes.GPUPipelineBase.methods] +[classes.GPUPipelineBase.methods.get_bind_group_layout] +doc = """ +Get the GPUBindGroupLayout of the pipeline for the given bind group index. + +This is especially useful for pipelines created with enums.AutoLayoutMode.auto, where the layouts are derived from the shader. +""" +returns.doc = "A GPUBindGroupLayout." +args.index.doc = "The index of the bind group (the @group number in the shader)." + +[classes.GPUComputePipeline] +doc = """ +A pipeline that describes a compute shader and its resources. + +Created with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline(). +""" +[classes.GPUComputePipeline.methods] + +[classes.GPURenderPipeline] +doc = """ +A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending. + +Created with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline(). +""" +[classes.GPURenderPipeline.methods] + +[classes.GPUCommandBuffer] +doc = """ +A recorded list of GPU commands, ready to be submitted. + +Obtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once. +""" +[classes.GPUCommandBuffer.methods] + +[classes.GPUCommandsMixin] +doc = """ +A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +It has no methods of its own in the current version of the API. +""" +[classes.GPUCommandsMixin.methods] + +[classes.GPUCommandEncoder] +doc = """ +Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer. + +Create one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit(). +Only one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands. +""" +[classes.GPUCommandEncoder.methods] +[classes.GPUCommandEncoder.methods.begin_render_pass] +doc = """ +Begin a render pass, returning a GPURenderPassEncoder to record draw commands with. + +The pass must be ended with GPURenderPassEncoder.end() before the encoder can be used again. +""" +returns.doc = "A GPURenderPassEncoder." +args.descriptor.doc = "A structs.RenderPassDescriptor describing the attachments of the pass." +[classes.GPUCommandEncoder.methods.begin_compute_pass] +doc = """ +Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with. + +The pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again. +""" +returns.doc = "A GPUComputePassEncoder." +args.descriptor.doc = "A structs.ComputePassDescriptor. Optional." +[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] +doc = """ +Copy data from one GPUBuffer to another. + +The source needs flags.BufferUsage.COPY_SRC and the destination flags.BufferUsage.COPY_DST. +Offsets and size must be multiples of 4, and the ranges must not overlap if the buffers are the same. +""" +returns.doc = "None." +args.source.doc = "The GPUBuffer to copy from." +args.source_offset.doc = "The offset in bytes in the source buffer where the copy starts." +args.destination.doc = "The GPUBuffer to copy to." +args.destination_offset.doc = "The offset in bytes in the destination buffer where the data is written." +args.size.doc = "The number of bytes to copy." +[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] +doc = """ +Copy data from a GPUBuffer to a GPUTexture. + +The source buffer needs flags.BufferUsage.COPY_SRC and the texture flags.TextureUsage.COPY_DST. +""" +returns.doc = "None." +args.source.doc = "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." +args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." +args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." +[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] +doc = """ +Copy data from a GPUTexture to a GPUBuffer. + +The texture needs flags.TextureUsage.COPY_SRC and the destination buffer flags.BufferUsage.COPY_DST. +""" +returns.doc = "None." +args.source.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." +args.destination.doc = "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." +args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." +[classes.GPUCommandEncoder.methods.copy_texture_to_texture] +doc = """ +Copy data from one GPUTexture to another. + +The source needs flags.TextureUsage.COPY_SRC and the destination flags.TextureUsage.COPY_DST. +The formats must be compatible, and the sample counts equal. +""" +returns.doc = "None." +args.source.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." +args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." +args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." +[classes.GPUCommandEncoder.methods.clear_buffer] +doc = """ +Fill (a part of) a GPUBuffer with zeros. + +The buffer needs flags.BufferUsage.COPY_DST. +""" +returns.doc = "None." +args.buffer.doc = "The GPUBuffer to clear." +args.offset.doc = "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." +args.size.doc = "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." +[classes.GPUCommandEncoder.methods.resolve_query_set] +doc = """ +Resolve the results of queries in a GPUQuerySet into a GPUBuffer. + +The destination buffer needs flags.BufferUsage.QUERY_RESOLVE. Each result is written as a 64-bit unsigned integer. +""" +returns.doc = "None." +args.query_set.doc = "The GPUQuerySet to read results from." +args.first_query.doc = "The index of the first query to resolve." +args.query_count.doc = "The number of queries to resolve." +args.destination.doc = "The GPUBuffer to write the results to." +args.destination_offset.doc = "The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256." +[classes.GPUCommandEncoder.methods.finish] +doc = """ +Finish recording and return a GPUCommandBuffer. + +The command buffer can be submitted with GPUQueue.submit(). The encoder cannot be used after this call. +""" +returns.doc = "A GPUCommandBuffer." +args.descriptor.doc = "A structs.CommandBufferDescriptor. Optional." + +[classes.GPUBindingCommandsMixin] +doc = """ +A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +It provides methods to set bind groups and immediate data. +""" +[classes.GPUBindingCommandsMixin.methods] +[classes.GPUBindingCommandsMixin.methods.set_bind_group] +doc = """ +Set a GPUBindGroup for the given bind group index, to be used by subsequent draw or dispatch commands. + +The bind group must be compatible with the layout of the pipeline. If the layout has entries with +dynamic offsets (see the has_dynamic_offset field of structs.BufferBindingLayout), offsets must be provided. +The dynamic offsets can be given as a list, or as a range of an array (using the start and length arguments). +""" +returns.doc = "None." +args.index.doc = "The index of the bind group (the @group number in the shader)." +args.bind_group.doc = "The GPUBindGroup to set, or None to unset it." +args.dynamic_offsets_data.doc = "A list or array of offsets in bytes, one for each dynamic buffer binding, in order of binding number." +args.dynamic_offsets_data_start.doc = "If dynamic_offsets_data is an array, the index of the first offset to use." +args.dynamic_offsets_data_length.doc = "If dynamic_offsets_data is an array, the number of offsets to use." +[classes.GPUBindingCommandsMixin.methods.set_immediates] +doc = """ +Set immediate data: a small amount of data (typically a few hundred bytes at most) that is passed to shaders directly without a buffer. + +The size of the immediate data is determined by the immediate_size field of structs.PipelineLayoutDescriptor. +""" +returns.doc = "None." +args.range_offset.doc = "The offset in bytes in the immediate data range where the data is written. Must be a multiple of 4." +args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." +args.data_offset.doc = "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." +args.data_size.doc = "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." + +[classes.GPUDebugCommandsMixin] +doc = """ +A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +Debug groups and markers show up in debugging tools and in error messages. +""" +[classes.GPUDebugCommandsMixin.methods] +[classes.GPUDebugCommandsMixin.methods.push_debug_group] +doc = """ +Begin a labeled debug group. Every call must be matched with a call to pop_debug_group(). +""" +returns.doc = "None." +args.group_label.doc = "The label of the debug group." +[classes.GPUDebugCommandsMixin.methods.pop_debug_group] +doc = """ +End the most recent debug group that was started with push_debug_group(). +""" +returns.doc = "None." +[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] +doc = """ +Insert a single labeled marker into the command stream. +""" +returns.doc = "None." +args.marker_label.doc = "The label of the marker." + +[classes.GPUComputePassEncoder] +doc = """ +Records the commands of a compute pass. + +Created with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work, +and finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin. +""" +[classes.GPUComputePassEncoder.methods] +[classes.GPUComputePassEncoder.methods.set_pipeline] +doc = """ +Set the GPUComputePipeline to use for subsequent dispatch commands. +""" +returns.doc = "None." +args.pipeline.doc = "The GPUComputePipeline to use." +[classes.GPUComputePassEncoder.methods.dispatch_workgroups] +doc = """ +Run the compute shader of the current pipeline for a grid of workgroups. + +The total number of invocations is the number of workgroups times the workgroup size defined in the shader. +""" +returns.doc = "None." +args.workgroup_count_x.doc = "The number of workgroups in the x dimension." +args.workgroup_count_y.doc = "The number of workgroups in the y dimension. Defaults to 1." +args.workgroup_count_z.doc = "The number of workgroups in the z dimension. Defaults to 1." +[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] +doc = """ +Like dispatch_workgroups(), but the workgroup counts are read from a GPUBuffer. + +The buffer must have flags.BufferUsage.INDIRECT, and contain three consecutive 32-bit unsigned integers (x, y, z) at the given offset. +""" +returns.doc = "None." +args.indirect_buffer.doc = "The GPUBuffer that contains the workgroup counts." +args.indirect_offset.doc = "The offset in bytes in the buffer where the counts start. Must be a multiple of 4." +[classes.GPUComputePassEncoder.methods.end] +doc = """ +End the compute pass. The encoder can no longer be used afterwards. +""" +returns.doc = "None." + +[classes.GPURenderPassEncoder] +doc = """ +Records the commands of a render pass. + +Created with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers, +draw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin. +""" +[classes.GPURenderPassEncoder.methods] +[classes.GPURenderPassEncoder.methods.set_viewport] +doc = """ +Set the viewport: the region of the attachments that the clip-space output is mapped to. + +Defaults to the full size of the attachments. +""" +returns.doc = "None." +args.x.doc = "The x coordinate of the top-left corner of the viewport, in pixels." +args.y.doc = "The y coordinate of the top-left corner of the viewport, in pixels." +args.width.doc = "The width of the viewport, in pixels." +args.height.doc = "The height of the viewport, in pixels." +args.min_depth.doc = "The minimum depth value of the viewport (between 0 and 1)." +args.max_depth.doc = "The maximum depth value of the viewport (between 0 and 1)." +[classes.GPURenderPassEncoder.methods.set_scissor_rect] +doc = """ +Set the scissor rectangle: fragments outside of this rectangle are discarded. + +Defaults to the full size of the attachments. +""" +returns.doc = "None." +args.x.doc = "The x coordinate of the top-left corner of the rectangle, in pixels." +args.y.doc = "The y coordinate of the top-left corner of the rectangle, in pixels." +args.width.doc = "The width of the rectangle, in pixels." +args.height.doc = "The height of the rectangle, in pixels." +[classes.GPURenderPassEncoder.methods.set_blend_constant] +doc = """ +Set the blend constant color, used by blend factors enums.BlendFactor.constant and enums.BlendFactor.one_minus_constant. + +Defaults to transparent black (0, 0, 0, 0). +""" +returns.doc = "None." +args.color.doc = "The color, as a structs.Color or a tuple (r, g, b, a)." +[classes.GPURenderPassEncoder.methods.set_stencil_reference] +doc = """ +Set the stencil reference value, used in stencil comparisons and by enums.StencilOperation.replace. + +Defaults to 0. +""" +returns.doc = "None." +args.reference.doc = "The stencil reference value (an unsigned integer)." +[classes.GPURenderPassEncoder.methods.begin_occlusion_query] +doc = """ +Begin an occlusion query, which counts the samples that pass the depth and stencil tests. + +The result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor). +End the query with end_occlusion_query(). +""" +returns.doc = "None." +args.query_index.doc = "The index in the query set where the result is stored." +[classes.GPURenderPassEncoder.methods.end_occlusion_query] +doc = """ +End the occlusion query that was started with begin_occlusion_query(). +""" +returns.doc = "None." +[classes.GPURenderPassEncoder.methods.execute_bundles] +doc = """ +Execute pre-recorded GPURenderBundle objects as part of this pass. + +After executing bundles, the pipeline, bind groups and vertex/index buffers need to be set again. +""" +returns.doc = "None." +args.bundles.doc = "A list of GPURenderBundle objects to execute, in order." +[classes.GPURenderPassEncoder.methods.end] +doc = """ +End the render pass. The encoder can no longer be used afterwards. +""" +returns.doc = "None." + +[classes.GPURenderCommandsMixin] +doc = """ +A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder. + +It provides methods to set the pipeline, vertex and index buffers, and to draw. +""" +[classes.GPURenderCommandsMixin.methods] +[classes.GPURenderCommandsMixin.methods.set_pipeline] +doc = """ +Set the GPURenderPipeline to use for subsequent draw commands. +""" +returns.doc = "None." +args.pipeline.doc = "The GPURenderPipeline to use." +[classes.GPURenderCommandsMixin.methods.set_index_buffer] +doc = """ +Set the index buffer to use for subsequent indexed draw commands. + +The buffer needs flags.BufferUsage.INDEX. +""" +returns.doc = "None." +args.buffer.doc = "The GPUBuffer that contains the indices." +args.index_format.doc = "The data type of the indices, see enums.IndexFormat." +args.offset.doc = "The offset in bytes in the buffer where the indices start. Defaults to 0." +args.size.doc = "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." +[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] +doc = """ +Set a vertex buffer for the given slot, to be used by subsequent draw commands. + +The buffer needs flags.BufferUsage.VERTEX. The layout is defined by the buffers field of structs.VertexState. +""" +returns.doc = "None." +args.slot.doc = "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." +args.buffer.doc = "The GPUBuffer that contains the vertex data, or None to unset the slot." +args.offset.doc = "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." +args.size.doc = "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." +[classes.GPURenderCommandsMixin.methods.draw] +doc = """ +Draw primitives using the current pipeline and vertex buffers. +""" +returns.doc = "None." +args.vertex_count.doc = "The number of vertices to draw." +args.instance_count.doc = "The number of instances to draw. Defaults to 1." +args.first_vertex.doc = "The index of the first vertex to draw. Defaults to 0." +args.first_instance.doc = "The instance index of the first instance to draw. Defaults to 0." +[classes.GPURenderCommandsMixin.methods.draw_indexed] +doc = """ +Draw primitives using the current pipeline, vertex buffers and index buffer (see set_index_buffer()). +""" +returns.doc = "None." +args.index_count.doc = "The number of indices to draw." +args.instance_count.doc = "The number of instances to draw. Defaults to 1." +args.first_index.doc = "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." +args.base_vertex.doc = "A value added to each index before looking up the vertex. Defaults to 0." +args.first_instance.doc = "The instance index of the first instance to draw. Defaults to 0." +[classes.GPURenderCommandsMixin.methods.draw_indirect] +doc = """ +Like draw(), but the parameters are read from a GPUBuffer. + +The buffer must have flags.BufferUsage.INDIRECT, and contain four consecutive 32-bit unsigned integers +at the given offset: vertex_count, instance_count, first_vertex and first_instance. +A non-zero first_instance requires feature indirect_first_instance. +""" +returns.doc = "None." +args.indirect_buffer.doc = "The GPUBuffer that contains the draw parameters." +args.indirect_offset.doc = "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." +[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] +doc = """ +Like draw_indexed(), but the parameters are read from a GPUBuffer. + +The buffer must have flags.BufferUsage.INDIRECT, and contain five consecutive 32-bit values at the given offset: +index_count, instance_count, first_index, base_vertex (signed) and first_instance. +A non-zero first_instance requires feature indirect_first_instance. +""" +returns.doc = "None." +args.indirect_buffer.doc = "The GPUBuffer that contains the draw parameters." +args.indirect_offset.doc = "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." + +[classes.GPURenderBundle] +doc = """ +A pre-recorded sequence of render commands that can be executed in render passes. + +Obtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles(). +""" +[classes.GPURenderBundle.methods] + +[classes.GPURenderBundleEncoder] +doc = """ +Records render commands into a GPURenderBundle, which can be replayed in multiple render passes. + +Created with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin, +GPUDebugCommandsMixin and GPURenderCommandsMixin. +""" +[classes.GPURenderBundleEncoder.methods] +[classes.GPURenderBundleEncoder.methods.finish] +doc = """ +Finish recording and return a GPURenderBundle. + +The encoder cannot be used after this call. +""" +returns.doc = "A GPURenderBundle." +args.descriptor.doc = "A structs.RenderBundleDescriptor. Optional." + +[classes.GPUQueue] +doc = """ +The queue on which work is submitted to the GPU. + +Each GPUDevice has a default queue, available via the queue property of GPUDevice. +It is used to submit command buffers and to upload data to buffers and textures. +""" +[classes.GPUQueue.methods] +[classes.GPUQueue.methods.submit] +doc = """ +Submit a list of command buffers for execution on the GPU. + +Each command buffer can only be submitted once. +""" +returns.doc = "None." +args.command_buffers.doc = "A list of GPUCommandBuffer objects, executed in order." +[classes.GPUQueue.methods.on_submitted_work_done] +doc = """ +Wait until all work that was submitted so far has been completed by the GPU. +""" +returns.doc = "None (awaitable); resolves when the submitted work is done." +[classes.GPUQueue.methods.write_buffer] +doc = """ +Write data to a GPUBuffer. + +This is a convenient way to upload data. The buffer needs flags.BufferUsage.COPY_DST. +The size of the data to write and the offset must be multiples of 4. +""" +returns.doc = "None." +args.buffer.doc = "The GPUBuffer to write to." +args.buffer_offset.doc = "The offset in bytes in the buffer where the data is written." +args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." +args.data_offset.doc = "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." +args.size.doc = "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." +[classes.GPUQueue.methods.write_texture] +doc = """ +Write data to a GPUTexture. + +This is a convenient way to upload texture data. The texture needs flags.TextureUsage.COPY_DST. +""" +returns.doc = "None." +args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to write to." +args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." +args.data_layout.doc = "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." +args.size.doc = "A structs.Extent3D (or tuple) with the size of the region to write, in texels." +[classes.GPUQueue.methods.copy_external_image_to_texture] +doc = """ +Copy an external image (e.g. an image, canvas or video frame) to a GPUTexture. + +The texture needs flags.TextureUsage.COPY_DST and flags.TextureUsage.RENDER_ATTACHMENT. +""" +returns.doc = "None." +args.source.doc = "A structs.CopyExternalImageSourceInfo describing the image to copy from." +args.destination.doc = "A structs.CopyExternalImageDestInfo describing the part of the texture to copy to." +args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." + +[classes.GPUQuerySet] +doc = """ +A set of queries that hold results such as occlusion counts or timestamps. + +Created with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving +them into a buffer with GPUCommandEncoder.resolve_query_set(). +""" +properties.type.doc = "The type of queries in the set, see enums.QueryType." +properties.count.doc = "The number of queries in the set." +[classes.GPUQuerySet.methods] +[classes.GPUQuerySet.methods.destroy] +doc = """ +Destroy the query set and free its resources. + +The query set can no longer be used. Calling this multiple times is allowed. +""" +returns.doc = "None." + +[classes.GPUCanvasContext] +doc = """ +The connection between a canvas (or window) and the GPU, used to present rendered images. + +Configure it with configure(), then each frame obtain a texture with get_current_texture(), +render to it, and submit the work. The result is presented when the frame ends. +""" +properties.canvas.doc = "The canvas (or window/surface object) that this context belongs to." +[classes.GPUCanvasContext.methods] +[classes.GPUCanvasContext.methods.configure] +doc = """ +Configure the context for use with a device, so that textures can be obtained from it. + +Calling this again replaces the previous configuration. +""" +returns.doc = "None." +args.configuration.doc = "A structs.CanvasConfiguration with the device, format and other settings." +[classes.GPUCanvasContext.methods.unconfigure] +doc = """ +Remove the configuration, releasing the textures associated with the context. + +After this, get_current_texture() cannot be used until the context is configured again. +""" +returns.doc = "None." +[classes.GPUCanvasContext.methods.get_configuration] +doc = """ +Get the current configuration of the context. +""" +returns.doc = "The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured." +[classes.GPUCanvasContext.methods.get_current_texture] +doc = """ +Get the GPUTexture to render to for the current frame. + +The texture has the size of the canvas, and is the texture that will be presented. The same texture is returned +until the frame is presented; a new one is returned for the next frame. +""" +returns.doc = "A GPUTexture." + +[classes.GPUDeviceLostInfo] +doc = """ +Information about why a GPUDevice was lost. + +Available via the lost property of GPUDevice. +""" +properties.reason.doc = "The reason the device was lost, see enums.DeviceLostReason." +properties.message.doc = "A human-readable message with details about why the device was lost." +[classes.GPUDeviceLostInfo.methods] + +[classes.GPUError] +doc = """ +The base class of errors that are generated by the GPU API. + +Subclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError. +Errors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice. +""" +properties.message.doc = "A human-readable description of the error." +[classes.GPUError.methods] + +[classes.GPUValidationError] +doc = """ +An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage. + +Captured by error scopes with enums.ErrorFilter.validation. +""" +[classes.GPUValidationError.methods] +[classes.GPUValidationError.methods.constructor] +doc = """ +Create a GPUValidationError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = "A GPUValidationError." +args.message.doc = "The human-readable error message." + +[classes.GPUOutOfMemoryError] +doc = """ +An error that signals that there was not enough memory to complete an operation. + +Captured by error scopes with enums.ErrorFilter.out_of_memory. +""" +[classes.GPUOutOfMemoryError.methods] +[classes.GPUOutOfMemoryError.methods.constructor] +doc = """ +Create a GPUOutOfMemoryError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = "A GPUOutOfMemoryError." +args.message.doc = "The human-readable error message." + +[classes.GPUInternalError] +doc = """ +An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit. + +Captured by error scopes with enums.ErrorFilter.internal. +""" +[classes.GPUInternalError.methods] +[classes.GPUInternalError.methods.constructor] +doc = """ +Create a GPUInternalError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = "A GPUInternalError." +args.message.doc = "The human-readable error message." diff --git a/apigen/definitions/docs_dev.toml b/apigen/definitions/docs_dev.toml new file mode 100644 index 00000000..5fef2a6e --- /dev/null +++ b/apigen/definitions/docs_dev.toml @@ -0,0 +1,3 @@ +# docs_dev.toml +# +# Define hand-written docs to overload the ai-generated docs. diff --git a/apigen/definitions/docs_ts.toml b/apigen/definitions/docs_ts.toml new file mode 100644 index 00000000..1baa9e09 --- /dev/null +++ b/apigen/definitions/docs_ts.toml @@ -0,0 +1,1400 @@ +# doc_ts.toml: Docs generated from 'index.d.ts'. + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[flags] + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[enums] + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[structs] + +BindGroupDescriptor.fields.entries.doc = ''' +A list of entries describing the resources to expose to the shader for each binding +described by the {@link GPUBindGroupDescriptor#layout}. +''' +BindGroupDescriptor.fields.layout.doc = 'The {@link GPUBindGroupLayout} the entries of this bind group will conform to.' + +BindGroupEntry.fields.binding.doc = ''' +A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a +{@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding +attribute in the {@link GPUShaderModule}. +''' +BindGroupEntry.fields.resource.doc = ''' +The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, +{@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. +''' + +BindGroupLayoutDescriptor.fields.entries.doc = 'A list of entries describing the shader resource bindings for a bind group.' + +BindGroupLayoutEntry.fields.binding.doc = ''' +A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding +to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding +attribute in the {@link GPUShaderModule}. +''' +BindGroupLayoutEntry.fields.external_texture.doc = ''' +Exactly one of these members must be set, indicating the binding type. +The contents of the member specify options specific to that type. +The corresponding resource in {@link GPUDevice#createBindGroup} requires +the corresponding binding resource type for this binding. +''' +BindGroupLayoutEntry.fields.visibility.doc = ''' +A bitset of the members of {@link GPUShaderStage}. +Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource +will be accessible from the associated shader stage. +''' + +BlendComponent.fields.dst_factor.doc = 'Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.' +BlendComponent.fields.operation.doc = ''' +Defines the {@link GPUBlendOperation} used to calculate the values written to the target +attachment components. +''' +BlendComponent.fields.src_factor.doc = 'Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.' + +BlendState.fields.alpha.doc = 'Defines the blending behavior of the corresponding render target for the alpha channel.' +BlendState.fields.color.doc = 'Defines the blending behavior of the corresponding render target for color channels.' + +BufferBinding.fields.buffer.doc = 'The {@link GPUBuffer} to bind.' +BufferBinding.fields.offset.doc = ''' +The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the +beginning of the range exposed to the shader by the buffer binding. +''' +BufferBinding.fields.size.doc = ''' +The size, in bytes, of the buffer binding. +If not map/exist|provided, specifies the range starting at +{@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. +''' + +BufferBindingLayout.fields.has_dynamic_offset.doc = 'Indicates whether this binding requires a dynamic offset.' +BufferBindingLayout.fields.min_binding_size.doc = ''' +Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. +Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. +If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] +that this value ≥ the minimum buffer binding size of the variable. +If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands +[$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} +satisfies the minimum buffer binding size of the variable. +Note: +Similar execution-time validation is theoretically possible for other +binding-related fields specified for early validation, like +{@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, +which currently can only be validated in pipeline creation. +However, such execution-time validation could be costly or unnecessarily complex, so it is +available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the +most ergonomic impact. +''' +BufferBindingLayout.fields.type.doc = 'Indicates the type required for buffers bound to this binding.' + +BufferDescriptor.fields.mapped_at_creation.doc = ''' +If `true` creates the buffer in an already mapped state, allowing +{@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set +{@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} +does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be +used to set the buffer's initial data. +Guarantees that even if the buffer creation eventually fails, it will still appear as if the +mapped range can be written/read to until it is unmapped. +''' +BufferDescriptor.fields.size.doc = 'The size of the buffer in bytes.' +BufferDescriptor.fields.usage.doc = 'The allowed usages for the buffer.' + +CanvasConfiguration.fields.alpha_mode.doc = ''' +Determines the effect that alpha values will have on the content of textures returned by +{@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. +''' +CanvasConfiguration.fields.color_space.doc = ''' +The color space that values written into textures returned by +{@link GPUCanvasContext#getCurrentTexture} should be displayed with. +''' +CanvasConfiguration.fields.device.doc = ''' +The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be +compatible with. +''' +CanvasConfiguration.fields.format.doc = ''' +The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. +Must be one of the Supported context formats. +''' +CanvasConfiguration.fields.tone_mapping.doc = ''' +The tone mapping determines how the content of textures returned by +{@link GPUCanvasContext#getCurrentTexture} are to be displayed. +
+This is a required feature, but user agents might not yet implement it, +effectively supporting only the default {@link GPUCanvasToneMapping}. +In such implementations, this member **should not** exist in its implementation of +{@link GPUCanvasConfiguration}, to make feature detection possible using +{@link GPUCanvasContext#getConfiguration}. +This is especially important in implementations which otherwise have HDR capabilities +(where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be +exposed). +If an implementation exposes this member and a `high` dynamic range, it **should** render the +canvas as an HDR element, not clamp values to the SDR range of the HDR display. +
+''' +CanvasConfiguration.fields.usage.doc = ''' +The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. +{@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included +if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} +when setting a custom usage if you wish to use textures returned by +{@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. +''' +CanvasConfiguration.fields.view_formats.doc = ''' +The formats that views created from textures returned by +{@link GPUCanvasContext#getCurrentTexture} may use. +''' + +CanvasConfigurationOut.fields.tone_mapping.doc = '{@inheritDoc GPUCanvasConfiguration.toneMapping}' +CanvasConfigurationOut.fields.view_formats.doc = '{@inheritDoc GPUCanvasConfiguration.viewFormats}' + +ColorDict.fields.a.doc = 'The alpha channel value.' +ColorDict.fields.b.doc = 'The blue channel value.' +ColorDict.fields.g.doc = 'The green channel value.' +ColorDict.fields.r.doc = 'The red channel value.' + +ColorTargetState.fields.blend.doc = ''' +The blending behavior for this color target. If left undefined, disables blending for this +color target. +''' +ColorTargetState.fields.format.doc = ''' +The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with +{@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the +corresponding color attachment. +''' +ColorTargetState.fields.write_mask.doc = 'Bitmask controlling which channels are are written to when drawing to this color target.' + +ComputePassDescriptor.fields.timestamp_writes.doc = 'Defines which timestamp values will be written for this pass, and where to write them to.' + +ComputePassTimestampWrites.fields.beginning_of_pass_write_index.doc = ''' +If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the beginning of the compute pass will be written. +''' +ComputePassTimestampWrites.fields.end_of_pass_write_index.doc = ''' +If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the end of the compute pass will be written. +''' +ComputePassTimestampWrites.fields.query_set.doc = ''' +The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be +written to. +''' + +ComputePipelineDescriptor.fields.compute.doc = 'Describes the compute shader entry point of the pipeline.' + +CopyExternalImageDestInfo.fields.color_space.doc = ''' +Describes the color space and encoding used to encode data into the destination texture. +This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1] +being written to the target texture, if its format can represent them. +Otherwise, the results are clamped to the target texture format's range. +Note: +If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, +conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. +''' +CopyExternalImageDestInfo.fields.premultiplied_alpha.doc = ''' +Describes whether the data written into the texture should have its RGB channels +premultiplied by the alpha channel, or not. +If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also +premultiplied, the source RGB values must be preserved even if they exceed their +corresponding alpha values. +Note: +If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, +conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. +''' + +CopyExternalImageSourceInfo.fields.flip_y.doc = ''' +Describes whether the source image is vertically flipped, or not. +If this option is set to `true`, the copy is flipped vertically: the bottom row of the source +region is copied into the first row of the destination region, and so on. +The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner +of the source image, increasing downward. +''' +CopyExternalImageSourceInfo.fields.origin.doc = ''' +Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from. +Together with `copySize`, defines the full copy sub-region. +''' +CopyExternalImageSourceInfo.fields.source.doc = ''' +The source of the texel copy. The copy source data is captured at the moment that +{@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described +by the external source dimensions table. +''' + +DepthStencilState.fields.depth_bias.doc = 'Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.' +DepthStencilState.fields.depth_bias_clamp.doc = 'The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.' +DepthStencilState.fields.depth_bias_slope_scale.doc = 'Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.' +DepthStencilState.fields.depth_compare.doc = ''' +The comparison operation used to test fragment depths against +{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. +''' +DepthStencilState.fields.depth_write_enabled.doc = ''' +Indicates if this {@link GPURenderPipeline} can modify +{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. +''' +DepthStencilState.fields.format.doc = ''' +The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} +this {@link GPURenderPipeline} will be compatible with. +''' +DepthStencilState.fields.stencil_back.doc = 'Defines how stencil comparisons and operations are performed for back-facing primitives.' +DepthStencilState.fields.stencil_front.doc = 'Defines how stencil comparisons and operations are performed for front-facing primitives.' +DepthStencilState.fields.stencil_read_mask.doc = ''' +Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value +bits are read when performing stencil comparison tests. +''' +DepthStencilState.fields.stencil_write_mask.doc = ''' +Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value +bits are written to when performing stencil operations. +''' + +DeviceDescriptor.fields.default_queue.doc = 'The descriptor for the default {@link GPUQueue}.' +DeviceDescriptor.fields.required_features.doc = ''' +Specifies the features that are required by the device request. +The request will fail if the adapter cannot provide these features. +Exactly the specified set of features, and no more or less, will be allowed in validation +of API calls on the resulting device. +''' +DeviceDescriptor.fields.required_limits.doc = ''' +Specifies the limits that are required by the device request. +The request will fail if the adapter cannot provide these limits. +Each key with a non-`undefined` value must be the name of a member of supported limits. +API calls on the resulting device perform validation according to the exact limits of the +device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). + +''' + +Error.fields.message.doc = ''' +A human-readable, localizable text message providing information about the error that +occurred. +Note: This message is generally intended for application developers to debug their +applications and capture information for debug reports, not to be surfaced to end-users. +Note: User agents should not include potentially machine-parsable details in this message, +such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the +conditions under which memory was exhausted. +Note: The {@link GPUError#message} should follow the best practices for language and +direction information. This includes making use of any future standards which may emerge +regarding the reporting of string language and direction metadata. +

Editorial note: +At the time of this writing, no language/direction recommendation is available that provides +compatibility and consistency with legacy APIs, but when there is, adopt it formally. +''' + +Extent3DDict.fields.depth_or_array_layers.doc = ''' +The depth of the extent or the number of array layers it contains. +If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `"3d"` +defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension} +of {@link GPUTextureDimension} `"2d"` defines the number of array layers in the texture. +''' +Extent3DDict.fields.height.doc = 'The height of the extent.' +Extent3DDict.fields.width.doc = 'The width of the extent.' + +Extent3DDictStrict.fields.depth.doc = '@deprecated The correct name is `depthOrArrayLayers`.' + +ExternalTextureDescriptor.fields.color_space.doc = ''' +The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be +converted into when reading. +''' +ExternalTextureDescriptor.fields.source.doc = ''' +The video source to import the external texture from. Source size is determined as described +by the external source dimensions table. +''' + +FragmentState.fields.targets.doc = ''' +A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets +this pipeline writes to. +''' + +MultisampleState.fields.alpha_to_coverage_enabled.doc = ''' +When `true` indicates that a fragment's alpha channel should be used to generate a sample +coverage mask. +''' +MultisampleState.fields.count.doc = ''' +Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only +with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} +and {@link GPURenderPassDescriptor#depthStencilAttachment}) +with matching {@link GPUTextureDescriptor#sampleCount}s. +''' +MultisampleState.fields.mask.doc = 'Mask determining which samples are written to.' + +NavigatorGPU.fields.gpu.doc = 'A global singleton providing top-level entry points like {@link GPU#requestAdapter}.' + +ObjectDescriptorBase.fields.label.doc = 'The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}.' + +Origin2DDictStrict.fields.z.doc = '@deprecated Does not exist for GPUOrigin2D.' + +PipelineDescriptorBase.fields.layout.doc = ''' +The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `"auto"` to generate +the pipeline layout automatically. +Note: If {@link GPUAutoLayoutMode} `"auto"` is used the pipeline cannot share {@link GPUBindGroup}s +with any other pipelines. +''' + +PipelineLayoutDescriptor.fields.bind_group_layouts.doc = ''' +A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds +to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding +with `@group(N)`. +''' +PipelineLayoutDescriptor.fields.immediate_size.doc = 'The size, in bytes, of the immediate data range used by the pipeline.' + +PrimitiveState.fields.cull_mode.doc = 'Defines which polygon orientation will be culled, if any.' +PrimitiveState.fields.front_face.doc = 'Defines which polygons are considered front-facing.' +PrimitiveState.fields.strip_index_format.doc = ''' +For pipelines with strip topologies +({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), +this determines the index buffer format and primitive restart value +({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). +It is not allowed on pipelines with non-strip topologies. +Note: Some implementations require knowledge of the primitive restart value to compile +pipeline state objects. +To use a strip-topology pipeline with an indexed draw call +({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), +this must be set, and it must match the index buffer format used with the draw call +(set in {@link GPURenderCommandsMixin#setIndexBuffer}). +See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. +''' +PrimitiveState.fields.topology.doc = 'The type of primitive to be constructed from the vertex inputs.' +PrimitiveState.fields.unclipped_depth.doc = ''' +If true, indicates that depth clipping is disabled. +Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. +''' + +ProgrammableStage.fields.constants.doc = ''' +Specifies the values of pipeline-overridable constants in the shader module +{@link GPUProgrammableStage#module}. +Each such pipeline-overridable constant is uniquely identified by a single +pipeline-overridable constant identifier string, representing the pipeline +constant ID of the constant if its declaration specifies one, and otherwise the +constant's identifier name. +The key of each key-value pair must equal the +pipeline-overridable constant identifier string|identifier string +of one such constant, with the comparison performed +according to the rules for WGSL identifier comparison. +When the pipeline is executed, that constant will have the specified value. +Values are specified as GPUPipelineConstantValue, which is a `double`. +They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). +If conversion fails, a validation error is generated. +

+Pipeline-overridable constants defined in WGSL: +```wgsl +override width: f32 = 0.0; // Specifed at the API level +// using the name "width". +override depth: f32; // Specifed at the API level +// using the name "depth". +// Must be overridden. +override height = 2 * depth; // The default value +// (if not set at the API level), +// depends on another +// overridable constant. +``` +Corresponding JavaScript code, providing only the overrides which are required +(have no defaults): +```js +{ +// ... +constants: { +1300: 2.0, // "gain" +depth: -1, // "depth" +} +} +``` +Corresponding JavaScript code, overriding all constants: +```js +{ +// ... +constants: { +0: false, // "has_point_light" +1200: 3.0, // "specular_param" +1300: 2.0, // "gain" +width: 20, // "width" +depth: -1, // "depth" +height: 15, // "height" +} +} +``` +
+''' +ProgrammableStage.fields.entry_point.doc = ''' +The name of the function in {@link GPUProgrammableStage#module} that this stage will use to +perform its work. +NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is +not required, methods which consume a {@link GPUProgrammableStage} must use the +"[$get the entry point$]" algorithm to determine which entry point +it refers to. +''' +ProgrammableStage.fields.module.doc = 'The {@link GPUShaderModule} containing the code that this programmable stage will execute.' + +QuerySetDescriptor.fields.count.doc = 'The number of queries managed by {@link GPUQuerySet}.' +QuerySetDescriptor.fields.type.doc = 'The type of queries managed by {@link GPUQuerySet}.' + +RenderBundleEncoderDescriptor.fields.depth_read_only.doc = ''' +If `true`, indicates that the render bundle does not modify the depth component of the +{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed +in. +See read-only depth-stencil. +''' +RenderBundleEncoderDescriptor.fields.stencil_read_only.doc = ''' +If `true`, indicates that the render bundle does not modify the stencil component of the +{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed +in. +See read-only depth-stencil. +''' + +RenderPassColorAttachment.fields.clear_value.doc = ''' +Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the +render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored +if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. +The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. +They are converted [$to a texel value of texture format$] matching the render attachment. +If conversion fails, a validation error is generated. +''' +RenderPassColorAttachment.fields.depth_slice.doc = ''' +Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} +that will be output to for this color attachment. +''' +RenderPassColorAttachment.fields.load_op.doc = ''' +Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to +executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +''' +RenderPassColorAttachment.fields.resolve_target.doc = ''' +Describes the texture subresource that will receive the resolved output for this color +attachment if {@link GPURenderPassColorAttachment#view} is multisampled. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). +''' +RenderPassColorAttachment.fields.store_op.doc = ''' +The store operation to perform on {@link GPURenderPassColorAttachment#view} +after executing the render pass. +''' +RenderPassColorAttachment.fields.view.doc = ''' +Describes the texture subresource that will be output to for this color attachment. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). +''' + +RenderPassDepthStencilAttachment.fields.depth_clear_value.doc = ''' +Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component +to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} +is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. + +''' +RenderPassDepthStencilAttachment.fields.depth_load_op.doc = ''' +Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +depth component prior to executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +''' +RenderPassDepthStencilAttachment.fields.depth_read_only.doc = ''' +Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} +is read only. +''' +RenderPassDepthStencilAttachment.fields.depth_store_op.doc = ''' +The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +depth component after executing the render pass. +''' +RenderPassDepthStencilAttachment.fields.stencil_clear_value.doc = ''' +Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component +to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} +is not {@link GPULoadOp} `"clear"`. +The value will be converted to the type of the stencil aspect of `view` by taking the same +number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. +''' +RenderPassDepthStencilAttachment.fields.stencil_load_op.doc = ''' +Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +stencil component prior to executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +''' +RenderPassDepthStencilAttachment.fields.stencil_read_only.doc = ''' +Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} +is read only. +''' +RenderPassDepthStencilAttachment.fields.stencil_store_op.doc = ''' +The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +stencil component after executing the render pass. +''' +RenderPassDepthStencilAttachment.fields.view.doc = ''' +Describes the texture subresource that will be output to and read from for this +depth/stencil attachment. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). +''' + +RenderPassDescriptor.fields.color_attachments.doc = ''' +The set of {@link GPURenderPassColorAttachment} values in this sequence defines which +color attachments will be output to when executing this render pass. +Due to compatible usage list|usage compatibility, no color attachment +may alias another attachment or any resource used inside the render pass. +''' +RenderPassDescriptor.fields.depth_stencil_attachment.doc = ''' +The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil +attachment that will be output to and tested against when executing this render pass. +Due to compatible usage list|usage compatibility, no writable depth/stencil attachment +may alias another attachment or any resource used inside the render pass. +''' +RenderPassDescriptor.fields.max_draw_count.doc = ''' +The maximum number of draw calls that will be done in the render pass. Used by some +implementations to size work injected before the render pass. Keeping the default value +is a good default, unless it is known that more draw calls will be done. +''' +RenderPassDescriptor.fields.occlusion_query_set.doc = 'The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.' +RenderPassDescriptor.fields.timestamp_writes.doc = 'Defines which timestamp values will be written for this pass, and where to write them to.' + +RenderPassLayout.fields.color_formats.doc = 'A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.' +RenderPassLayout.fields.depth_stencil_format.doc = 'The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.' +RenderPassLayout.fields.sample_count.doc = 'Number of samples per pixel in the attachments for this pass or bundle.' + +RenderPassTimestampWrites.fields.beginning_of_pass_write_index.doc = ''' +If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the beginning of the render pass will be written. +''' +RenderPassTimestampWrites.fields.end_of_pass_write_index.doc = ''' +If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the end of the render pass will be written. +''' +RenderPassTimestampWrites.fields.query_set.doc = ''' +The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be +written to. +''' + +RenderPipelineDescriptor.fields.depth_stencil.doc = 'Describes the optional depth-stencil properties, including the testing, operations, and bias.' +RenderPipelineDescriptor.fields.fragment.doc = ''' +Describes the fragment shader entry point of the pipeline and its output colors. If +not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. +''' +RenderPipelineDescriptor.fields.multisample.doc = 'Describes the multi-sampling properties of the pipeline.' +RenderPipelineDescriptor.fields.primitive.doc = 'Describes the primitive-related properties of the pipeline.' +RenderPipelineDescriptor.fields.vertex.doc = 'Describes the vertex shader entry point of the pipeline and its input buffer layouts.' + +RequestAdapterOptions.fields.feature_level.doc = ''' +Requests an adapter that supports at least a particular set of capabilities. +This influences the {@link adapter#[[default feature level]]} of devices created +from this adapter. The capabilities for each level are defined below, and the exact +steps are defined in {@link GPU#requestAdapter} and "a new device". +If the implementation or system does not support all of the capabilities in the +requested feature level, {@link GPU#requestAdapter} will return `null`. +Note: +Applications should typically make a single {@link GPU#requestAdapter} call with the lowest +feature level they support, then inspect the adapter for additional capabilities they can +use optionally, and request those in {@link GPUAdapter#requestDevice}. +The allowed feature level string values are: +
+: "core" +The following set of capabilities: +- The limit/Default limits. +- {@link GPUFeatureName} `"core-features-and-limits"`. +Note: +Adapters with this {@link adapter#[[default feature level]]} may +conventionally be referred to as "Core-defaulting". +: "compatibility" +The following set of capabilities: +- The limit/Compatibility Mode Default limits. +- No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) +If the implementation cannot enforce the stricter "Compatibility Mode" +validation rules, {@link GPU#requestAdapter} will ignore this request and +treat it as a request for feature level string/"core". +Note: +Adapters with this {@link adapter#[[default feature level]]} may +conventionally be referred to as "Compatibility-defaulting". +''' +RequestAdapterOptions.fields.force_fallback_adapter.doc = ''' +When set to `true` indicates that only a fallback adapter may be returned. If the user +agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to +resolve to `null`. +Note: +{@link GPU#requestAdapter} may still return a fallback adapter if +{@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no +other appropriate adapter is available or the user agent chooses to return a +fallback adapter. Developers that wish to prevent their applications from running on +fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} +attribute prior to requesting a {@link GPUDevice}. +''' +RequestAdapterOptions.fields.power_preference.doc = ''' +Optionally provides a hint indicating what class of adapter should be selected from +the system's available adapters. +The value of this hint may influence which adapter is chosen, but it must not +influence whether an adapter is returned or not. +Note: +The primary utility of this hint is to influence which GPU is used in a multi-GPU system. +For instance, some laptops have a low-power integrated GPU and a high-performance +discrete GPU. This hint may also affect the power configuration of the selected GPU to +match the requested power preference. +Note: +Depending on the exact hardware configuration, such as battery status and attached displays +or removable GPUs, the user agent may select different adapters given the same power +preference. +Typically, given the same hardware configuration and state and +`powerPreference`, the user agent is likely to select the same adapter. +''' + +SamplerBindingLayout.fields.type.doc = 'Indicates the required type of a sampler bound to this bindings.' + +SamplerDescriptor.fields.address_mode_w.doc = ''' +Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth +coordinates, respectively. +''' +SamplerDescriptor.fields.compare.doc = ''' +When provided the sampler will be a comparison sampler with the specified +{@link GPUCompareFunction}. +Note: Comparison samplers may use filtering, but the sampling results will be +implementation-dependent and may differ from the normal filtering rules. +''' +SamplerDescriptor.fields.lod_max_clamp.doc = ''' +Specifies the minimum and maximum levels of detail, respectively, used internally when +sampling a texture. +''' +SamplerDescriptor.fields.mag_filter.doc = ''' +Specifies the sampling behavior when the sampled area is smaller than or equal to one +texel. +''' +SamplerDescriptor.fields.max_anisotropy.doc = ''' +Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is +enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. +Anisotropic filtering improves the image quality of textures sampled at oblique viewing +angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of +anisotropy supported when filtering. +
+Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range +between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} +will be clamped to the maximum value that the platform supports. +The precise filtering behavior is implementation-dependent. +
+''' +SamplerDescriptor.fields.min_filter.doc = 'Specifies the sampling behavior when the sampled area is larger than one texel.' +SamplerDescriptor.fields.mipmap_filter.doc = 'Specifies behavior for sampling between mipmap levels.' + +ShaderModuleCompilationHint.fields.layout.doc = ''' +A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future +{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. +If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] +for the entry point associated with this hint will be used. +''' + +ShaderModuleDescriptor.fields.code.doc = ''' +The WGSL source code for the shader +module. +''' +ShaderModuleDescriptor.fields.compilation_hints.doc = ''' +A list of {@link GPUShaderModuleCompilationHint}s. +Any hint provided by an application **should** contain information about one entry point of +a pipeline that will eventually be created from the entry point. +Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} +to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. +Aside from type-checking, these hints are not validated in any way. +
+Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any +observable effect, other than performance. It may be detrimental to performance to +provide hints for pipelines that never end up being created. +Because a single shader module can hold multiple entry points, and multiple pipelines +can be created from a single shader module, it can be more performant for an +implementation to do as much compilation as possible once in +{@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to +{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. +Hints are only applied to the entry points they explicitly name. +Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, +there is no default, even if only one entry point is present in the module. +
+Note: +Hints are not validated in an observable way, but user agents **may** surface identifiable +errors (like unknown entry point names or incompatible pipeline layouts) to developers, +for example in the browser developer console. +''' + +StencilFaceState.fields.compare.doc = ''' +The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value +against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. +''' +StencilFaceState.fields.depth_fail_op.doc = ''' +The {@link GPUStencilOperation} performed if the fragment depth comparison described by +{@link GPUDepthStencilState#depthCompare} fails. +''' +StencilFaceState.fields.fail_op.doc = ''' +The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by +{@link GPUStencilFaceState#compare} fails. +''' +StencilFaceState.fields.pass_op.doc = ''' +The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by +{@link GPUStencilFaceState#compare} passes. +''' + +StorageTextureBindingLayout.fields.access.doc = 'The access mode for this binding, indicating readability and writability.' +StorageTextureBindingLayout.fields.format.doc = 'The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.' +StorageTextureBindingLayout.fields.view_dimension.doc = ''' +Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to +this binding. +''' + +TexelCopyBufferInfo.fields.buffer.doc = ''' +A buffer which either contains texel data to be copied or will store the texel data being +copied, depending on the method it is being passed to. +''' + +TexelCopyBufferLayout.fields.bytes_per_row.doc = ''' +The stride, in bytes, between the beginning of each texel block row and the subsequent +texel block row. +Required if there are multiple texel block rows (i.e. the copy height or depth is more +than one block). +''' +TexelCopyBufferLayout.fields.offset.doc = ''' +The offset, in bytes, from the beginning of the texel data source (such as a +{@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data +within that source. +''' +TexelCopyBufferLayout.fields.rows_per_image.doc = ''' +Number of texel block rows per single texel image of the texture. +{@link GPUTexelCopyBufferLayout#rowsPerImage} × +{@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each +texel image of data and the subsequent texel image. +Required if there are multiple texel images (i.e. the copy depth is more than one). +''' + +TexelCopyTextureInfo.fields.aspect.doc = 'Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.' +TexelCopyTextureInfo.fields.mip_level.doc = 'Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.' +TexelCopyTextureInfo.fields.origin.doc = ''' +Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. +Together with `copySize`, defines the full copy sub-region. +''' +TexelCopyTextureInfo.fields.texture.doc = 'Texture to copy to/from.' + +TextureBindingLayout.fields.multisampled.doc = 'Indicates whether or not texture views bound to this binding must be multisampled.' +TextureBindingLayout.fields.sample_type.doc = 'Indicates the type required for texture views bound to this binding.' +TextureBindingLayout.fields.view_dimension.doc = ''' +Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to +this binding. +''' + +TextureDescriptor.fields.dimension.doc = 'Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.' +TextureDescriptor.fields.format.doc = 'The format of the texture.' +TextureDescriptor.fields.mip_level_count.doc = 'The number of mip levels the texture will contain.' +TextureDescriptor.fields.sample_count.doc = ''' +The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates +a multisampled texture. +''' +TextureDescriptor.fields.size.doc = 'The width, height, and depth or layer count of the texture.' +TextureDescriptor.fields.texture_binding_view_dimension.doc = ''' +
+On devices without {@link GPUFeatureName} `"core-features-and-limits"`, +views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. +If not specified, a default is chosen. +
+On devices with {@link GPUFeatureName} `"core-features-and-limits"`, +this is ignored, and there is no such restriction. +''' +TextureDescriptor.fields.usage.doc = 'The allowed usages for the texture.' +TextureDescriptor.fields.view_formats.doc = ''' +Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling +{@link GPUTexture#createView} on this texture (in addition to the texture's actual +{@link GPUTextureDescriptor#format}). +
+Adding a format to this list may have a significant performance impact, so it is best +to avoid adding formats unnecessarily. +The actual performance impact is highly dependent on the target system; developers must +test various systems to find out the impact on their particular application. +For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or +{@link GPUTextureDescriptor#viewFormats} entry including +{@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a +{@link GPUTextureFormat} `"rgba8unorm"` texture which does not. +Similar caveats exist for other formats and pairs of formats on other systems. +
+Formats in this list must be texture view format compatible with the texture format. +
+Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: +- `format` equals `viewFormat`, or +- `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. +
+''' + +TextureViewDescriptor.fields.array_layer_count.doc = ''' +How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible +to the texture view. +''' +TextureViewDescriptor.fields.aspect.doc = 'Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.' +TextureViewDescriptor.fields.base_array_layer.doc = 'The index of the first array layer accessible to the texture view.' +TextureViewDescriptor.fields.base_mip_level.doc = 'The first (most detailed) mipmap level accessible to the texture view.' +TextureViewDescriptor.fields.dimension.doc = 'The dimension to view the texture as.' +TextureViewDescriptor.fields.format.doc = ''' +The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the +texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. +''' +TextureViewDescriptor.fields.mip_level_count.doc = ''' +How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to +the texture view. +''' +TextureViewDescriptor.fields.swizzle.doc = ''' +A string of length four, with each character mapping to the texture view's red/green/blue/alpha +channels, respectively. +When accessed by a shader, the red/green/blue/alpha channels are replaced by the value +corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and +`swizzle[3]`, respectively: +- `"r"`: Take its value from the red channel of the texture. +- `"g"`: Take its value from the green channel of the texture. +- `"b"`: Take its value from the blue channel of the texture. +- `"a"`: Take its value from the alpha channel of the texture. +- `"0"`: Force its value to 0. +- `"1"`: Force its value to 1. +Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. +''' +TextureViewDescriptor.fields.usage.doc = ''' +The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the +{@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of +{@link GPUTexture#usage} flags of the texture. +Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the +texture's {@link GPUTextureDescriptor#usage}s, the default will fail, +and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. +''' + +VertexAttribute.fields.format.doc = 'The {@link GPUVertexFormat} of the attribute.' +VertexAttribute.fields.offset.doc = 'The offset, in bytes, from the beginning of the element to the data for the attribute.' +VertexAttribute.fields.shader_location.doc = ''' +The numeric location associated with this attribute, which will correspond with a +"@location" attribute +declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. +''' + +VertexBufferLayout.fields.array_stride.doc = 'The stride, in bytes, between elements of this array.' +VertexBufferLayout.fields.attributes.doc = 'An array defining the layout of the vertex attributes within each element.' +VertexBufferLayout.fields.step_mode.doc = 'Whether each element of this array represents per-vertex data or per-instance data' + +VertexState.fields.buffers.doc = ''' +A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a +vertex buffer used by this pipeline. +''' + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[classes] + +GPU.methods.get_preferred_canvas_format.doc = ''' +Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range +content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or +{@link GPUTextureFormat} `"bgra8unorm"`. +The returned value can be passed as the {@link GPUCanvasConfiguration#format} to +{@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated +canvas is able to display its contents efficiently. +Note: Canvases which are not displayed to the screen may or may not benefit from using this +format. +''' +GPU.methods.request_adapter.args.options.doc = 'Criteria used to select the adapter.' +GPU.methods.request_adapter.doc = ''' +Requests an adapter from the user agent. +The user agent chooses whether to return an adapter, and, if so, +chooses according to the provided options. +''' + +GPUAdapter.methods.features.doc = 'The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}.' +GPUAdapter.methods.info.doc = ''' +Information about the physical adapter underlying this {@link GPUAdapter}. +For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time. +The same object is returned each time. To create that object for the first time: +
+
+**Called on:** {@link GPUAdapter} `this`. +**Returns:** {@link GPUAdapterInfo} +Content timeline steps: +1. Return a [$new adapter info$] for `this.adapter`. +
+
+''' +GPUAdapter.methods.limits.doc = 'The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}.' +GPUAdapter.methods.request_device.args.descriptor.doc = 'Description of the {@link GPUDevice} to request.' +GPUAdapter.methods.request_device.doc = ''' +Requests a device from the adapter. +This is a one-time action: if a device is returned successfully, +the adapter becomes {@link adapter#[[state]]#"consumed"}. +''' + +GPUAdapterInfo.methods.architecture.doc = ''' +The name of the family or class of GPUs the adapter belongs to, if available. Empty +string otherwise. +''' +GPUAdapterInfo.methods.description.doc = ''' +A human readable string describing the adapter as reported by the driver, if available. +Empty string otherwise. +Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse +this value is not recommended. Applications which change their behavior based on the +{@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the +other fields when possible. +''' +GPUAdapterInfo.methods.device.doc = ''' +A vendor-specific identifier for the adapter, if available. Empty string otherwise. +Note: This is a value that represents the type of adapter. For example, it may be a +[PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of +hardware like a serial number. +''' +GPUAdapterInfo.methods.is_fallback_adapter.doc = 'Whether the adapter is a fallback adapter.' +GPUAdapterInfo.methods.subgroup_max_size.doc = ''' +If the "subgroups" feature is supported, the maximum supported subgroup size for the +adapter. + +Check support before using. (Use the non-null assertion operator `!` where needed.) +''' +GPUAdapterInfo.methods.subgroup_min_size.doc = ''' +If the "subgroups" feature is supported, the minimum supported subgroup size for the +adapter. + +Check support before using. (Use the non-null assertion operator `!` where needed.) +''' +GPUAdapterInfo.methods.vendor.doc = 'The name of the vendor of the adapter, if available. Empty string otherwise.' + +GPUBindingCommandsMixin.methods.set_bind_group.args.bind_group.doc = 'Bind group to use for subsequent render or compute commands.' +GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets.doc = 'Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.-->' +GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data.doc = 'Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.' +GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data_length.doc = 'Number of buffer offsets to read from `dynamicOffsetsData`.' +GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data_start.doc = 'Offset in elements into `dynamicOffsetsData` where the buffer offset data begins.' +GPUBindingCommandsMixin.methods.set_bind_group.args.index.doc = 'The index to set the bind group at.' +GPUBindingCommandsMixin.methods.set_bind_group.doc = ''' +Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset +of a Uint32Array. +''' +GPUBindingCommandsMixin.methods.set_immediates.args.data.doc = 'Data to write into the immediate data range.' +GPUBindingCommandsMixin.methods.set_immediates.args.data_offset.doc = 'Offset into `data` to begin writing from. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.' +GPUBindingCommandsMixin.methods.set_immediates.args.data_size.doc = 'Size of content to write from `data`. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.' +GPUBindingCommandsMixin.methods.set_immediates.args.range_offset.doc = 'Offset in bytes into the immediate data range to begin writing at.' +GPUBindingCommandsMixin.methods.set_immediates.doc = 'Sets immediate data for subsequent render or compute commands.' + +GPUBuffer.methods.destroy.doc = ''' +Destroys the {@link GPUBuffer}. +Note: It is valid to destroy a buffer multiple times. +Note: Since no further operations can be enqueued using this buffer, implementations can +free resource allocations, including mapped memory that was just unmapped. +''' +GPUBuffer.methods.get_mapped_range.args.offset.doc = 'Offset in bytes into the buffer to return buffer contents from.' +GPUBuffer.methods.get_mapped_range.args.size.doc = 'Size in bytes of the ArrayBuffer to return.' +GPUBuffer.methods.get_mapped_range.doc = 'Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.' +GPUBuffer.methods.map_async.args.mode.doc = 'Whether the buffer should be mapped for reading or writing.' +GPUBuffer.methods.map_async.args.offset.doc = 'Offset in bytes into the buffer to the start of the range to map.' +GPUBuffer.methods.map_async.args.size.doc = 'Size in bytes of the range to map.' +GPUBuffer.methods.map_async.doc = ''' +Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the +{@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. +The resolution of the returned Promise **only** indicates that the buffer has been mapped. +It does not guarantee the completion of any other operations visible to the content timeline, +and in particular does not imply that any other Promise returned from +{@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s +have resolved. +The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} +**does** imply the completion of +{@link GPUBuffer#mapAsync} calls made prior to that call, +on {@link GPUBuffer}s last used exclusively on that queue. +''' +GPUBuffer.methods.unmap.doc = ''' +Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the +GPU again. +''' + +GPUCanvasContext.methods.canvas.doc = 'The canvas this context was created from.' +GPUCanvasContext.methods.configure.args.configuration.doc = 'Desired configuration for the context.' +GPUCanvasContext.methods.configure.doc = ''' +Configures the context for this canvas. +This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). +See {@link GPUCanvasContext#getConfiguration} for information on feature detection. +''' +GPUCanvasContext.methods.get_configuration.doc = ''' +Returns the context configuration, or `null` if the context is not configured. +Note: +This method exists primarily for feature detection of members (and sub-members) of +{@link GPUCanvasConfiguration}; see those members for details. +For supported members, it returns the originally-supplied values. +''' +GPUCanvasContext.methods.get_current_texture.doc = ''' +Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} +next. +Note: The same {@link GPUTexture} object will be returned by every +call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" +runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. +''' +GPUCanvasContext.methods.unconfigure.doc = 'Removes the context configuration. Destroys any textures produced while configured.' + +GPUCommandEncoder.methods.begin_render_pass.args.descriptor.doc = 'Description of the {@link GPURenderPassEncoder} to create.' +GPUCommandEncoder.methods.begin_render_pass.doc = 'Begins encoding a render pass described by `descriptor`.' +GPUCommandEncoder.methods.clear_buffer.args.buffer.doc = 'The {@link GPUBuffer} to clear.' +GPUCommandEncoder.methods.clear_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the sub-region to clear begins.' +GPUCommandEncoder.methods.clear_buffer.args.size.doc = 'Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.' +GPUCommandEncoder.methods.clear_buffer.doc = ''' +Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a +{@link GPUBuffer} with zeros. +''' +GPUCommandEncoder.methods.copy_buffer_to_buffer.args.destination.doc = 'The {@link GPUBuffer} to copy to.' +GPUCommandEncoder.methods.copy_buffer_to_buffer.args.destination_offset.doc = 'Offset in bytes into `destination` to place the copied data.' +GPUCommandEncoder.methods.copy_buffer_to_buffer.args.size.doc = 'Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.' +GPUCommandEncoder.methods.copy_buffer_to_buffer.args.source.doc = 'The {@link GPUBuffer} to copy from.' +GPUCommandEncoder.methods.copy_buffer_to_buffer.args.source_offset.doc = 'Offset in bytes into `source` to begin copying from.' +GPUCommandEncoder.methods.copy_buffer_to_buffer.doc = ''' +Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a +{@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. +''' +GPUCommandEncoder.methods.copy_buffer_to_texture.args.destination.doc = 'Combined with `copySize`, defines the region of the destination texture subresource. `copySize`:' +GPUCommandEncoder.methods.copy_buffer_to_texture.args.source.doc = 'Combined with `copySize`, defines the region of the source buffer.' +GPUCommandEncoder.methods.copy_buffer_to_texture.doc = ''' +Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a +{@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. +''' +GPUCommandEncoder.methods.copy_texture_to_buffer.args.destination.doc = 'Combined with `copySize`, defines the region of the destination buffer. `copySize`:' +GPUCommandEncoder.methods.copy_texture_to_buffer.args.source.doc = 'Combined with `copySize`, defines the region of the source texture subresources.' +GPUCommandEncoder.methods.copy_texture_to_buffer.doc = ''' +Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or +multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. +''' +GPUCommandEncoder.methods.copy_texture_to_texture.args.destination.doc = 'Combined with `copySize`, defines the region of the destination texture subresources. `copySize`:' +GPUCommandEncoder.methods.copy_texture_to_texture.args.source.doc = 'Combined with `copySize`, defines the region of the source texture subresources.' +GPUCommandEncoder.methods.copy_texture_to_texture.doc = ''' +Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one +or multiple contiguous texture subresources to another sub-region of one or +multiple continuous texture subresources. +''' +GPUCommandEncoder.methods.finish.doc = ''' +Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. + descriptor: +''' +GPUCommandEncoder.methods.resolve_query_set.doc = ''' +Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. + querySet: + firstQuery: + queryCount: + destination: + destinationOffset: +''' + +GPUCompilationMessage.methods.length.doc = ''' +The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message} +corresponds to. If the message does not correspond with a substring then +{@link GPUCompilationMessage#length} must be 0. +''' +GPUCompilationMessage.methods.line_num.doc = ''' +The line number in the shader {@link GPUShaderModuleDescriptor#code} the +{@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of +`1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are +delimited by line breaks. +If the {@link GPUCompilationMessage#message} corresponds to a substring this points to +the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message} +does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. +''' +GPUCompilationMessage.methods.line_pos.doc = ''' +The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum} +of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring +that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a +{@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line. +If {@link GPUCompilationMessage#message} corresponds to a substring this points to the +first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message} +does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. +''' +GPUCompilationMessage.methods.message.doc = ''' +The human-readable, localizable text for this compilation message. +Note: The {@link GPUCompilationMessage#message} should follow the best practices for language +and direction information. This includes making use of any future standards which may +emerge regarding the reporting of string language and direction metadata. +

Editorial note: +At the time of this writing, no language/direction recommendation is available that provides +compatibility and consistency with legacy APIs, but when there is, adopt it formally. +''' +GPUCompilationMessage.methods.offset.doc = ''' +The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16 +code units to the point or beginning of the substring that {@link GPUCompilationMessage#message} +corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and +{@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message} +does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. +''' +GPUCompilationMessage.methods.type.doc = ''' +The severity level of the message. +If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it +corresponds to a shader-creation error. +''' + +GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_x.doc = 'X dimension of the grid of workgroups to dispatch.' +GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_y.doc = 'Y dimension of the grid of workgroups to dispatch.' +GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_z.doc = 'Z dimension of the grid of workgroups to dispatch.' +GPUComputePassEncoder.methods.dispatch_workgroups.doc = ''' +Dispatch work to be performed with the current {@link GPUComputePipeline}. +See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. +''' +GPUComputePassEncoder.methods.dispatch_workgroups_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect dispatch parameters.' +GPUComputePassEncoder.methods.dispatch_workgroups_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the dispatch data begins.' +GPUComputePassEncoder.methods.dispatch_workgroups_indirect.doc = ''' +Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read +from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. +packed block of **three 32-bit unsigned integer values (12 bytes total)**, +given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. +For example: +''' +GPUComputePassEncoder.methods.end.doc = 'Completes recording of the compute pass commands sequence.' +GPUComputePassEncoder.methods.set_pipeline.args.pipeline.doc = 'The compute pipeline to use for subsequent dispatch commands.' +GPUComputePassEncoder.methods.set_pipeline.doc = 'Sets the current {@link GPUComputePipeline}.' + +GPUDebugCommandsMixin.methods.insert_debug_marker.args.marker_label.doc = 'The label to insert.' +GPUDebugCommandsMixin.methods.insert_debug_marker.doc = 'Marks a point in a stream of commands with a label.' +GPUDebugCommandsMixin.methods.pop_debug_group.doc = 'Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.' +GPUDebugCommandsMixin.methods.push_debug_group.args.group_label.doc = 'The label for the command group.' +GPUDebugCommandsMixin.methods.push_debug_group.doc = 'Begins a labeled debug group containing subsequent commands.' + +GPUDevice.methods.adapter_info.doc = ''' +Information about the physical adapter which created the device +that this GPUDevice refers to. +For a given GPUDevice, the GPUAdapterInfo values exposed are constant +over time. +''' +GPUDevice.methods.create_bind_group.args.descriptor.doc = 'Description of the {@link GPUBindGroup} to create.' +GPUDevice.methods.create_bind_group.doc = 'Creates a {@link GPUBindGroup}.' +GPUDevice.methods.create_bind_group_layout.args.descriptor.doc = 'Description of the {@link GPUBindGroupLayout} to create.' +GPUDevice.methods.create_bind_group_layout.doc = 'Creates a {@link GPUBindGroupLayout}.' +GPUDevice.methods.create_buffer.args.descriptor.doc = 'Description of the {@link GPUBuffer} to create.' +GPUDevice.methods.create_buffer.doc = 'Creates a {@link GPUBuffer}.' +GPUDevice.methods.create_command_encoder.args.descriptor.doc = 'Description of the {@link GPUCommandEncoder} to create.' +GPUDevice.methods.create_command_encoder.doc = 'Creates a {@link GPUCommandEncoder}.' +GPUDevice.methods.create_compute_pipeline.args.descriptor.doc = 'Description of the {@link GPUComputePipeline} to create.' +GPUDevice.methods.create_compute_pipeline.doc = 'Creates a {@link GPUComputePipeline} using immediate pipeline creation.' +GPUDevice.methods.create_compute_pipeline_async.args.descriptor.doc = 'Description of the {@link GPUComputePipeline} to create.' +GPUDevice.methods.create_compute_pipeline_async.doc = ''' +Creates a {@link GPUComputePipeline} using async pipeline creation. +The returned Promise resolves when the created pipeline +is ready to be used without additional delay. +If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. +(A {@link GPUError} is not dispatched to the device.) +Note: Use of this method is preferred whenever possible, as it prevents blocking the +queue timeline work on pipeline compilation. +''' +GPUDevice.methods.create_pipeline_layout.args.descriptor.doc = 'Description of the {@link GPUPipelineLayout} to create.' +GPUDevice.methods.create_pipeline_layout.doc = 'Creates a {@link GPUPipelineLayout}.' +GPUDevice.methods.create_query_set.args.descriptor.doc = 'Description of the {@link GPUQuerySet} to create.' +GPUDevice.methods.create_query_set.doc = 'Creates a {@link GPUQuerySet}.' +GPUDevice.methods.create_render_bundle_encoder.args.descriptor.doc = 'Description of the {@link GPURenderBundleEncoder} to create.' +GPUDevice.methods.create_render_bundle_encoder.doc = 'Creates a {@link GPURenderBundleEncoder}.' +GPUDevice.methods.create_render_pipeline.args.descriptor.doc = 'Description of the {@link GPURenderPipeline} to create.' +GPUDevice.methods.create_render_pipeline.doc = 'Creates a {@link GPURenderPipeline} using immediate pipeline creation.' +GPUDevice.methods.create_render_pipeline_async.args.descriptor.doc = 'Description of the {@link GPURenderPipeline} to create.' +GPUDevice.methods.create_render_pipeline_async.doc = ''' +Creates a {@link GPURenderPipeline} using async pipeline creation. +The returned Promise resolves when the created pipeline +is ready to be used without additional delay. +If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. +(A {@link GPUError} is not dispatched to the device.) +Note: Use of this method is preferred whenever possible, as it prevents blocking the +queue timeline work on pipeline compilation. +''' +GPUDevice.methods.create_sampler.args.descriptor.doc = 'Description of the {@link GPUSampler} to create.' +GPUDevice.methods.create_sampler.doc = 'Creates a {@link GPUSampler}.' +GPUDevice.methods.create_shader_module.args.descriptor.doc = 'Description of the {@link GPUShaderModule} to create.' +GPUDevice.methods.create_shader_module.doc = 'Creates a {@link GPUShaderModule}.' +GPUDevice.methods.create_texture.args.descriptor.doc = 'Description of the {@link GPUTexture} to create.' +GPUDevice.methods.create_texture.doc = 'Creates a {@link GPUTexture}.' +GPUDevice.methods.destroy.doc = ''' +Destroys the device, preventing further operations on it. +Outstanding asynchronous operations will fail. +Note: It is valid to destroy a device multiple times. +Note: Since no further operations can be enqueued on this device, implementations can abort +outstanding asynchronous operations immediately and free resource allocations, including +mapped memory that was just unmapped. +''' +GPUDevice.methods.features.doc = ''' +A set containing the {@link GPUFeatureName} values of the features +supported by the device (i.e. the ones with which it was created). +''' +GPUDevice.methods.import_external_texture.args.descriptor.doc = 'Provides the external image source object (and any creation options).' +GPUDevice.methods.import_external_texture.doc = 'Creates a {@link GPUExternalTexture} wrapping the provided image source.' +GPUDevice.methods.limits.doc = ''' +Exposes the limits supported by the device +(which are exactly the ones with which it was created). +''' +GPUDevice.methods.lost.doc = ''' +A slot-backed attribute holding a promise which is created with the device, remains +pending for the lifetime of the device, then resolves when the device is lost. +Upon initialization, it is set to a new promise. +''' +GPUDevice.methods.onuncapturederror.doc = 'An event handler IDL attribute for the `uncapturederror` event type.' +GPUDevice.methods.pop_error_scope.doc = ''' +Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` +and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. +There is no guarantee of the ordering of promise resolution. +''' +GPUDevice.methods.push_error_scope.args.filter.doc = 'Which class of errors this error scope observes.' +GPUDevice.methods.push_error_scope.doc = 'Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.' +GPUDevice.methods.queue.doc = 'The primary {@link GPUQueue} for this device.' + +GPUPipelineBase.methods.get_bind_group_layout.args.index.doc = "Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` sequence." +GPUPipelineBase.methods.get_bind_group_layout.doc = ''' +Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s +{@link GPUBindGroupLayout} at `index`. +''' + +GPUPipelineError.methods.reason.doc = ''' +A read-only slot-backed attribute exposing the type of error encountered in pipeline creation +as a GPUPipelineErrorReason: +

+''' + +GPUQuerySet.methods.count.doc = 'The number of queries managed by this {@link GPUQuerySet}.' +GPUQuerySet.methods.destroy.doc = 'Destroys the {@link GPUQuerySet}.' +GPUQuerySet.methods.type.doc = 'The type of the queries managed by this {@link GPUQuerySet}.' + +GPUQueue.methods.copy_external_image_to_texture.args.copy_size.doc = 'Extents of the content to write from `source` to `destination`.' +GPUQueue.methods.copy_external_image_to_texture.args.destination.doc = 'The texture subresource and origin to write to, and its encoding metadata.' +GPUQueue.methods.copy_external_image_to_texture.args.source.doc = 'source image and origin to copy to `destination`.' +GPUQueue.methods.copy_external_image_to_texture.doc = ''' +Issues a copy operation of the contents of a platform image/canvas +into the destination texture. +This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination +encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}. +Copying into a `-srgb` texture results in the same texture bytes, not the same decoded +values, as copying into the corresponding non-`-srgb` format. +Thus, after a copy operation, sampling the destination texture has +different results depending on whether its format is `-srgb`, all else unchanged. + +''' +GPUQueue.methods.on_submitted_work_done.doc = ''' +Returns a Promise that resolves once this queue finishes processing all the work submitted +up to this moment. +Resolution of this Promise implies the completion of +{@link GPUBuffer#mapAsync} calls made prior to that call, +on {@link GPUBuffer}s last used exclusively on that queue. +''' +GPUQueue.methods.submit.doc = ''' +Schedules the execution of the command buffers by the GPU on this queue. +Submitted command buffers cannot be used again. + `commandBuffers`: +''' +GPUQueue.methods.write_buffer.args.buffer.doc = 'The buffer to write to.' +GPUQueue.methods.write_buffer.args.buffer_offset.doc = 'Offset in bytes into `buffer` to begin writing at.' +GPUQueue.methods.write_buffer.args.data.doc = 'Data to write into `buffer`.' +GPUQueue.methods.write_buffer.args.data_offset.doc = 'Offset in into `data` to begin writing from. Given in elements if `data` is a `TypedArray` and bytes otherwise.' +GPUQueue.methods.write_buffer.args.size.doc = 'Size of content to write from `data` to `buffer`. Given in elements if `data` is a `TypedArray` and bytes otherwise.' +GPUQueue.methods.write_buffer.doc = 'Issues a write operation of the provided data into a {@link GPUBuffer}.' +GPUQueue.methods.write_texture.args.data.doc = 'Data to write into `destination`.' +GPUQueue.methods.write_texture.args.data_layout.doc = 'Layout of the content in `data`.' +GPUQueue.methods.write_texture.args.destination.doc = 'The texture subresource and origin to write to.' +GPUQueue.methods.write_texture.args.size.doc = 'Extents of the content to write from `data` to `destination`.' +GPUQueue.methods.write_texture.doc = 'Issues a write operation of the provided data into a {@link GPUTexture}.' + +GPURenderBundleEncoder.methods.finish.doc = ''' +Completes recording of the render bundle commands sequence. + descriptor: +''' + +GPURenderCommandsMixin.methods.draw.args.first_instance.doc = 'First instance to draw.' +GPURenderCommandsMixin.methods.draw.args.first_vertex.doc = 'Offset into the vertex buffers, in vertices, to begin drawing from.' +GPURenderCommandsMixin.methods.draw.args.instance_count.doc = 'The number of instances to draw.' +GPURenderCommandsMixin.methods.draw.args.vertex_count.doc = 'The number of vertices to draw.' +GPURenderCommandsMixin.methods.draw.doc = ''' +Draws primitives. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +''' +GPURenderCommandsMixin.methods.draw_indexed.args.base_vertex.doc = 'Added to each index value before indexing into the vertex buffers.' +GPURenderCommandsMixin.methods.draw_indexed.args.first_index.doc = 'Offset into the index buffer, in indices, begin drawing from.' +GPURenderCommandsMixin.methods.draw_indexed.args.first_instance.doc = 'First instance to draw.' +GPURenderCommandsMixin.methods.draw_indexed.args.index_count.doc = 'The number of indices to draw.' +GPURenderCommandsMixin.methods.draw_indexed.args.instance_count.doc = 'The number of instances to draw.' +GPURenderCommandsMixin.methods.draw_indexed.doc = ''' +Draws indexed primitives. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +''' +GPURenderCommandsMixin.methods.draw_indexed_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect drawIndexed parameters.' +GPURenderCommandsMixin.methods.draw_indexed_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the drawing data begins.' +GPURenderCommandsMixin.methods.draw_indexed_indirect.doc = ''' +Draws indexed primitives using parameters read from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in +the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: +''' +GPURenderCommandsMixin.methods.draw_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect draw parameters.' +GPURenderCommandsMixin.methods.draw_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the drawing data begins.' +GPURenderCommandsMixin.methods.draw_indirect.doc = ''' +Draws primitives using parameters read from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same +order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: +''' +GPURenderCommandsMixin.methods.set_index_buffer.args.buffer.doc = 'Buffer containing index data to use for subsequent drawing commands.' +GPURenderCommandsMixin.methods.set_index_buffer.args.index_format.doc = 'Format of the index data contained in `buffer`.' +GPURenderCommandsMixin.methods.set_index_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the index data begins. Defaults to `0`.' +GPURenderCommandsMixin.methods.set_index_buffer.args.size.doc = 'Size in bytes of the index data in `buffer`. Defaults to the size of the buffer minus the offset.' +GPURenderCommandsMixin.methods.set_index_buffer.doc = 'Sets the current index buffer.' +GPURenderCommandsMixin.methods.set_pipeline.args.pipeline.doc = 'The render pipeline to use for subsequent drawing commands.' +GPURenderCommandsMixin.methods.set_pipeline.doc = 'Sets the current {@link GPURenderPipeline}.' +GPURenderCommandsMixin.methods.set_vertex_buffer.args.buffer.doc = 'Buffer containing vertex data to use for subsequent drawing commands.' +GPURenderCommandsMixin.methods.set_vertex_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.' +GPURenderCommandsMixin.methods.set_vertex_buffer.args.size.doc = 'Size in bytes of the vertex data in `buffer`. Defaults to the size of the buffer minus the offset.' +GPURenderCommandsMixin.methods.set_vertex_buffer.args.slot.doc = 'The vertex buffer slot to set the vertex buffer for.' +GPURenderCommandsMixin.methods.set_vertex_buffer.doc = 'Sets the current vertex buffer for the given slot.' + +GPURenderPassEncoder.methods.begin_occlusion_query.args.query_index.doc = 'The index of the query in the query set.' +GPURenderPassEncoder.methods.end.doc = 'Completes recording of the render pass commands sequence.' +GPURenderPassEncoder.methods.execute_bundles.args.bundles.doc = 'List of render bundles to execute.' +GPURenderPassEncoder.methods.execute_bundles.doc = ''' +Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of +this render pass. +When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind +groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render +pass's pipeline, bind group, and vertex/index buffer state is cleared +(to the initial, empty values). +Note: The state is cleared, not restored to the previous state. +This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. +''' +GPURenderPassEncoder.methods.set_blend_constant.args.color.doc = 'The color to use when blending.' +GPURenderPassEncoder.methods.set_blend_constant.doc = ''' +Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` +and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. +''' +GPURenderPassEncoder.methods.set_scissor_rect.args.height.doc = 'Height of the scissor rectangle in pixels.' +GPURenderPassEncoder.methods.set_scissor_rect.args.width.doc = 'Width of the scissor rectangle in pixels.' +GPURenderPassEncoder.methods.set_scissor_rect.args.x.doc = 'Minimum X value of the scissor rectangle in pixels.' +GPURenderPassEncoder.methods.set_scissor_rect.args.y.doc = 'Minimum Y value of the scissor rectangle in pixels.' +GPURenderPassEncoder.methods.set_scissor_rect.doc = ''' +Sets the scissor rectangle used during the rasterization stage. +After transformation into viewport coordinates any fragments which fall outside the scissor +rectangle will be discarded. +''' +GPURenderPassEncoder.methods.set_stencil_reference.args.reference.doc = 'The new stencil reference value.' +GPURenderPassEncoder.methods.set_stencil_reference.doc = ''' +Sets the RenderState.`[[stencilReference]]` value used during stencil tests with +the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. +''' +GPURenderPassEncoder.methods.set_viewport.args.height.doc = 'Height of the viewport in pixels.' +GPURenderPassEncoder.methods.set_viewport.args.max_depth.doc = 'Maximum depth value of the viewport.' +GPURenderPassEncoder.methods.set_viewport.args.min_depth.doc = 'Minimum depth value of the viewport.' +GPURenderPassEncoder.methods.set_viewport.args.width.doc = 'Width of the viewport in pixels.' +GPURenderPassEncoder.methods.set_viewport.args.x.doc = 'Minimum X value of the viewport in pixels.' +GPURenderPassEncoder.methods.set_viewport.args.y.doc = 'Minimum Y value of the viewport in pixels.' +GPURenderPassEncoder.methods.set_viewport.doc = ''' +Sets the viewport used during the rasterization stage to linearly map from +NDC|normalized device coordinates to viewport coordinates. +''' + +GPUShaderModule.methods.get_compilation_info.doc = ''' +Returns any messages generated during the {@link GPUShaderModule}'s compilation. +The locations, order, and contents of messages are implementation-defined. +In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. +''' + +GPUSupportedLimits.methods.max_storage_buffers_in_fragment_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' +GPUSupportedLimits.methods.max_storage_buffers_in_vertex_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' +GPUSupportedLimits.methods.max_storage_textures_in_fragment_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' +GPUSupportedLimits.methods.max_storage_textures_in_vertex_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' + +GPUTexture.methods.create_view.args.descriptor.doc = 'Description of the {@link GPUTextureView} to create.' +GPUTexture.methods.create_view.doc = 'Creates a {@link GPUTextureView}.' +GPUTexture.methods.depth_or_array_layers.doc = 'The depth or layer count of this {@link GPUTexture}.' +GPUTexture.methods.destroy.doc = 'Destroys the {@link GPUTexture}.' +GPUTexture.methods.dimension.doc = "The dimension of the set of texel for each of this {@link GPUTexture}'s subresources." +GPUTexture.methods.format.doc = 'The format of this {@link GPUTexture}.' +GPUTexture.methods.height.doc = 'The height of this {@link GPUTexture}.' +GPUTexture.methods.mip_level_count.doc = 'The number of mip levels of this {@link GPUTexture}.' +GPUTexture.methods.sample_count.doc = 'The number of sample count of this {@link GPUTexture}.' +GPUTexture.methods.texture_binding_view_dimension.doc = ''' +On devices without "core-features-and-limits", views created from this +texture must have this as their dimension. + +On devices with "core-features-and-limits", this is undefined, and there is +no such restriction. + +It is safe to access on any browser, as it will just (correctly) return +`undefined` if not implemented. Note, depending on the device, `undefined` +is a valid value even in browsers that implement this attribute. (So be +careful if using the non-null assertion operator `!` on this.) +''' +GPUTexture.methods.usage.doc = 'The allowed usages for this {@link GPUTexture}.' +GPUTexture.methods.width.doc = 'The width of this {@link GPUTexture}.' + +GPUUncapturedErrorEvent.methods.error.doc = ''' +A slot-backed attribute holding an object representing the error that was uncaptured. +This has the same type as errors returned by {@link GPUDevice#popErrorScope}. +''' diff --git a/apigen/definitions/index.d.ts b/apigen/definitions/index.d.ts new file mode 100644 index 00000000..ddd9ca28 --- /dev/null +++ b/apigen/definitions/index.d.ts @@ -0,0 +1,3420 @@ +// ********************************************************************************************* +// This file is manually-edited by diffing against an autogenerated file. See README.md. +// ********************************************************************************************* + +// ********************************************************************************************* +// Manually-written - auto copied from extra.d.ts +// ********************************************************************************************* + +// AllowSharedBufferSource wasn't introduced until TypeScript 5.2. +// But it also didn't include SharedArrayBuffer in the union. +// This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't. +// So, we use our own definition for AllowSharedBufferSource. + +type GPUAllowSharedBufferSource = + + | BufferSource + | SharedArrayBuffer; + +// Stronger typing for getContext() + +interface HTMLCanvasElement { + getContext( + contextId: + | "webgpu" + ): GPUCanvasContext | null; +} +interface OffscreenCanvas { + getContext( + contextId: + | "webgpu" + ): GPUCanvasContext | null; +} + +// Defined as an empty interface here to prevent errors when using these types in a worker. + +interface HTMLVideoElement {} + +// Strict types defined to help developers catch a common class of errors. +// This interface defines depth as an undefined, which will cause a type check failure if someone +// attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.) + +type GPUOrigin2DStrict = + + | Iterable + | GPUOrigin2DDictStrict; +interface GPUOrigin2DDictStrict + extends GPUOrigin2DDict { + /** @deprecated Does not exist for GPUOrigin2D. */ + z?: undefined; +} +type GPUExtent3DStrict = + + | Iterable + | GPUExtent3DDictStrict; +interface GPUExtent3DDictStrict + extends GPUExtent3DDict { + /** @deprecated The correct name is `depthOrArrayLayers`. */ + depth?: undefined; +} + +// Stronger typing for event listeners. + +/** @internal */ +interface __GPUDeviceEventMap { + uncapturederror: GPUUncapturedErrorEvent; +} + +// Extensions to the generated definition below. +interface GPUDevice { + addEventListener< + K extends keyof __GPUDeviceEventMap + >( + type: K, + listener: ( + this: GPUDevice, + ev: __GPUDeviceEventMap[K] + ) => any, + options?: + | boolean + | AddEventListenerOptions + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: + | boolean + | AddEventListenerOptions + ): void; + removeEventListener< + K extends keyof __GPUDeviceEventMap + >( + type: K, + listener: ( + this: GPUDevice, + ev: __GPUDeviceEventMap[K] + ) => any, + options?: + | boolean + | EventListenerOptions + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: + | boolean + | EventListenerOptions + ): void; +} + +interface GPUCanvasConfigurationOut + extends Required< + Omit< + GPUCanvasConfiguration, + "toneMapping" + > + > { + /** {@inheritDoc GPUCanvasConfiguration.viewFormats} */ + viewFormats: GPUTextureFormat[]; + /** + * {@inheritDoc GPUCanvasConfiguration.toneMapping} + */ + toneMapping?: GPUCanvasToneMapping; +} + +/** @deprecated Use {@link GPUTexelCopyBufferLayout} */ +type GPUImageDataLayout = + GPUTexelCopyBufferLayout; +/** @deprecated Use {@link GPUTexelCopyBufferInfo} */ +type GPUImageCopyBuffer = + GPUTexelCopyBufferInfo; +/** @deprecated Use {@link GPUTexelCopyTextureInfo} */ +type GPUImageCopyTexture = + GPUTexelCopyTextureInfo; +/** @deprecated Use {@link GPUCopyExternalImageDestInfo} */ +type GPUImageCopyTextureTagged = + GPUCopyExternalImageDestInfo; +/** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */ +type GPUImageCopyExternalImage = + GPUCopyExternalImageSourceInfo; +/** @deprecated Use {@link GPUCopyExternalImageSource} */ +type GPUImageCopyExternalImageSource = + GPUCopyExternalImageSource; + +// ********************************************************************************************* +// Semi-auto-generated (by manual diff with autogenerated types) +// ********************************************************************************************* + +type GPUBindingResource = + + | GPUSampler + | GPUTexture + | GPUTextureView + | GPUBuffer + | GPUBufferBinding + | GPUExternalTexture; +type GPUBufferDynamicOffset = + number; +type GPUBufferUsageFlags = + number; +type GPUColor = + + | Iterable + | GPUColorDict; +type GPUColorWriteFlags = + number; +type GPUCopyExternalImageSource = + + | ImageBitmap + | ImageData + | HTMLImageElement + | HTMLVideoElement + | VideoFrame + | HTMLCanvasElement + | OffscreenCanvas; +type GPUDepthBias = + number; +type GPUExtent3D = + + | Iterable + | GPUExtent3DDict; +type GPUFlagsConstant = + number; +type GPUIndex32 = + number; +type GPUIntegerCoordinate = + number; +type GPUIntegerCoordinateOut = + number; +type GPUMapModeFlags = + number; +type GPUOrigin2D = + + | Iterable + | GPUOrigin2DDict; +type GPUOrigin3D = + + | Iterable + | GPUOrigin3DDict; +type GPUPipelineConstantValue = + number; +type GPUSampleMask = + number; +type GPUShaderStageFlags = + number; +type GPUSignedOffset32 = + number; +type GPUSize32 = + number; +type GPUSize32Out = + number; +type GPUSize64 = + number; +type GPUSize64Out = + number; +type GPUStencilValue = + number; +type GPUTextureUsageFlags = + number; +type GPUAddressMode = + + | "clamp-to-edge" + | "repeat" + | "mirror-repeat"; +type GPUAutoLayoutMode = + "auto"; +type GPUBlendFactor = + + | "zero" + | "one" + | "src" + | "one-minus-src" + | "src-alpha" + | "one-minus-src-alpha" + | "dst" + | "one-minus-dst" + | "dst-alpha" + | "one-minus-dst-alpha" + | "src-alpha-saturated" + | "constant" + | "one-minus-constant" + | "src1" + | "one-minus-src1" + | "src1-alpha" + | "one-minus-src1-alpha"; +type GPUBlendOperation = + + | "add" + | "subtract" + | "reverse-subtract" + | "min" + | "max"; +type GPUBufferBindingType = + + | "uniform" + | "storage" + | "read-only-storage"; +type GPUBufferMapState = + + | "unmapped" + | "pending" + | "mapped"; +type GPUCanvasAlphaMode = + + | "opaque" + | "premultiplied"; +type GPUCanvasToneMappingMode = + + | "standard" + | "extended"; +type GPUCompareFunction = + + | "never" + | "less" + | "equal" + | "less-equal" + | "greater" + | "not-equal" + | "greater-equal" + | "always"; +type GPUCompilationMessageType = + + | "error" + | "warning" + | "info"; +type GPUCullMode = + + | "none" + | "front" + | "back"; +type GPUDeviceLostReason = + + | "unknown" + | "destroyed"; +type GPUErrorFilter = + + | "validation" + | "out-of-memory" + | "internal"; +type GPUFeatureName = + + | "core-features-and-limits" + | "depth-clip-control" + | "depth32float-stencil8" + | "texture-compression-bc" + | "texture-compression-bc-sliced-3d" + | "texture-compression-etc2" + | "texture-compression-astc" + | "texture-compression-astc-sliced-3d" + | "timestamp-query" + | "indirect-first-instance" + | "shader-f16" + | "rg11b10ufloat-renderable" + | "bgra8unorm-storage" + | "float32-filterable" + | "float32-blendable" + | "clip-distances" + | "dual-source-blending" + | "subgroups" + | "texture-formats-tier1" + | "texture-formats-tier2" + | "primitive-index" + | "texture-component-swizzle" + | "subgroup-size-control" + | "texture-compression-unaligned" + | "atomic-vec2u-min-max"; +type GPUFilterMode = + + | "nearest" + | "linear"; +type GPUFrontFace = + + | "ccw" + | "cw"; +type GPUIndexFormat = + + | "uint16" + | "uint32"; +type GPULoadOp = + + | "load" + | "clear"; +type GPUMipmapFilterMode = + + | "nearest" + | "linear"; +type GPUPipelineErrorReason = + + | "validation" + | "internal"; +type GPUPowerPreference = + + | "low-power" + | "high-performance"; +type GPUPrimitiveTopology = + + | "point-list" + | "line-list" + | "line-strip" + | "triangle-list" + | "triangle-strip"; +type GPUQueryType = + + | "occlusion" + | "timestamp"; +type GPUSamplerBindingType = + + | "filtering" + | "non-filtering" + | "comparison"; +type GPUStencilOperation = + + | "keep" + | "zero" + | "replace" + | "invert" + | "increment-clamp" + | "decrement-clamp" + | "increment-wrap" + | "decrement-wrap"; +type GPUStorageTextureAccess = + + | "write-only" + | "read-only" + | "read-write"; +type GPUStoreOp = + + | "store" + | "discard"; +type GPUTextureAspect = + + | "all" + | "stencil-only" + | "depth-only"; +type GPUTextureDimension = + + | "1d" + | "2d" + | "3d"; +type GPUTextureFormat = + + | "r8unorm" + | "r8snorm" + | "r8uint" + | "r8sint" + | "r16unorm" + | "r16snorm" + | "r16uint" + | "r16sint" + | "r16float" + | "rg8unorm" + | "rg8snorm" + | "rg8uint" + | "rg8sint" + | "r32uint" + | "r32sint" + | "r32float" + | "rg16unorm" + | "rg16snorm" + | "rg16uint" + | "rg16sint" + | "rg16float" + | "rgba8unorm" + | "rgba8unorm-srgb" + | "rgba8snorm" + | "rgba8uint" + | "rgba8sint" + | "bgra8unorm" + | "bgra8unorm-srgb" + | "rgb9e5ufloat" + | "rgb10a2uint" + | "rgb10a2unorm" + | "rg11b10ufloat" + | "rg32uint" + | "rg32sint" + | "rg32float" + | "rgba16unorm" + | "rgba16snorm" + | "rgba16uint" + | "rgba16sint" + | "rgba16float" + | "rgba32uint" + | "rgba32sint" + | "rgba32float" + | "stencil8" + | "depth16unorm" + | "depth24plus" + | "depth24plus-stencil8" + | "depth32float" + | "depth32float-stencil8" + | "bc1-rgba-unorm" + | "bc1-rgba-unorm-srgb" + | "bc2-rgba-unorm" + | "bc2-rgba-unorm-srgb" + | "bc3-rgba-unorm" + | "bc3-rgba-unorm-srgb" + | "bc4-r-unorm" + | "bc4-r-snorm" + | "bc5-rg-unorm" + | "bc5-rg-snorm" + | "bc6h-rgb-ufloat" + | "bc6h-rgb-float" + | "bc7-rgba-unorm" + | "bc7-rgba-unorm-srgb" + | "etc2-rgb8unorm" + | "etc2-rgb8unorm-srgb" + | "etc2-rgb8a1unorm" + | "etc2-rgb8a1unorm-srgb" + | "etc2-rgba8unorm" + | "etc2-rgba8unorm-srgb" + | "eac-r11unorm" + | "eac-r11snorm" + | "eac-rg11unorm" + | "eac-rg11snorm" + | "astc-4x4-unorm" + | "astc-4x4-unorm-srgb" + | "astc-5x4-unorm" + | "astc-5x4-unorm-srgb" + | "astc-5x5-unorm" + | "astc-5x5-unorm-srgb" + | "astc-6x5-unorm" + | "astc-6x5-unorm-srgb" + | "astc-6x6-unorm" + | "astc-6x6-unorm-srgb" + | "astc-8x5-unorm" + | "astc-8x5-unorm-srgb" + | "astc-8x6-unorm" + | "astc-8x6-unorm-srgb" + | "astc-8x8-unorm" + | "astc-8x8-unorm-srgb" + | "astc-10x5-unorm" + | "astc-10x5-unorm-srgb" + | "astc-10x6-unorm" + | "astc-10x6-unorm-srgb" + | "astc-10x8-unorm" + | "astc-10x8-unorm-srgb" + | "astc-10x10-unorm" + | "astc-10x10-unorm-srgb" + | "astc-12x10-unorm" + | "astc-12x10-unorm-srgb" + | "astc-12x12-unorm" + | "astc-12x12-unorm-srgb"; +type GPUTextureSampleType = + + | "float" + | "unfilterable-float" + | "depth" + | "sint" + | "uint"; +type GPUTextureViewDimension = + + | "1d" + | "2d" + | "2d-array" + | "cube" + | "cube-array" + | "3d"; +type GPUVertexFormat = + + | "uint8" + | "uint8x2" + | "uint8x4" + | "sint8" + | "sint8x2" + | "sint8x4" + | "unorm8" + | "unorm8x2" + | "unorm8x4" + | "snorm8" + | "snorm8x2" + | "snorm8x4" + | "uint16" + | "uint16x2" + | "uint16x4" + | "sint16" + | "sint16x2" + | "sint16x4" + | "unorm16" + | "unorm16x2" + | "unorm16x4" + | "snorm16" + | "snorm16x2" + | "snorm16x4" + | "float16" + | "float16x2" + | "float16x4" + | "float32" + | "float32x2" + | "float32x3" + | "float32x4" + | "uint32" + | "uint32x2" + | "uint32x3" + | "uint32x4" + | "sint32" + | "sint32x2" + | "sint32x3" + | "sint32x4" + | "unorm10-10-10-2" + | "unorm8x4-bgra" + | "snorm10-10-10-2"; +type GPUVertexStepMode = + + | "vertex" + | "instance"; + +interface GPUBindGroupDescriptor + extends GPUObjectDescriptorBase { + /** + * The {@link GPUBindGroupLayout} the entries of this bind group will conform to. + */ + layout: GPUBindGroupLayout; + /** + * A list of entries describing the resources to expose to the shader for each binding + * described by the {@link GPUBindGroupDescriptor#layout}. + */ + entries: Iterable; +} + +interface GPUBindGroupEntry { + /** + * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a + * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding + * attribute in the {@link GPUShaderModule}. + */ + binding: GPUIndex32; + /** + * The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, + * {@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. + */ + resource: GPUBindingResource; +} + +interface GPUBindGroupLayoutDescriptor + extends GPUObjectDescriptorBase { + /** + * A list of entries describing the shader resource bindings for a bind group. + */ + entries: Iterable; +} + +interface GPUBindGroupLayoutEntry { + /** + * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding + * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding + * attribute in the {@link GPUShaderModule}. + */ + binding: GPUIndex32; + /** + * A bitset of the members of {@link GPUShaderStage}. + * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource + * will be accessible from the associated shader stage. + */ + visibility: GPUShaderStageFlags; + /** + */ + buffer?: GPUBufferBindingLayout; + /** + */ + sampler?: GPUSamplerBindingLayout; + /** + */ + texture?: GPUTextureBindingLayout; + /** + */ + storageTexture?: GPUStorageTextureBindingLayout; + /** + * Exactly one of these members must be set, indicating the binding type. + * The contents of the member specify options specific to that type. + * The corresponding resource in {@link GPUDevice#createBindGroup} requires + * the corresponding binding resource type for this binding. + */ + externalTexture?: GPUExternalTextureBindingLayout; +} + +interface GPUBlendComponent { + /** + * Defines the {@link GPUBlendOperation} used to calculate the values written to the target + * attachment components. + */ + operation?: GPUBlendOperation; + /** + * Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader. + */ + srcFactor?: GPUBlendFactor; + /** + * Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment. + */ + dstFactor?: GPUBlendFactor; +} + +interface GPUBlendState { + /** + * Defines the blending behavior of the corresponding render target for color channels. + */ + color: GPUBlendComponent; + /** + * Defines the blending behavior of the corresponding render target for the alpha channel. + */ + alpha: GPUBlendComponent; +} + +interface GPUBufferBinding { + /** + * The {@link GPUBuffer} to bind. + */ + buffer: GPUBuffer; + /** + * The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the + * beginning of the range exposed to the shader by the buffer binding. + */ + offset?: GPUSize64; + /** + * The size, in bytes, of the buffer binding. + * If not map/exist|provided, specifies the range starting at + * {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. + */ + size?: GPUSize64; +} + +interface GPUBufferBindingLayout { + /** + * Indicates the type required for buffers bound to this binding. + */ + type?: GPUBufferBindingType; + /** + * Indicates whether this binding requires a dynamic offset. + */ + hasDynamicOffset?: boolean; + /** + * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. + * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. + * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] + * that this value ≥ the minimum buffer binding size of the variable. + * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands + * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} + * satisfies the minimum buffer binding size of the variable. + * Note: + * Similar execution-time validation is theoretically possible for other + * binding-related fields specified for early validation, like + * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, + * which currently can only be validated in pipeline creation. + * However, such execution-time validation could be costly or unnecessarily complex, so it is + * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the + * most ergonomic impact. + */ + minBindingSize?: GPUSize64; +} + +interface GPUBufferDescriptor + extends GPUObjectDescriptorBase { + /** + * The size of the buffer in bytes. + */ + size: GPUSize64; + /** + * The allowed usages for the buffer. + */ + usage: GPUBufferUsageFlags; + /** + * If `true` creates the buffer in an already mapped state, allowing + * {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set + * {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} + * does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be + * used to set the buffer's initial data. + * Guarantees that even if the buffer creation eventually fails, it will still appear as if the + * mapped range can be written/read to until it is unmapped. + */ + mappedAtCreation?: boolean; +} + +interface GPUCanvasConfiguration { + /** + * The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be + * compatible with. + */ + device: GPUDevice; + /** + * The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. + * Must be one of the Supported context formats. + */ + format: GPUTextureFormat; + /** + * The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. + * {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included + * if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} + * when setting a custom usage if you wish to use textures returned by + * {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. + */ + usage?: GPUTextureUsageFlags; + /** + * The formats that views created from textures returned by + * {@link GPUCanvasContext#getCurrentTexture} may use. + */ + viewFormats?: Iterable; + /** + * The color space that values written into textures returned by + * {@link GPUCanvasContext#getCurrentTexture} should be displayed with. + */ + colorSpace?: PredefinedColorSpace; + /** + * The tone mapping determines how the content of textures returned by + * {@link GPUCanvasContext#getCurrentTexture} are to be displayed. + *
+ * This is a required feature, but user agents might not yet implement it, + * effectively supporting only the default {@link GPUCanvasToneMapping}. + * In such implementations, this member **should not** exist in its implementation of + * {@link GPUCanvasConfiguration}, to make feature detection possible using + * {@link GPUCanvasContext#getConfiguration}. + * This is especially important in implementations which otherwise have HDR capabilities + * (where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be + * exposed). + * If an implementation exposes this member and a `high` dynamic range, it **should** render the + * canvas as an HDR element, not clamp values to the SDR range of the HDR display. + *
+ */ + toneMapping?: GPUCanvasToneMapping; + /** + * Determines the effect that alpha values will have on the content of textures returned by + * {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. + */ + alphaMode?: GPUCanvasAlphaMode; +} + +interface GPUCanvasToneMapping { + mode?: GPUCanvasToneMappingMode; +} + +interface GPUColorDict { + /** + * The red channel value. + */ + r: number; + /** + * The green channel value. + */ + g: number; + /** + * The blue channel value. + */ + b: number; + /** + * The alpha channel value. + */ + a: number; +} + +interface GPUColorTargetState { + /** + * The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with + * {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the + * corresponding color attachment. + */ + format: GPUTextureFormat; + /** + * The blending behavior for this color target. If left undefined, disables blending for this + * color target. + */ + blend?: GPUBlendState; + /** + * Bitmask controlling which channels are are written to when drawing to this color target. + */ + writeMask?: GPUColorWriteFlags; +} + +type GPUCommandBufferDescriptor = + GPUObjectDescriptorBase; +type GPUCommandEncoderDescriptor = + GPUObjectDescriptorBase; + +interface GPUComputePassDescriptor + extends GPUObjectDescriptorBase { + /** + * Defines which timestamp values will be written for this pass, and where to write them to. + */ + timestampWrites?: GPUComputePassTimestampWrites; +} + +interface GPUComputePassTimestampWrites { + /** + * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be + * written to. + */ + querySet: GPUQuerySet; + /** + * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into + * which the timestamp at the beginning of the compute pass will be written. + */ + beginningOfPassWriteIndex?: GPUSize32; + /** + * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into + * which the timestamp at the end of the compute pass will be written. + */ + endOfPassWriteIndex?: GPUSize32; +} + +interface GPUComputePipelineDescriptor + extends GPUPipelineDescriptorBase { + /** + * Describes the compute shader entry point of the pipeline. + */ + compute: GPUProgrammableStage; +} + +interface GPUCopyExternalImageDestInfo + extends GPUTexelCopyTextureInfo { + /** + * Describes the color space and encoding used to encode data into the destination texture. + * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1] + * being written to the target texture, if its format can represent them. + * Otherwise, the results are clamped to the target texture format's range. + * Note: + * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, + * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. + */ + colorSpace?: PredefinedColorSpace; + /** + * Describes whether the data written into the texture should have its RGB channels + * premultiplied by the alpha channel, or not. + * If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also + * premultiplied, the source RGB values must be preserved even if they exceed their + * corresponding alpha values. + * Note: + * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, + * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. + */ + premultipliedAlpha?: boolean; +} + +interface GPUCopyExternalImageSourceInfo { + /** + * The source of the texel copy. The copy source data is captured at the moment that + * {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described + * by the external source dimensions table. + */ + source: GPUCopyExternalImageSource; + /** + * Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from. + * Together with `copySize`, defines the full copy sub-region. + */ + origin?: GPUOrigin2D; + /** + * Describes whether the source image is vertically flipped, or not. + * If this option is set to `true`, the copy is flipped vertically: the bottom row of the source + * region is copied into the first row of the destination region, and so on. + * The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner + * of the source image, increasing downward. + */ + flipY?: boolean; +} + +interface GPUDepthStencilState { + /** + * The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} + * this {@link GPURenderPipeline} will be compatible with. + */ + format: GPUTextureFormat; + /** + * Indicates if this {@link GPURenderPipeline} can modify + * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values. + */ + depthWriteEnabled?: boolean; + /** + * The comparison operation used to test fragment depths against + * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values. + */ + depthCompare?: GPUCompareFunction; + /** + * Defines how stencil comparisons and operations are performed for front-facing primitives. + */ + stencilFront?: GPUStencilFaceState; + /** + * Defines how stencil comparisons and operations are performed for back-facing primitives. + */ + stencilBack?: GPUStencilFaceState; + /** + * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value + * bits are read when performing stencil comparison tests. + */ + stencilReadMask?: GPUStencilValue; + /** + * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value + * bits are written to when performing stencil operations. + */ + stencilWriteMask?: GPUStencilValue; + /** + * Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details. + */ + depthBias?: GPUDepthBias; + /** + * Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details. + */ + depthBiasSlopeScale?: number; + /** + * The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details. + */ + depthBiasClamp?: number; +} + +interface GPUDeviceDescriptor + extends GPUObjectDescriptorBase { + /** + * Specifies the features that are required by the device request. + * The request will fail if the adapter cannot provide these features. + * Exactly the specified set of features, and no more or less, will be allowed in validation + * of API calls on the resulting device. + */ + requiredFeatures?: Iterable; + /** + * Specifies the limits that are required by the device request. + * The request will fail if the adapter cannot provide these limits. + * Each key with a non-`undefined` value must be the name of a member of supported limits. + * API calls on the resulting device perform validation according to the exact limits of the + * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). + * + */ + requiredLimits?: Record< + string, + | GPUSize64 + | undefined + >; + /** + * The descriptor for the default {@link GPUQueue}. + */ + defaultQueue?: GPUQueueDescriptor; +} + +interface GPUExtent3DDict { + /** + * The width of the extent. + */ + width: GPUIntegerCoordinate; + /** + * The height of the extent. + */ + height?: GPUIntegerCoordinate; + /** + * The depth of the extent or the number of array layers it contains. + * If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `"3d"` + * defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension} + * of {@link GPUTextureDimension} `"2d"` defines the number of array layers in the texture. + */ + depthOrArrayLayers?: GPUIntegerCoordinate; +} + +interface GPUExternalTextureBindingLayout {} + +interface GPUExternalTextureDescriptor + extends GPUObjectDescriptorBase { + /** + * The video source to import the external texture from. Source size is determined as described + * by the external source dimensions table. + */ + source: + | HTMLVideoElement + | VideoFrame; + /** + * The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be + * converted into when reading. + */ + colorSpace?: PredefinedColorSpace; +} + +interface GPUFragmentState + extends GPUProgrammableStage { + /** + * A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets + * this pipeline writes to. + */ + targets: Iterable< + | GPUColorTargetState + | null + | undefined + >; +} + +interface GPUMultisampleState { + /** + * Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only + * with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} + * and {@link GPURenderPassDescriptor#depthStencilAttachment}) + * with matching {@link GPUTextureDescriptor#sampleCount}s. + */ + count?: GPUSize32; + /** + * Mask determining which samples are written to. + */ + mask?: GPUSampleMask; + /** + * When `true` indicates that a fragment's alpha channel should be used to generate a sample + * coverage mask. + */ + alphaToCoverageEnabled?: boolean; +} + +interface GPUObjectDescriptorBase { + /** + * The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}. + */ + label?: string; +} + +interface GPUOrigin2DDict { + x?: GPUIntegerCoordinate; + y?: GPUIntegerCoordinate; +} + +interface GPUOrigin3DDict { + x?: GPUIntegerCoordinate; + y?: GPUIntegerCoordinate; + z?: GPUIntegerCoordinate; +} + +interface GPUPipelineDescriptorBase + extends GPUObjectDescriptorBase { + /** + * The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `"auto"` to generate + * the pipeline layout automatically. + * Note: If {@link GPUAutoLayoutMode} `"auto"` is used the pipeline cannot share {@link GPUBindGroup}s + * with any other pipelines. + */ + layout: + | GPUPipelineLayout + | GPUAutoLayoutMode; +} + +interface GPUPipelineErrorInit { + reason: GPUPipelineErrorReason; +} + +interface GPUPipelineLayoutDescriptor + extends GPUObjectDescriptorBase { + /** + * A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds + * to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding + * with `@group(N)`. + */ + bindGroupLayouts: Iterable< + | GPUBindGroupLayout + | null + | undefined + >; + /** + * The size, in bytes, of the immediate data range used by the pipeline. + */ + immediateSize?: GPUSize32; +} + +interface GPUPrimitiveState { + /** + * The type of primitive to be constructed from the vertex inputs. + */ + topology?: GPUPrimitiveTopology; + /** + * For pipelines with strip topologies + * ({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), + * this determines the index buffer format and primitive restart value + * ({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). + * It is not allowed on pipelines with non-strip topologies. + * Note: Some implementations require knowledge of the primitive restart value to compile + * pipeline state objects. + * To use a strip-topology pipeline with an indexed draw call + * ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), + * this must be set, and it must match the index buffer format used with the draw call + * (set in {@link GPURenderCommandsMixin#setIndexBuffer}). + * See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. + */ + stripIndexFormat?: GPUIndexFormat; + /** + * Defines which polygons are considered front-facing. + */ + frontFace?: GPUFrontFace; + /** + * Defines which polygon orientation will be culled, if any. + */ + cullMode?: GPUCullMode; + /** + * If true, indicates that depth clipping is disabled. + * Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. + */ + unclippedDepth?: boolean; +} + +interface GPUProgrammableStage { + /** + * The {@link GPUShaderModule} containing the code that this programmable stage will execute. + */ + module: GPUShaderModule; + /** + * The name of the function in {@link GPUProgrammableStage#module} that this stage will use to + * perform its work. + * NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is + * not required, methods which consume a {@link GPUProgrammableStage} must use the + * "[$get the entry point$]" algorithm to determine which entry point + * it refers to. + */ + entryPoint?: string; + /** + * Specifies the values of pipeline-overridable constants in the shader module + * {@link GPUProgrammableStage#module}. + * Each such pipeline-overridable constant is uniquely identified by a single + * pipeline-overridable constant identifier string, representing the pipeline + * constant ID of the constant if its declaration specifies one, and otherwise the + * constant's identifier name. + * The key of each key-value pair must equal the + * pipeline-overridable constant identifier string|identifier string + * of one such constant, with the comparison performed + * according to the rules for WGSL identifier comparison. + * When the pipeline is executed, that constant will have the specified value. + * Values are specified as GPUPipelineConstantValue, which is a `double`. + * They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). + * If conversion fails, a validation error is generated. + *
+ * Pipeline-overridable constants defined in WGSL: + * ```wgsl + * @id(0) override has_point_light: bool = true; // Algorithmic control. + * @id(1200) override specular_param: f32 = 2.3; // Numeric control. + * @id(1300) override gain: f32; // Must be overridden. + * override width: f32 = 0.0; // Specifed at the API level + * // using the name "width". + * override depth: f32; // Specifed at the API level + * // using the name "depth". + * // Must be overridden. + * override height = 2 * depth; // The default value + * // (if not set at the API level), + * // depends on another + * // overridable constant. + * ``` + * Corresponding JavaScript code, providing only the overrides which are required + * (have no defaults): + * ```js + * { + * // ... + * constants: { + * 1300: 2.0, // "gain" + * depth: -1, // "depth" + * } + * } + * ``` + * Corresponding JavaScript code, overriding all constants: + * ```js + * { + * // ... + * constants: { + * 0: false, // "has_point_light" + * 1200: 3.0, // "specular_param" + * 1300: 2.0, // "gain" + * width: 20, // "width" + * depth: -1, // "depth" + * height: 15, // "height" + * } + * } + * ``` + *
+ */ + constants?: Record< + string, + GPUPipelineConstantValue + >; +} + +interface GPUQuerySetDescriptor + extends GPUObjectDescriptorBase { + /** + * The type of queries managed by {@link GPUQuerySet}. + */ + type: GPUQueryType; + /** + * The number of queries managed by {@link GPUQuerySet}. + */ + count: GPUSize32; +} + +type GPUQueueDescriptor = + GPUObjectDescriptorBase; +type GPURenderBundleDescriptor = + GPUObjectDescriptorBase; + +interface GPURenderBundleEncoderDescriptor + extends GPURenderPassLayout { + /** + * If `true`, indicates that the render bundle does not modify the depth component of the + * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed + * in. + * See read-only depth-stencil. + */ + depthReadOnly?: boolean; + /** + * If `true`, indicates that the render bundle does not modify the stencil component of the + * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed + * in. + * See read-only depth-stencil. + */ + stencilReadOnly?: boolean; +} + +interface GPURenderPassColorAttachment { + /** + * Describes the texture subresource that will be output to for this color attachment. + * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). + */ + view: + | GPUTexture + | GPUTextureView; + /** + * Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} + * that will be output to for this color attachment. + */ + depthSlice?: GPUIntegerCoordinate; + /** + * Describes the texture subresource that will receive the resolved output for this color + * attachment if {@link GPURenderPassColorAttachment#view} is multisampled. + * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). + */ + resolveTarget?: + | GPUTexture + | GPUTextureView; + /** + * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the + * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored + * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. + * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. + * They are converted [$to a texel value of texture format$] matching the render attachment. + * If conversion fails, a validation error is generated. + */ + clearValue?: GPUColor; + /** + * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to + * executing the render pass. + * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. + */ + loadOp: GPULoadOp; + /** + * The store operation to perform on {@link GPURenderPassColorAttachment#view} + * after executing the render pass. + */ + storeOp: GPUStoreOp; +} + +interface GPURenderPassDepthStencilAttachment { + /** + * Describes the texture subresource that will be output to and read from for this + * depth/stencil attachment. + * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). + */ + view: + | GPUTexture + | GPUTextureView; + /** + * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component + * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} + * is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. + * + */ + depthClearValue?: number; + /** + * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s + * depth component prior to executing the render pass. + * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. + */ + depthLoadOp?: GPULoadOp; + /** + * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s + * depth component after executing the render pass. + */ + depthStoreOp?: GPUStoreOp; + /** + * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} + * is read only. + */ + depthReadOnly?: boolean; + /** + * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component + * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} + * is not {@link GPULoadOp} `"clear"`. + * The value will be converted to the type of the stencil aspect of `view` by taking the same + * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. + */ + stencilClearValue?: GPUStencilValue; + /** + * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s + * stencil component prior to executing the render pass. + * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. + */ + stencilLoadOp?: GPULoadOp; + /** + * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s + * stencil component after executing the render pass. + */ + stencilStoreOp?: GPUStoreOp; + /** + * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} + * is read only. + */ + stencilReadOnly?: boolean; +} + +interface GPURenderPassDescriptor + extends GPUObjectDescriptorBase { + /** + * The set of {@link GPURenderPassColorAttachment} values in this sequence defines which + * color attachments will be output to when executing this render pass. + * Due to compatible usage list|usage compatibility, no color attachment + * may alias another attachment or any resource used inside the render pass. + */ + colorAttachments: Iterable< + | GPURenderPassColorAttachment + | null + | undefined + >; + /** + * The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil + * attachment that will be output to and tested against when executing this render pass. + * Due to compatible usage list|usage compatibility, no writable depth/stencil attachment + * may alias another attachment or any resource used inside the render pass. + */ + depthStencilAttachment?: GPURenderPassDepthStencilAttachment; + /** + * The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass. + */ + occlusionQuerySet?: GPUQuerySet; + /** + * Defines which timestamp values will be written for this pass, and where to write them to. + */ + timestampWrites?: GPURenderPassTimestampWrites; + /** + * The maximum number of draw calls that will be done in the render pass. Used by some + * implementations to size work injected before the render pass. Keeping the default value + * is a good default, unless it is known that more draw calls will be done. + */ + maxDrawCount?: GPUSize64; +} + +interface GPURenderPassLayout + extends GPUObjectDescriptorBase { + /** + * A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle. + */ + colorFormats: Iterable< + | GPUTextureFormat + | null + | undefined + >; + /** + * The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle. + */ + depthStencilFormat?: GPUTextureFormat; + /** + * Number of samples per pixel in the attachments for this pass or bundle. + */ + sampleCount?: GPUSize32; +} + +interface GPURenderPassTimestampWrites { + /** + * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be + * written to. + */ + querySet: GPUQuerySet; + /** + * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into + * which the timestamp at the beginning of the render pass will be written. + */ + beginningOfPassWriteIndex?: GPUSize32; + /** + * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into + * which the timestamp at the end of the render pass will be written. + */ + endOfPassWriteIndex?: GPUSize32; +} + +interface GPURenderPipelineDescriptor + extends GPUPipelineDescriptorBase { + /** + * Describes the vertex shader entry point of the pipeline and its input buffer layouts. + */ + vertex: GPUVertexState; + /** + * Describes the primitive-related properties of the pipeline. + */ + primitive?: GPUPrimitiveState; + /** + * Describes the optional depth-stencil properties, including the testing, operations, and bias. + */ + depthStencil?: GPUDepthStencilState; + /** + * Describes the multi-sampling properties of the pipeline. + */ + multisample?: GPUMultisampleState; + /** + * Describes the fragment shader entry point of the pipeline and its output colors. If + * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. + */ + fragment?: GPUFragmentState; +} + +interface GPURequestAdapterOptions { + /** + * Requests an adapter that supports at least a particular set of capabilities. + * This influences the {@link adapter#[[default feature level]]} of devices created + * from this adapter. The capabilities for each level are defined below, and the exact + * steps are defined in {@link GPU#requestAdapter} and "a new device". + * If the implementation or system does not support all of the capabilities in the + * requested feature level, {@link GPU#requestAdapter} will return `null`. + * Note: + * Applications should typically make a single {@link GPU#requestAdapter} call with the lowest + * feature level they support, then inspect the adapter for additional capabilities they can + * use optionally, and request those in {@link GPUAdapter#requestDevice}. + * The allowed feature level string values are: + *
+ * : "core" + * The following set of capabilities: + * - The limit/Default limits. + * - {@link GPUFeatureName} `"core-features-and-limits"`. + * Note: + * Adapters with this {@link adapter#[[default feature level]]} may + * conventionally be referred to as "Core-defaulting". + * : "compatibility" + * The following set of capabilities: + * - The limit/Compatibility Mode Default limits. + * - No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) + * If the implementation cannot enforce the stricter "Compatibility Mode" + * validation rules, {@link GPU#requestAdapter} will ignore this request and + * treat it as a request for feature level string/"core". + * Note: + * Adapters with this {@link adapter#[[default feature level]]} may + * conventionally be referred to as "Compatibility-defaulting". + */ + featureLevel?: string; + /** + * Optionally provides a hint indicating what class of adapter should be selected from + * the system's available adapters. + * The value of this hint may influence which adapter is chosen, but it must not + * influence whether an adapter is returned or not. + * Note: + * The primary utility of this hint is to influence which GPU is used in a multi-GPU system. + * For instance, some laptops have a low-power integrated GPU and a high-performance + * discrete GPU. This hint may also affect the power configuration of the selected GPU to + * match the requested power preference. + * Note: + * Depending on the exact hardware configuration, such as battery status and attached displays + * or removable GPUs, the user agent may select different adapters given the same power + * preference. + * Typically, given the same hardware configuration and state and + * `powerPreference`, the user agent is likely to select the same adapter. + */ + powerPreference?: GPUPowerPreference; + /** + * When set to `true` indicates that only a fallback adapter may be returned. If the user + * agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to + * resolve to `null`. + * Note: + * {@link GPU#requestAdapter} may still return a fallback adapter if + * {@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no + * other appropriate adapter is available or the user agent chooses to return a + * fallback adapter. Developers that wish to prevent their applications from running on + * fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} + * attribute prior to requesting a {@link GPUDevice}. + */ + forceFallbackAdapter?: boolean; + xrCompatible?: boolean; +} + +interface GPUSamplerBindingLayout { + /** + * Indicates the required type of a sampler bound to this bindings. + */ + type?: GPUSamplerBindingType; +} + +interface GPUSamplerDescriptor + extends GPUObjectDescriptorBase { + /** + */ + addressModeU?: GPUAddressMode; + /** + */ + addressModeV?: GPUAddressMode; + /** + * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth + * coordinates, respectively. + */ + addressModeW?: GPUAddressMode; + /** + * Specifies the sampling behavior when the sampled area is smaller than or equal to one + * texel. + */ + magFilter?: GPUFilterMode; + /** + * Specifies the sampling behavior when the sampled area is larger than one texel. + */ + minFilter?: GPUFilterMode; + /** + * Specifies behavior for sampling between mipmap levels. + */ + mipmapFilter?: GPUMipmapFilterMode; + /** + */ + lodMinClamp?: number; + /** + * Specifies the minimum and maximum levels of detail, respectively, used internally when + * sampling a texture. + */ + lodMaxClamp?: number; + /** + * When provided the sampler will be a comparison sampler with the specified + * {@link GPUCompareFunction}. + * Note: Comparison samplers may use filtering, but the sampling results will be + * implementation-dependent and may differ from the normal filtering rules. + */ + compare?: GPUCompareFunction; + /** + * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is + * enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. + * Anisotropic filtering improves the image quality of textures sampled at oblique viewing + * angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of + * anisotropy supported when filtering. + *
+ * Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range + * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} + * will be clamped to the maximum value that the platform supports. + * The precise filtering behavior is implementation-dependent. + *
+ */ + maxAnisotropy?: number; +} + +interface GPUShaderModuleCompilationHint { + entryPoint: string; + /** + * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future + * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. + * If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] + * for the entry point associated with this hint will be used. + */ + layout?: + | GPUPipelineLayout + | GPUAutoLayoutMode; +} + +interface GPUShaderModuleDescriptor + extends GPUObjectDescriptorBase { + /** + * The WGSL source code for the shader + * module. + */ + code: string; + /** + * A list of {@link GPUShaderModuleCompilationHint}s. + * Any hint provided by an application **should** contain information about one entry point of + * a pipeline that will eventually be created from the entry point. + * Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} + * to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. + * Aside from type-checking, these hints are not validated in any way. + *
+ * Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any + * observable effect, other than performance. It may be detrimental to performance to + * provide hints for pipelines that never end up being created. + * Because a single shader module can hold multiple entry points, and multiple pipelines + * can be created from a single shader module, it can be more performant for an + * implementation to do as much compilation as possible once in + * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to + * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. + * Hints are only applied to the entry points they explicitly name. + * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, + * there is no default, even if only one entry point is present in the module. + *
+ * Note: + * Hints are not validated in an observable way, but user agents **may** surface identifiable + * errors (like unknown entry point names or incompatible pipeline layouts) to developers, + * for example in the browser developer console. + */ + compilationHints?: Iterable; +} + +interface GPUStencilFaceState { + /** + * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value + * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. + */ + compare?: GPUCompareFunction; + /** + * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by + * {@link GPUStencilFaceState#compare} fails. + */ + failOp?: GPUStencilOperation; + /** + * The {@link GPUStencilOperation} performed if the fragment depth comparison described by + * {@link GPUDepthStencilState#depthCompare} fails. + */ + depthFailOp?: GPUStencilOperation; + /** + * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by + * {@link GPUStencilFaceState#compare} passes. + */ + passOp?: GPUStencilOperation; +} + +interface GPUStorageTextureBindingLayout { + /** + * The access mode for this binding, indicating readability and writability. + */ + access?: GPUStorageTextureAccess; + /** + * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding. + */ + format: GPUTextureFormat; + /** + * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to + * this binding. + */ + viewDimension?: GPUTextureViewDimension; +} + +interface GPUTexelCopyBufferInfo + extends GPUTexelCopyBufferLayout { + /** + * A buffer which either contains texel data to be copied or will store the texel data being + * copied, depending on the method it is being passed to. + */ + buffer: GPUBuffer; +} + +interface GPUTexelCopyBufferLayout { + /** + * The offset, in bytes, from the beginning of the texel data source (such as a + * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data + * within that source. + */ + offset?: GPUSize64; + /** + * The stride, in bytes, between the beginning of each texel block row and the subsequent + * texel block row. + * Required if there are multiple texel block rows (i.e. the copy height or depth is more + * than one block). + */ + bytesPerRow?: GPUSize32; + /** + * Number of texel block rows per single texel image of the texture. + * {@link GPUTexelCopyBufferLayout#rowsPerImage} × + * {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each + * texel image of data and the subsequent texel image. + * Required if there are multiple texel images (i.e. the copy depth is more than one). + */ + rowsPerImage?: GPUSize32; +} + +interface GPUTexelCopyTextureInfo { + /** + * Texture to copy to/from. + */ + texture: GPUTexture; + /** + * Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. + */ + mipLevel?: GPUIntegerCoordinate; + /** + * Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. + * Together with `copySize`, defines the full copy sub-region. + */ + origin?: GPUOrigin3D; + /** + * Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. + */ + aspect?: GPUTextureAspect; +} + +interface GPUTextureBindingLayout { + /** + * Indicates the type required for texture views bound to this binding. + */ + sampleType?: GPUTextureSampleType; + /** + * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to + * this binding. + */ + viewDimension?: GPUTextureViewDimension; + /** + * Indicates whether or not texture views bound to this binding must be multisampled. + */ + multisampled?: boolean; +} + +interface GPUTextureDescriptor + extends GPUObjectDescriptorBase { + /** + * The width, height, and depth or layer count of the texture. + */ + size: GPUExtent3DStrict; + /** + * The number of mip levels the texture will contain. + */ + mipLevelCount?: GPUIntegerCoordinate; + /** + * The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates + * a multisampled texture. + */ + sampleCount?: GPUSize32; + /** + * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional. + */ + dimension?: GPUTextureDimension; + /** + * The format of the texture. + */ + format: GPUTextureFormat; + /** + * The allowed usages for the texture. + */ + usage: GPUTextureUsageFlags; + /** + * Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling + * {@link GPUTexture#createView} on this texture (in addition to the texture's actual + * {@link GPUTextureDescriptor#format}). + *
+ * Adding a format to this list may have a significant performance impact, so it is best + * to avoid adding formats unnecessarily. + * The actual performance impact is highly dependent on the target system; developers must + * test various systems to find out the impact on their particular application. + * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or + * {@link GPUTextureDescriptor#viewFormats} entry including + * {@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a + * {@link GPUTextureFormat} `"rgba8unorm"` texture which does not. + * Similar caveats exist for other formats and pairs of formats on other systems. + *
+ * Formats in this list must be texture view format compatible with the texture format. + *
+ * Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: + * - `format` equals `viewFormat`, or + * - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. + *
+ */ + viewFormats?: Iterable; + /** + *
+ * On devices without {@link GPUFeatureName} `"core-features-and-limits"`, + * views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. + * If not specified, a default is chosen. + *
+ * On devices with {@link GPUFeatureName} `"core-features-and-limits"`, + * this is ignored, and there is no such restriction. + */ + textureBindingViewDimension?: GPUTextureViewDimension; +} + +interface GPUTextureViewDescriptor + extends GPUObjectDescriptorBase { + /** + * The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the + * texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. + */ + format?: GPUTextureFormat; + /** + * The dimension to view the texture as. + */ + dimension?: GPUTextureViewDimension; + /** + * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the + * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of + * {@link GPUTexture#usage} flags of the texture. + * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the + * texture's {@link GPUTextureDescriptor#usage}s, the default will fail, + * and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. + */ + usage?: GPUTextureUsageFlags; + /** + * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view. + */ + aspect?: GPUTextureAspect; + /** + * The first (most detailed) mipmap level accessible to the texture view. + */ + baseMipLevel?: GPUIntegerCoordinate; + /** + * How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to + * the texture view. + */ + mipLevelCount?: GPUIntegerCoordinate; + /** + * The index of the first array layer accessible to the texture view. + */ + baseArrayLayer?: GPUIntegerCoordinate; + /** + * How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible + * to the texture view. + */ + arrayLayerCount?: GPUIntegerCoordinate; + /** + * A string of length four, with each character mapping to the texture view's red/green/blue/alpha + * channels, respectively. + * When accessed by a shader, the red/green/blue/alpha channels are replaced by the value + * corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and + * `swizzle[3]`, respectively: + * - `"r"`: Take its value from the red channel of the texture. + * - `"g"`: Take its value from the green channel of the texture. + * - `"b"`: Take its value from the blue channel of the texture. + * - `"a"`: Take its value from the alpha channel of the texture. + * - `"0"`: Force its value to 0. + * - `"1"`: Force its value to 1. + * Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. + */ + swizzle?: string; +} + +interface GPUUncapturedErrorEventInit + extends EventInit { + error: GPUError; +} + +interface GPUVertexAttribute { + /** + * The {@link GPUVertexFormat} of the attribute. + */ + format: GPUVertexFormat; + /** + * The offset, in bytes, from the beginning of the element to the data for the attribute. + */ + offset: GPUSize64; + /** + * The numeric location associated with this attribute, which will correspond with a + * "@location" attribute + * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. + */ + shaderLocation: GPUIndex32; +} + +interface GPUVertexBufferLayout { + /** + * The stride, in bytes, between elements of this array. + */ + arrayStride: GPUSize64; + /** + * Whether each element of this array represents per-vertex data or per-instance data + */ + stepMode?: GPUVertexStepMode; + /** + * An array defining the layout of the vertex attributes within each element. + */ + attributes: Iterable; +} + +interface GPUVertexState + extends GPUProgrammableStage { + /** + * A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a + * vertex buffer used by this pipeline. + */ + buffers?: Iterable< + | GPUVertexBufferLayout + | null + | undefined + >; +} + +interface GPUBindingCommandsMixin { + /** + * Sets the current {@link GPUBindGroup} for the given index. + * @param index - The index to set the bind group at. + * @param bindGroup - Bind group to use for subsequent render or compute commands. + * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in + * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.--> + */ + setBindGroup( + index: GPUIndex32, + bindGroup: + | GPUBindGroup + | null + | undefined, + dynamicOffsets?: Iterable + ): undefined; + /** + * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset + * of a Uint32Array. + * @param index - The index to set the bind group at. + * @param bindGroup - Bind group to use for subsequent render or compute commands. + * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in + * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}. + * @param dynamicOffsetsDataStart - Offset in elements into `dynamicOffsetsData` where the + * buffer offset data begins. + * @param dynamicOffsetsDataLength - Number of buffer offsets to read from `dynamicOffsetsData`. + */ + setBindGroup( + index: GPUIndex32, + bindGroup: + | GPUBindGroup + | null + | undefined, + dynamicOffsetsData: Uint32Array, + dynamicOffsetsDataStart: GPUSize64, + dynamicOffsetsDataLength: GPUSize32 + ): undefined; + /** + * Sets immediate data for subsequent render or compute commands. + * @param rangeOffset - Offset in bytes into the immediate data range to begin writing at. + * @param data - Data to write into the immediate data range. + * @param dataOffset - Offset into `data` to begin writing from. Given in elements if + * `data` is a {@link TypedArray} and bytes otherwise. + * @param dataSize - Size of content to write from `data`. Given in elements if + * `data` is a {@link TypedArray} and bytes otherwise. + */ + setImmediates( + rangeOffset: GPUSize32, + data: GPUAllowSharedBufferSource, + dataOffset?: GPUSize64, + dataSize?: GPUSize64 + ): undefined; +} + +interface GPUCommandsMixin {} + +interface GPUDebugCommandsMixin { + /** + * Begins a labeled debug group containing subsequent commands. + * @param groupLabel - The label for the command group. + */ + pushDebugGroup( + groupLabel: string + ): undefined; + /** + * Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}. + */ + popDebugGroup(): undefined; + /** + * Marks a point in a stream of commands with a label. + * @param markerLabel - The label to insert. + */ + insertDebugMarker( + markerLabel: string + ): undefined; +} + +interface GPUObjectBase { + label: string; +} + +interface GPUPipelineBase { + /** + * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s + * {@link GPUBindGroupLayout} at `index`. + * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` + * sequence. + */ + getBindGroupLayout( + index: number + ): GPUBindGroupLayout; +} + +interface GPURenderCommandsMixin { + /** + * Sets the current {@link GPURenderPipeline}. + * @param pipeline - The render pipeline to use for subsequent drawing commands. + */ + setPipeline( + pipeline: GPURenderPipeline + ): undefined; + /** + * Sets the current index buffer. + * @param buffer - Buffer containing index data to use for subsequent drawing commands. + * @param indexFormat - Format of the index data contained in `buffer`. + * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`. + * @param size - Size in bytes of the index data in `buffer`. + * Defaults to the size of the buffer minus the offset. + */ + setIndexBuffer( + buffer: GPUBuffer, + indexFormat: GPUIndexFormat, + offset?: GPUSize64, + size?: GPUSize64 + ): undefined; + /** + * Sets the current vertex buffer for the given slot. + * @param slot - The vertex buffer slot to set the vertex buffer for. + * @param buffer - Buffer containing vertex data to use for subsequent drawing commands. + * @param offset - Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`. + * @param size - Size in bytes of the vertex data in `buffer`. + * Defaults to the size of the buffer minus the offset. + */ + setVertexBuffer( + slot: GPUIndex32, + buffer: + | GPUBuffer + | null + | undefined, + offset?: GPUSize64, + size?: GPUSize64 + ): undefined; + /** + * Draws primitives. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. + * @param vertexCount - The number of vertices to draw. + * @param instanceCount - The number of instances to draw. + * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from. + * @param firstInstance - First instance to draw. + */ + draw( + vertexCount: GPUSize32, + instanceCount?: GPUSize32, + firstVertex?: GPUSize32, + firstInstance?: GPUSize32 + ): undefined; + /** + * Draws indexed primitives. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. + * @param indexCount - The number of indices to draw. + * @param instanceCount - The number of instances to draw. + * @param firstIndex - Offset into the index buffer, in indices, begin drawing from. + * @param baseVertex - Added to each index value before indexing into the vertex buffers. + * @param firstInstance - First instance to draw. + */ + drawIndexed( + indexCount: GPUSize32, + instanceCount?: GPUSize32, + firstIndex?: GPUSize32, + baseVertex?: GPUSignedOffset32, + firstInstance?: GPUSize32 + ): undefined; + /** + * Draws primitives using parameters read from a {@link GPUBuffer}. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. + * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same + * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: + * @param indirectBuffer - Buffer containing the indirect draw parameters. + * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. + */ + drawIndirect( + indirectBuffer: GPUBuffer, + indirectOffset: GPUSize64 + ): undefined; + /** + * Draws indexed primitives using parameters read from a {@link GPUBuffer}. + * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. + * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in + * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: + * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters. + * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. + */ + drawIndexedIndirect( + indirectBuffer: GPUBuffer, + indirectOffset: GPUSize64 + ): undefined; +} + +interface NavigatorGPU { + /** + * A global singleton providing top-level entry points like {@link GPU#requestAdapter}. + */ + readonly gpu: GPU; +} + +interface GPU { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPU"; + /** + * Requests an adapter from the user agent. + * The user agent chooses whether to return an adapter, and, if so, + * chooses according to the provided options. + * @param options - Criteria used to select the adapter. + */ + requestAdapter( + options?: GPURequestAdapterOptions + ): Promise; + /** + * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range + * content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or + * {@link GPUTextureFormat} `"bgra8unorm"`. + * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to + * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated + * canvas is able to display its contents efficiently. + * Note: Canvases which are not displayed to the screen may or may not benefit from using this + * format. + */ + getPreferredCanvasFormat(): GPUTextureFormat; + readonly wgslLanguageFeatures: WGSLLanguageFeatures; +} + +declare var GPU: { + prototype: GPU; + new (): never; +}; + +interface GPUAdapter { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUAdapter"; + /** + * The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}. + */ + readonly features: GPUSupportedFeatures; + /** + * The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}. + */ + readonly limits: GPUSupportedLimits; + /** + * Information about the physical adapter underlying this {@link GPUAdapter}. + * For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time. + * The same object is returned each time. To create that object for the first time: + *
+ *
+ * **Called on:** {@link GPUAdapter} `this`. + * **Returns:** {@link GPUAdapterInfo} + * Content timeline steps: + * 1. Return a [$new adapter info$] for `this.adapter`. + *
+ *
+ */ + readonly info: GPUAdapterInfo; + /** + * Requests a device from the adapter. + * This is a one-time action: if a device is returned successfully, + * the adapter becomes {@link adapter#[[state]]#"consumed"}. + * @param descriptor - Description of the {@link GPUDevice} to request. + */ + requestDevice( + descriptor?: GPUDeviceDescriptor + ): Promise; +} + +declare var GPUAdapter: { + prototype: GPUAdapter; + new (): never; +}; + +interface GPUAdapterInfo { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUAdapterInfo"; + /** + * The name of the vendor of the adapter, if available. Empty string otherwise. + */ + readonly vendor: string; + /** + * The name of the family or class of GPUs the adapter belongs to, if available. Empty + * string otherwise. + */ + readonly architecture: string; + /** + * A vendor-specific identifier for the adapter, if available. Empty string otherwise. + * Note: This is a value that represents the type of adapter. For example, it may be a + * [PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of + * hardware like a serial number. + */ + readonly device: string; + /** + * A human readable string describing the adapter as reported by the driver, if available. + * Empty string otherwise. + * Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse + * this value is not recommended. Applications which change their behavior based on the + * {@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the + * other fields when possible. + */ + readonly description: string; + /** + * If the "subgroups" feature is supported, the minimum supported subgroup size for the + * adapter. + * + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly subgroupMinSize?: number; + /** + * If the "subgroups" feature is supported, the maximum supported subgroup size for the + * adapter. + * + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly subgroupMaxSize?: number; + /** + * Whether the adapter is a fallback adapter. + **/ + readonly isFallbackAdapter: boolean; +} + +declare var GPUAdapterInfo: { + prototype: GPUAdapterInfo; + new (): never; +}; + +interface GPUBindGroup + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUBindGroup"; +} + +declare var GPUBindGroup: { + prototype: GPUBindGroup; + new (): never; +}; + +interface GPUBindGroupLayout + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUBindGroupLayout"; +} + +declare var GPUBindGroupLayout: { + prototype: GPUBindGroupLayout; + new (): never; +}; + +interface GPUBuffer + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUBuffer"; + readonly size: GPUSize64Out; + readonly usage: GPUFlagsConstant; + readonly mapState: GPUBufferMapState; + /** + * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the + * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. + * The resolution of the returned Promise **only** indicates that the buffer has been mapped. + * It does not guarantee the completion of any other operations visible to the content timeline, + * and in particular does not imply that any other Promise returned from + * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s + * have resolved. + * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} + * **does** imply the completion of + * {@link GPUBuffer#mapAsync} calls made prior to that call, + * on {@link GPUBuffer}s last used exclusively on that queue. + * @param mode - Whether the buffer should be mapped for reading or writing. + * @param offset - Offset in bytes into the buffer to the start of the range to map. + * @param size - Size in bytes of the range to map. + */ + mapAsync( + mode: GPUMapModeFlags, + offset?: GPUSize64, + size?: GPUSize64 + ): Promise; + /** + * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range. + * @param offset - Offset in bytes into the buffer to return buffer contents from. + * @param size - Size in bytes of the ArrayBuffer to return. + */ + getMappedRange( + offset?: GPUSize64, + size?: GPUSize64 + ): ArrayBuffer; + /** + * Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the + * GPU again. + */ + unmap(): undefined; + /** + * Destroys the {@link GPUBuffer}. + * Note: It is valid to destroy a buffer multiple times. + * Note: Since no further operations can be enqueued using this buffer, implementations can + * free resource allocations, including mapped memory that was just unmapped. + */ + destroy(): undefined; +} + +declare var GPUBuffer: { + prototype: GPUBuffer; + new (): never; +}; + +interface GPUCanvasContext { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUCanvasContext"; + /** + * The canvas this context was created from. + */ + readonly canvas: + | HTMLCanvasElement + | OffscreenCanvas; + /** + * Configures the context for this canvas. + * This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). + * See {@link GPUCanvasContext#getConfiguration} for information on feature detection. + * @param configuration - Desired configuration for the context. + */ + configure( + configuration: GPUCanvasConfiguration + ): undefined; + /** + * Removes the context configuration. Destroys any textures produced while configured. + */ + unconfigure(): undefined; + /** + * Returns the context configuration, or `null` if the context is not configured. + * Note: + * This method exists primarily for feature detection of members (and sub-members) of + * {@link GPUCanvasConfiguration}; see those members for details. + * For supported members, it returns the originally-supplied values. + */ + getConfiguration(): GPUCanvasConfigurationOut | null; + /** + * Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} + * next. + * Note: The same {@link GPUTexture} object will be returned by every + * call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" + * runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. + */ + getCurrentTexture(): GPUTexture; +} + +declare var GPUCanvasContext: { + prototype: GPUCanvasContext; + new (): never; +}; + +interface GPUCommandBuffer + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUCommandBuffer"; +} + +declare var GPUCommandBuffer: { + prototype: GPUCommandBuffer; + new (): never; +}; + +interface GPUCommandEncoder + extends GPUObjectBase, + GPUCommandsMixin, + GPUDebugCommandsMixin { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUCommandEncoder"; + /** + * Begins encoding a render pass described by `descriptor`. + * @param descriptor - Description of the {@link GPURenderPassEncoder} to create. + */ + beginRenderPass( + descriptor: GPURenderPassDescriptor + ): GPURenderPassEncoder; + beginComputePass( + descriptor?: GPUComputePassDescriptor + ): GPUComputePassEncoder; + /** + * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}. + */ + copyBufferToBuffer( + source: GPUBuffer, + destination: GPUBuffer, + size?: GPUSize64 + ): undefined; + /** + * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a + * {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. + * @param source - The {@link GPUBuffer} to copy from. + * @param sourceOffset - Offset in bytes into `source` to begin copying from. + * @param destination - The {@link GPUBuffer} to copy to. + * @param destinationOffset - Offset in bytes into `destination` to place the copied data. + * @param size - Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`. + */ + copyBufferToBuffer( + source: GPUBuffer, + sourceOffset: GPUSize64, + destination: GPUBuffer, + destinationOffset: GPUSize64, + size?: GPUSize64 + ): undefined; + /** + * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a + * {@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. + * @param source - Combined with `copySize`, defines the region of the source buffer. + * @param destination - Combined with `copySize`, defines the region of the destination texture subresource. + * `copySize`: + */ + copyBufferToTexture( + source: GPUTexelCopyBufferInfo, + destination: GPUTexelCopyTextureInfo, + copySize: GPUExtent3DStrict + ): undefined; + /** + * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or + * multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. + * @param source - Combined with `copySize`, defines the region of the source texture subresources. + * @param destination - Combined with `copySize`, defines the region of the destination buffer. + * `copySize`: + */ + copyTextureToBuffer( + source: GPUTexelCopyTextureInfo, + destination: GPUTexelCopyBufferInfo, + copySize: GPUExtent3DStrict + ): undefined; + /** + * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one + * or multiple contiguous texture subresources to another sub-region of one or + * multiple continuous texture subresources. + * @param source - Combined with `copySize`, defines the region of the source texture subresources. + * @param destination - Combined with `copySize`, defines the region of the destination texture subresources. + * `copySize`: + */ + copyTextureToTexture( + source: GPUTexelCopyTextureInfo, + destination: GPUTexelCopyTextureInfo, + copySize: GPUExtent3DStrict + ): undefined; + /** + * Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a + * {@link GPUBuffer} with zeros. + * @param buffer - The {@link GPUBuffer} to clear. + * @param offset - Offset in bytes into `buffer` where the sub-region to clear begins. + * @param size - Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`. + */ + clearBuffer( + buffer: GPUBuffer, + offset?: GPUSize64, + size?: GPUSize64 + ): undefined; + /** + * Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. + * querySet: + * firstQuery: + * queryCount: + * destination: + * destinationOffset: + */ + resolveQuerySet( + querySet: GPUQuerySet, + firstQuery: GPUSize32, + queryCount: GPUSize32, + destination: GPUBuffer, + destinationOffset: GPUSize64 + ): undefined; + /** + * Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. + * descriptor: + */ + finish( + descriptor?: GPUCommandBufferDescriptor + ): GPUCommandBuffer; +} + +declare var GPUCommandEncoder: { + prototype: GPUCommandEncoder; + new (): never; +}; + +interface GPUCompilationInfo { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUCompilationInfo"; + readonly messages: ReadonlyArray; +} + +declare var GPUCompilationInfo: { + prototype: GPUCompilationInfo; + new (): never; +}; + +interface GPUCompilationMessage { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUCompilationMessage"; + /** + * The human-readable, localizable text for this compilation message. + * Note: The {@link GPUCompilationMessage#message} should follow the best practices for language + * and direction information. This includes making use of any future standards which may + * emerge regarding the reporting of string language and direction metadata. + *

Editorial note: + * At the time of this writing, no language/direction recommendation is available that provides + * compatibility and consistency with legacy APIs, but when there is, adopt it formally. + */ + readonly message: string; + /** + * The severity level of the message. + * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it + * corresponds to a shader-creation error. + */ + readonly type: GPUCompilationMessageType; + /** + * The line number in the shader {@link GPUShaderModuleDescriptor#code} the + * {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of + * `1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are + * delimited by line breaks. + * If the {@link GPUCompilationMessage#message} corresponds to a substring this points to + * the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message} + * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. + */ + readonly lineNum: number; + /** + * The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum} + * of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring + * that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a + * {@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line. + * If {@link GPUCompilationMessage#message} corresponds to a substring this points to the + * first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message} + * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. + */ + readonly linePos: number; + /** + * The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16 + * code units to the point or beginning of the substring that {@link GPUCompilationMessage#message} + * corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and + * {@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message} + * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. + */ + readonly offset: number; + /** + * The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message} + * corresponds to. If the message does not correspond with a substring then + * {@link GPUCompilationMessage#length} must be 0. + */ + readonly length: number; +} + +declare var GPUCompilationMessage: { + prototype: GPUCompilationMessage; + new (): never; +}; + +interface GPUComputePassEncoder + extends GPUObjectBase, + GPUCommandsMixin, + GPUDebugCommandsMixin, + GPUBindingCommandsMixin { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUComputePassEncoder"; + /** + * Sets the current {@link GPUComputePipeline}. + * @param pipeline - The compute pipeline to use for subsequent dispatch commands. + */ + setPipeline( + pipeline: GPUComputePipeline + ): undefined; + /** + * Dispatch work to be performed with the current {@link GPUComputePipeline}. + * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. + * @param workgroupCountX - X dimension of the grid of workgroups to dispatch. + * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch. + * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch. + */ + dispatchWorkgroups( + workgroupCountX: GPUSize32, + workgroupCountY?: GPUSize32, + workgroupCountZ?: GPUSize32 + ): undefined; + /** + * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read + * from a {@link GPUBuffer}. + * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. + * packed block of **three 32-bit unsigned integer values (12 bytes total)**, + * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. + * For example: + * @param indirectBuffer - Buffer containing the indirect dispatch parameters. + * @param indirectOffset - Offset in bytes into `indirectBuffer` where the dispatch data begins. + */ + dispatchWorkgroupsIndirect( + indirectBuffer: GPUBuffer, + indirectOffset: GPUSize64 + ): undefined; + /** + * Completes recording of the compute pass commands sequence. + */ + end(): undefined; +} + +declare var GPUComputePassEncoder: { + prototype: GPUComputePassEncoder; + new (): never; +}; + +interface GPUComputePipeline + extends GPUObjectBase, + GPUPipelineBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUComputePipeline"; +} + +declare var GPUComputePipeline: { + prototype: GPUComputePipeline; + new (): never; +}; + +interface GPUDevice + extends EventTarget, + GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUDevice"; + /** + * A set containing the {@link GPUFeatureName} values of the features + * supported by the device (i.e. the ones with which it was created). + */ + readonly features: GPUSupportedFeatures; + /** + * Exposes the limits supported by the device + * (which are exactly the ones with which it was created). + */ + readonly limits: GPUSupportedLimits; + /** + * Information about the physical adapter which created the device + * that this GPUDevice refers to. + * For a given GPUDevice, the GPUAdapterInfo values exposed are constant + * over time. + */ + readonly adapterInfo: GPUAdapterInfo; + /** + * The primary {@link GPUQueue} for this device. + */ + readonly queue: GPUQueue; + /** + * Destroys the device, preventing further operations on it. + * Outstanding asynchronous operations will fail. + * Note: It is valid to destroy a device multiple times. + * Note: Since no further operations can be enqueued on this device, implementations can abort + * outstanding asynchronous operations immediately and free resource allocations, including + * mapped memory that was just unmapped. + */ + destroy(): undefined; + /** + * Creates a {@link GPUBuffer}. + * @param descriptor - Description of the {@link GPUBuffer} to create. + */ + createBuffer( + descriptor: GPUBufferDescriptor + ): GPUBuffer; + /** + * Creates a {@link GPUTexture}. + * @param descriptor - Description of the {@link GPUTexture} to create. + */ + createTexture( + descriptor: GPUTextureDescriptor + ): GPUTexture; + /** + * Creates a {@link GPUSampler}. + * @param descriptor - Description of the {@link GPUSampler} to create. + */ + createSampler( + descriptor?: GPUSamplerDescriptor + ): GPUSampler; + /** + * Creates a {@link GPUExternalTexture} wrapping the provided image source. + * @param descriptor - Provides the external image source object (and any creation options). + */ + importExternalTexture( + descriptor: GPUExternalTextureDescriptor + ): GPUExternalTexture; + /** + * Creates a {@link GPUBindGroupLayout}. + * @param descriptor - Description of the {@link GPUBindGroupLayout} to create. + */ + createBindGroupLayout( + descriptor: GPUBindGroupLayoutDescriptor + ): GPUBindGroupLayout; + /** + * Creates a {@link GPUPipelineLayout}. + * @param descriptor - Description of the {@link GPUPipelineLayout} to create. + */ + createPipelineLayout( + descriptor: GPUPipelineLayoutDescriptor + ): GPUPipelineLayout; + /** + * Creates a {@link GPUBindGroup}. + * @param descriptor - Description of the {@link GPUBindGroup} to create. + */ + createBindGroup( + descriptor: GPUBindGroupDescriptor + ): GPUBindGroup; + /** + * Creates a {@link GPUShaderModule}. + * @param descriptor - Description of the {@link GPUShaderModule} to create. + */ + createShaderModule( + descriptor: GPUShaderModuleDescriptor + ): GPUShaderModule; + /** + * Creates a {@link GPUComputePipeline} using immediate pipeline creation. + * @param descriptor - Description of the {@link GPUComputePipeline} to create. + */ + createComputePipeline( + descriptor: GPUComputePipelineDescriptor + ): GPUComputePipeline; + /** + * Creates a {@link GPURenderPipeline} using immediate pipeline creation. + * @param descriptor - Description of the {@link GPURenderPipeline} to create. + */ + createRenderPipeline( + descriptor: GPURenderPipelineDescriptor + ): GPURenderPipeline; + /** + * Creates a {@link GPUComputePipeline} using async pipeline creation. + * The returned Promise resolves when the created pipeline + * is ready to be used without additional delay. + * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. + * (A {@link GPUError} is not dispatched to the device.) + * Note: Use of this method is preferred whenever possible, as it prevents blocking the + * queue timeline work on pipeline compilation. + * @param descriptor - Description of the {@link GPUComputePipeline} to create. + */ + createComputePipelineAsync( + descriptor: GPUComputePipelineDescriptor + ): Promise; + /** + * Creates a {@link GPURenderPipeline} using async pipeline creation. + * The returned Promise resolves when the created pipeline + * is ready to be used without additional delay. + * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. + * (A {@link GPUError} is not dispatched to the device.) + * Note: Use of this method is preferred whenever possible, as it prevents blocking the + * queue timeline work on pipeline compilation. + * @param descriptor - Description of the {@link GPURenderPipeline} to create. + */ + createRenderPipelineAsync( + descriptor: GPURenderPipelineDescriptor + ): Promise; + /** + * Creates a {@link GPUCommandEncoder}. + * @param descriptor - Description of the {@link GPUCommandEncoder} to create. + */ + createCommandEncoder( + descriptor?: GPUCommandEncoderDescriptor + ): GPUCommandEncoder; + /** + * Creates a {@link GPURenderBundleEncoder}. + * @param descriptor - Description of the {@link GPURenderBundleEncoder} to create. + */ + createRenderBundleEncoder( + descriptor: GPURenderBundleEncoderDescriptor + ): GPURenderBundleEncoder; + /** + * Creates a {@link GPUQuerySet}. + * @param descriptor - Description of the {@link GPUQuerySet} to create. + */ + createQuerySet( + descriptor: GPUQuerySetDescriptor + ): GPUQuerySet; + /** + * A slot-backed attribute holding a promise which is created with the device, remains + * pending for the lifetime of the device, then resolves when the device is lost. + * Upon initialization, it is set to a new promise. + */ + readonly lost: Promise; + /** + * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`. + * @param filter - Which class of errors this error scope observes. + */ + pushErrorScope( + filter: GPUErrorFilter + ): undefined; + /** + * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` + * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. + * There is no guarantee of the ordering of promise resolution. + */ + popErrorScope(): Promise; + /** + * An event handler IDL attribute for the `uncapturederror` event type. + */ + onuncapturederror: + | (( + this: GPUDevice, + ev: GPUUncapturedErrorEvent + ) => any) + | null; +} + +declare var GPUDevice: { + prototype: GPUDevice; + new (): never; +}; + +interface GPUDeviceLostInfo { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUDeviceLostInfo"; + readonly reason: GPUDeviceLostReason; + readonly message: string; +} + +declare var GPUDeviceLostInfo: { + prototype: GPUDeviceLostInfo; + new (): never; +}; + +interface GPUError { + /** + * A human-readable, localizable text message providing information about the error that + * occurred. + * Note: This message is generally intended for application developers to debug their + * applications and capture information for debug reports, not to be surfaced to end-users. + * Note: User agents should not include potentially machine-parsable details in this message, + * such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the + * conditions under which memory was exhausted. + * Note: The {@link GPUError#message} should follow the best practices for language and + * direction information. This includes making use of any future standards which may emerge + * regarding the reporting of string language and direction metadata. + *

Editorial note: + * At the time of this writing, no language/direction recommendation is available that provides + * compatibility and consistency with legacy APIs, but when there is, adopt it formally. + */ + readonly message: string; +} + +declare var GPUError: { + prototype: GPUError; + new (): never; +}; + +interface GPUExternalTexture + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUExternalTexture"; +} + +declare var GPUExternalTexture: { + prototype: GPUExternalTexture; + new (): never; +}; + +interface GPUInternalError + extends GPUError { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUInternalError"; +} + +declare var GPUInternalError: { + prototype: GPUInternalError; + new ( + message: string + ): GPUInternalError; +}; + +interface GPUOutOfMemoryError + extends GPUError { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUOutOfMemoryError"; +} + +declare var GPUOutOfMemoryError: { + prototype: GPUOutOfMemoryError; + new ( + message: string + ): GPUOutOfMemoryError; +}; + +interface GPUPipelineError + extends DOMException { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUPipelineError"; + /** + * A read-only slot-backed attribute exposing the type of error encountered in pipeline creation + * as a GPUPipelineErrorReason: + *

    + * - "validation": A [$validation error$]. + * - "internal": An [$internal error$]. + *
+ */ + readonly reason: GPUPipelineErrorReason; +} + +declare var GPUPipelineError: { + prototype: GPUPipelineError; + new ( + message: + | string + | undefined, + options: GPUPipelineErrorInit + ): GPUPipelineError; +}; + +interface GPUPipelineLayout + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUPipelineLayout"; +} + +declare var GPUPipelineLayout: { + prototype: GPUPipelineLayout; + new (): never; +}; + +interface GPUQuerySet + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUQuerySet"; + /** + * Destroys the {@link GPUQuerySet}. + */ + destroy(): undefined; + /** + * The type of the queries managed by this {@link GPUQuerySet}. + */ + readonly type: GPUQueryType; + /** + * The number of queries managed by this {@link GPUQuerySet}. + */ + readonly count: GPUSize32Out; +} + +declare var GPUQuerySet: { + prototype: GPUQuerySet; + new (): never; +}; + +interface GPUQueue + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUQueue"; + /** + * Schedules the execution of the command buffers by the GPU on this queue. + * Submitted command buffers cannot be used again. + * `commandBuffers`: + */ + submit( + commandBuffers: Iterable + ): undefined; + /** + * Returns a Promise that resolves once this queue finishes processing all the work submitted + * up to this moment. + * Resolution of this Promise implies the completion of + * {@link GPUBuffer#mapAsync} calls made prior to that call, + * on {@link GPUBuffer}s last used exclusively on that queue. + */ + onSubmittedWorkDone(): Promise; + /** + * Issues a write operation of the provided data into a {@link GPUBuffer}. + * @param buffer - The buffer to write to. + * @param bufferOffset - Offset in bytes into `buffer` to begin writing at. + * @param data - Data to write into `buffer`. + * @param dataOffset - Offset in into `data` to begin writing from. Given in elements if + * `data` is a `TypedArray` and bytes otherwise. + * @param size - Size of content to write from `data` to `buffer`. Given in elements if + * `data` is a `TypedArray` and bytes otherwise. + */ + writeBuffer( + buffer: GPUBuffer, + bufferOffset: GPUSize64, + data: GPUAllowSharedBufferSource, + dataOffset?: GPUSize64, + size?: GPUSize64 + ): undefined; + /** + * Issues a write operation of the provided data into a {@link GPUTexture}. + * @param destination - The texture subresource and origin to write to. + * @param data - Data to write into `destination`. + * @param dataLayout - Layout of the content in `data`. + * @param size - Extents of the content to write from `data` to `destination`. + */ + writeTexture( + destination: GPUTexelCopyTextureInfo, + data: GPUAllowSharedBufferSource, + dataLayout: GPUTexelCopyBufferLayout, + size: GPUExtent3DStrict + ): undefined; + /** + * Issues a copy operation of the contents of a platform image/canvas + * into the destination texture. + * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination + * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}. + * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded + * values, as copying into the corresponding non-`-srgb` format. + * Thus, after a copy operation, sampling the destination texture has + * different results depending on whether its format is `-srgb`, all else unchanged. + * + * @param source - source image and origin to copy to `destination`. + * @param destination - The texture subresource and origin to write to, and its encoding metadata. + * @param copySize - Extents of the content to write from `source` to `destination`. + */ + copyExternalImageToTexture( + source: GPUCopyExternalImageSourceInfo, + destination: GPUCopyExternalImageDestInfo, + copySize: GPUExtent3DStrict + ): undefined; +} + +declare var GPUQueue: { + prototype: GPUQueue; + new (): never; +}; + +interface GPURenderBundle + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPURenderBundle"; +} + +declare var GPURenderBundle: { + prototype: GPURenderBundle; + new (): never; +}; + +interface GPURenderBundleEncoder + extends GPUObjectBase, + GPUCommandsMixin, + GPUDebugCommandsMixin, + GPUBindingCommandsMixin, + GPURenderCommandsMixin { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPURenderBundleEncoder"; + /** + * Completes recording of the render bundle commands sequence. + * descriptor: + */ + finish( + descriptor?: GPURenderBundleDescriptor + ): GPURenderBundle; +} + +declare var GPURenderBundleEncoder: { + prototype: GPURenderBundleEncoder; + new (): never; +}; + +interface GPURenderPassEncoder + extends GPUObjectBase, + GPUCommandsMixin, + GPUDebugCommandsMixin, + GPUBindingCommandsMixin, + GPURenderCommandsMixin { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPURenderPassEncoder"; + /** + * Sets the viewport used during the rasterization stage to linearly map from + * NDC|normalized device coordinates to viewport coordinates. + * @param x - Minimum X value of the viewport in pixels. + * @param y - Minimum Y value of the viewport in pixels. + * @param width - Width of the viewport in pixels. + * @param height - Height of the viewport in pixels. + * @param minDepth - Minimum depth value of the viewport. + * @param maxDepth - Maximum depth value of the viewport. + */ + setViewport( + x: number, + y: number, + width: number, + height: number, + minDepth: number, + maxDepth: number + ): undefined; + /** + * Sets the scissor rectangle used during the rasterization stage. + * After transformation into viewport coordinates any fragments which fall outside the scissor + * rectangle will be discarded. + * @param x - Minimum X value of the scissor rectangle in pixels. + * @param y - Minimum Y value of the scissor rectangle in pixels. + * @param width - Width of the scissor rectangle in pixels. + * @param height - Height of the scissor rectangle in pixels. + */ + setScissorRect( + x: GPUIntegerCoordinate, + y: GPUIntegerCoordinate, + width: GPUIntegerCoordinate, + height: GPUIntegerCoordinate + ): undefined; + /** + * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` + * and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. + * @param color - The color to use when blending. + */ + setBlendConstant( + color: GPUColor + ): undefined; + /** + * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with + * the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. + * @param reference - The new stencil reference value. + */ + setStencilReference( + reference: GPUStencilValue + ): undefined; + /** + * @param queryIndex - The index of the query in the query set. + */ + beginOcclusionQuery( + queryIndex: GPUSize32 + ): undefined; + /** + */ + endOcclusionQuery(): undefined; + /** + * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of + * this render pass. + * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind + * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render + * pass's pipeline, bind group, and vertex/index buffer state is cleared + * (to the initial, empty values). + * Note: The state is cleared, not restored to the previous state. + * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. + * @param bundles - List of render bundles to execute. + */ + executeBundles( + bundles: Iterable + ): undefined; + /** + * Completes recording of the render pass commands sequence. + */ + end(): undefined; +} + +declare var GPURenderPassEncoder: { + prototype: GPURenderPassEncoder; + new (): never; +}; + +interface GPURenderPipeline + extends GPUObjectBase, + GPUPipelineBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPURenderPipeline"; +} + +declare var GPURenderPipeline: { + prototype: GPURenderPipeline; + new (): never; +}; + +interface GPUSampler + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUSampler"; +} + +declare var GPUSampler: { + prototype: GPUSampler; + new (): never; +}; + +interface GPUShaderModule + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUShaderModule"; + /** + * Returns any messages generated during the {@link GPUShaderModule}'s compilation. + * The locations, order, and contents of messages are implementation-defined. + * In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. + */ + getCompilationInfo(): Promise; +} + +declare var GPUShaderModule: { + prototype: GPUShaderModule; + new (): never; +}; + +type GPUSupportedFeatures = + ReadonlySet; + +interface GPUSupportedLimits { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUSupportedLimits"; + readonly maxTextureDimension1D: number; + readonly maxTextureDimension2D: number; + readonly maxTextureDimension3D: number; + readonly maxTextureArrayLayers: number; + readonly maxBindGroups: number; + readonly maxBindGroupsPlusVertexBuffers: number; + readonly maxBindingsPerBindGroup: number; + readonly maxDynamicUniformBuffersPerPipelineLayout: number; + readonly maxDynamicStorageBuffersPerPipelineLayout: number; + readonly maxSampledTexturesPerShaderStage: number; + readonly maxSamplersPerShaderStage: number; + readonly maxStorageBuffersPerShaderStage: number; + /** + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly maxStorageBuffersInVertexStage?: number; + /** + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly maxStorageBuffersInFragmentStage?: number; + readonly maxStorageTexturesPerShaderStage: number; + /** + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly maxStorageTexturesInVertexStage?: number; + /** + * @todo Temporarily optional until all browsers have implemented it. + * Check support before using. (Use the non-null assertion operator `!` where needed.) + */ + readonly maxStorageTexturesInFragmentStage?: number; + readonly maxUniformBuffersPerShaderStage: number; + readonly maxUniformBufferBindingSize: number; + readonly maxStorageBufferBindingSize: number; + readonly minUniformBufferOffsetAlignment: number; + readonly minStorageBufferOffsetAlignment: number; + readonly maxVertexBuffers: number; + readonly maxBufferSize: number; + readonly maxVertexAttributes: number; + readonly maxVertexBufferArrayStride: number; + readonly maxInterStageShaderVariables: number; + readonly maxColorAttachments: number; + readonly maxColorAttachmentBytesPerSample: number; + readonly maxComputeWorkgroupStorageSize: number; + readonly maxComputeInvocationsPerWorkgroup: number; + readonly maxComputeWorkgroupSizeX: number; + readonly maxComputeWorkgroupSizeY: number; + readonly maxComputeWorkgroupSizeZ: number; + readonly maxComputeWorkgroupsPerDimension: number; + readonly maxImmediateSize: number; +} + +declare var GPUSupportedLimits: { + prototype: GPUSupportedLimits; + new (): never; +}; + +interface GPUTexture + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUTexture"; + /** + * Creates a {@link GPUTextureView}. + * @param descriptor - Description of the {@link GPUTextureView} to create. + */ + createView( + descriptor?: GPUTextureViewDescriptor + ): GPUTextureView; + /** + * Destroys the {@link GPUTexture}. + */ + destroy(): undefined; + /** + * The width of this {@link GPUTexture}. + */ + readonly width: GPUIntegerCoordinateOut; + /** + * The height of this {@link GPUTexture}. + */ + readonly height: GPUIntegerCoordinateOut; + /** + * The depth or layer count of this {@link GPUTexture}. + */ + readonly depthOrArrayLayers: GPUIntegerCoordinateOut; + /** + * The number of mip levels of this {@link GPUTexture}. + */ + readonly mipLevelCount: GPUIntegerCoordinateOut; + /** + * The number of sample count of this {@link GPUTexture}. + */ + readonly sampleCount: GPUSize32Out; + /** + * The dimension of the set of texel for each of this {@link GPUTexture}'s subresources. + */ + readonly dimension: GPUTextureDimension; + /** + * The format of this {@link GPUTexture}. + */ + readonly format: GPUTextureFormat; + /** + * The allowed usages for this {@link GPUTexture}. + */ + readonly usage: GPUFlagsConstant; + /** + * On devices without "core-features-and-limits", views created from this + * texture must have this as their dimension. + * + * On devices with "core-features-and-limits", this is undefined, and there is + * no such restriction. + * + * @todo Temporarily optional until all browsers have implemented it. + * It is safe to access on any browser, as it will just (correctly) return + * `undefined` if not implemented. Note, depending on the device, `undefined` + * is a valid value even in browsers that implement this attribute. (So be + * careful if using the non-null assertion operator `!` on this.) + */ + readonly textureBindingViewDimension?: + | GPUTextureViewDimension + | undefined; +} + +declare var GPUTexture: { + prototype: GPUTexture; + new (): never; +}; + +interface GPUTextureView + extends GPUObjectBase { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUTextureView"; +} + +declare var GPUTextureView: { + prototype: GPUTextureView; + new (): never; +}; + +interface GPUUncapturedErrorEvent + extends Event { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUUncapturedErrorEvent"; + /** + * A slot-backed attribute holding an object representing the error that was uncaptured. + * This has the same type as errors returned by {@link GPUDevice#popErrorScope}. + */ + readonly error: GPUError; +} + +declare var GPUUncapturedErrorEvent: { + prototype: GPUUncapturedErrorEvent; + new ( + type: string, + gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit + ): GPUUncapturedErrorEvent; +}; + +interface GPUValidationError + extends GPUError { + /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ + readonly __brand: "GPUValidationError"; +} + +declare var GPUValidationError: { + prototype: GPUValidationError; + new ( + message: string + ): GPUValidationError; +}; + +type WGSLLanguageFeatures = + ReadonlySet; + +interface Navigator + extends NavigatorGPU {} + +interface WorkerNavigator + extends NavigatorGPU {} + +interface GPUBufferUsage { + readonly MAP_READ: GPUFlagsConstant; + readonly MAP_WRITE: GPUFlagsConstant; + readonly COPY_SRC: GPUFlagsConstant; + readonly COPY_DST: GPUFlagsConstant; + readonly INDEX: GPUFlagsConstant; + readonly VERTEX: GPUFlagsConstant; + readonly UNIFORM: GPUFlagsConstant; + readonly STORAGE: GPUFlagsConstant; + readonly INDIRECT: GPUFlagsConstant; + readonly QUERY_RESOLVE: GPUFlagsConstant; +} + +declare var GPUBufferUsage: GPUBufferUsage; + +interface GPUColorWrite { + readonly RED: GPUFlagsConstant; + readonly GREEN: GPUFlagsConstant; + readonly BLUE: GPUFlagsConstant; + readonly ALPHA: GPUFlagsConstant; + readonly ALL: GPUFlagsConstant; +} + +declare var GPUColorWrite: GPUColorWrite; + +interface GPUMapMode { + readonly READ: GPUFlagsConstant; + readonly WRITE: GPUFlagsConstant; +} + +declare var GPUMapMode: GPUMapMode; + +interface GPUShaderStage { + readonly VERTEX: GPUFlagsConstant; + readonly FRAGMENT: GPUFlagsConstant; + readonly COMPUTE: GPUFlagsConstant; +} + +declare var GPUShaderStage: GPUShaderStage; + +interface GPUTextureUsage { + readonly COPY_SRC: GPUFlagsConstant; + readonly COPY_DST: GPUFlagsConstant; + readonly TEXTURE_BINDING: GPUFlagsConstant; + readonly STORAGE_BINDING: GPUFlagsConstant; + readonly RENDER_ATTACHMENT: GPUFlagsConstant; + readonly TRANSIENT_ATTACHMENT: GPUFlagsConstant; +} + +declare var GPUTextureUsage: GPUTextureUsage; diff --git a/apigen/definitions/webgpu.idl b/apigen/definitions/webgpu.idl new file mode 100644 index 00000000..28233714 --- /dev/null +++ b/apigen/definitions/webgpu.idl @@ -0,0 +1,1383 @@ +// Copyright (C) [2026] World Wide Web Consortium, +// (Massachusetts Institute of Technology, European Research Consortium for +// Informatics and Mathematics, Keio University, Beihang). +// All Rights Reserved. +// +// This work is distributed under the W3C (R) Software License [1] in the hope +// that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// +// [1] http://www.w3.org/Consortium/Legal/copyright-software + +// **** This file is auto-generated. Do not edit. **** + +interface mixin GPUObjectBase { + attribute USVString label; +}; + +dictionary GPUObjectDescriptorBase { + USVString label = ""; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUSupportedLimits { + readonly attribute unsigned long maxTextureDimension1D; + readonly attribute unsigned long maxTextureDimension2D; + readonly attribute unsigned long maxTextureDimension3D; + readonly attribute unsigned long maxTextureArrayLayers; + readonly attribute unsigned long maxBindGroups; + readonly attribute unsigned long maxBindGroupsPlusVertexBuffers; + readonly attribute unsigned long maxImmediateSize; + readonly attribute unsigned long maxBindingsPerBindGroup; + readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout; + readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout; + readonly attribute unsigned long maxSampledTexturesPerShaderStage; + readonly attribute unsigned long maxSamplersPerShaderStage; + readonly attribute unsigned long maxStorageBuffersPerShaderStage; + readonly attribute unsigned long maxStorageBuffersInVertexStage; + readonly attribute unsigned long maxStorageBuffersInFragmentStage; + readonly attribute unsigned long maxStorageTexturesPerShaderStage; + readonly attribute unsigned long maxStorageTexturesInVertexStage; + readonly attribute unsigned long maxStorageTexturesInFragmentStage; + readonly attribute unsigned long maxUniformBuffersPerShaderStage; + readonly attribute unsigned long long maxUniformBufferBindingSize; + readonly attribute unsigned long long maxStorageBufferBindingSize; + readonly attribute unsigned long minUniformBufferOffsetAlignment; + readonly attribute unsigned long minStorageBufferOffsetAlignment; + readonly attribute unsigned long maxVertexBuffers; + readonly attribute unsigned long long maxBufferSize; + readonly attribute unsigned long maxVertexAttributes; + readonly attribute unsigned long maxVertexBufferArrayStride; + readonly attribute unsigned long maxInterStageShaderVariables; + readonly attribute unsigned long maxColorAttachments; + readonly attribute unsigned long maxColorAttachmentBytesPerSample; + readonly attribute unsigned long maxComputeWorkgroupStorageSize; + readonly attribute unsigned long maxComputeInvocationsPerWorkgroup; + readonly attribute unsigned long maxComputeWorkgroupSizeX; + readonly attribute unsigned long maxComputeWorkgroupSizeY; + readonly attribute unsigned long maxComputeWorkgroupSizeZ; + readonly attribute unsigned long maxComputeWorkgroupsPerDimension; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUSupportedFeatures { + readonly setlike; +}; + +[Exposed=(Window, Worker), SecureContext] +interface WGSLLanguageFeatures { + readonly setlike; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUAdapterInfo { + readonly attribute DOMString vendor; + readonly attribute DOMString architecture; + readonly attribute DOMString device; + readonly attribute DOMString description; + readonly attribute unsigned long subgroupMinSize; + readonly attribute unsigned long subgroupMaxSize; + readonly attribute boolean isFallbackAdapter; +}; + +interface mixin NavigatorGPU { + [SameObject, SecureContext] readonly attribute GPU gpu; +}; +Navigator includes NavigatorGPU; +WorkerNavigator includes NavigatorGPU; + +[Exposed=(Window, Worker), SecureContext] +interface GPU { + Promise requestAdapter(optional GPURequestAdapterOptions options = {}); + GPUTextureFormat getPreferredCanvasFormat(); + [SameObject] readonly attribute WGSLLanguageFeatures wgslLanguageFeatures; +}; + +dictionary GPURequestAdapterOptions { + DOMString featureLevel = "core"; + GPUPowerPreference powerPreference; + boolean forceFallbackAdapter = false; + boolean xrCompatible = false; +}; + +enum GPUPowerPreference { + "low-power", + "high-performance", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUAdapter { + [SameObject] readonly attribute GPUSupportedFeatures features; + [SameObject] readonly attribute GPUSupportedLimits limits; + [SameObject] readonly attribute GPUAdapterInfo info; + + Promise requestDevice(optional GPUDeviceDescriptor descriptor = {}); +}; + +dictionary GPUDeviceDescriptor + : GPUObjectDescriptorBase { + sequence requiredFeatures = []; + record requiredLimits = {}; + GPUQueueDescriptor defaultQueue = {}; +}; + +enum GPUFeatureName { + "core-features-and-limits", + "depth-clip-control", + "depth32float-stencil8", + "texture-compression-bc", + "texture-compression-bc-sliced-3d", + "texture-compression-etc2", + "texture-compression-astc", + "texture-compression-astc-sliced-3d", + "timestamp-query", + "indirect-first-instance", + "shader-f16", + "rg11b10ufloat-renderable", + "bgra8unorm-storage", + "float32-filterable", + "float32-blendable", + "clip-distances", + "dual-source-blending", + "subgroups", + "texture-formats-tier1", + "texture-formats-tier2", + "primitive-index", + "texture-component-swizzle", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUDevice : EventTarget { + [SameObject] readonly attribute GPUSupportedFeatures features; + [SameObject] readonly attribute GPUSupportedLimits limits; + [SameObject] readonly attribute GPUAdapterInfo adapterInfo; + + [SameObject] readonly attribute GPUQueue queue; + + undefined destroy(); + + GPUBuffer createBuffer(GPUBufferDescriptor descriptor); + GPUTexture createTexture(GPUTextureDescriptor descriptor); + GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {}); + GPUExternalTexture importExternalTexture(GPUExternalTextureDescriptor descriptor); + + GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); + GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor); + GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor); + + GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); + GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); + GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor); + Promise createComputePipelineAsync(GPUComputePipelineDescriptor descriptor); + Promise createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor); + + GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); + GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); + + GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor); +}; +GPUDevice includes GPUObjectBase; + +[Exposed=(Window, Worker), SecureContext] +interface GPUBuffer { + readonly attribute GPUSize64Out size; + readonly attribute GPUFlagsConstant usage; + + readonly attribute GPUBufferMapState mapState; + + Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); + ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size); + undefined unmap(); + + undefined destroy(); +}; +GPUBuffer includes GPUObjectBase; + +enum GPUBufferMapState { + "unmapped", + "pending", + "mapped", +}; + +dictionary GPUBufferDescriptor + : GPUObjectDescriptorBase { + required GPUSize64 size; + required GPUBufferUsageFlags usage; + boolean mappedAtCreation = false; +}; + +typedef [EnforceRange] unsigned long GPUBufferUsageFlags; +[Exposed=(Window, Worker), SecureContext] +namespace GPUBufferUsage { + const GPUFlagsConstant MAP_READ = 0x0001; + const GPUFlagsConstant MAP_WRITE = 0x0002; + const GPUFlagsConstant COPY_SRC = 0x0004; + const GPUFlagsConstant COPY_DST = 0x0008; + const GPUFlagsConstant INDEX = 0x0010; + const GPUFlagsConstant VERTEX = 0x0020; + const GPUFlagsConstant UNIFORM = 0x0040; + const GPUFlagsConstant STORAGE = 0x0080; + const GPUFlagsConstant INDIRECT = 0x0100; + const GPUFlagsConstant QUERY_RESOLVE = 0x0200; +}; + +typedef [EnforceRange] unsigned long GPUMapModeFlags; +[Exposed=(Window, Worker), SecureContext] +namespace GPUMapMode { + const GPUFlagsConstant READ = 0x0001; + const GPUFlagsConstant WRITE = 0x0002; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUTexture { + GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {}); + + undefined destroy(); + + readonly attribute GPUIntegerCoordinateOut width; + readonly attribute GPUIntegerCoordinateOut height; + readonly attribute GPUIntegerCoordinateOut depthOrArrayLayers; + readonly attribute GPUIntegerCoordinateOut mipLevelCount; + readonly attribute GPUSize32Out sampleCount; + readonly attribute GPUTextureDimension dimension; + readonly attribute GPUTextureFormat format; + readonly attribute GPUFlagsConstant usage; + readonly attribute (GPUTextureViewDimension or undefined) textureBindingViewDimension; +}; +GPUTexture includes GPUObjectBase; + +dictionary GPUTextureDescriptor + : GPUObjectDescriptorBase { + required GPUExtent3D size; + GPUIntegerCoordinate mipLevelCount = 1; + GPUSize32 sampleCount = 1; + GPUTextureDimension dimension = "2d"; + required GPUTextureFormat format; + required GPUTextureUsageFlags usage; + sequence viewFormats = []; + GPUTextureViewDimension textureBindingViewDimension; +}; + +enum GPUTextureDimension { + "1d", + "2d", + "3d", +}; + +typedef [EnforceRange] unsigned long GPUTextureUsageFlags; +[Exposed=(Window, Worker), SecureContext] +namespace GPUTextureUsage { + const GPUFlagsConstant COPY_SRC = 0x01; + const GPUFlagsConstant COPY_DST = 0x02; + const GPUFlagsConstant TEXTURE_BINDING = 0x04; + const GPUFlagsConstant STORAGE_BINDING = 0x08; + const GPUFlagsConstant RENDER_ATTACHMENT = 0x10; + const GPUFlagsConstant TRANSIENT_ATTACHMENT = 0x20; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUTextureView { +}; +GPUTextureView includes GPUObjectBase; + +dictionary GPUTextureViewDescriptor + : GPUObjectDescriptorBase { + GPUTextureFormat format; + GPUTextureViewDimension dimension; + GPUTextureUsageFlags usage = 0; + GPUTextureAspect aspect = "all"; + GPUIntegerCoordinate baseMipLevel = 0; + GPUIntegerCoordinate mipLevelCount; + GPUIntegerCoordinate baseArrayLayer = 0; + GPUIntegerCoordinate arrayLayerCount; + + // Requires "texture-component-swizzle" feature. + DOMString swizzle = "rgba"; +}; + +enum GPUTextureViewDimension { + "1d", + "2d", + "2d-array", + "cube", + "cube-array", + "3d", +}; + +enum GPUTextureAspect { + "all", + "stencil-only", + "depth-only", +}; + +enum GPUTextureFormat { + // 8-bit formats + "r8unorm", + "r8snorm", + "r8uint", + "r8sint", + + // 16-bit formats + "r16unorm", + "r16snorm", + "r16uint", + "r16sint", + "r16float", + "rg8unorm", + "rg8snorm", + "rg8uint", + "rg8sint", + + // 32-bit formats + "r32uint", + "r32sint", + "r32float", + "rg16unorm", + "rg16snorm", + "rg16uint", + "rg16sint", + "rg16float", + "rgba8unorm", + "rgba8unorm-srgb", + "rgba8snorm", + "rgba8uint", + "rgba8sint", + "bgra8unorm", + "bgra8unorm-srgb", + // Packed 32-bit formats + "rgb9e5ufloat", + "rgb10a2uint", + "rgb10a2unorm", + "rg11b10ufloat", + + // 64-bit formats + "rg32uint", + "rg32sint", + "rg32float", + "rgba16unorm", + "rgba16snorm", + "rgba16uint", + "rgba16sint", + "rgba16float", + + // 128-bit formats + "rgba32uint", + "rgba32sint", + "rgba32float", + + // Depth/stencil formats + "stencil8", + "depth16unorm", + "depth24plus", + "depth24plus-stencil8", + "depth32float", + + // "depth32float-stencil8" feature + "depth32float-stencil8", + + // BC compressed formats usable if "texture-compression-bc" is both + // supported by the device/user agent and enabled in requestDevice. + "bc1-rgba-unorm", + "bc1-rgba-unorm-srgb", + "bc2-rgba-unorm", + "bc2-rgba-unorm-srgb", + "bc3-rgba-unorm", + "bc3-rgba-unorm-srgb", + "bc4-r-unorm", + "bc4-r-snorm", + "bc5-rg-unorm", + "bc5-rg-snorm", + "bc6h-rgb-ufloat", + "bc6h-rgb-float", + "bc7-rgba-unorm", + "bc7-rgba-unorm-srgb", + + // ETC2 compressed formats usable if "texture-compression-etc2" is both + // supported by the device/user agent and enabled in requestDevice. + "etc2-rgb8unorm", + "etc2-rgb8unorm-srgb", + "etc2-rgb8a1unorm", + "etc2-rgb8a1unorm-srgb", + "etc2-rgba8unorm", + "etc2-rgba8unorm-srgb", + "eac-r11unorm", + "eac-r11snorm", + "eac-rg11unorm", + "eac-rg11snorm", + + // ASTC compressed formats usable if "texture-compression-astc" is both + // supported by the device/user agent and enabled in requestDevice. + "astc-4x4-unorm", + "astc-4x4-unorm-srgb", + "astc-5x4-unorm", + "astc-5x4-unorm-srgb", + "astc-5x5-unorm", + "astc-5x5-unorm-srgb", + "astc-6x5-unorm", + "astc-6x5-unorm-srgb", + "astc-6x6-unorm", + "astc-6x6-unorm-srgb", + "astc-8x5-unorm", + "astc-8x5-unorm-srgb", + "astc-8x6-unorm", + "astc-8x6-unorm-srgb", + "astc-8x8-unorm", + "astc-8x8-unorm-srgb", + "astc-10x5-unorm", + "astc-10x5-unorm-srgb", + "astc-10x6-unorm", + "astc-10x6-unorm-srgb", + "astc-10x8-unorm", + "astc-10x8-unorm-srgb", + "astc-10x10-unorm", + "astc-10x10-unorm-srgb", + "astc-12x10-unorm", + "astc-12x10-unorm-srgb", + "astc-12x12-unorm", + "astc-12x12-unorm-srgb", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUExternalTexture { +}; +GPUExternalTexture includes GPUObjectBase; + +dictionary GPUExternalTextureDescriptor + : GPUObjectDescriptorBase { + required (HTMLVideoElement or VideoFrame) source; + PredefinedColorSpace colorSpace = "srgb"; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUSampler { +}; +GPUSampler includes GPUObjectBase; + +dictionary GPUSamplerDescriptor + : GPUObjectDescriptorBase { + GPUAddressMode addressModeU = "clamp-to-edge"; + GPUAddressMode addressModeV = "clamp-to-edge"; + GPUAddressMode addressModeW = "clamp-to-edge"; + GPUFilterMode magFilter = "nearest"; + GPUFilterMode minFilter = "nearest"; + GPUMipmapFilterMode mipmapFilter = "nearest"; + float lodMinClamp = 0; + float lodMaxClamp = 32; + GPUCompareFunction compare; + [Clamp] unsigned short maxAnisotropy = 1; +}; + +enum GPUAddressMode { + "clamp-to-edge", + "repeat", + "mirror-repeat", +}; + +enum GPUFilterMode { + "nearest", + "linear", +}; + +enum GPUMipmapFilterMode { + "nearest", + "linear", +}; + +enum GPUCompareFunction { + "never", + "less", + "equal", + "less-equal", + "greater", + "not-equal", + "greater-equal", + "always", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUBindGroupLayout { +}; +GPUBindGroupLayout includes GPUObjectBase; + +dictionary GPUBindGroupLayoutDescriptor + : GPUObjectDescriptorBase { + required sequence entries; +}; + +dictionary GPUBindGroupLayoutEntry { + required GPUIndex32 binding; + required GPUShaderStageFlags visibility; + + GPUBufferBindingLayout buffer; + GPUSamplerBindingLayout sampler; + GPUTextureBindingLayout texture; + GPUStorageTextureBindingLayout storageTexture; + GPUExternalTextureBindingLayout externalTexture; +}; + +typedef [EnforceRange] unsigned long GPUShaderStageFlags; +[Exposed=(Window, Worker), SecureContext] +namespace GPUShaderStage { + const GPUFlagsConstant VERTEX = 0x1; + const GPUFlagsConstant FRAGMENT = 0x2; + const GPUFlagsConstant COMPUTE = 0x4; +}; + +enum GPUBufferBindingType { + "uniform", + "storage", + "read-only-storage", +}; + +dictionary GPUBufferBindingLayout { + GPUBufferBindingType type = "uniform"; + boolean hasDynamicOffset = false; + GPUSize64 minBindingSize = 0; +}; + +enum GPUSamplerBindingType { + "filtering", + "non-filtering", + "comparison", +}; + +dictionary GPUSamplerBindingLayout { + GPUSamplerBindingType type = "filtering"; +}; + +enum GPUTextureSampleType { + "float", + "unfilterable-float", + "depth", + "sint", + "uint", +}; + +dictionary GPUTextureBindingLayout { + GPUTextureSampleType sampleType = "float"; + GPUTextureViewDimension viewDimension = "2d"; + boolean multisampled = false; +}; + +enum GPUStorageTextureAccess { + "write-only", + "read-only", + "read-write", +}; + +dictionary GPUStorageTextureBindingLayout { + GPUStorageTextureAccess access = "write-only"; + required GPUTextureFormat format; + GPUTextureViewDimension viewDimension = "2d"; +}; + +dictionary GPUExternalTextureBindingLayout { +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUBindGroup { +}; +GPUBindGroup includes GPUObjectBase; + +dictionary GPUBindGroupDescriptor + : GPUObjectDescriptorBase { + required GPUBindGroupLayout layout; + required sequence entries; +}; + +typedef (GPUSampler or + GPUTexture or + GPUTextureView or + GPUBuffer or + GPUBufferBinding or + GPUExternalTexture) GPUBindingResource; + +dictionary GPUBindGroupEntry { + required GPUIndex32 binding; + required GPUBindingResource resource; +}; + +dictionary GPUBufferBinding { + required GPUBuffer buffer; + GPUSize64 offset = 0; + GPUSize64 size; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUPipelineLayout { +}; +GPUPipelineLayout includes GPUObjectBase; + +dictionary GPUPipelineLayoutDescriptor + : GPUObjectDescriptorBase { + required sequence bindGroupLayouts; + GPUSize32 immediateSize = 0; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUShaderModule { + Promise getCompilationInfo(); +}; +GPUShaderModule includes GPUObjectBase; + +dictionary GPUShaderModuleDescriptor + : GPUObjectDescriptorBase { + required USVString code; + sequence compilationHints = []; +}; + +dictionary GPUShaderModuleCompilationHint { + required USVString entryPoint; + (GPUPipelineLayout or GPUAutoLayoutMode) layout; +}; + +enum GPUCompilationMessageType { + "error", + "warning", + "info", +}; + +[Exposed=(Window, Worker), Serializable, SecureContext] +interface GPUCompilationMessage { + readonly attribute DOMString message; + readonly attribute GPUCompilationMessageType type; + readonly attribute unsigned long long lineNum; + readonly attribute unsigned long long linePos; + readonly attribute unsigned long long offset; + readonly attribute unsigned long long length; +}; + +[Exposed=(Window, Worker), Serializable, SecureContext] +interface GPUCompilationInfo { + readonly attribute FrozenArray messages; +}; + +[Exposed=(Window, Worker), SecureContext, Serializable] +interface GPUPipelineError : DOMException { + constructor(optional DOMString message = "", GPUPipelineErrorInit options); + readonly attribute GPUPipelineErrorReason reason; +}; + +dictionary GPUPipelineErrorInit { + required GPUPipelineErrorReason reason; +}; + +enum GPUPipelineErrorReason { + "validation", + "internal", +}; + +enum GPUAutoLayoutMode { + "auto", +}; + +dictionary GPUPipelineDescriptorBase + : GPUObjectDescriptorBase { + required (GPUPipelineLayout or GPUAutoLayoutMode) layout; +}; + +interface mixin GPUPipelineBase { + [NewObject] GPUBindGroupLayout getBindGroupLayout(unsigned long index); +}; + +dictionary GPUProgrammableStage { + required GPUShaderModule module; + USVString entryPoint; + record constants = {}; +}; + +typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled. + +[Exposed=(Window, Worker), SecureContext] +interface GPUComputePipeline { +}; +GPUComputePipeline includes GPUObjectBase; +GPUComputePipeline includes GPUPipelineBase; + +dictionary GPUComputePipelineDescriptor + : GPUPipelineDescriptorBase { + required GPUProgrammableStage compute; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPURenderPipeline { +}; +GPURenderPipeline includes GPUObjectBase; +GPURenderPipeline includes GPUPipelineBase; + +dictionary GPURenderPipelineDescriptor + : GPUPipelineDescriptorBase { + required GPUVertexState vertex; + GPUPrimitiveState primitive = {}; + GPUDepthStencilState depthStencil; + GPUMultisampleState multisample = {}; + GPUFragmentState fragment; +}; + +dictionary GPUPrimitiveState { + GPUPrimitiveTopology topology = "triangle-list"; + GPUIndexFormat stripIndexFormat; + GPUFrontFace frontFace = "ccw"; + GPUCullMode cullMode = "none"; + + // Requires "depth-clip-control" feature. + boolean unclippedDepth = false; +}; + +enum GPUPrimitiveTopology { + "point-list", + "line-list", + "line-strip", + "triangle-list", + "triangle-strip", +}; + +enum GPUFrontFace { + "ccw", + "cw", +}; + +enum GPUCullMode { + "none", + "front", + "back", +}; + +dictionary GPUMultisampleState { + GPUSize32 count = 1; + GPUSampleMask mask = 0xFFFFFFFF; + boolean alphaToCoverageEnabled = false; +}; + +dictionary GPUFragmentState + : GPUProgrammableStage { + required sequence targets; +}; + +dictionary GPUColorTargetState { + required GPUTextureFormat format; + + GPUBlendState blend; + GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL +}; + +dictionary GPUBlendState { + required GPUBlendComponent color; + required GPUBlendComponent alpha; +}; + +typedef [EnforceRange] unsigned long GPUColorWriteFlags; +[Exposed=(Window, Worker), SecureContext] +namespace GPUColorWrite { + const GPUFlagsConstant RED = 0x1; + const GPUFlagsConstant GREEN = 0x2; + const GPUFlagsConstant BLUE = 0x4; + const GPUFlagsConstant ALPHA = 0x8; + const GPUFlagsConstant ALL = 0xF; +}; + +dictionary GPUBlendComponent { + GPUBlendOperation operation = "add"; + GPUBlendFactor srcFactor = "one"; + GPUBlendFactor dstFactor = "zero"; +}; + +enum GPUBlendFactor { + "zero", + "one", + "src", + "one-minus-src", + "src-alpha", + "one-minus-src-alpha", + "dst", + "one-minus-dst", + "dst-alpha", + "one-minus-dst-alpha", + "src-alpha-saturated", + "constant", + "one-minus-constant", + "src1", + "one-minus-src1", + "src1-alpha", + "one-minus-src1-alpha", +}; + +enum GPUBlendOperation { + "add", + "subtract", + "reverse-subtract", + "min", + "max", +}; + +dictionary GPUDepthStencilState { + required GPUTextureFormat format; + + boolean depthWriteEnabled; + GPUCompareFunction depthCompare; + + GPUStencilFaceState stencilFront = {}; + GPUStencilFaceState stencilBack = {}; + + GPUStencilValue stencilReadMask = 0xFFFFFFFF; + GPUStencilValue stencilWriteMask = 0xFFFFFFFF; + + GPUDepthBias depthBias = 0; + float depthBiasSlopeScale = 0; + float depthBiasClamp = 0; +}; + +dictionary GPUStencilFaceState { + GPUCompareFunction compare = "always"; + GPUStencilOperation failOp = "keep"; + GPUStencilOperation depthFailOp = "keep"; + GPUStencilOperation passOp = "keep"; +}; + +enum GPUStencilOperation { + "keep", + "zero", + "replace", + "invert", + "increment-clamp", + "decrement-clamp", + "increment-wrap", + "decrement-wrap", +}; + +enum GPUIndexFormat { + "uint16", + "uint32", +}; + +enum GPUVertexFormat { + "uint8", + "uint8x2", + "uint8x4", + "sint8", + "sint8x2", + "sint8x4", + "unorm8", + "unorm8x2", + "unorm8x4", + "snorm8", + "snorm8x2", + "snorm8x4", + "uint16", + "uint16x2", + "uint16x4", + "sint16", + "sint16x2", + "sint16x4", + "unorm16", + "unorm16x2", + "unorm16x4", + "snorm16", + "snorm16x2", + "snorm16x4", + "float16", + "float16x2", + "float16x4", + "float32", + "float32x2", + "float32x3", + "float32x4", + "uint32", + "uint32x2", + "uint32x3", + "uint32x4", + "sint32", + "sint32x2", + "sint32x3", + "sint32x4", + "unorm10-10-10-2", + "unorm8x4-bgra", +}; + +enum GPUVertexStepMode { + "vertex", + "instance", +}; + +dictionary GPUVertexState + : GPUProgrammableStage { + sequence buffers = []; +}; + +dictionary GPUVertexBufferLayout { + required GPUSize64 arrayStride; + GPUVertexStepMode stepMode = "vertex"; + required sequence attributes; +}; + +dictionary GPUVertexAttribute { + required GPUVertexFormat format; + required GPUSize64 offset; + + required GPUIndex32 shaderLocation; +}; + +dictionary GPUTexelCopyBufferLayout { + GPUSize64 offset = 0; + GPUSize32 bytesPerRow; + GPUSize32 rowsPerImage; +}; + +dictionary GPUTexelCopyBufferInfo + : GPUTexelCopyBufferLayout { + required GPUBuffer buffer; +}; + +dictionary GPUTexelCopyTextureInfo { + required GPUTexture texture; + GPUIntegerCoordinate mipLevel = 0; + GPUOrigin3D origin = {}; + GPUTextureAspect aspect = "all"; +}; + +dictionary GPUCopyExternalImageDestInfo + : GPUTexelCopyTextureInfo { + PredefinedColorSpace colorSpace = "srgb"; + boolean premultipliedAlpha = false; +}; + +typedef (ImageBitmap or + ImageData or + HTMLImageElement or + HTMLVideoElement or + VideoFrame or + HTMLCanvasElement or + OffscreenCanvas) GPUCopyExternalImageSource; + +dictionary GPUCopyExternalImageSourceInfo { + required GPUCopyExternalImageSource source; + GPUOrigin2D origin = {}; + boolean flipY = false; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUCommandBuffer { +}; +GPUCommandBuffer includes GPUObjectBase; + +dictionary GPUCommandBufferDescriptor + : GPUObjectDescriptorBase { +}; + +interface mixin GPUCommandsMixin { +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUCommandEncoder { + GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); + GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); + + undefined copyBufferToBuffer( + GPUBuffer source, + GPUBuffer destination, + optional GPUSize64 size); + undefined copyBufferToBuffer( + GPUBuffer source, + GPUSize64 sourceOffset, + GPUBuffer destination, + GPUSize64 destinationOffset, + optional GPUSize64 size); + + undefined copyBufferToTexture( + GPUTexelCopyBufferInfo source, + GPUTexelCopyTextureInfo destination, + GPUExtent3D copySize); + + undefined copyTextureToBuffer( + GPUTexelCopyTextureInfo source, + GPUTexelCopyBufferInfo destination, + GPUExtent3D copySize); + + undefined copyTextureToTexture( + GPUTexelCopyTextureInfo source, + GPUTexelCopyTextureInfo destination, + GPUExtent3D copySize); + + undefined clearBuffer( + GPUBuffer buffer, + optional GPUSize64 offset = 0, + optional GPUSize64 size); + + undefined resolveQuerySet( + GPUQuerySet querySet, + GPUSize32 firstQuery, + GPUSize32 queryCount, + GPUBuffer destination, + GPUSize64 destinationOffset); + + GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); +}; +GPUCommandEncoder includes GPUObjectBase; +GPUCommandEncoder includes GPUCommandsMixin; +GPUCommandEncoder includes GPUDebugCommandsMixin; + +dictionary GPUCommandEncoderDescriptor + : GPUObjectDescriptorBase { +}; + +interface mixin GPUBindingCommandsMixin { + undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup, + optional sequence dynamicOffsets = []); + + undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup, + [AllowShared] Uint32Array dynamicOffsetsData, + GPUSize64 dynamicOffsetsDataStart, + GPUSize32 dynamicOffsetsDataLength); + + undefined setImmediates(GPUSize32 rangeOffset, AllowSharedBufferSource data, + optional GPUSize64 dataOffset = 0, optional GPUSize64 dataSize); +}; + +interface mixin GPUDebugCommandsMixin { + undefined pushDebugGroup(USVString groupLabel); + undefined popDebugGroup(); + undefined insertDebugMarker(USVString markerLabel); +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUComputePassEncoder { + undefined setPipeline(GPUComputePipeline pipeline); + undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1); + undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); + + undefined end(); +}; +GPUComputePassEncoder includes GPUObjectBase; +GPUComputePassEncoder includes GPUCommandsMixin; +GPUComputePassEncoder includes GPUDebugCommandsMixin; +GPUComputePassEncoder includes GPUBindingCommandsMixin; + +dictionary GPUComputePassTimestampWrites { + required GPUQuerySet querySet; + GPUSize32 beginningOfPassWriteIndex; + GPUSize32 endOfPassWriteIndex; +}; + +dictionary GPUComputePassDescriptor + : GPUObjectDescriptorBase { + GPUComputePassTimestampWrites timestampWrites; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPURenderPassEncoder { + undefined setViewport(float x, float y, + float width, float height, + float minDepth, float maxDepth); + + undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, + GPUIntegerCoordinate width, GPUIntegerCoordinate height); + + undefined setBlendConstant(GPUColor color); + undefined setStencilReference(GPUStencilValue reference); + + undefined beginOcclusionQuery(GPUSize32 queryIndex); + undefined endOcclusionQuery(); + + undefined executeBundles(sequence bundles); + undefined end(); +}; +GPURenderPassEncoder includes GPUObjectBase; +GPURenderPassEncoder includes GPUCommandsMixin; +GPURenderPassEncoder includes GPUDebugCommandsMixin; +GPURenderPassEncoder includes GPUBindingCommandsMixin; +GPURenderPassEncoder includes GPURenderCommandsMixin; + +dictionary GPURenderPassTimestampWrites { + required GPUQuerySet querySet; + GPUSize32 beginningOfPassWriteIndex; + GPUSize32 endOfPassWriteIndex; +}; + +dictionary GPURenderPassDescriptor + : GPUObjectDescriptorBase { + required sequence colorAttachments; + GPURenderPassDepthStencilAttachment depthStencilAttachment; + GPUQuerySet occlusionQuerySet; + GPURenderPassTimestampWrites timestampWrites; + GPUSize64 maxDrawCount = 50000000; +}; + +dictionary GPURenderPassColorAttachment { + required (GPUTexture or GPUTextureView) view; + GPUIntegerCoordinate depthSlice; + (GPUTexture or GPUTextureView) resolveTarget; + + GPUColor clearValue; + required GPULoadOp loadOp; + required GPUStoreOp storeOp; +}; + +dictionary GPURenderPassDepthStencilAttachment { + required (GPUTexture or GPUTextureView) view; + + float depthClearValue; + GPULoadOp depthLoadOp; + GPUStoreOp depthStoreOp; + boolean depthReadOnly = false; + + GPUStencilValue stencilClearValue = 0; + GPULoadOp stencilLoadOp; + GPUStoreOp stencilStoreOp; + boolean stencilReadOnly = false; +}; + +enum GPULoadOp { + "load", + "clear", +}; + +enum GPUStoreOp { + "store", + "discard", +}; + +dictionary GPURenderPassLayout + : GPUObjectDescriptorBase { + required sequence colorFormats; + GPUTextureFormat depthStencilFormat; + GPUSize32 sampleCount = 1; +}; + +interface mixin GPURenderCommandsMixin { + undefined setPipeline(GPURenderPipeline pipeline); + + undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size); + undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer? buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); + + undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1, + optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0); + undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1, + optional GPUSize32 firstIndex = 0, + optional GPUSignedOffset32 baseVertex = 0, + optional GPUSize32 firstInstance = 0); + + undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); + undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPURenderBundle { +}; +GPURenderBundle includes GPUObjectBase; + +dictionary GPURenderBundleDescriptor + : GPUObjectDescriptorBase { +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPURenderBundleEncoder { + GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {}); +}; +GPURenderBundleEncoder includes GPUObjectBase; +GPURenderBundleEncoder includes GPUCommandsMixin; +GPURenderBundleEncoder includes GPUDebugCommandsMixin; +GPURenderBundleEncoder includes GPUBindingCommandsMixin; +GPURenderBundleEncoder includes GPURenderCommandsMixin; + +dictionary GPURenderBundleEncoderDescriptor + : GPURenderPassLayout { + boolean depthReadOnly = false; + boolean stencilReadOnly = false; +}; + +dictionary GPUQueueDescriptor + : GPUObjectDescriptorBase { +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUQueue { + undefined submit(sequence commandBuffers); + + Promise onSubmittedWorkDone(); + + undefined writeBuffer( + GPUBuffer buffer, + GPUSize64 bufferOffset, + AllowSharedBufferSource data, + optional GPUSize64 dataOffset = 0, + optional GPUSize64 size); + + undefined writeTexture( + GPUTexelCopyTextureInfo destination, + AllowSharedBufferSource data, + GPUTexelCopyBufferLayout dataLayout, + GPUExtent3D size); + + undefined copyExternalImageToTexture( + GPUCopyExternalImageSourceInfo source, + GPUCopyExternalImageDestInfo destination, + GPUExtent3D copySize); +}; +GPUQueue includes GPUObjectBase; + +[Exposed=(Window, Worker), SecureContext] +interface GPUQuerySet { + undefined destroy(); + + readonly attribute GPUQueryType type; + readonly attribute GPUSize32Out count; +}; +GPUQuerySet includes GPUObjectBase; + +dictionary GPUQuerySetDescriptor + : GPUObjectDescriptorBase { + required GPUQueryType type; + required GPUSize32 count; +}; + +enum GPUQueryType { + "occlusion", + "timestamp", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUCanvasContext { + readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; + + undefined configure(GPUCanvasConfiguration configuration); + undefined unconfigure(); + + GPUCanvasConfiguration? getConfiguration(); + GPUTexture getCurrentTexture(); +}; + +enum GPUCanvasAlphaMode { + "opaque", + "premultiplied", +}; + +enum GPUCanvasToneMappingMode { + "standard", + "extended", +}; + +dictionary GPUCanvasToneMapping { + GPUCanvasToneMappingMode mode = "standard"; +}; + +dictionary GPUCanvasConfiguration { + required GPUDevice device; + required GPUTextureFormat format; + GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT + sequence viewFormats = []; + PredefinedColorSpace colorSpace = "srgb"; + GPUCanvasToneMapping toneMapping = {}; + GPUCanvasAlphaMode alphaMode = "opaque"; +}; + +enum GPUDeviceLostReason { + "unknown", + "destroyed", +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUDeviceLostInfo { + readonly attribute GPUDeviceLostReason reason; + readonly attribute DOMString message; +}; + +partial interface GPUDevice { + readonly attribute Promise lost; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUError { + readonly attribute DOMString message; +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUValidationError + : GPUError { + constructor(DOMString message); +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUOutOfMemoryError + : GPUError { + constructor(DOMString message); +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUInternalError + : GPUError { + constructor(DOMString message); +}; + +enum GPUErrorFilter { + "validation", + "out-of-memory", + "internal", +}; + +partial interface GPUDevice { + undefined pushErrorScope(GPUErrorFilter filter); + Promise popErrorScope(); +}; + +[Exposed=(Window, Worker), SecureContext] +interface GPUUncapturedErrorEvent : Event { + constructor( + DOMString type, + GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict + ); + [SameObject] readonly attribute GPUError error; +}; + +dictionary GPUUncapturedErrorEventInit : EventInit { + required GPUError error; +}; + +partial interface GPUDevice { + attribute EventHandler onuncapturederror; +}; + +typedef [EnforceRange] unsigned long GPUBufferDynamicOffset; +typedef [EnforceRange] unsigned long GPUStencilValue; +typedef [EnforceRange] unsigned long GPUSampleMask; +typedef [EnforceRange] long GPUDepthBias; + +typedef [EnforceRange] unsigned long long GPUSize64; +typedef [EnforceRange] unsigned long GPUIntegerCoordinate; +typedef [EnforceRange] unsigned long GPUIndex32; +typedef [EnforceRange] unsigned long GPUSize32; +typedef [EnforceRange] long GPUSignedOffset32; + +typedef unsigned long long GPUSize64Out; +typedef unsigned long GPUIntegerCoordinateOut; +typedef unsigned long GPUSize32Out; + +typedef unsigned long GPUFlagsConstant; + +dictionary GPUColorDict { + required double r; + required double g; + required double b; + required double a; +}; +typedef (sequence or GPUColorDict) GPUColor; + +dictionary GPUOrigin2DDict { + GPUIntegerCoordinate x = 0; + GPUIntegerCoordinate y = 0; +}; +typedef (sequence or GPUOrigin2DDict) GPUOrigin2D; + +dictionary GPUOrigin3DDict { + GPUIntegerCoordinate x = 0; + GPUIntegerCoordinate y = 0; + GPUIntegerCoordinate z = 0; +}; +typedef (sequence or GPUOrigin3DDict) GPUOrigin3D; + +dictionary GPUExtent3DDict { + required GPUIntegerCoordinate width; + GPUIntegerCoordinate height = 1; + GPUIntegerCoordinate depthOrArrayLayers = 1; +}; +typedef (sequence or GPUExtent3DDict) GPUExtent3D; + diff --git a/apigen/definitions/wgpu_api.toml b/apigen/definitions/wgpu_api.toml new file mode 100644 index 00000000..f9bb56b9 --- /dev/null +++ b/apigen/definitions/wgpu_api.toml @@ -0,0 +1,1190 @@ +# wgpu_api.toml: the base wgpu-py API, generated from 'wgpu_api_web.toml' and 'diff_base.toml'. + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[flags] + +[flags.BufferUsage] +fields.MAP_READ = { value = 1 } +fields.MAP_WRITE = { value = 2 } +fields.COPY_SRC = { value = 4 } +fields.COPY_DST = { value = 8 } +fields.INDEX = { value = 16 } +fields.VERTEX = { value = 32 } +fields.UNIFORM = { value = 64 } +fields.STORAGE = { value = 128 } +fields.INDIRECT = { value = 256 } +fields.QUERY_RESOLVE = { value = 512 } + +[flags.MapMode] +fields.READ = { value = 1 } +fields.WRITE = { value = 2 } + +[flags.TextureUsage] +fields.COPY_SRC = { value = 1 } +fields.COPY_DST = { value = 2 } +fields.TEXTURE_BINDING = { value = 4 } +fields.STORAGE_BINDING = { value = 8 } +fields.RENDER_ATTACHMENT = { value = 16 } +fields.TRANSIENT_ATTACHMENT = { value = 32 } + +[flags.ShaderStage] +fields.VERTEX = { value = 1 } +fields.FRAGMENT = { value = 2 } +fields.COMPUTE = { value = 4 } + +[flags.ColorWrite] +fields.RED = { value = 1 } +fields.GREEN = { value = 2 } +fields.BLUE = { value = 4 } +fields.ALPHA = { value = 8 } +fields.ALL = { value = 15 } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[enums] + +[enums.PowerPreference] +fields.low_power = { value = 'low-power' } +fields.high_performance = { value = 'high-performance' } + +[enums.FeatureName] +fields.core_features_and_limits = { value = 'core-features-and-limits' } +fields.depth_clip_control = { value = 'depth-clip-control' } +fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } +fields.texture_compression_bc = { value = 'texture-compression-bc' } +fields.texture_compression_bc_sliced_d3 = { value = 'texture-compression-bc-sliced-3d' } +fields.texture_compression_etc2 = { value = 'texture-compression-etc2' } +fields.texture_compression_astc = { value = 'texture-compression-astc' } +fields.texture_compression_astc_sliced_d3 = { value = 'texture-compression-astc-sliced-3d' } +fields.timestamp_query = { value = 'timestamp-query' } +fields.indirect_first_instance = { value = 'indirect-first-instance' } +fields.shader_f16 = { value = 'shader-f16' } +fields.rg11b10ufloat_renderable = { value = 'rg11b10ufloat-renderable' } +fields.bgra8unorm_storage = { value = 'bgra8unorm-storage' } +fields.float32_filterable = { value = 'float32-filterable' } +fields.float32_blendable = { value = 'float32-blendable' } +fields.clip_distances = { value = 'clip-distances' } +fields.dual_source_blending = { value = 'dual-source-blending' } +fields.subgroups = { value = 'subgroups' } +fields.texture_formats_tier1 = { value = 'texture-formats-tier1' } +fields.texture_formats_tier2 = { value = 'texture-formats-tier2' } +fields.primitive_index = { value = 'primitive-index' } +fields.texture_component_swizzle = { value = 'texture-component-swizzle' } + +[enums.BufferMapState] +fields.unmapped = { value = 'unmapped' } +fields.pending = { value = 'pending' } +fields.mapped = { value = 'mapped' } + +[enums.TextureDimension] +fields.d1 = { value = '1d' } +fields.d2 = { value = '2d' } +fields.d3 = { value = '3d' } + +[enums.TextureViewDimension] +fields.d1 = { value = '1d' } +fields.d2 = { value = '2d' } +fields.d2_array = { value = '2d-array' } +fields.cube = { value = 'cube' } +fields.cube_array = { value = 'cube-array' } +fields.d3 = { value = '3d' } + +[enums.TextureAspect] +fields.all = { value = 'all' } +fields.stencil_only = { value = 'stencil-only' } +fields.depth_only = { value = 'depth-only' } + +[enums.TextureFormat] +fields.r8unorm = { value = 'r8unorm' } +fields.r8snorm = { value = 'r8snorm' } +fields.r8uint = { value = 'r8uint' } +fields.r8sint = { value = 'r8sint' } +fields.r16unorm = { value = 'r16unorm' } +fields.r16snorm = { value = 'r16snorm' } +fields.r16uint = { value = 'r16uint' } +fields.r16sint = { value = 'r16sint' } +fields.r16float = { value = 'r16float' } +fields.rg8unorm = { value = 'rg8unorm' } +fields.rg8snorm = { value = 'rg8snorm' } +fields.rg8uint = { value = 'rg8uint' } +fields.rg8sint = { value = 'rg8sint' } +fields.r32uint = { value = 'r32uint' } +fields.r32sint = { value = 'r32sint' } +fields.r32float = { value = 'r32float' } +fields.rg16unorm = { value = 'rg16unorm' } +fields.rg16snorm = { value = 'rg16snorm' } +fields.rg16uint = { value = 'rg16uint' } +fields.rg16sint = { value = 'rg16sint' } +fields.rg16float = { value = 'rg16float' } +fields.rgba8unorm = { value = 'rgba8unorm' } +fields.rgba8unorm_srgb = { value = 'rgba8unorm-srgb' } +fields.rgba8snorm = { value = 'rgba8snorm' } +fields.rgba8uint = { value = 'rgba8uint' } +fields.rgba8sint = { value = 'rgba8sint' } +fields.bgra8unorm = { value = 'bgra8unorm' } +fields.bgra8unorm_srgb = { value = 'bgra8unorm-srgb' } +fields.rgb9e5ufloat = { value = 'rgb9e5ufloat' } +fields.rgb10a2uint = { value = 'rgb10a2uint' } +fields.rgb10a2unorm = { value = 'rgb10a2unorm' } +fields.rg11b10ufloat = { value = 'rg11b10ufloat' } +fields.rg32uint = { value = 'rg32uint' } +fields.rg32sint = { value = 'rg32sint' } +fields.rg32float = { value = 'rg32float' } +fields.rgba16unorm = { value = 'rgba16unorm' } +fields.rgba16snorm = { value = 'rgba16snorm' } +fields.rgba16uint = { value = 'rgba16uint' } +fields.rgba16sint = { value = 'rgba16sint' } +fields.rgba16float = { value = 'rgba16float' } +fields.rgba32uint = { value = 'rgba32uint' } +fields.rgba32sint = { value = 'rgba32sint' } +fields.rgba32float = { value = 'rgba32float' } +fields.stencil8 = { value = 'stencil8' } +fields.depth16unorm = { value = 'depth16unorm' } +fields.depth24plus = { value = 'depth24plus' } +fields.depth24plus_stencil8 = { value = 'depth24plus-stencil8' } +fields.depth32float = { value = 'depth32float' } +fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } +fields.bc1_rgba_unorm = { value = 'bc1-rgba-unorm' } +fields.bc1_rgba_unorm_srgb = { value = 'bc1-rgba-unorm-srgb' } +fields.bc2_rgba_unorm = { value = 'bc2-rgba-unorm' } +fields.bc2_rgba_unorm_srgb = { value = 'bc2-rgba-unorm-srgb' } +fields.bc3_rgba_unorm = { value = 'bc3-rgba-unorm' } +fields.bc3_rgba_unorm_srgb = { value = 'bc3-rgba-unorm-srgb' } +fields.bc4_r_unorm = { value = 'bc4-r-unorm' } +fields.bc4_r_snorm = { value = 'bc4-r-snorm' } +fields.bc5_rg_unorm = { value = 'bc5-rg-unorm' } +fields.bc5_rg_snorm = { value = 'bc5-rg-snorm' } +fields.bc6h_rgb_ufloat = { value = 'bc6h-rgb-ufloat' } +fields.bc6h_rgb_float = { value = 'bc6h-rgb-float' } +fields.bc7_rgba_unorm = { value = 'bc7-rgba-unorm' } +fields.bc7_rgba_unorm_srgb = { value = 'bc7-rgba-unorm-srgb' } +fields.etc2_rgb8unorm = { value = 'etc2-rgb8unorm' } +fields.etc2_rgb8unorm_srgb = { value = 'etc2-rgb8unorm-srgb' } +fields.etc2_rgb8a1unorm = { value = 'etc2-rgb8a1unorm' } +fields.etc2_rgb8a1unorm_srgb = { value = 'etc2-rgb8a1unorm-srgb' } +fields.etc2_rgba8unorm = { value = 'etc2-rgba8unorm' } +fields.etc2_rgba8unorm_srgb = { value = 'etc2-rgba8unorm-srgb' } +fields.eac_r11unorm = { value = 'eac-r11unorm' } +fields.eac_r11snorm = { value = 'eac-r11snorm' } +fields.eac_rg11unorm = { value = 'eac-rg11unorm' } +fields.eac_rg11snorm = { value = 'eac-rg11snorm' } +fields.astc_4x4_unorm = { value = 'astc-4x4-unorm' } +fields.astc_4x4_unorm_srgb = { value = 'astc-4x4-unorm-srgb' } +fields.astc_5x4_unorm = { value = 'astc-5x4-unorm' } +fields.astc_5x4_unorm_srgb = { value = 'astc-5x4-unorm-srgb' } +fields.astc_5x5_unorm = { value = 'astc-5x5-unorm' } +fields.astc_5x5_unorm_srgb = { value = 'astc-5x5-unorm-srgb' } +fields.astc_6x5_unorm = { value = 'astc-6x5-unorm' } +fields.astc_6x5_unorm_srgb = { value = 'astc-6x5-unorm-srgb' } +fields.astc_6x6_unorm = { value = 'astc-6x6-unorm' } +fields.astc_6x6_unorm_srgb = { value = 'astc-6x6-unorm-srgb' } +fields.astc_8x5_unorm = { value = 'astc-8x5-unorm' } +fields.astc_8x5_unorm_srgb = { value = 'astc-8x5-unorm-srgb' } +fields.astc_8x6_unorm = { value = 'astc-8x6-unorm' } +fields.astc_8x6_unorm_srgb = { value = 'astc-8x6-unorm-srgb' } +fields.astc_8x8_unorm = { value = 'astc-8x8-unorm' } +fields.astc_8x8_unorm_srgb = { value = 'astc-8x8-unorm-srgb' } +fields.astc_10x5_unorm = { value = 'astc-10x5-unorm' } +fields.astc_10x5_unorm_srgb = { value = 'astc-10x5-unorm-srgb' } +fields.astc_10x6_unorm = { value = 'astc-10x6-unorm' } +fields.astc_10x6_unorm_srgb = { value = 'astc-10x6-unorm-srgb' } +fields.astc_10x8_unorm = { value = 'astc-10x8-unorm' } +fields.astc_10x8_unorm_srgb = { value = 'astc-10x8-unorm-srgb' } +fields.astc_10x10_unorm = { value = 'astc-10x10-unorm' } +fields.astc_10x10_unorm_srgb = { value = 'astc-10x10-unorm-srgb' } +fields.astc_12x10_unorm = { value = 'astc-12x10-unorm' } +fields.astc_12x10_unorm_srgb = { value = 'astc-12x10-unorm-srgb' } +fields.astc_12x12_unorm = { value = 'astc-12x12-unorm' } +fields.astc_12x12_unorm_srgb = { value = 'astc-12x12-unorm-srgb' } + +[enums.AddressMode] +fields.clamp_to_edge = { value = 'clamp-to-edge' } +fields.repeat = { value = 'repeat' } +fields.mirror_repeat = { value = 'mirror-repeat' } + +[enums.FilterMode] +fields.nearest = { value = 'nearest' } +fields.linear = { value = 'linear' } + +[enums.MipmapFilterMode] +fields.nearest = { value = 'nearest' } +fields.linear = { value = 'linear' } + +[enums.CompareFunction] +fields.never = { value = 'never' } +fields.less = { value = 'less' } +fields.equal = { value = 'equal' } +fields.less_equal = { value = 'less-equal' } +fields.greater = { value = 'greater' } +fields.not_equal = { value = 'not-equal' } +fields.greater_equal = { value = 'greater-equal' } +fields.always = { value = 'always' } + +[enums.BufferBindingType] +fields.uniform = { value = 'uniform' } +fields.storage = { value = 'storage' } +fields.read_only_storage = { value = 'read-only-storage' } + +[enums.SamplerBindingType] +fields.filtering = { value = 'filtering' } +fields.non_filtering = { value = 'non-filtering' } +fields.comparison = { value = 'comparison' } + +[enums.TextureSampleType] +fields.float = { value = 'float' } +fields.unfilterable_float = { value = 'unfilterable-float' } +fields.depth = { value = 'depth' } +fields.sint = { value = 'sint' } +fields.uint = { value = 'uint' } + +[enums.StorageTextureAccess] +fields.write_only = { value = 'write-only' } +fields.read_only = { value = 'read-only' } +fields.read_write = { value = 'read-write' } + +[enums.CompilationMessageType] +fields.error = { value = 'error' } +fields.warning = { value = 'warning' } +fields.info = { value = 'info' } + +[enums.PipelineErrorReason] +fields.validation = { value = 'validation' } +fields.internal = { value = 'internal' } + +[enums.AutoLayoutMode] +fields.auto = { value = 'auto' } + +[enums.PrimitiveTopology] +fields.point_list = { value = 'point-list' } +fields.line_list = { value = 'line-list' } +fields.line_strip = { value = 'line-strip' } +fields.triangle_list = { value = 'triangle-list' } +fields.triangle_strip = { value = 'triangle-strip' } + +[enums.FrontFace] +fields.ccw = { value = 'ccw' } +fields.cw = { value = 'cw' } + +[enums.CullMode] +fields.none = { value = 'none' } +fields.front = { value = 'front' } +fields.back = { value = 'back' } + +[enums.BlendFactor] +fields.zero = { value = 'zero' } +fields.one = { value = 'one' } +fields.src = { value = 'src' } +fields.one_minus_src = { value = 'one-minus-src' } +fields.src_alpha = { value = 'src-alpha' } +fields.one_minus_src_alpha = { value = 'one-minus-src-alpha' } +fields.dst = { value = 'dst' } +fields.one_minus_dst = { value = 'one-minus-dst' } +fields.dst_alpha = { value = 'dst-alpha' } +fields.one_minus_dst_alpha = { value = 'one-minus-dst-alpha' } +fields.src_alpha_saturated = { value = 'src-alpha-saturated' } +fields.constant = { value = 'constant' } +fields.one_minus_constant = { value = 'one-minus-constant' } +fields.src1 = { value = 'src1' } +fields.one_minus_src1 = { value = 'one-minus-src1' } +fields.src1_alpha = { value = 'src1-alpha' } +fields.one_minus_src1_alpha = { value = 'one-minus-src1-alpha' } + +[enums.BlendOperation] +fields.add = { value = 'add' } +fields.subtract = { value = 'subtract' } +fields.reverse_subtract = { value = 'reverse-subtract' } +fields.min = { value = 'min' } +fields.max = { value = 'max' } + +[enums.StencilOperation] +fields.keep = { value = 'keep' } +fields.zero = { value = 'zero' } +fields.replace = { value = 'replace' } +fields.invert = { value = 'invert' } +fields.increment_clamp = { value = 'increment-clamp' } +fields.decrement_clamp = { value = 'decrement-clamp' } +fields.increment_wrap = { value = 'increment-wrap' } +fields.decrement_wrap = { value = 'decrement-wrap' } + +[enums.IndexFormat] +fields.uint16 = { value = 'uint16' } +fields.uint32 = { value = 'uint32' } + +[enums.VertexFormat] +fields.uint8 = { value = 'uint8' } +fields.uint8x2 = { value = 'uint8x2' } +fields.uint8x4 = { value = 'uint8x4' } +fields.sint8 = { value = 'sint8' } +fields.sint8x2 = { value = 'sint8x2' } +fields.sint8x4 = { value = 'sint8x4' } +fields.unorm8 = { value = 'unorm8' } +fields.unorm8x2 = { value = 'unorm8x2' } +fields.unorm8x4 = { value = 'unorm8x4' } +fields.snorm8 = { value = 'snorm8' } +fields.snorm8x2 = { value = 'snorm8x2' } +fields.snorm8x4 = { value = 'snorm8x4' } +fields.uint16 = { value = 'uint16' } +fields.uint16x2 = { value = 'uint16x2' } +fields.uint16x4 = { value = 'uint16x4' } +fields.sint16 = { value = 'sint16' } +fields.sint16x2 = { value = 'sint16x2' } +fields.sint16x4 = { value = 'sint16x4' } +fields.unorm16 = { value = 'unorm16' } +fields.unorm16x2 = { value = 'unorm16x2' } +fields.unorm16x4 = { value = 'unorm16x4' } +fields.snorm16 = { value = 'snorm16' } +fields.snorm16x2 = { value = 'snorm16x2' } +fields.snorm16x4 = { value = 'snorm16x4' } +fields.float16 = { value = 'float16' } +fields.float16x2 = { value = 'float16x2' } +fields.float16x4 = { value = 'float16x4' } +fields.float32 = { value = 'float32' } +fields.float32x2 = { value = 'float32x2' } +fields.float32x3 = { value = 'float32x3' } +fields.float32x4 = { value = 'float32x4' } +fields.uint32 = { value = 'uint32' } +fields.uint32x2 = { value = 'uint32x2' } +fields.uint32x3 = { value = 'uint32x3' } +fields.uint32x4 = { value = 'uint32x4' } +fields.sint32 = { value = 'sint32' } +fields.sint32x2 = { value = 'sint32x2' } +fields.sint32x3 = { value = 'sint32x3' } +fields.sint32x4 = { value = 'sint32x4' } +fields.unorm10_10_10_2 = { value = 'unorm10-10-10-2' } +fields.unorm8x4_bgra = { value = 'unorm8x4-bgra' } + +[enums.VertexStepMode] +fields.vertex = { value = 'vertex' } +fields.instance = { value = 'instance' } + +[enums.LoadOp] +fields.load = { value = 'load' } +fields.clear = { value = 'clear' } + +[enums.StoreOp] +fields.store = { value = 'store' } +fields.discard = { value = 'discard' } + +[enums.QueryType] +fields.occlusion = { value = 'occlusion' } +fields.timestamp = { value = 'timestamp' } + +[enums.CanvasAlphaMode] +fields.opaque = { value = 'opaque' } +fields.premultiplied = { value = 'premultiplied' } + +[enums.CanvasToneMappingMode] +fields.standard = { value = 'standard' } +fields.extended = { value = 'extended' } + +[enums.DeviceLostReason] +fields.unknown = { value = 'unknown' } +fields.destroyed = { value = 'destroyed' } + +[enums.ErrorFilter] +fields.validation = { value = 'validation' } +fields.out_of_memory = { value = 'out-of-memory' } +fields.internal = { value = 'internal' } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[structs] + +[structs.RequestAdapterOptions] +fields.feature_level = { type = 'str', default = '"core"', required = false } +fields.power_preference = { type = 'enums.PowerPreferenceEnum', default = 'None', required = false } +fields.force_fallback_adapter = { type = 'bool', default = 'False', required = false } +fields.xr_compatible = { type = 'bool', default = 'False', required = false } + +[structs.DeviceDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.required_features = { type = 'list[enums.FeatureNameEnum]', default = '[]', required = false } +fields.required_limits = { type = 'dict[str, int | None]', default = '{}', required = false } +fields.default_queue = { type = 'structs.QueueDescriptorStruct', default = '{}', required = false } + +[structs.BufferDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.size = { type = 'int', default = 'None', required = true } +fields.usage = { type = 'flags.BufferUsageFlags', default = 'None', required = true } +fields.mapped_at_creation = { type = 'bool', default = 'False', required = false } + +[structs.TextureDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +fields.mip_level_count = { type = 'int', default = '1', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } +fields.dimension = { type = 'enums.TextureDimensionEnum', default = '"2d"', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.usage = { type = 'flags.TextureUsageFlags', default = 'None', required = true } +fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } +fields.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } + +[structs.TextureViewDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } +fields.usage = { type = 'flags.TextureUsageFlags', default = '0', required = false } +fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } +fields.base_mip_level = { type = 'int', default = '0', required = false } +fields.mip_level_count = { type = 'int', default = 'None', required = false } +fields.base_array_layer = { type = 'int', default = '0', required = false } +fields.array_layer_count = { type = 'int', default = 'None', required = false } +fields.swizzle = { type = 'str', default = '"rgba"', required = false } + +[structs.ExternalTextureDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.source = { type = 'ArrayLike | object', default = 'None', required = true } +fields.color_space = { type = 'str', default = '"srgb"', required = false } + +[structs.SamplerDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.address_mode_u = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.address_mode_v = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.address_mode_w = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.mag_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } +fields.min_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } +fields.mipmap_filter = { type = 'enums.MipmapFilterModeEnum', default = '"nearest"', required = false } +fields.lod_min_clamp = { type = 'float', default = '0', required = false } +fields.lod_max_clamp = { type = 'float', default = '32', required = false } +fields.compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } +fields.max_anisotropy = { type = 'int', default = '1', required = false } + +[structs.BindGroupLayoutDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.entries = { type = 'list[structs.BindGroupLayoutEntryStruct]', default = 'None', required = true } + +[structs.BindGroupLayoutEntry] +fields.binding = { type = 'int', default = 'None', required = true } +fields.visibility = { type = 'flags.ShaderStageFlags', default = 'None', required = true } +fields.buffer = { type = 'structs.BufferBindingLayoutStruct', default = 'None', required = false } +fields.sampler = { type = 'structs.SamplerBindingLayoutStruct', default = 'None', required = false } +fields.texture = { type = 'structs.TextureBindingLayoutStruct', default = 'None', required = false } +fields.storage_texture = { type = 'structs.StorageTextureBindingLayoutStruct', default = 'None', required = false } + +[structs.BufferBindingLayout] +fields.type = { type = 'enums.BufferBindingTypeEnum', default = '"uniform"', required = false } +fields.has_dynamic_offset = { type = 'bool', default = 'False', required = false } +fields.min_binding_size = { type = 'int', default = '0', required = false } + +[structs.SamplerBindingLayout] +fields.type = { type = 'enums.SamplerBindingTypeEnum', default = '"filtering"', required = false } + +[structs.TextureBindingLayout] +fields.sample_type = { type = 'enums.TextureSampleTypeEnum', default = '"float"', required = false } +fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } +fields.multisampled = { type = 'bool', default = 'False', required = false } + +[structs.StorageTextureBindingLayout] +fields.access = { type = 'enums.StorageTextureAccessEnum', default = '"write-only"', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } + +[structs.BindGroupDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUBindGroupLayout', default = 'None', required = true } +fields.entries = { type = 'list[structs.BindGroupEntryStruct]', default = 'None', required = true } + +[structs.BindGroupEntry] +fields.binding = { type = 'int', default = 'None', required = true } +fields.resource = { type = 'GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct', default = 'None', required = true } + +[structs.BufferBinding] +fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } +fields.offset = { type = 'int', default = '0', required = false } +fields.size = { type = 'int', default = 'None', required = false } + +[structs.PipelineLayoutDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.bind_group_layouts = { type = 'list[GPUBindGroupLayout]', default = 'None', required = true } +fields.immediate_size = { type = 'int', default = '0', required = false } + +[structs.ShaderModuleDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.code = { type = 'str', default = 'None', required = true } +fields.compilation_hints = { type = 'list[structs.ShaderModuleCompilationHintStruct]', default = '[]', required = false } + +[structs.ShaderModuleCompilationHint] +fields.entry_point = { type = 'str', default = 'None', required = true } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = false } + +[structs.PipelineErrorInit] +fields.reason = { type = 'enums.PipelineErrorReasonEnum', default = 'None', required = true } + +[structs.ProgrammableStage] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } + +[structs.ComputePipelineDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } +fields.compute = { type = 'structs.ProgrammableStageStruct', default = 'None', required = true } + +[structs.RenderPipelineDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } +fields.vertex = { type = 'structs.VertexStateStruct', default = 'None', required = true } +fields.primitive = { type = 'structs.PrimitiveStateStruct', default = '{}', required = false } +fields.depth_stencil = { type = 'structs.DepthStencilStateStruct', default = 'None', required = false } +fields.multisample = { type = 'structs.MultisampleStateStruct', default = '{}', required = false } +fields.fragment = { type = 'structs.FragmentStateStruct', default = 'None', required = false } + +[structs.PrimitiveState] +fields.topology = { type = 'enums.PrimitiveTopologyEnum', default = '"triangle-list"', required = false } +fields.strip_index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = false } +fields.front_face = { type = 'enums.FrontFaceEnum', default = '"ccw"', required = false } +fields.cull_mode = { type = 'enums.CullModeEnum', default = '"none"', required = false } +fields.unclipped_depth = { type = 'bool', default = 'False', required = false } + +[structs.MultisampleState] +fields.count = { type = 'int', default = '1', required = false } +fields.mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.alpha_to_coverage_enabled = { type = 'bool', default = 'False', required = false } + +[structs.FragmentState] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } +fields.targets = { type = 'list[structs.ColorTargetStateStruct]', default = 'None', required = true } + +[structs.ColorTargetState] +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.blend = { type = 'structs.BlendStateStruct', default = 'None', required = false } +fields.write_mask = { type = 'flags.ColorWriteFlags', default = '0xF', required = false } + +[structs.BlendState] +fields.color = { type = 'structs.BlendComponentStruct', default = 'None', required = true } +fields.alpha = { type = 'structs.BlendComponentStruct', default = 'None', required = true } + +[structs.BlendComponent] +fields.operation = { type = 'enums.BlendOperationEnum', default = '"add"', required = false } +fields.src_factor = { type = 'enums.BlendFactorEnum', default = '"one"', required = false } +fields.dst_factor = { type = 'enums.BlendFactorEnum', default = '"zero"', required = false } + +[structs.DepthStencilState] +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.depth_write_enabled = { type = 'bool', default = 'None', required = false } +fields.depth_compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } +fields.stencil_front = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } +fields.stencil_back = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } +fields.stencil_read_mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.stencil_write_mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.depth_bias = { type = 'int', default = '0', required = false } +fields.depth_bias_slope_scale = { type = 'float', default = '0', required = false } +fields.depth_bias_clamp = { type = 'float', default = '0', required = false } + +[structs.StencilFaceState] +fields.compare = { type = 'enums.CompareFunctionEnum', default = '"always"', required = false } +fields.fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } +fields.depth_fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } +fields.pass_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } + +[structs.VertexState] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } +fields.buffers = { type = 'list[structs.VertexBufferLayoutStruct]', default = '[]', required = false } + +[structs.VertexBufferLayout] +fields.array_stride = { type = 'int', default = 'None', required = true } +fields.step_mode = { type = 'enums.VertexStepModeEnum', default = '"vertex"', required = false } +fields.attributes = { type = 'list[structs.VertexAttributeStruct]', default = 'None', required = true } + +[structs.VertexAttribute] +fields.format = { type = 'enums.VertexFormatEnum', default = 'None', required = true } +fields.offset = { type = 'int', default = 'None', required = true } +fields.shader_location = { type = 'int', default = 'None', required = true } + +[structs.TexelCopyBufferLayout] +fields.offset = { type = 'int', default = '0', required = false } +fields.bytes_per_row = { type = 'int', default = 'None', required = false } +fields.rows_per_image = { type = 'int', default = 'None', required = false } + +[structs.TexelCopyBufferInfo] +fields.offset = { type = 'int', default = '0', required = false } +fields.bytes_per_row = { type = 'int', default = 'None', required = false } +fields.rows_per_image = { type = 'int', default = 'None', required = false } +fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } + +[structs.TexelCopyTextureInfo] +fields.texture = { type = 'GPUTexture', default = 'None', required = true } +fields.mip_level = { type = 'int', default = '0', required = false } +fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } +fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } + +[structs.CommandBufferDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.CommandEncoderDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.ComputePassTimestampWrites] +fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } +fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } + +[structs.ComputePassDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.timestamp_writes = { type = 'structs.ComputePassTimestampWritesStruct', default = 'None', required = false } + +[structs.RenderPassTimestampWrites] +fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } +fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } + +[structs.RenderPassDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.color_attachments = { type = 'list[structs.RenderPassColorAttachmentStruct]', default = 'None', required = true } +fields.depth_stencil_attachment = { type = 'structs.RenderPassDepthStencilAttachmentStruct', default = 'None', required = false } +fields.occlusion_query_set = { type = 'GPUQuerySet', default = 'None', required = false } +fields.timestamp_writes = { type = 'structs.RenderPassTimestampWritesStruct', default = 'None', required = false } +fields.max_draw_count = { type = 'int', default = '50000000', required = false } + +[structs.RenderPassColorAttachment] +fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } +fields.depth_slice = { type = 'int', default = 'None', required = false } +fields.resolve_target = { type = 'GPUTexture | GPUTextureView', default = 'None', required = false } +fields.clear_value = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = false } +fields.load_op = { type = 'enums.LoadOpEnum', default = 'None', required = true } +fields.store_op = { type = 'enums.StoreOpEnum', default = 'None', required = true } + +[structs.RenderPassDepthStencilAttachment] +fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } +fields.depth_clear_value = { type = 'float', default = 'None', required = false } +fields.depth_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } +fields.depth_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } +fields.depth_read_only = { type = 'bool', default = 'False', required = false } +fields.stencil_clear_value = { type = 'int', default = '0', required = false } +fields.stencil_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } +fields.stencil_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } +fields.stencil_read_only = { type = 'bool', default = 'False', required = false } + +[structs.RenderPassLayout] +fields.label = { type = 'str', default = '""', required = false } +fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } +fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } + +[structs.RenderBundleDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.RenderBundleEncoderDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } +fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } +fields.depth_read_only = { type = 'bool', default = 'False', required = false } +fields.stencil_read_only = { type = 'bool', default = 'False', required = false } + +[structs.QueueDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.QuerySetDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.type = { type = 'enums.QueryTypeEnum', default = 'None', required = true } +fields.count = { type = 'int', default = 'None', required = true } + +[structs.CanvasToneMapping] +fields.mode = { type = 'enums.CanvasToneMappingModeEnum', default = '"standard"', required = false } + +[structs.CanvasConfiguration] +fields.device = { type = 'GPUDevice', default = 'None', required = true } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.usage = { type = 'flags.TextureUsageFlags', default = '0x10', required = false } +fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } +fields.color_space = { type = 'str', default = '"srgb"', required = false } +fields.tone_mapping = { type = 'structs.CanvasToneMappingStruct', default = '{}', required = false } +fields.alpha_mode = { type = 'enums.CanvasAlphaModeEnum', default = '"opaque"', required = false } + +[structs.UncapturedErrorEventInit] +fields.error = { type = 'GPUError', default = 'None', required = true } + +[structs.Color] +fields.r = { type = 'float', default = 'None', required = true } +fields.g = { type = 'float', default = 'None', required = true } +fields.b = { type = 'float', default = 'None', required = true } +fields.a = { type = 'float', default = 'None', required = true } + +[structs.Origin2D] +fields.x = { type = 'int', default = '0', required = false } +fields.y = { type = 'int', default = '0', required = false } + +[structs.Origin3D] +fields.x = { type = 'int', default = '0', required = false } +fields.y = { type = 'int', default = '0', required = false } +fields.z = { type = 'int', default = '0', required = false } + +[structs.Extent3D] +fields.width = { type = 'int', default = 'None', required = true } +fields.height = { type = 'int', default = '1', required = false } +fields.depth_or_array_layers = { type = 'int', default = '1', required = false } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[classes] + +[classes.GPUObjectBase] +bases = [] +properties.label = { type = 'str' } +[classes.GPUObjectBase.methods] + +[classes.GPUAdapterInfo] +bases = [] +properties.vendor = { type = 'str' } +properties.architecture = { type = 'str' } +properties.device = { type = 'str' } +properties.description = { type = 'str' } +properties.subgroup_min_size = { type = 'int' } +properties.subgroup_max_size = { type = 'int' } +properties.is_fallback_adapter = { type = 'bool' } +[classes.GPUAdapterInfo.methods] + +[classes.GPU] +bases = [] +properties.wgsl_language_features = { type = 'set' } +[classes.GPU.methods] +[classes.GPU.methods.request_adapter] +returns = { type = 'GPUAdapter' } +args.options = { type = 'structs.RequestAdapterOptionsStruct', default = '{}', required = false } +[classes.GPU.methods.get_preferred_canvas_format] +returns = { type = 'enums.TextureFormatEnum' } + +[classes.GPUAdapter] +bases = [] +properties.features = { type = 'set' } +properties.limits = { type = 'dict' } +properties.info = { type = 'GPUAdapterInfo' } +[classes.GPUAdapter.methods] +[classes.GPUAdapter.methods.request_device] +returns = { type = 'GPUDevice' } +args.descriptor = { type = 'structs.DeviceDescriptorStruct', default = '{}', required = false } + +[classes.GPUDevice] +bases = ['EventTarget', 'GPUObjectBase'] +properties.features = { type = 'set' } +properties.limits = { type = 'dict' } +properties.adapter_info = { type = 'GPUAdapterInfo' } +properties.queue = { type = 'GPUQueue' } +properties.lost = { type = 'GPUDeviceLostInfo' } +properties.onuncapturederror = { type = 'None' } +[classes.GPUDevice.methods] +[classes.GPUDevice.methods.destroy] +returns = { type = 'None' } +[classes.GPUDevice.methods.create_buffer] +returns = { type = 'GPUBuffer' } +args.descriptor = { type = 'structs.BufferDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_texture] +returns = { type = 'GPUTexture' } +args.descriptor = { type = 'structs.TextureDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_sampler] +returns = { type = 'GPUSampler' } +args.descriptor = { type = 'structs.SamplerDescriptorStruct', default = '{}', required = false } +[classes.GPUDevice.methods.create_bind_group_layout] +returns = { type = 'GPUBindGroupLayout' } +args.descriptor = { type = 'structs.BindGroupLayoutDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_pipeline_layout] +returns = { type = 'GPUPipelineLayout' } +args.descriptor = { type = 'structs.PipelineLayoutDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_bind_group] +returns = { type = 'GPUBindGroup' } +args.descriptor = { type = 'structs.BindGroupDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_shader_module] +returns = { type = 'GPUShaderModule' } +args.descriptor = { type = 'structs.ShaderModuleDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_compute_pipeline] +returns = { type = 'GPUComputePipeline' } +args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_render_pipeline] +returns = { type = 'GPURenderPipeline' } +args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_compute_pipeline_async] +returns = { type = 'GPUPromise[GPUComputePipeline]' } +args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_render_pipeline_async] +returns = { type = 'GPUPromise[GPURenderPipeline]' } +args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_command_encoder] +returns = { type = 'GPUCommandEncoder' } +args.descriptor = { type = 'structs.CommandEncoderDescriptorStruct', default = '{}', required = false } +[classes.GPUDevice.methods.create_render_bundle_encoder] +returns = { type = 'GPURenderBundleEncoder' } +args.descriptor = { type = 'structs.RenderBundleEncoderDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_query_set] +returns = { type = 'GPUQuerySet' } +args.descriptor = { type = 'structs.QuerySetDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.push_error_scope] +returns = { type = 'None' } +args.filter = { type = 'enums.ErrorFilterEnum', default = 'None', required = true } +[classes.GPUDevice.methods.pop_error_scope] +returns = { type = 'GPUError' } + +[classes.GPUBuffer] +bases = ['GPUObjectBase'] +properties.size = { type = 'int' } +properties.usage = { type = 'int' } +properties.map_state = { type = 'enums.BufferMapStateEnum' } +[classes.GPUBuffer.methods] +[classes.GPUBuffer.methods.map_async] +returns = { type = 'GPUPromise[None]' } +args.mode = { type = 'flags.MapModeFlags', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUBuffer.methods.get_mapped_range] +returns = { type = 'ArrayLike' } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUBuffer.methods.unmap] +returns = { type = 'None' } +[classes.GPUBuffer.methods.destroy] +returns = { type = 'None' } + +[classes.GPUTexture] +bases = ['GPUObjectBase'] +properties.width = { type = 'int' } +properties.height = { type = 'int' } +properties.depth_or_array_layers = { type = 'int' } +properties.mip_level_count = { type = 'int' } +properties.sample_count = { type = 'int' } +properties.dimension = { type = 'enums.TextureDimensionEnum' } +properties.format = { type = 'enums.TextureFormatEnum' } +properties.usage = { type = 'int' } +properties.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum | None' } +[classes.GPUTexture.methods] +[classes.GPUTexture.methods.create_view] +returns = { type = 'GPUTextureView' } +args.descriptor = { type = 'structs.TextureViewDescriptorStruct', default = '{}', required = false } +[classes.GPUTexture.methods.destroy] +returns = { type = 'None' } + +[classes.GPUTextureView] +bases = ['GPUObjectBase'] +[classes.GPUTextureView.methods] + +[classes.GPUSampler] +bases = ['GPUObjectBase'] +[classes.GPUSampler.methods] + +[classes.GPUBindGroupLayout] +bases = ['GPUObjectBase'] +[classes.GPUBindGroupLayout.methods] + +[classes.GPUBindGroup] +bases = ['GPUObjectBase'] +[classes.GPUBindGroup.methods] + +[classes.GPUPipelineLayout] +bases = ['GPUObjectBase'] +[classes.GPUPipelineLayout.methods] + +[classes.GPUShaderModule] +bases = ['GPUObjectBase'] +[classes.GPUShaderModule.methods] +[classes.GPUShaderModule.methods.get_compilation_info] +returns = { type = 'GPUCompilationInfo' } + +[classes.GPUCompilationMessage] +bases = [] +properties.message = { type = 'str' } +properties.type = { type = 'enums.CompilationMessageTypeEnum' } +properties.line_num = { type = 'int' } +properties.line_pos = { type = 'int' } +properties.offset = { type = 'int' } +properties.length = { type = 'int' } +[classes.GPUCompilationMessage.methods] + +[classes.GPUCompilationInfo] +bases = [] +properties.messages = { type = 'list[GPUCompilationMessage]' } +[classes.GPUCompilationInfo.methods] + +[classes.GPUPipelineError] +bases = ['DOMException'] +properties.reason = { type = 'enums.PipelineErrorReasonEnum' } +[classes.GPUPipelineError.methods] +[classes.GPUPipelineError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = '""', required = false } +args.options = { type = 'structs.PipelineErrorInitStruct', default = 'None', required = true } + +[classes.GPUPipelineBase] +bases = [] +[classes.GPUPipelineBase.methods] +[classes.GPUPipelineBase.methods.get_bind_group_layout] +returns = { type = 'GPUBindGroupLayout' } +args.index = { type = 'int', default = 'None', required = true } + +[classes.GPUComputePipeline] +bases = ['GPUObjectBase', 'GPUPipelineBase'] +[classes.GPUComputePipeline.methods] + +[classes.GPURenderPipeline] +bases = ['GPUObjectBase', 'GPUPipelineBase'] +[classes.GPURenderPipeline.methods] + +[classes.GPUCommandBuffer] +bases = ['GPUObjectBase'] +[classes.GPUCommandBuffer.methods] + +[classes.GPUCommandsMixin] +bases = [] +[classes.GPUCommandsMixin.methods] + +[classes.GPUCommandEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin'] +[classes.GPUCommandEncoder.methods] +[classes.GPUCommandEncoder.methods.begin_render_pass] +returns = { type = 'GPURenderPassEncoder' } +args.descriptor = { type = 'structs.RenderPassDescriptorStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.begin_compute_pass] +returns = { type = 'GPUComputePassEncoder' } +args.descriptor = { type = 'structs.ComputePassDescriptorStruct', default = '{}', required = false } +[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] +returns = { type = 'None' } +args.source = { type = 'GPUBuffer', default = 'None', required = true } +args.source_offset = { type = 'int', default = 'None', required = true } +args.destination = { type = 'GPUBuffer', default = 'None', required = true } +args.destination_offset = { type = 'int', default = 'None', required = true } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.copy_texture_to_texture] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.clear_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUCommandEncoder.methods.resolve_query_set] +returns = { type = 'None' } +args.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +args.first_query = { type = 'int', default = 'None', required = true } +args.query_count = { type = 'int', default = 'None', required = true } +args.destination = { type = 'GPUBuffer', default = 'None', required = true } +args.destination_offset = { type = 'int', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.finish] +returns = { type = 'GPUCommandBuffer' } +args.descriptor = { type = 'structs.CommandBufferDescriptorStruct', default = '{}', required = false } + +[classes.GPUBindingCommandsMixin] +bases = [] +[classes.GPUBindingCommandsMixin.methods] +[classes.GPUBindingCommandsMixin.methods.set_bind_group] +returns = { type = 'None' } +args.index = { type = 'int', default = 'None', required = true } +args.bind_group = { type = 'GPUBindGroup', default = 'None', required = true } +args.dynamic_offsets_data = { type = 'ArrayLike', default = 'None', required = true } +args.dynamic_offsets_data_start = { type = 'int', default = 'None', required = true } +args.dynamic_offsets_data_length = { type = 'int', default = 'None', required = true } +[classes.GPUBindingCommandsMixin.methods.set_immediates] +returns = { type = 'None' } +args.range_offset = { type = 'int', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_offset = { type = 'int', default = '0', required = false } +args.data_size = { type = 'int', default = 'None', required = false } + +[classes.GPUDebugCommandsMixin] +bases = [] +[classes.GPUDebugCommandsMixin.methods] +[classes.GPUDebugCommandsMixin.methods.push_debug_group] +returns = { type = 'None' } +args.group_label = { type = 'str', default = 'None', required = true } +[classes.GPUDebugCommandsMixin.methods.pop_debug_group] +returns = { type = 'None' } +[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] +returns = { type = 'None' } +args.marker_label = { type = 'str', default = 'None', required = true } + +[classes.GPUComputePassEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin'] +[classes.GPUComputePassEncoder.methods] +[classes.GPUComputePassEncoder.methods.set_pipeline] +returns = { type = 'None' } +args.pipeline = { type = 'GPUComputePipeline', default = 'None', required = true } +[classes.GPUComputePassEncoder.methods.dispatch_workgroups] +returns = { type = 'None' } +args.workgroup_count_x = { type = 'int', default = 'None', required = true } +args.workgroup_count_y = { type = 'int', default = '1', required = false } +args.workgroup_count_z = { type = 'int', default = '1', required = false } +[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } +[classes.GPUComputePassEncoder.methods.end] +returns = { type = 'None' } + +[classes.GPURenderPassEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] +[classes.GPURenderPassEncoder.methods] +[classes.GPURenderPassEncoder.methods.set_viewport] +returns = { type = 'None' } +args.x = { type = 'float', default = 'None', required = true } +args.y = { type = 'float', default = 'None', required = true } +args.width = { type = 'float', default = 'None', required = true } +args.height = { type = 'float', default = 'None', required = true } +args.min_depth = { type = 'float', default = 'None', required = true } +args.max_depth = { type = 'float', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_scissor_rect] +returns = { type = 'None' } +args.x = { type = 'int', default = 'None', required = true } +args.y = { type = 'int', default = 'None', required = true } +args.width = { type = 'int', default = 'None', required = true } +args.height = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_blend_constant] +returns = { type = 'None' } +args.color = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_stencil_reference] +returns = { type = 'None' } +args.reference = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.begin_occlusion_query] +returns = { type = 'None' } +args.query_index = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.end_occlusion_query] +returns = { type = 'None' } +[classes.GPURenderPassEncoder.methods.execute_bundles] +returns = { type = 'None' } +args.bundles = { type = 'list[GPURenderBundle]', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.end] +returns = { type = 'None' } + +[classes.GPURenderCommandsMixin] +bases = [] +[classes.GPURenderCommandsMixin.methods] +[classes.GPURenderCommandsMixin.methods.set_pipeline] +returns = { type = 'None' } +args.pipeline = { type = 'GPURenderPipeline', default = 'None', required = true } +[classes.GPURenderCommandsMixin.methods.set_index_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] +returns = { type = 'None' } +args.slot = { type = 'int', default = 'None', required = true } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPURenderCommandsMixin.methods.draw] +returns = { type = 'None' } +args.vertex_count = { type = 'int', default = 'None', required = true } +args.instance_count = { type = 'int', default = '1', required = false } +args.first_vertex = { type = 'int', default = '0', required = false } +args.first_instance = { type = 'int', default = '0', required = false } +[classes.GPURenderCommandsMixin.methods.draw_indexed] +returns = { type = 'None' } +args.index_count = { type = 'int', default = 'None', required = true } +args.instance_count = { type = 'int', default = '1', required = false } +args.first_index = { type = 'int', default = '0', required = false } +args.base_vertex = { type = 'int', default = '0', required = false } +args.first_instance = { type = 'int', default = '0', required = false } +[classes.GPURenderCommandsMixin.methods.draw_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } +[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } + +[classes.GPURenderBundle] +bases = ['GPUObjectBase'] +[classes.GPURenderBundle.methods] + +[classes.GPURenderBundleEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] +[classes.GPURenderBundleEncoder.methods] +[classes.GPURenderBundleEncoder.methods.finish] +returns = { type = 'GPURenderBundle' } +args.descriptor = { type = 'structs.RenderBundleDescriptorStruct', default = '{}', required = false } + +[classes.GPUQueue] +bases = ['GPUObjectBase'] +[classes.GPUQueue.methods] +[classes.GPUQueue.methods.submit] +returns = { type = 'None' } +args.command_buffers = { type = 'list[GPUCommandBuffer]', default = 'None', required = true } +[classes.GPUQueue.methods.on_submitted_work_done] +returns = { type = 'None' } +[classes.GPUQueue.methods.write_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.buffer_offset = { type = 'int', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUQueue.methods.write_texture] +returns = { type = 'None' } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_layout = { type = 'structs.TexelCopyBufferLayoutStruct', default = 'None', required = true } +args.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } + +[classes.GPUQuerySet] +bases = ['GPUObjectBase'] +properties.type = { type = 'enums.QueryTypeEnum' } +properties.count = { type = 'int' } +[classes.GPUQuerySet.methods] +[classes.GPUQuerySet.methods.destroy] +returns = { type = 'None' } + +[classes.GPUCanvasContext] +bases = [] +properties.canvas = { type = 'CanvasLike' } +[classes.GPUCanvasContext.methods] +[classes.GPUCanvasContext.methods.configure] +returns = { type = 'None' } +args.configuration = { type = 'structs.CanvasConfigurationStruct', default = 'None', required = true } +[classes.GPUCanvasContext.methods.unconfigure] +returns = { type = 'None' } +[classes.GPUCanvasContext.methods.get_configuration] +returns = { type = 'structs.CanvasConfigurationStruct' } +[classes.GPUCanvasContext.methods.get_current_texture] +returns = { type = 'GPUTexture' } + +[classes.GPUDeviceLostInfo] +bases = [] +properties.reason = { type = 'enums.DeviceLostReasonEnum' } +properties.message = { type = 'str' } +[classes.GPUDeviceLostInfo.methods] + +[classes.GPUError] +bases = [] +properties.message = { type = 'str' } +[classes.GPUError.methods] + +[classes.GPUValidationError] +bases = ['GPUError'] +[classes.GPUValidationError.methods] +[classes.GPUValidationError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } + +[classes.GPUOutOfMemoryError] +bases = ['GPUError'] +[classes.GPUOutOfMemoryError.methods] +[classes.GPUOutOfMemoryError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } + +[classes.GPUInternalError] +bases = ['GPUError'] +[classes.GPUInternalError.methods] +[classes.GPUInternalError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } diff --git a/apigen/definitions/wgpu_api_web.toml b/apigen/definitions/wgpu_api_web.toml new file mode 100644 index 00000000..4a33c954 --- /dev/null +++ b/apigen/definitions/wgpu_api_web.toml @@ -0,0 +1,1217 @@ +# wgpu_api_web.toml: Python-flavoured WebGPU API, generated from 'webgpu.idl'. +# All types are converted to the Python equivalents. +# All names are made Pythonic snake_case. +# Methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly. + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[flags] + +[flags.BufferUsage] +fields.MAP_READ = { value = 1 } +fields.MAP_WRITE = { value = 2 } +fields.COPY_SRC = { value = 4 } +fields.COPY_DST = { value = 8 } +fields.INDEX = { value = 16 } +fields.VERTEX = { value = 32 } +fields.UNIFORM = { value = 64 } +fields.STORAGE = { value = 128 } +fields.INDIRECT = { value = 256 } +fields.QUERY_RESOLVE = { value = 512 } + +[flags.MapMode] +fields.READ = { value = 1 } +fields.WRITE = { value = 2 } + +[flags.TextureUsage] +fields.COPY_SRC = { value = 1 } +fields.COPY_DST = { value = 2 } +fields.TEXTURE_BINDING = { value = 4 } +fields.STORAGE_BINDING = { value = 8 } +fields.RENDER_ATTACHMENT = { value = 16 } +fields.TRANSIENT_ATTACHMENT = { value = 32 } + +[flags.ShaderStage] +fields.VERTEX = { value = 1 } +fields.FRAGMENT = { value = 2 } +fields.COMPUTE = { value = 4 } + +[flags.ColorWrite] +fields.RED = { value = 1 } +fields.GREEN = { value = 2 } +fields.BLUE = { value = 4 } +fields.ALPHA = { value = 8 } +fields.ALL = { value = 15 } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[enums] + +[enums.PowerPreference] +fields.low_power = { value = 'low-power' } +fields.high_performance = { value = 'high-performance' } + +[enums.FeatureName] +fields.core_features_and_limits = { value = 'core-features-and-limits' } +fields.depth_clip_control = { value = 'depth-clip-control' } +fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } +fields.texture_compression_bc = { value = 'texture-compression-bc' } +fields.texture_compression_bc_sliced_d3 = { value = 'texture-compression-bc-sliced-3d' } +fields.texture_compression_etc2 = { value = 'texture-compression-etc2' } +fields.texture_compression_astc = { value = 'texture-compression-astc' } +fields.texture_compression_astc_sliced_d3 = { value = 'texture-compression-astc-sliced-3d' } +fields.timestamp_query = { value = 'timestamp-query' } +fields.indirect_first_instance = { value = 'indirect-first-instance' } +fields.shader_f16 = { value = 'shader-f16' } +fields.rg11b10ufloat_renderable = { value = 'rg11b10ufloat-renderable' } +fields.bgra8unorm_storage = { value = 'bgra8unorm-storage' } +fields.float32_filterable = { value = 'float32-filterable' } +fields.float32_blendable = { value = 'float32-blendable' } +fields.clip_distances = { value = 'clip-distances' } +fields.dual_source_blending = { value = 'dual-source-blending' } +fields.subgroups = { value = 'subgroups' } +fields.texture_formats_tier1 = { value = 'texture-formats-tier1' } +fields.texture_formats_tier2 = { value = 'texture-formats-tier2' } +fields.primitive_index = { value = 'primitive-index' } +fields.texture_component_swizzle = { value = 'texture-component-swizzle' } + +[enums.BufferMapState] +fields.unmapped = { value = 'unmapped' } +fields.pending = { value = 'pending' } +fields.mapped = { value = 'mapped' } + +[enums.TextureDimension] +fields.d1 = { value = '1d' } +fields.d2 = { value = '2d' } +fields.d3 = { value = '3d' } + +[enums.TextureViewDimension] +fields.d1 = { value = '1d' } +fields.d2 = { value = '2d' } +fields.d2_array = { value = '2d-array' } +fields.cube = { value = 'cube' } +fields.cube_array = { value = 'cube-array' } +fields.d3 = { value = '3d' } + +[enums.TextureAspect] +fields.all = { value = 'all' } +fields.stencil_only = { value = 'stencil-only' } +fields.depth_only = { value = 'depth-only' } + +[enums.TextureFormat] +fields.r8unorm = { value = 'r8unorm' } +fields.r8snorm = { value = 'r8snorm' } +fields.r8uint = { value = 'r8uint' } +fields.r8sint = { value = 'r8sint' } +fields.r16unorm = { value = 'r16unorm' } +fields.r16snorm = { value = 'r16snorm' } +fields.r16uint = { value = 'r16uint' } +fields.r16sint = { value = 'r16sint' } +fields.r16float = { value = 'r16float' } +fields.rg8unorm = { value = 'rg8unorm' } +fields.rg8snorm = { value = 'rg8snorm' } +fields.rg8uint = { value = 'rg8uint' } +fields.rg8sint = { value = 'rg8sint' } +fields.r32uint = { value = 'r32uint' } +fields.r32sint = { value = 'r32sint' } +fields.r32float = { value = 'r32float' } +fields.rg16unorm = { value = 'rg16unorm' } +fields.rg16snorm = { value = 'rg16snorm' } +fields.rg16uint = { value = 'rg16uint' } +fields.rg16sint = { value = 'rg16sint' } +fields.rg16float = { value = 'rg16float' } +fields.rgba8unorm = { value = 'rgba8unorm' } +fields.rgba8unorm_srgb = { value = 'rgba8unorm-srgb' } +fields.rgba8snorm = { value = 'rgba8snorm' } +fields.rgba8uint = { value = 'rgba8uint' } +fields.rgba8sint = { value = 'rgba8sint' } +fields.bgra8unorm = { value = 'bgra8unorm' } +fields.bgra8unorm_srgb = { value = 'bgra8unorm-srgb' } +fields.rgb9e5ufloat = { value = 'rgb9e5ufloat' } +fields.rgb10a2uint = { value = 'rgb10a2uint' } +fields.rgb10a2unorm = { value = 'rgb10a2unorm' } +fields.rg11b10ufloat = { value = 'rg11b10ufloat' } +fields.rg32uint = { value = 'rg32uint' } +fields.rg32sint = { value = 'rg32sint' } +fields.rg32float = { value = 'rg32float' } +fields.rgba16unorm = { value = 'rgba16unorm' } +fields.rgba16snorm = { value = 'rgba16snorm' } +fields.rgba16uint = { value = 'rgba16uint' } +fields.rgba16sint = { value = 'rgba16sint' } +fields.rgba16float = { value = 'rgba16float' } +fields.rgba32uint = { value = 'rgba32uint' } +fields.rgba32sint = { value = 'rgba32sint' } +fields.rgba32float = { value = 'rgba32float' } +fields.stencil8 = { value = 'stencil8' } +fields.depth16unorm = { value = 'depth16unorm' } +fields.depth24plus = { value = 'depth24plus' } +fields.depth24plus_stencil8 = { value = 'depth24plus-stencil8' } +fields.depth32float = { value = 'depth32float' } +fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } +fields.bc1_rgba_unorm = { value = 'bc1-rgba-unorm' } +fields.bc1_rgba_unorm_srgb = { value = 'bc1-rgba-unorm-srgb' } +fields.bc2_rgba_unorm = { value = 'bc2-rgba-unorm' } +fields.bc2_rgba_unorm_srgb = { value = 'bc2-rgba-unorm-srgb' } +fields.bc3_rgba_unorm = { value = 'bc3-rgba-unorm' } +fields.bc3_rgba_unorm_srgb = { value = 'bc3-rgba-unorm-srgb' } +fields.bc4_r_unorm = { value = 'bc4-r-unorm' } +fields.bc4_r_snorm = { value = 'bc4-r-snorm' } +fields.bc5_rg_unorm = { value = 'bc5-rg-unorm' } +fields.bc5_rg_snorm = { value = 'bc5-rg-snorm' } +fields.bc6h_rgb_ufloat = { value = 'bc6h-rgb-ufloat' } +fields.bc6h_rgb_float = { value = 'bc6h-rgb-float' } +fields.bc7_rgba_unorm = { value = 'bc7-rgba-unorm' } +fields.bc7_rgba_unorm_srgb = { value = 'bc7-rgba-unorm-srgb' } +fields.etc2_rgb8unorm = { value = 'etc2-rgb8unorm' } +fields.etc2_rgb8unorm_srgb = { value = 'etc2-rgb8unorm-srgb' } +fields.etc2_rgb8a1unorm = { value = 'etc2-rgb8a1unorm' } +fields.etc2_rgb8a1unorm_srgb = { value = 'etc2-rgb8a1unorm-srgb' } +fields.etc2_rgba8unorm = { value = 'etc2-rgba8unorm' } +fields.etc2_rgba8unorm_srgb = { value = 'etc2-rgba8unorm-srgb' } +fields.eac_r11unorm = { value = 'eac-r11unorm' } +fields.eac_r11snorm = { value = 'eac-r11snorm' } +fields.eac_rg11unorm = { value = 'eac-rg11unorm' } +fields.eac_rg11snorm = { value = 'eac-rg11snorm' } +fields.astc_4x4_unorm = { value = 'astc-4x4-unorm' } +fields.astc_4x4_unorm_srgb = { value = 'astc-4x4-unorm-srgb' } +fields.astc_5x4_unorm = { value = 'astc-5x4-unorm' } +fields.astc_5x4_unorm_srgb = { value = 'astc-5x4-unorm-srgb' } +fields.astc_5x5_unorm = { value = 'astc-5x5-unorm' } +fields.astc_5x5_unorm_srgb = { value = 'astc-5x5-unorm-srgb' } +fields.astc_6x5_unorm = { value = 'astc-6x5-unorm' } +fields.astc_6x5_unorm_srgb = { value = 'astc-6x5-unorm-srgb' } +fields.astc_6x6_unorm = { value = 'astc-6x6-unorm' } +fields.astc_6x6_unorm_srgb = { value = 'astc-6x6-unorm-srgb' } +fields.astc_8x5_unorm = { value = 'astc-8x5-unorm' } +fields.astc_8x5_unorm_srgb = { value = 'astc-8x5-unorm-srgb' } +fields.astc_8x6_unorm = { value = 'astc-8x6-unorm' } +fields.astc_8x6_unorm_srgb = { value = 'astc-8x6-unorm-srgb' } +fields.astc_8x8_unorm = { value = 'astc-8x8-unorm' } +fields.astc_8x8_unorm_srgb = { value = 'astc-8x8-unorm-srgb' } +fields.astc_10x5_unorm = { value = 'astc-10x5-unorm' } +fields.astc_10x5_unorm_srgb = { value = 'astc-10x5-unorm-srgb' } +fields.astc_10x6_unorm = { value = 'astc-10x6-unorm' } +fields.astc_10x6_unorm_srgb = { value = 'astc-10x6-unorm-srgb' } +fields.astc_10x8_unorm = { value = 'astc-10x8-unorm' } +fields.astc_10x8_unorm_srgb = { value = 'astc-10x8-unorm-srgb' } +fields.astc_10x10_unorm = { value = 'astc-10x10-unorm' } +fields.astc_10x10_unorm_srgb = { value = 'astc-10x10-unorm-srgb' } +fields.astc_12x10_unorm = { value = 'astc-12x10-unorm' } +fields.astc_12x10_unorm_srgb = { value = 'astc-12x10-unorm-srgb' } +fields.astc_12x12_unorm = { value = 'astc-12x12-unorm' } +fields.astc_12x12_unorm_srgb = { value = 'astc-12x12-unorm-srgb' } + +[enums.AddressMode] +fields.clamp_to_edge = { value = 'clamp-to-edge' } +fields.repeat = { value = 'repeat' } +fields.mirror_repeat = { value = 'mirror-repeat' } + +[enums.FilterMode] +fields.nearest = { value = 'nearest' } +fields.linear = { value = 'linear' } + +[enums.MipmapFilterMode] +fields.nearest = { value = 'nearest' } +fields.linear = { value = 'linear' } + +[enums.CompareFunction] +fields.never = { value = 'never' } +fields.less = { value = 'less' } +fields.equal = { value = 'equal' } +fields.less_equal = { value = 'less-equal' } +fields.greater = { value = 'greater' } +fields.not_equal = { value = 'not-equal' } +fields.greater_equal = { value = 'greater-equal' } +fields.always = { value = 'always' } + +[enums.BufferBindingType] +fields.uniform = { value = 'uniform' } +fields.storage = { value = 'storage' } +fields.read_only_storage = { value = 'read-only-storage' } + +[enums.SamplerBindingType] +fields.filtering = { value = 'filtering' } +fields.non_filtering = { value = 'non-filtering' } +fields.comparison = { value = 'comparison' } + +[enums.TextureSampleType] +fields.float = { value = 'float' } +fields.unfilterable_float = { value = 'unfilterable-float' } +fields.depth = { value = 'depth' } +fields.sint = { value = 'sint' } +fields.uint = { value = 'uint' } + +[enums.StorageTextureAccess] +fields.write_only = { value = 'write-only' } +fields.read_only = { value = 'read-only' } +fields.read_write = { value = 'read-write' } + +[enums.CompilationMessageType] +fields.error = { value = 'error' } +fields.warning = { value = 'warning' } +fields.info = { value = 'info' } + +[enums.PipelineErrorReason] +fields.validation = { value = 'validation' } +fields.internal = { value = 'internal' } + +[enums.AutoLayoutMode] +fields.auto = { value = 'auto' } + +[enums.PrimitiveTopology] +fields.point_list = { value = 'point-list' } +fields.line_list = { value = 'line-list' } +fields.line_strip = { value = 'line-strip' } +fields.triangle_list = { value = 'triangle-list' } +fields.triangle_strip = { value = 'triangle-strip' } + +[enums.FrontFace] +fields.ccw = { value = 'ccw' } +fields.cw = { value = 'cw' } + +[enums.CullMode] +fields.none = { value = 'none' } +fields.front = { value = 'front' } +fields.back = { value = 'back' } + +[enums.BlendFactor] +fields.zero = { value = 'zero' } +fields.one = { value = 'one' } +fields.src = { value = 'src' } +fields.one_minus_src = { value = 'one-minus-src' } +fields.src_alpha = { value = 'src-alpha' } +fields.one_minus_src_alpha = { value = 'one-minus-src-alpha' } +fields.dst = { value = 'dst' } +fields.one_minus_dst = { value = 'one-minus-dst' } +fields.dst_alpha = { value = 'dst-alpha' } +fields.one_minus_dst_alpha = { value = 'one-minus-dst-alpha' } +fields.src_alpha_saturated = { value = 'src-alpha-saturated' } +fields.constant = { value = 'constant' } +fields.one_minus_constant = { value = 'one-minus-constant' } +fields.src1 = { value = 'src1' } +fields.one_minus_src1 = { value = 'one-minus-src1' } +fields.src1_alpha = { value = 'src1-alpha' } +fields.one_minus_src1_alpha = { value = 'one-minus-src1-alpha' } + +[enums.BlendOperation] +fields.add = { value = 'add' } +fields.subtract = { value = 'subtract' } +fields.reverse_subtract = { value = 'reverse-subtract' } +fields.min = { value = 'min' } +fields.max = { value = 'max' } + +[enums.StencilOperation] +fields.keep = { value = 'keep' } +fields.zero = { value = 'zero' } +fields.replace = { value = 'replace' } +fields.invert = { value = 'invert' } +fields.increment_clamp = { value = 'increment-clamp' } +fields.decrement_clamp = { value = 'decrement-clamp' } +fields.increment_wrap = { value = 'increment-wrap' } +fields.decrement_wrap = { value = 'decrement-wrap' } + +[enums.IndexFormat] +fields.uint16 = { value = 'uint16' } +fields.uint32 = { value = 'uint32' } + +[enums.VertexFormat] +fields.uint8 = { value = 'uint8' } +fields.uint8x2 = { value = 'uint8x2' } +fields.uint8x4 = { value = 'uint8x4' } +fields.sint8 = { value = 'sint8' } +fields.sint8x2 = { value = 'sint8x2' } +fields.sint8x4 = { value = 'sint8x4' } +fields.unorm8 = { value = 'unorm8' } +fields.unorm8x2 = { value = 'unorm8x2' } +fields.unorm8x4 = { value = 'unorm8x4' } +fields.snorm8 = { value = 'snorm8' } +fields.snorm8x2 = { value = 'snorm8x2' } +fields.snorm8x4 = { value = 'snorm8x4' } +fields.uint16 = { value = 'uint16' } +fields.uint16x2 = { value = 'uint16x2' } +fields.uint16x4 = { value = 'uint16x4' } +fields.sint16 = { value = 'sint16' } +fields.sint16x2 = { value = 'sint16x2' } +fields.sint16x4 = { value = 'sint16x4' } +fields.unorm16 = { value = 'unorm16' } +fields.unorm16x2 = { value = 'unorm16x2' } +fields.unorm16x4 = { value = 'unorm16x4' } +fields.snorm16 = { value = 'snorm16' } +fields.snorm16x2 = { value = 'snorm16x2' } +fields.snorm16x4 = { value = 'snorm16x4' } +fields.float16 = { value = 'float16' } +fields.float16x2 = { value = 'float16x2' } +fields.float16x4 = { value = 'float16x4' } +fields.float32 = { value = 'float32' } +fields.float32x2 = { value = 'float32x2' } +fields.float32x3 = { value = 'float32x3' } +fields.float32x4 = { value = 'float32x4' } +fields.uint32 = { value = 'uint32' } +fields.uint32x2 = { value = 'uint32x2' } +fields.uint32x3 = { value = 'uint32x3' } +fields.uint32x4 = { value = 'uint32x4' } +fields.sint32 = { value = 'sint32' } +fields.sint32x2 = { value = 'sint32x2' } +fields.sint32x3 = { value = 'sint32x3' } +fields.sint32x4 = { value = 'sint32x4' } +fields.unorm10_10_10_2 = { value = 'unorm10-10-10-2' } +fields.unorm8x4_bgra = { value = 'unorm8x4-bgra' } + +[enums.VertexStepMode] +fields.vertex = { value = 'vertex' } +fields.instance = { value = 'instance' } + +[enums.LoadOp] +fields.load = { value = 'load' } +fields.clear = { value = 'clear' } + +[enums.StoreOp] +fields.store = { value = 'store' } +fields.discard = { value = 'discard' } + +[enums.QueryType] +fields.occlusion = { value = 'occlusion' } +fields.timestamp = { value = 'timestamp' } + +[enums.CanvasAlphaMode] +fields.opaque = { value = 'opaque' } +fields.premultiplied = { value = 'premultiplied' } + +[enums.CanvasToneMappingMode] +fields.standard = { value = 'standard' } +fields.extended = { value = 'extended' } + +[enums.DeviceLostReason] +fields.unknown = { value = 'unknown' } +fields.destroyed = { value = 'destroyed' } + +[enums.ErrorFilter] +fields.validation = { value = 'validation' } +fields.out_of_memory = { value = 'out-of-memory' } +fields.internal = { value = 'internal' } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[structs] + +[structs.RequestAdapterOptions] +fields.feature_level = { type = 'str', default = '"core"', required = false } +fields.power_preference = { type = 'enums.PowerPreferenceEnum', default = 'None', required = false } +fields.force_fallback_adapter = { type = 'bool', default = 'False', required = false } +fields.xr_compatible = { type = 'bool', default = 'False', required = false } + +[structs.DeviceDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.required_features = { type = 'list[enums.FeatureNameEnum]', default = '[]', required = false } +fields.required_limits = { type = 'dict[str, int | None]', default = '{}', required = false } +fields.default_queue = { type = 'structs.QueueDescriptorStruct', default = '{}', required = false } + +[structs.BufferDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.size = { type = 'int', default = 'None', required = true } +fields.usage = { type = 'flags.BufferUsageFlags', default = 'None', required = true } +fields.mapped_at_creation = { type = 'bool', default = 'False', required = false } + +[structs.TextureDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +fields.mip_level_count = { type = 'int', default = '1', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } +fields.dimension = { type = 'enums.TextureDimensionEnum', default = '"2d"', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.usage = { type = 'flags.TextureUsageFlags', default = 'None', required = true } +fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } +fields.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } + +[structs.TextureViewDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } +fields.usage = { type = 'flags.TextureUsageFlags', default = '0', required = false } +fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } +fields.base_mip_level = { type = 'int', default = '0', required = false } +fields.mip_level_count = { type = 'int', default = 'None', required = false } +fields.base_array_layer = { type = 'int', default = '0', required = false } +fields.array_layer_count = { type = 'int', default = 'None', required = false } +fields.swizzle = { type = 'str', default = '"rgba"', required = false } + +[structs.ExternalTextureDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.source = { type = 'ArrayLike | object', default = 'None', required = true } +fields.color_space = { type = 'str', default = '"srgb"', required = false } + +[structs.SamplerDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.address_mode_u = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.address_mode_v = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.address_mode_w = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } +fields.mag_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } +fields.min_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } +fields.mipmap_filter = { type = 'enums.MipmapFilterModeEnum', default = '"nearest"', required = false } +fields.lod_min_clamp = { type = 'float', default = '0', required = false } +fields.lod_max_clamp = { type = 'float', default = '32', required = false } +fields.compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } +fields.max_anisotropy = { type = 'int', default = '1', required = false } + +[structs.BindGroupLayoutDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.entries = { type = 'list[structs.BindGroupLayoutEntryStruct]', default = 'None', required = true } + +[structs.BindGroupLayoutEntry] +fields.binding = { type = 'int', default = 'None', required = true } +fields.visibility = { type = 'flags.ShaderStageFlags', default = 'None', required = true } +fields.buffer = { type = 'structs.BufferBindingLayoutStruct', default = 'None', required = false } +fields.sampler = { type = 'structs.SamplerBindingLayoutStruct', default = 'None', required = false } +fields.texture = { type = 'structs.TextureBindingLayoutStruct', default = 'None', required = false } +fields.storage_texture = { type = 'structs.StorageTextureBindingLayoutStruct', default = 'None', required = false } +fields.external_texture = { type = 'structs.ExternalTextureBindingLayoutStruct', default = 'None', required = false } + +[structs.BufferBindingLayout] +fields.type = { type = 'enums.BufferBindingTypeEnum', default = '"uniform"', required = false } +fields.has_dynamic_offset = { type = 'bool', default = 'False', required = false } +fields.min_binding_size = { type = 'int', default = '0', required = false } + +[structs.SamplerBindingLayout] +fields.type = { type = 'enums.SamplerBindingTypeEnum', default = '"filtering"', required = false } + +[structs.TextureBindingLayout] +fields.sample_type = { type = 'enums.TextureSampleTypeEnum', default = '"float"', required = false } +fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } +fields.multisampled = { type = 'bool', default = 'False', required = false } + +[structs.StorageTextureBindingLayout] +fields.access = { type = 'enums.StorageTextureAccessEnum', default = '"write-only"', required = false } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } + +[structs.ExternalTextureBindingLayout] + +[structs.BindGroupDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUBindGroupLayout', default = 'None', required = true } +fields.entries = { type = 'list[structs.BindGroupEntryStruct]', default = 'None', required = true } + +[structs.BindGroupEntry] +fields.binding = { type = 'int', default = 'None', required = true } +fields.resource = { type = 'GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct', default = 'None', required = true } + +[structs.BufferBinding] +fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } +fields.offset = { type = 'int', default = '0', required = false } +fields.size = { type = 'int', default = 'None', required = false } + +[structs.PipelineLayoutDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.bind_group_layouts = { type = 'list[GPUBindGroupLayout]', default = 'None', required = true } +fields.immediate_size = { type = 'int', default = '0', required = false } + +[structs.ShaderModuleDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.code = { type = 'str', default = 'None', required = true } +fields.compilation_hints = { type = 'list[structs.ShaderModuleCompilationHintStruct]', default = '[]', required = false } + +[structs.ShaderModuleCompilationHint] +fields.entry_point = { type = 'str', default = 'None', required = true } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = false } + +[structs.PipelineErrorInit] +fields.reason = { type = 'enums.PipelineErrorReasonEnum', default = 'None', required = true } + +[structs.ProgrammableStage] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } + +[structs.ComputePipelineDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } +fields.compute = { type = 'structs.ProgrammableStageStruct', default = 'None', required = true } + +[structs.RenderPipelineDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } +fields.vertex = { type = 'structs.VertexStateStruct', default = 'None', required = true } +fields.primitive = { type = 'structs.PrimitiveStateStruct', default = '{}', required = false } +fields.depth_stencil = { type = 'structs.DepthStencilStateStruct', default = 'None', required = false } +fields.multisample = { type = 'structs.MultisampleStateStruct', default = '{}', required = false } +fields.fragment = { type = 'structs.FragmentStateStruct', default = 'None', required = false } + +[structs.PrimitiveState] +fields.topology = { type = 'enums.PrimitiveTopologyEnum', default = '"triangle-list"', required = false } +fields.strip_index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = false } +fields.front_face = { type = 'enums.FrontFaceEnum', default = '"ccw"', required = false } +fields.cull_mode = { type = 'enums.CullModeEnum', default = '"none"', required = false } +fields.unclipped_depth = { type = 'bool', default = 'False', required = false } + +[structs.MultisampleState] +fields.count = { type = 'int', default = '1', required = false } +fields.mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.alpha_to_coverage_enabled = { type = 'bool', default = 'False', required = false } + +[structs.FragmentState] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } +fields.targets = { type = 'list[structs.ColorTargetStateStruct]', default = 'None', required = true } + +[structs.ColorTargetState] +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.blend = { type = 'structs.BlendStateStruct', default = 'None', required = false } +fields.write_mask = { type = 'flags.ColorWriteFlags', default = '0xF', required = false } + +[structs.BlendState] +fields.color = { type = 'structs.BlendComponentStruct', default = 'None', required = true } +fields.alpha = { type = 'structs.BlendComponentStruct', default = 'None', required = true } + +[structs.BlendComponent] +fields.operation = { type = 'enums.BlendOperationEnum', default = '"add"', required = false } +fields.src_factor = { type = 'enums.BlendFactorEnum', default = '"one"', required = false } +fields.dst_factor = { type = 'enums.BlendFactorEnum', default = '"zero"', required = false } + +[structs.DepthStencilState] +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.depth_write_enabled = { type = 'bool', default = 'None', required = false } +fields.depth_compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } +fields.stencil_front = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } +fields.stencil_back = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } +fields.stencil_read_mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.stencil_write_mask = { type = 'int', default = '0xFFFFFFFF', required = false } +fields.depth_bias = { type = 'int', default = '0', required = false } +fields.depth_bias_slope_scale = { type = 'float', default = '0', required = false } +fields.depth_bias_clamp = { type = 'float', default = '0', required = false } + +[structs.StencilFaceState] +fields.compare = { type = 'enums.CompareFunctionEnum', default = '"always"', required = false } +fields.fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } +fields.depth_fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } +fields.pass_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } + +[structs.VertexState] +fields.module = { type = 'GPUShaderModule', default = 'None', required = true } +fields.entry_point = { type = 'str', default = 'None', required = false } +fields.constants = { type = 'dict[str, float]', default = '{}', required = false } +fields.buffers = { type = 'list[structs.VertexBufferLayoutStruct]', default = '[]', required = false } + +[structs.VertexBufferLayout] +fields.array_stride = { type = 'int', default = 'None', required = true } +fields.step_mode = { type = 'enums.VertexStepModeEnum', default = '"vertex"', required = false } +fields.attributes = { type = 'list[structs.VertexAttributeStruct]', default = 'None', required = true } + +[structs.VertexAttribute] +fields.format = { type = 'enums.VertexFormatEnum', default = 'None', required = true } +fields.offset = { type = 'int', default = 'None', required = true } +fields.shader_location = { type = 'int', default = 'None', required = true } + +[structs.TexelCopyBufferLayout] +fields.offset = { type = 'int', default = '0', required = false } +fields.bytes_per_row = { type = 'int', default = 'None', required = false } +fields.rows_per_image = { type = 'int', default = 'None', required = false } + +[structs.TexelCopyBufferInfo] +fields.offset = { type = 'int', default = '0', required = false } +fields.bytes_per_row = { type = 'int', default = 'None', required = false } +fields.rows_per_image = { type = 'int', default = 'None', required = false } +fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } + +[structs.TexelCopyTextureInfo] +fields.texture = { type = 'GPUTexture', default = 'None', required = true } +fields.mip_level = { type = 'int', default = '0', required = false } +fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } +fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } + +[structs.CopyExternalImageDestInfo] +fields.texture = { type = 'GPUTexture', default = 'None', required = true } +fields.mip_level = { type = 'int', default = '0', required = false } +fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } +fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } +fields.color_space = { type = 'str', default = '"srgb"', required = false } +fields.premultiplied_alpha = { type = 'bool', default = 'False', required = false } + +[structs.CopyExternalImageSourceInfo] +fields.source = { type = 'ArrayLike | CanvasLike | object', default = 'None', required = true } +fields.origin = { type = 'tuple[int, int] | structs.Origin2DStruct', default = '{}', required = false } +fields.flip_y = { type = 'bool', default = 'False', required = false } + +[structs.CommandBufferDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.CommandEncoderDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.ComputePassTimestampWrites] +fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } +fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } + +[structs.ComputePassDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.timestamp_writes = { type = 'structs.ComputePassTimestampWritesStruct', default = 'None', required = false } + +[structs.RenderPassTimestampWrites] +fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } +fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } + +[structs.RenderPassDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.color_attachments = { type = 'list[structs.RenderPassColorAttachmentStruct]', default = 'None', required = true } +fields.depth_stencil_attachment = { type = 'structs.RenderPassDepthStencilAttachmentStruct', default = 'None', required = false } +fields.occlusion_query_set = { type = 'GPUQuerySet', default = 'None', required = false } +fields.timestamp_writes = { type = 'structs.RenderPassTimestampWritesStruct', default = 'None', required = false } +fields.max_draw_count = { type = 'int', default = '50000000', required = false } + +[structs.RenderPassColorAttachment] +fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } +fields.depth_slice = { type = 'int', default = 'None', required = false } +fields.resolve_target = { type = 'GPUTexture | GPUTextureView', default = 'None', required = false } +fields.clear_value = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = false } +fields.load_op = { type = 'enums.LoadOpEnum', default = 'None', required = true } +fields.store_op = { type = 'enums.StoreOpEnum', default = 'None', required = true } + +[structs.RenderPassDepthStencilAttachment] +fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } +fields.depth_clear_value = { type = 'float', default = 'None', required = false } +fields.depth_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } +fields.depth_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } +fields.depth_read_only = { type = 'bool', default = 'False', required = false } +fields.stencil_clear_value = { type = 'int', default = '0', required = false } +fields.stencil_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } +fields.stencil_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } +fields.stencil_read_only = { type = 'bool', default = 'False', required = false } + +[structs.RenderPassLayout] +fields.label = { type = 'str', default = '""', required = false } +fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } +fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } + +[structs.RenderBundleDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.RenderBundleEncoderDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } +fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } +fields.sample_count = { type = 'int', default = '1', required = false } +fields.depth_read_only = { type = 'bool', default = 'False', required = false } +fields.stencil_read_only = { type = 'bool', default = 'False', required = false } + +[structs.QueueDescriptor] +fields.label = { type = 'str', default = '""', required = false } + +[structs.QuerySetDescriptor] +fields.label = { type = 'str', default = '""', required = false } +fields.type = { type = 'enums.QueryTypeEnum', default = 'None', required = true } +fields.count = { type = 'int', default = 'None', required = true } + +[structs.CanvasToneMapping] +fields.mode = { type = 'enums.CanvasToneMappingModeEnum', default = '"standard"', required = false } + +[structs.CanvasConfiguration] +fields.device = { type = 'GPUDevice', default = 'None', required = true } +fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } +fields.usage = { type = 'flags.TextureUsageFlags', default = '0x10', required = false } +fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } +fields.color_space = { type = 'str', default = '"srgb"', required = false } +fields.tone_mapping = { type = 'structs.CanvasToneMappingStruct', default = '{}', required = false } +fields.alpha_mode = { type = 'enums.CanvasAlphaModeEnum', default = '"opaque"', required = false } + +[structs.UncapturedErrorEventInit] +fields.error = { type = 'GPUError', default = 'None', required = true } + +[structs.Color] +fields.r = { type = 'float', default = 'None', required = true } +fields.g = { type = 'float', default = 'None', required = true } +fields.b = { type = 'float', default = 'None', required = true } +fields.a = { type = 'float', default = 'None', required = true } + +[structs.Origin2D] +fields.x = { type = 'int', default = '0', required = false } +fields.y = { type = 'int', default = '0', required = false } + +[structs.Origin3D] +fields.x = { type = 'int', default = '0', required = false } +fields.y = { type = 'int', default = '0', required = false } +fields.z = { type = 'int', default = '0', required = false } + +[structs.Extent3D] +fields.width = { type = 'int', default = 'None', required = true } +fields.height = { type = 'int', default = '1', required = false } +fields.depth_or_array_layers = { type = 'int', default = '1', required = false } + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[classes] + +[classes.GPUObjectBase] +bases = [] +properties.label = { type = 'str' } +[classes.GPUObjectBase.methods] + +[classes.GPUAdapterInfo] +bases = [] +properties.vendor = { type = 'str' } +properties.architecture = { type = 'str' } +properties.device = { type = 'str' } +properties.description = { type = 'str' } +properties.subgroup_min_size = { type = 'int' } +properties.subgroup_max_size = { type = 'int' } +properties.is_fallback_adapter = { type = 'bool' } +[classes.GPUAdapterInfo.methods] + +[classes.GPU] +bases = [] +properties.wgsl_language_features = { type = 'set' } +[classes.GPU.methods] +[classes.GPU.methods.request_adapter] +returns = { type = 'GPUAdapter' } +args.options = { type = 'structs.RequestAdapterOptionsStruct', default = '{}', required = false } +[classes.GPU.methods.get_preferred_canvas_format] +returns = { type = 'enums.TextureFormatEnum' } + +[classes.GPUAdapter] +bases = [] +properties.features = { type = 'set' } +properties.limits = { type = 'dict' } +properties.info = { type = 'GPUAdapterInfo' } +[classes.GPUAdapter.methods] +[classes.GPUAdapter.methods.request_device] +returns = { type = 'GPUDevice' } +args.descriptor = { type = 'structs.DeviceDescriptorStruct', default = '{}', required = false } + +[classes.GPUDevice] +bases = ['EventTarget', 'GPUObjectBase'] +properties.features = { type = 'set' } +properties.limits = { type = 'dict' } +properties.adapter_info = { type = 'GPUAdapterInfo' } +properties.queue = { type = 'GPUQueue' } +properties.lost = { type = 'GPUDeviceLostInfo' } +properties.onuncapturederror = { type = 'None' } +[classes.GPUDevice.methods] +[classes.GPUDevice.methods.destroy] +returns = { type = 'None' } +[classes.GPUDevice.methods.create_buffer] +returns = { type = 'GPUBuffer' } +args.descriptor = { type = 'structs.BufferDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_texture] +returns = { type = 'GPUTexture' } +args.descriptor = { type = 'structs.TextureDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_sampler] +returns = { type = 'GPUSampler' } +args.descriptor = { type = 'structs.SamplerDescriptorStruct', default = '{}', required = false } +[classes.GPUDevice.methods.import_external_texture] +returns = { type = 'object' } +args.descriptor = { type = 'structs.ExternalTextureDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_bind_group_layout] +returns = { type = 'GPUBindGroupLayout' } +args.descriptor = { type = 'structs.BindGroupLayoutDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_pipeline_layout] +returns = { type = 'GPUPipelineLayout' } +args.descriptor = { type = 'structs.PipelineLayoutDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_bind_group] +returns = { type = 'GPUBindGroup' } +args.descriptor = { type = 'structs.BindGroupDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_shader_module] +returns = { type = 'GPUShaderModule' } +args.descriptor = { type = 'structs.ShaderModuleDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_compute_pipeline] +returns = { type = 'GPUComputePipeline' } +args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_render_pipeline] +returns = { type = 'GPURenderPipeline' } +args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_compute_pipeline_async] +returns = { type = 'GPUPromise[GPUComputePipeline]' } +args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_render_pipeline_async] +returns = { type = 'GPUPromise[GPURenderPipeline]' } +args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_command_encoder] +returns = { type = 'GPUCommandEncoder' } +args.descriptor = { type = 'structs.CommandEncoderDescriptorStruct', default = '{}', required = false } +[classes.GPUDevice.methods.create_render_bundle_encoder] +returns = { type = 'GPURenderBundleEncoder' } +args.descriptor = { type = 'structs.RenderBundleEncoderDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.create_query_set] +returns = { type = 'GPUQuerySet' } +args.descriptor = { type = 'structs.QuerySetDescriptorStruct', default = 'None', required = true } +[classes.GPUDevice.methods.push_error_scope] +returns = { type = 'None' } +args.filter = { type = 'enums.ErrorFilterEnum', default = 'None', required = true } +[classes.GPUDevice.methods.pop_error_scope] +returns = { type = 'GPUError' } + +[classes.GPUBuffer] +bases = ['GPUObjectBase'] +properties.size = { type = 'int' } +properties.usage = { type = 'int' } +properties.map_state = { type = 'enums.BufferMapStateEnum' } +[classes.GPUBuffer.methods] +[classes.GPUBuffer.methods.map_async] +returns = { type = 'GPUPromise[None]' } +args.mode = { type = 'flags.MapModeFlags', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUBuffer.methods.get_mapped_range] +returns = { type = 'ArrayLike' } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUBuffer.methods.unmap] +returns = { type = 'None' } +[classes.GPUBuffer.methods.destroy] +returns = { type = 'None' } + +[classes.GPUTexture] +bases = ['GPUObjectBase'] +properties.width = { type = 'int' } +properties.height = { type = 'int' } +properties.depth_or_array_layers = { type = 'int' } +properties.mip_level_count = { type = 'int' } +properties.sample_count = { type = 'int' } +properties.dimension = { type = 'enums.TextureDimensionEnum' } +properties.format = { type = 'enums.TextureFormatEnum' } +properties.usage = { type = 'int' } +properties.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum | None' } +[classes.GPUTexture.methods] +[classes.GPUTexture.methods.create_view] +returns = { type = 'GPUTextureView' } +args.descriptor = { type = 'structs.TextureViewDescriptorStruct', default = '{}', required = false } +[classes.GPUTexture.methods.destroy] +returns = { type = 'None' } + +[classes.GPUTextureView] +bases = ['GPUObjectBase'] +[classes.GPUTextureView.methods] + +[classes.GPUSampler] +bases = ['GPUObjectBase'] +[classes.GPUSampler.methods] + +[classes.GPUBindGroupLayout] +bases = ['GPUObjectBase'] +[classes.GPUBindGroupLayout.methods] + +[classes.GPUBindGroup] +bases = ['GPUObjectBase'] +[classes.GPUBindGroup.methods] + +[classes.GPUPipelineLayout] +bases = ['GPUObjectBase'] +[classes.GPUPipelineLayout.methods] + +[classes.GPUShaderModule] +bases = ['GPUObjectBase'] +[classes.GPUShaderModule.methods] +[classes.GPUShaderModule.methods.get_compilation_info] +returns = { type = 'GPUCompilationInfo' } + +[classes.GPUCompilationMessage] +bases = [] +properties.message = { type = 'str' } +properties.type = { type = 'enums.CompilationMessageTypeEnum' } +properties.line_num = { type = 'int' } +properties.line_pos = { type = 'int' } +properties.offset = { type = 'int' } +properties.length = { type = 'int' } +[classes.GPUCompilationMessage.methods] + +[classes.GPUCompilationInfo] +bases = [] +properties.messages = { type = 'list[GPUCompilationMessage]' } +[classes.GPUCompilationInfo.methods] + +[classes.GPUPipelineError] +bases = ['DOMException'] +properties.reason = { type = 'enums.PipelineErrorReasonEnum' } +[classes.GPUPipelineError.methods] +[classes.GPUPipelineError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = '""', required = false } +args.options = { type = 'structs.PipelineErrorInitStruct', default = 'None', required = true } + +[classes.GPUPipelineBase] +bases = [] +[classes.GPUPipelineBase.methods] +[classes.GPUPipelineBase.methods.get_bind_group_layout] +returns = { type = 'GPUBindGroupLayout' } +args.index = { type = 'int', default = 'None', required = true } + +[classes.GPUComputePipeline] +bases = ['GPUObjectBase', 'GPUPipelineBase'] +[classes.GPUComputePipeline.methods] + +[classes.GPURenderPipeline] +bases = ['GPUObjectBase', 'GPUPipelineBase'] +[classes.GPURenderPipeline.methods] + +[classes.GPUCommandBuffer] +bases = ['GPUObjectBase'] +[classes.GPUCommandBuffer.methods] + +[classes.GPUCommandsMixin] +bases = [] +[classes.GPUCommandsMixin.methods] + +[classes.GPUCommandEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin'] +[classes.GPUCommandEncoder.methods] +[classes.GPUCommandEncoder.methods.begin_render_pass] +returns = { type = 'GPURenderPassEncoder' } +args.descriptor = { type = 'structs.RenderPassDescriptorStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.begin_compute_pass] +returns = { type = 'GPUComputePassEncoder' } +args.descriptor = { type = 'structs.ComputePassDescriptorStruct', default = '{}', required = false } +[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] +returns = { type = 'None' } +args.source = { type = 'GPUBuffer', default = 'None', required = true } +args.source_offset = { type = 'int', default = 'None', required = true } +args.destination = { type = 'GPUBuffer', default = 'None', required = true } +args.destination_offset = { type = 'int', default = 'None', required = true } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.copy_texture_to_texture] +returns = { type = 'None' } +args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.clear_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUCommandEncoder.methods.resolve_query_set] +returns = { type = 'None' } +args.query_set = { type = 'GPUQuerySet', default = 'None', required = true } +args.first_query = { type = 'int', default = 'None', required = true } +args.query_count = { type = 'int', default = 'None', required = true } +args.destination = { type = 'GPUBuffer', default = 'None', required = true } +args.destination_offset = { type = 'int', default = 'None', required = true } +[classes.GPUCommandEncoder.methods.finish] +returns = { type = 'GPUCommandBuffer' } +args.descriptor = { type = 'structs.CommandBufferDescriptorStruct', default = '{}', required = false } + +[classes.GPUBindingCommandsMixin] +bases = [] +[classes.GPUBindingCommandsMixin.methods] +[classes.GPUBindingCommandsMixin.methods.set_bind_group] +returns = { type = 'None' } +args.index = { type = 'int', default = 'None', required = true } +args.bind_group = { type = 'GPUBindGroup', default = 'None', required = true } +args.dynamic_offsets_data = { type = 'ArrayLike', default = 'None', required = true } +args.dynamic_offsets_data_start = { type = 'int', default = 'None', required = true } +args.dynamic_offsets_data_length = { type = 'int', default = 'None', required = true } +[classes.GPUBindingCommandsMixin.methods.set_immediates] +returns = { type = 'None' } +args.range_offset = { type = 'int', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_offset = { type = 'int', default = '0', required = false } +args.data_size = { type = 'int', default = 'None', required = false } + +[classes.GPUDebugCommandsMixin] +bases = [] +[classes.GPUDebugCommandsMixin.methods] +[classes.GPUDebugCommandsMixin.methods.push_debug_group] +returns = { type = 'None' } +args.group_label = { type = 'str', default = 'None', required = true } +[classes.GPUDebugCommandsMixin.methods.pop_debug_group] +returns = { type = 'None' } +[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] +returns = { type = 'None' } +args.marker_label = { type = 'str', default = 'None', required = true } + +[classes.GPUComputePassEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin'] +[classes.GPUComputePassEncoder.methods] +[classes.GPUComputePassEncoder.methods.set_pipeline] +returns = { type = 'None' } +args.pipeline = { type = 'GPUComputePipeline', default = 'None', required = true } +[classes.GPUComputePassEncoder.methods.dispatch_workgroups] +returns = { type = 'None' } +args.workgroup_count_x = { type = 'int', default = 'None', required = true } +args.workgroup_count_y = { type = 'int', default = '1', required = false } +args.workgroup_count_z = { type = 'int', default = '1', required = false } +[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } +[classes.GPUComputePassEncoder.methods.end] +returns = { type = 'None' } + +[classes.GPURenderPassEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] +[classes.GPURenderPassEncoder.methods] +[classes.GPURenderPassEncoder.methods.set_viewport] +returns = { type = 'None' } +args.x = { type = 'float', default = 'None', required = true } +args.y = { type = 'float', default = 'None', required = true } +args.width = { type = 'float', default = 'None', required = true } +args.height = { type = 'float', default = 'None', required = true } +args.min_depth = { type = 'float', default = 'None', required = true } +args.max_depth = { type = 'float', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_scissor_rect] +returns = { type = 'None' } +args.x = { type = 'int', default = 'None', required = true } +args.y = { type = 'int', default = 'None', required = true } +args.width = { type = 'int', default = 'None', required = true } +args.height = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_blend_constant] +returns = { type = 'None' } +args.color = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.set_stencil_reference] +returns = { type = 'None' } +args.reference = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.begin_occlusion_query] +returns = { type = 'None' } +args.query_index = { type = 'int', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.end_occlusion_query] +returns = { type = 'None' } +[classes.GPURenderPassEncoder.methods.execute_bundles] +returns = { type = 'None' } +args.bundles = { type = 'list[GPURenderBundle]', default = 'None', required = true } +[classes.GPURenderPassEncoder.methods.end] +returns = { type = 'None' } + +[classes.GPURenderCommandsMixin] +bases = [] +[classes.GPURenderCommandsMixin.methods] +[classes.GPURenderCommandsMixin.methods.set_pipeline] +returns = { type = 'None' } +args.pipeline = { type = 'GPURenderPipeline', default = 'None', required = true } +[classes.GPURenderCommandsMixin.methods.set_index_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] +returns = { type = 'None' } +args.slot = { type = 'int', default = 'None', required = true } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPURenderCommandsMixin.methods.draw] +returns = { type = 'None' } +args.vertex_count = { type = 'int', default = 'None', required = true } +args.instance_count = { type = 'int', default = '1', required = false } +args.first_vertex = { type = 'int', default = '0', required = false } +args.first_instance = { type = 'int', default = '0', required = false } +[classes.GPURenderCommandsMixin.methods.draw_indexed] +returns = { type = 'None' } +args.index_count = { type = 'int', default = 'None', required = true } +args.instance_count = { type = 'int', default = '1', required = false } +args.first_index = { type = 'int', default = '0', required = false } +args.base_vertex = { type = 'int', default = '0', required = false } +args.first_instance = { type = 'int', default = '0', required = false } +[classes.GPURenderCommandsMixin.methods.draw_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } +[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] +returns = { type = 'None' } +args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.indirect_offset = { type = 'int', default = 'None', required = true } + +[classes.GPURenderBundle] +bases = ['GPUObjectBase'] +[classes.GPURenderBundle.methods] + +[classes.GPURenderBundleEncoder] +bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] +[classes.GPURenderBundleEncoder.methods] +[classes.GPURenderBundleEncoder.methods.finish] +returns = { type = 'GPURenderBundle' } +args.descriptor = { type = 'structs.RenderBundleDescriptorStruct', default = '{}', required = false } + +[classes.GPUQueue] +bases = ['GPUObjectBase'] +[classes.GPUQueue.methods] +[classes.GPUQueue.methods.submit] +returns = { type = 'None' } +args.command_buffers = { type = 'list[GPUCommandBuffer]', default = 'None', required = true } +[classes.GPUQueue.methods.on_submitted_work_done] +returns = { type = 'None' } +[classes.GPUQueue.methods.write_buffer] +returns = { type = 'None' } +args.buffer = { type = 'GPUBuffer', default = 'None', required = true } +args.buffer_offset = { type = 'int', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_offset = { type = 'int', default = '0', required = false } +args.size = { type = 'int', default = 'None', required = false } +[classes.GPUQueue.methods.write_texture] +returns = { type = 'None' } +args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } +args.data = { type = 'ArrayLike', default = 'None', required = true } +args.data_layout = { type = 'structs.TexelCopyBufferLayoutStruct', default = 'None', required = true } +args.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } +[classes.GPUQueue.methods.copy_external_image_to_texture] +returns = { type = 'None' } +args.source = { type = 'structs.CopyExternalImageSourceInfoStruct', default = 'None', required = true } +args.destination = { type = 'structs.CopyExternalImageDestInfoStruct', default = 'None', required = true } +args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } + +[classes.GPUQuerySet] +bases = ['GPUObjectBase'] +properties.type = { type = 'enums.QueryTypeEnum' } +properties.count = { type = 'int' } +[classes.GPUQuerySet.methods] +[classes.GPUQuerySet.methods.destroy] +returns = { type = 'None' } + +[classes.GPUCanvasContext] +bases = [] +properties.canvas = { type = 'CanvasLike' } +[classes.GPUCanvasContext.methods] +[classes.GPUCanvasContext.methods.configure] +returns = { type = 'None' } +args.configuration = { type = 'structs.CanvasConfigurationStruct', default = 'None', required = true } +[classes.GPUCanvasContext.methods.unconfigure] +returns = { type = 'None' } +[classes.GPUCanvasContext.methods.get_configuration] +returns = { type = 'structs.CanvasConfigurationStruct' } +[classes.GPUCanvasContext.methods.get_current_texture] +returns = { type = 'GPUTexture' } + +[classes.GPUDeviceLostInfo] +bases = [] +properties.reason = { type = 'enums.DeviceLostReasonEnum' } +properties.message = { type = 'str' } +[classes.GPUDeviceLostInfo.methods] + +[classes.GPUError] +bases = [] +properties.message = { type = 'str' } +[classes.GPUError.methods] + +[classes.GPUValidationError] +bases = ['GPUError'] +[classes.GPUValidationError.methods] +[classes.GPUValidationError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } + +[classes.GPUOutOfMemoryError] +bases = ['GPUError'] +[classes.GPUOutOfMemoryError.methods] +[classes.GPUOutOfMemoryError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } + +[classes.GPUInternalError] +bases = ['GPUError'] +[classes.GPUInternalError.methods] +[classes.GPUInternalError.methods.constructor] +returns = { type = 'None' } +args.message = { type = 'str', default = 'None', required = true } diff --git a/apigen/definitions/wgpu_docs.toml b/apigen/definitions/wgpu_docs.toml new file mode 100644 index 00000000..e78b1ba4 --- /dev/null +++ b/apigen/definitions/wgpu_docs.toml @@ -0,0 +1,2413 @@ +# wgpu_docs.toml +# Documentation for the wgpu-py API, composed from 'docs_ai.toml', 'docs_ts.toml', and 'docs_dev.toml' + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[flags] + +[flags.BufferUsage] +doc = """Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator. + +The usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards. +Using a buffer in a way that was not declared here results in a validation error. +""" +fields.MAP_READ.doc = """The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST.""" +fields.MAP_WRITE.doc = """The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC.""" +fields.COPY_SRC.doc = """The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer().""" +fields.COPY_DST.doc = """The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer().""" +fields.INDEX.doc = """The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer().""" +fields.VERTEX.doc = """The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer().""" +fields.UNIFORM.doc = """The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform.""" +fields.STORAGE.doc = """The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage.""" +fields.INDIRECT.doc = """The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect().""" +fields.QUERY_RESOLVE.doc = """The buffer can be the destination of GPUCommandEncoder.resolve_query_set().""" + +[flags.MapMode] +doc = """Bit flags that specify whether a buffer is mapped for reading or writing. + +Used in the mode argument of the GPUBuffer.map_async() method. The mode must match the +flags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE. +""" +fields.READ.doc = """Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ.""" +fields.WRITE.doc = """Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE.""" + +[flags.TextureUsage] +doc = """Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator. + +The usage is set when creating the texture (see the usage field of structs.TextureDescriptor). +Texture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor). +""" +fields.COPY_SRC.doc = """The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer().""" +fields.COPY_DST.doc = """The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture().""" +fields.TEXTURE_BINDING.doc = """The texture can be bound for sampling in a shader, see structs.TextureBindingLayout.""" +fields.STORAGE_BINDING.doc = """The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout.""" +fields.RENDER_ATTACHMENT.doc = """The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor.""" +fields.TRANSIENT_ATTACHMENT.doc = """The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard.""" + +[flags.ShaderStage] +doc = """Bit flags that specify in which shader stages a resource is visible. + +Used in the visibility field of structs.BindGroupLayoutEntry. +""" +fields.VERTEX.doc = """The vertex shader stage.""" +fields.FRAGMENT.doc = """The fragment shader stage.""" +fields.COMPUTE.doc = """The compute shader stage.""" + +[flags.ColorWrite] +doc = """Bit flags that specify which color channels of a render target are written to. + +Used in the write_mask field of structs.ColorTargetState. +""" +fields.RED.doc = """Write the red channel.""" +fields.GREEN.doc = """Write the green channel.""" +fields.BLUE.doc = """Write the blue channel.""" +fields.ALPHA.doc = """Write the alpha channel.""" +fields.ALL.doc = """Write all channels (RED, GREEN, BLUE and ALPHA).""" + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[enums] + +[enums.PowerPreference] +doc = """Hint for which kind of adapter to select. + +Used in the power_preference field of structs.RequestAdapterOptions. This is only a hint; +the implementation may ignore it. +""" +fields.low_power.doc = """Prefer an adapter that uses little power, e.g. an integrated GPU.""" +fields.high_performance.doc = """Prefer an adapter with the highest performance, e.g. a discrete GPU.""" + +[enums.FeatureName] +doc = """Names of optional features that an adapter may support and a device may request. + +Available features can be inspected via the features property of GPUAdapter. Features +are enabled by listing them in the required_features field of structs.DeviceDescriptor. +The features of the device are available via the features property of GPUDevice. +""" +fields.core_features_and_limits.doc = """Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode).""" +fields.depth_clip_control.doc = """Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState.""" +fields.depth32float_stencil8.doc = """Enables enums.TextureFormat.depth32float_stencil8.""" +fields.texture_compression_bc.doc = """Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm.""" +fields.texture_compression_bc_sliced_d3.doc = """Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_bc.""" +fields.texture_compression_etc2.doc = """Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm.""" +fields.texture_compression_astc.doc = """Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm.""" +fields.texture_compression_astc_sliced_d3.doc = """Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_astc.""" +fields.timestamp_query.doc = """Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites.""" +fields.indirect_first_instance.doc = """Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect().""" +fields.shader_f16.doc = """Allows the use of the f16 type in WGSL shaders (the enable f16 directive).""" +fields.rg11b10ufloat_renderable.doc = """Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling.""" +fields.bgra8unorm_storage.doc = """Allows enums.TextureFormat.bgra8unorm to be used as a storage texture.""" +fields.float32_filterable.doc = """Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler.""" +fields.float32_blendable.doc = """Allows 32-bit float color attachments to be used with blending.""" +fields.clip_distances.doc = """Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes.""" +fields.dual_source_blending.doc = """Allows blending with a second fragment shader output, see enums.BlendFactor.src1.""" +fields.subgroups.doc = """Allows the use of subgroup operations in WGSL shaders.""" +fields.texture_formats_tier1.doc = """Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats.""" +fields.texture_formats_tier2.doc = """Enables further texture format capabilities, such as read-write storage access for more formats. Requires texture_formats_tier1.""" +fields.primitive_index.doc = """Allows the primitive_index built-in in WGSL fragment shaders.""" +fields.texture_component_swizzle.doc = """Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor.""" + +[enums.BufferMapState] +doc = """The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer. +""" +fields.unmapped.doc = """The buffer is not mapped; it can be used by the GPU.""" +fields.pending.doc = """A GPUBuffer.map_async() call is in progress but has not yet completed.""" +fields.mapped.doc = """The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range().""" + +[enums.TextureDimension] +doc = """The dimensionality of a GPUTexture. + +Used in the dimension field of structs.TextureDescriptor. +""" +fields.d1.doc = """A one-dimensional texture, with only a width.""" +fields.d2.doc = """A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers).""" +fields.d3.doc = """A three-dimensional (volume) texture, with width, height and depth.""" + +[enums.TextureViewDimension] +doc = """The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader. + +Used in the dimension field of structs.TextureViewDescriptor and the view_dimension field of +structs.TextureBindingLayout and structs.StorageTextureBindingLayout. +""" +fields.d1.doc = """A one-dimensional view; corresponds to texture_1d in WGSL.""" +fields.d2.doc = """A two-dimensional view of a single layer; corresponds to texture_2d in WGSL.""" +fields.d2_array.doc = """A view of an array of 2D layers; corresponds to texture_2d_array in WGSL.""" +fields.cube.doc = """A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL.""" +fields.cube_array.doc = """A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL.""" +fields.d3.doc = """A three-dimensional view; corresponds to texture_3d in WGSL.""" + +[enums.TextureAspect] +doc = """Which aspect (part) of a texture a view or copy operation refers to. + +This is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects. +""" +fields.all.doc = """All available aspects of the texture format.""" +fields.stencil_only.doc = """Only the stencil aspect of a depth-stencil format.""" +fields.depth_only.doc = """Only the depth aspect of a depth-stencil format.""" + +[enums.TextureFormat] +doc = """The pixel format of a GPUTexture. + +Names are of the form: channels, bit size per channel, and a type suffix. +The suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1), +uint/sint = unsigned/signed integer, float = floating point, and srgb = the color +is stored in sRGB and automatically converted to linear when sampled (and back when written). +Some formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage). +""" +fields.r8unorm.doc = """One channel (red), 8-bit unsigned normalized.""" +fields.r8snorm.doc = """One channel (red), 8-bit signed normalized.""" +fields.r8uint.doc = """One channel (red), 8-bit unsigned integer.""" +fields.r8sint.doc = """One channel (red), 8-bit signed integer.""" +fields.r16unorm.doc = """One channel (red), 16-bit unsigned normalized. Requires feature texture_formats_tier1.""" +fields.r16snorm.doc = """One channel (red), 16-bit signed normalized. Requires feature texture_formats_tier1.""" +fields.r16uint.doc = """One channel (red), 16-bit unsigned integer.""" +fields.r16sint.doc = """One channel (red), 16-bit signed integer.""" +fields.r16float.doc = """One channel (red), 16-bit floating point.""" +fields.rg8unorm.doc = """Two channels (red, green), 8-bit unsigned normalized each.""" +fields.rg8snorm.doc = """Two channels (red, green), 8-bit signed normalized each.""" +fields.rg8uint.doc = """Two channels (red, green), 8-bit unsigned integer each.""" +fields.rg8sint.doc = """Two channels (red, green), 8-bit signed integer each.""" +fields.r32uint.doc = """One channel (red), 32-bit unsigned integer.""" +fields.r32sint.doc = """One channel (red), 32-bit signed integer.""" +fields.r32float.doc = """One channel (red), 32-bit floating point.""" +fields.rg16unorm.doc = """Two channels (red, green), 16-bit unsigned normalized each. Requires feature texture_formats_tier1.""" +fields.rg16snorm.doc = """Two channels (red, green), 16-bit signed normalized each. Requires feature texture_formats_tier1.""" +fields.rg16uint.doc = """Two channels (red, green), 16-bit unsigned integer each.""" +fields.rg16sint.doc = """Two channels (red, green), 16-bit signed integer each.""" +fields.rg16float.doc = """Two channels (red, green), 16-bit floating point each.""" +fields.rgba8unorm.doc = """Four channels (red, green, blue, alpha), 8-bit unsigned normalized each.""" +fields.rgba8unorm_srgb.doc = """Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels.""" +fields.rgba8snorm.doc = """Four channels (RGBA), 8-bit signed normalized each.""" +fields.rgba8uint.doc = """Four channels (RGBA), 8-bit unsigned integer each.""" +fields.rgba8sint.doc = """Four channels (RGBA), 8-bit signed integer each.""" +fields.bgra8unorm.doc = """Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format().""" +fields.bgra8unorm_srgb.doc = """Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels.""" +fields.rgb9e5ufloat.doc = """Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable.""" +fields.rgb10a2uint.doc = """Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha.""" +fields.rgb10a2unorm.doc = """Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha.""" +fields.rg11b10ufloat.doc = """Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with feature rg11b10ufloat_renderable.""" +fields.rg32uint.doc = """Two channels (red, green), 32-bit unsigned integer each.""" +fields.rg32sint.doc = """Two channels (red, green), 32-bit signed integer each.""" +fields.rg32float.doc = """Two channels (red, green), 32-bit floating point each.""" +fields.rgba16unorm.doc = """Four channels (RGBA), 16-bit unsigned normalized each. Requires feature texture_formats_tier1.""" +fields.rgba16snorm.doc = """Four channels (RGBA), 16-bit signed normalized each. Requires feature texture_formats_tier1.""" +fields.rgba16uint.doc = """Four channels (RGBA), 16-bit unsigned integer each.""" +fields.rgba16sint.doc = """Four channels (RGBA), 16-bit signed integer each.""" +fields.rgba16float.doc = """Four channels (RGBA), 16-bit floating point each.""" +fields.rgba32uint.doc = """Four channels (RGBA), 32-bit unsigned integer each.""" +fields.rgba32sint.doc = """Four channels (RGBA), 32-bit signed integer each.""" +fields.rgba32float.doc = """Four channels (RGBA), 32-bit floating point each.""" +fields.stencil8.doc = """A stencil-only format with 8 bits per pixel.""" +fields.depth16unorm.doc = """A depth-only format with 16-bit unsigned normalized depth.""" +fields.depth24plus.doc = """A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer.""" +fields.depth24plus_stencil8.doc = """A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer.""" +fields.depth32float.doc = """A depth-only format with 32-bit floating point depth.""" +fields.depth32float_stencil8.doc = """A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires feature depth32float_stencil8.""" +fields.bc1_rgba_unorm.doc = """BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires feature texture_compression_bc.""" +fields.bc1_rgba_unorm_srgb.doc = """BC1 (DXT1) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" +fields.bc2_rgba_unorm.doc = """BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc.""" +fields.bc2_rgba_unorm_srgb.doc = """BC2 (DXT3) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" +fields.bc3_rgba_unorm.doc = """BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc.""" +fields.bc3_rgba_unorm_srgb.doc = """BC3 (DXT5) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" +fields.bc4_r_unorm.doc = """BC4 compressed single channel, unsigned normalized. Requires feature texture_compression_bc.""" +fields.bc4_r_snorm.doc = """BC4 compressed single channel, signed normalized. Requires feature texture_compression_bc.""" +fields.bc5_rg_unorm.doc = """BC5 compressed two channels, unsigned normalized. Requires feature texture_compression_bc.""" +fields.bc5_rg_snorm.doc = """BC5 compressed two channels, signed normalized. Requires feature texture_compression_bc.""" +fields.bc6h_rgb_ufloat.doc = """BC6H compressed HDR RGB, unsigned float. Requires feature texture_compression_bc.""" +fields.bc6h_rgb_float.doc = """BC6H compressed HDR RGB, signed float. Requires feature texture_compression_bc.""" +fields.bc7_rgba_unorm.doc = """BC7 compressed RGBA, unsigned normalized. Requires feature texture_compression_bc.""" +fields.bc7_rgba_unorm_srgb.doc = """BC7 compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" +fields.etc2_rgb8unorm.doc = """ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2.""" +fields.etc2_rgb8unorm_srgb.doc = """ETC2 compressed RGB with sRGB encoding. Requires feature texture_compression_etc2.""" +fields.etc2_rgb8a1unorm.doc = """ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires feature texture_compression_etc2.""" +fields.etc2_rgb8a1unorm_srgb.doc = """ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires feature texture_compression_etc2.""" +fields.etc2_rgba8unorm.doc = """ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2.""" +fields.etc2_rgba8unorm_srgb.doc = """ETC2 compressed RGBA with sRGB encoding. Requires feature texture_compression_etc2.""" +fields.eac_r11unorm.doc = """EAC compressed single channel, 11-bit unsigned normalized. Requires feature texture_compression_etc2.""" +fields.eac_r11snorm.doc = """EAC compressed single channel, 11-bit signed normalized. Requires feature texture_compression_etc2.""" +fields.eac_rg11unorm.doc = """EAC compressed two channels, 11-bit unsigned normalized each. Requires feature texture_compression_etc2.""" +fields.eac_rg11snorm.doc = """EAC compressed two channels, 11-bit signed normalized each. Requires feature texture_compression_etc2.""" +fields.astc_4x4_unorm.doc = """ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_4x4_unorm_srgb.doc = """ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_5x4_unorm.doc = """ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_5x4_unorm_srgb.doc = """ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_5x5_unorm.doc = """ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_5x5_unorm_srgb.doc = """ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_6x5_unorm.doc = """ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_6x5_unorm_srgb.doc = """ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_6x6_unorm.doc = """ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_6x6_unorm_srgb.doc = """ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_8x5_unorm.doc = """ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_8x5_unorm_srgb.doc = """ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_8x6_unorm.doc = """ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_8x6_unorm_srgb.doc = """ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_8x8_unorm.doc = """ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_8x8_unorm_srgb.doc = """ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_10x5_unorm.doc = """ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_10x5_unorm_srgb.doc = """ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_10x6_unorm.doc = """ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_10x6_unorm_srgb.doc = """ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_10x8_unorm.doc = """ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_10x8_unorm_srgb.doc = """ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_10x10_unorm.doc = """ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_10x10_unorm_srgb.doc = """ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_12x10_unorm.doc = """ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_12x10_unorm_srgb.doc = """ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires feature texture_compression_astc.""" +fields.astc_12x12_unorm.doc = """ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires feature texture_compression_astc.""" +fields.astc_12x12_unorm_srgb.doc = """ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires feature texture_compression_astc.""" + +[enums.AddressMode] +doc = """How a sampler handles texture coordinates outside the 0..1 range, per axis. + +Used in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor. +""" +fields.clamp_to_edge.doc = """Coordinates are clamped to the range 0..1, so the edge texels are repeated.""" +fields.repeat.doc = """The texture tiles: only the fractional part of the coordinate is used.""" +fields.mirror_repeat.doc = """The texture tiles, but is mirrored every other repetition.""" + +[enums.FilterMode] +doc = """How a sampler filters texels when a texture is magnified or minified. + +Used in the mag_filter and min_filter fields of structs.SamplerDescriptor. +""" +fields.nearest.doc = """Use the value of the nearest texel.""" +fields.linear.doc = """Linearly interpolate between the nearest texels.""" + +[enums.MipmapFilterMode] +doc = """How a sampler filters between mip levels. + +Used in the mipmap_filter field of structs.SamplerDescriptor. +""" +fields.nearest.doc = """Use the nearest mip level.""" +fields.linear.doc = """Linearly interpolate between the two nearest mip levels.""" + +[enums.CompareFunction] +doc = """A comparison function, used for depth testing, stencil testing and comparison samplers. + +The comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to +the existing value. If the comparison is true, the test passes. +""" +fields.never.doc = """The comparison never passes.""" +fields.less.doc = """Passes if the new value is less than the existing value.""" +fields.equal.doc = """Passes if the new value is equal to the existing value.""" +fields.less_equal.doc = """Passes if the new value is less than or equal to the existing value.""" +fields.greater.doc = """Passes if the new value is greater than the existing value.""" +fields.not_equal.doc = """Passes if the new value is not equal to the existing value.""" +fields.greater_equal.doc = """Passes if the new value is greater than or equal to the existing value.""" +fields.always.doc = """The comparison always passes.""" + +[enums.BufferBindingType] +doc = """The type of a buffer binding in a bind group layout. + +Used in the type field of structs.BufferBindingLayout. +""" +fields.uniform.doc = """A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM.""" +fields.storage.doc = """A read-write storage buffer. Requires flags.BufferUsage.STORAGE.""" +fields.read_only_storage.doc = """A read-only storage buffer. Requires flags.BufferUsage.STORAGE.""" + +[enums.SamplerBindingType] +doc = """The type of a sampler binding in a bind group layout. + +Used in the type field of structs.SamplerBindingLayout. +""" +fields.filtering.doc = """A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float.""" +fields.non_filtering.doc = """A sampler that only uses nearest filtering. Can be used with any float texture.""" +fields.comparison.doc = """A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor).""" + +[enums.TextureSampleType] +doc = """The type of values that is returned when sampling a texture in a shader. + +Used in the sample_type field of structs.TextureBindingLayout. +""" +fields.float.doc = """Floating point values; the texture can be sampled with a filtering sampler.""" +fields.unfilterable_float.doc = """Floating point values, but the texture cannot be filtered (e.g. 32-bit float without the float32_filterable feature).""" +fields.depth.doc = """Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler.""" +fields.sint.doc = """Signed integer values.""" +fields.uint.doc = """Unsigned integer values.""" + +[enums.StorageTextureAccess] +doc = """How a storage texture can be accessed by a shader. + +Used in the access field of structs.StorageTextureBindingLayout. +""" +fields.write_only.doc = """The shader can only write to the texture.""" +fields.read_only.doc = """The shader can only read from the texture.""" +fields.read_write.doc = """The shader can both read from and write to the texture.""" + +[enums.CompilationMessageType] +doc = """The severity of a GPUCompilationMessage. +""" +fields.error.doc = """An error; the shader module is invalid.""" +fields.warning.doc = """A warning; the shader module is valid but something may be wrong.""" +fields.info.doc = """An informational message.""" + +[enums.PipelineErrorReason] +doc = """The reason for a GPUPipelineError. + +Available via the reason property of GPUPipelineError. +""" +fields.validation.doc = """The pipeline failed validation, e.g. because of an invalid descriptor or shader.""" +fields.internal.doc = """An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend.""" + +[enums.AutoLayoutMode] +doc = """Indicates that a pipeline layout should be derived automatically from the shader code. + +Used as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor. +The resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout(). +""" +fields.auto.doc = """Derive the pipeline layout from the shader.""" + +[enums.PrimitiveTopology] +doc = """How vertices are assembled into primitives. + +Used in the topology field of structs.PrimitiveState. +""" +fields.point_list.doc = """Each vertex defines a point.""" +fields.line_list.doc = """Each pair of vertices defines a separate line.""" +fields.line_strip.doc = """Each vertex after the first defines a line to the previous vertex.""" +fields.triangle_list.doc = """Each triple of vertices defines a separate triangle.""" +fields.triangle_strip.doc = """Each vertex after the first two defines a triangle with the previous two vertices.""" + +[enums.FrontFace] +doc = """Defines which winding order of a triangle is considered front-facing. + +Used in the front_face field of structs.PrimitiveState. +""" +fields.ccw.doc = """Triangles with counter-clockwise vertices (in framebuffer space) are front-facing.""" +fields.cw.doc = """Triangles with clockwise vertices (in framebuffer space) are front-facing.""" + +[enums.CullMode] +doc = """Defines which faces of triangles are culled (not drawn). + +Used in the cull_mode field of structs.PrimitiveState. +""" +fields.none.doc = """No faces are culled.""" +fields.front.doc = """Front-facing triangles are culled.""" +fields.back.doc = """Back-facing triangles are culled.""" + +[enums.BlendFactor] +doc = """A factor that is multiplied with the source or destination color or alpha in blending. + +Used in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions, +src is the output of the fragment shader and dst is the existing value in the render target. +""" +fields.zero.doc = """Factor 0.""" +fields.one.doc = """Factor 1.""" +fields.src.doc = """The source color, per component.""" +fields.one_minus_src.doc = """One minus the source color, per component.""" +fields.src_alpha.doc = """The source alpha.""" +fields.one_minus_src_alpha.doc = """One minus the source alpha.""" +fields.dst.doc = """The destination color, per component.""" +fields.one_minus_dst.doc = """One minus the destination color, per component.""" +fields.dst_alpha.doc = """The destination alpha.""" +fields.one_minus_dst_alpha.doc = """One minus the destination alpha.""" +fields.src_alpha_saturated.doc = """The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha.""" +fields.constant.doc = """The blend constant color, see GPURenderPassEncoder.set_blend_constant().""" +fields.one_minus_constant.doc = """One minus the blend constant color.""" +fields.src1.doc = """The second source color output of the fragment shader. Requires feature dual_source_blending.""" +fields.one_minus_src1.doc = """One minus the second source color. Requires feature dual_source_blending.""" +fields.src1_alpha.doc = """The second source alpha. Requires feature dual_source_blending.""" +fields.one_minus_src1_alpha.doc = """One minus the second source alpha. Requires feature dual_source_blending.""" + +[enums.BlendOperation] +doc = """The operation used to combine the scaled source and destination values in blending. + +Used in the operation field of structs.BlendComponent. +""" +fields.add.doc = """Result is source plus destination.""" +fields.subtract.doc = """Result is source minus destination.""" +fields.reverse_subtract.doc = """Result is destination minus source.""" +fields.min.doc = """Result is the minimum of source and destination (blend factors are ignored).""" +fields.max.doc = """Result is the maximum of source and destination (blend factors are ignored).""" + +[enums.StencilOperation] +doc = """The operation performed on the stencil buffer value after a stencil or depth test. + +Used in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState. +""" +fields.keep.doc = """Keep the current stencil value.""" +fields.zero.doc = """Set the stencil value to zero.""" +fields.replace.doc = """Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference().""" +fields.invert.doc = """Bitwise invert the current stencil value.""" +fields.increment_clamp.doc = """Increment the stencil value, clamping to the maximum.""" +fields.decrement_clamp.doc = """Decrement the stencil value, clamping to zero.""" +fields.increment_wrap.doc = """Increment the stencil value, wrapping to zero on overflow.""" +fields.decrement_wrap.doc = """Decrement the stencil value, wrapping to the maximum on underflow.""" + +[enums.IndexFormat] +doc = """The data type of the indices in an index buffer. + +Used in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method +and the strip_index_format field of structs.PrimitiveState. +""" +fields.uint16.doc = """Indices are 16-bit unsigned integers.""" +fields.uint32.doc = """Indices are 32-bit unsigned integers.""" + +[enums.VertexFormat] +doc = """The format of a vertex attribute in a vertex buffer. + +Used in the format field of structs.VertexAttribute. The name consists of the component type and +bit size, optionally followed by xN for the number of components. The shader sees the data as +float (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components. +""" +fields.uint8.doc = """One 8-bit unsigned integer.""" +fields.uint8x2.doc = """Two 8-bit unsigned integers.""" +fields.uint8x4.doc = """Four 8-bit unsigned integers.""" +fields.sint8.doc = """One 8-bit signed integer.""" +fields.sint8x2.doc = """Two 8-bit signed integers.""" +fields.sint8x4.doc = """Four 8-bit signed integers.""" +fields.unorm8.doc = """One 8-bit unsigned normalized value (0..1).""" +fields.unorm8x2.doc = """Two 8-bit unsigned normalized values (0..1).""" +fields.unorm8x4.doc = """Four 8-bit unsigned normalized values (0..1).""" +fields.snorm8.doc = """One 8-bit signed normalized value (-1..1).""" +fields.snorm8x2.doc = """Two 8-bit signed normalized values (-1..1).""" +fields.snorm8x4.doc = """Four 8-bit signed normalized values (-1..1).""" +fields.uint16.doc = """One 16-bit unsigned integer.""" +fields.uint16x2.doc = """Two 16-bit unsigned integers.""" +fields.uint16x4.doc = """Four 16-bit unsigned integers.""" +fields.sint16.doc = """One 16-bit signed integer.""" +fields.sint16x2.doc = """Two 16-bit signed integers.""" +fields.sint16x4.doc = """Four 16-bit signed integers.""" +fields.unorm16.doc = """One 16-bit unsigned normalized value (0..1).""" +fields.unorm16x2.doc = """Two 16-bit unsigned normalized values (0..1).""" +fields.unorm16x4.doc = """Four 16-bit unsigned normalized values (0..1).""" +fields.snorm16.doc = """One 16-bit signed normalized value (-1..1).""" +fields.snorm16x2.doc = """Two 16-bit signed normalized values (-1..1).""" +fields.snorm16x4.doc = """Four 16-bit signed normalized values (-1..1).""" +fields.float16.doc = """One 16-bit float.""" +fields.float16x2.doc = """Two 16-bit floats.""" +fields.float16x4.doc = """Four 16-bit floats.""" +fields.float32.doc = """One 32-bit float.""" +fields.float32x2.doc = """Two 32-bit floats.""" +fields.float32x3.doc = """Three 32-bit floats.""" +fields.float32x4.doc = """Four 32-bit floats.""" +fields.uint32.doc = """One 32-bit unsigned integer.""" +fields.uint32x2.doc = """Two 32-bit unsigned integers.""" +fields.uint32x3.doc = """Three 32-bit unsigned integers.""" +fields.uint32x4.doc = """Four 32-bit unsigned integers.""" +fields.sint32.doc = """One 32-bit signed integer.""" +fields.sint32x2.doc = """Two 32-bit signed integers.""" +fields.sint32x3.doc = """Three 32-bit signed integers.""" +fields.sint32x4.doc = """Four 32-bit signed integers.""" +fields.unorm10_10_10_2.doc = """A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float.""" +fields.unorm8x4_bgra.doc = """Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order.""" + +[enums.VertexStepMode] +doc = """How often a vertex buffer is advanced. + +Used in the step_mode field of structs.VertexBufferLayout. +""" +fields.vertex.doc = """The buffer is advanced for each vertex.""" +fields.instance.doc = """The buffer is advanced for each instance.""" + +[enums.LoadOp] +doc = """What happens to the contents of an attachment at the start of a render pass. + +Used in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. +""" +fields.load.doc = """Keep the existing contents of the attachment.""" +fields.clear.doc = """Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment).""" + +[enums.StoreOp] +doc = """What happens to the contents of an attachment at the end of a render pass. + +Used in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. +""" +fields.store.doc = """Store the results of the render pass in the attachment.""" +fields.discard.doc = """Discard the results; the contents of the attachment become undefined (zero-initialized when next used).""" + +[enums.QueryType] +doc = """The type of queries in a GPUQuerySet. + +Used in the type field of structs.QuerySetDescriptor. +""" +fields.occlusion.doc = """Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query().""" +fields.timestamp.doc = """Timestamp queries record GPU timestamps. Requires feature timestamp_query.""" + +[enums.CanvasAlphaMode] +doc = """How the alpha channel of a canvas texture is interpreted when compositing with the page or window. + +Used in the alpha_mode field of structs.CanvasConfiguration. +""" +fields.opaque.doc = """The alpha channel is ignored and the canvas is treated as fully opaque.""" +fields.premultiplied.doc = """The color channels are expected to be premultiplied by the alpha channel.""" + +[enums.CanvasToneMappingMode] +doc = """How the content of a canvas is tone mapped when displayed. + +Used in the mode field of structs.CanvasToneMapping. +""" +fields.standard.doc = """Color values are clamped to the standard dynamic range (SDR) of the display.""" +fields.extended.doc = """Color values may exceed the SDR range, up to the dynamic range of the display (HDR).""" + +[enums.DeviceLostReason] +doc = """The reason a GPUDevice was lost. + +Available via the reason property of GPUDeviceLostInfo. +""" +fields.unknown.doc = """The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal.""" +fields.destroyed.doc = """The device was lost because GPUDevice.destroy() was called.""" + +[enums.ErrorFilter] +doc = """The type of error that is captured by an error scope. + +Used in the filter argument of the GPUDevice.push_error_scope() method. +""" +fields.validation.doc = """Captures GPUValidationError errors, which signal incorrect API usage.""" +fields.out_of_memory.doc = """Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation.""" +fields.internal.doc = """Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits).""" + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[structs] + +[structs.RequestAdapterOptions] +doc = """Options for requesting an adapter. + +Used as the options argument of the GPU.request_adapter() method. +""" +fields.feature_level.doc = """Requests an adapter that supports at least a particular set of capabilities. +This influences the {@link adapter#[[default feature level]]} of devices created +from this adapter. The capabilities for each level are defined below, and the exact +steps are defined in {@link GPU#requestAdapter} and "a new device". +If the implementation or system does not support all of the capabilities in the +requested feature level, {@link GPU#requestAdapter} will return `null`. +Note: +Applications should typically make a single {@link GPU#requestAdapter} call with the lowest +feature level they support, then inspect the adapter for additional capabilities they can +use optionally, and request those in {@link GPUAdapter#requestDevice}. +The allowed feature level string values are: +
+: "core" +The following set of capabilities: +- The limit/Default limits. +- {@link GPUFeatureName} `"core-features-and-limits"`. +Note: +Adapters with this {@link adapter#[[default feature level]]} may +conventionally be referred to as "Core-defaulting". +: "compatibility" +The following set of capabilities: +- The limit/Compatibility Mode Default limits. +- No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) +If the implementation cannot enforce the stricter "Compatibility Mode" +validation rules, {@link GPU#requestAdapter} will ignore this request and +treat it as a request for feature level string/"core". +Note: +Adapters with this {@link adapter#[[default feature level]]} may +conventionally be referred to as "Compatibility-defaulting". +""" +fields.power_preference.doc = """Optionally provides a hint indicating what class of adapter should be selected from +the system's available adapters. +The value of this hint may influence which adapter is chosen, but it must not +influence whether an adapter is returned or not. +Note: +The primary utility of this hint is to influence which GPU is used in a multi-GPU system. +For instance, some laptops have a low-power integrated GPU and a high-performance +discrete GPU. This hint may also affect the power configuration of the selected GPU to +match the requested power preference. +Note: +Depending on the exact hardware configuration, such as battery status and attached displays +or removable GPUs, the user agent may select different adapters given the same power +preference. +Typically, given the same hardware configuration and state and +`powerPreference`, the user agent is likely to select the same adapter. +""" +fields.force_fallback_adapter.doc = """When set to `true` indicates that only a fallback adapter may be returned. If the user +agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to +resolve to `null`. +Note: +{@link GPU#requestAdapter} may still return a fallback adapter if +{@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no +other appropriate adapter is available or the user agent chooses to return a +fallback adapter. Developers that wish to prevent their applications from running on +fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} +attribute prior to requesting a {@link GPUDevice}. +""" +fields.xr_compatible.doc = """If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers.""" + +[structs.DeviceDescriptor] +doc = """Descriptor for requesting a device. + +Used as the descriptor argument of the GPUAdapter.request_device() method. +""" +fields.label.doc = """A human-readable label for the device, used in debugging and error messages.""" +fields.required_features.doc = """Specifies the features that are required by the device request. +The request will fail if the adapter cannot provide these features. +Exactly the specified set of features, and no more or less, will be allowed in validation +of API calls on the resulting device. +""" +fields.required_limits.doc = """Specifies the limits that are required by the device request. +The request will fail if the adapter cannot provide these limits. +Each key with a non-`undefined` value must be the name of a member of supported limits. +API calls on the resulting device perform validation according to the exact limits of the +device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). + +""" +fields.default_queue.doc = """The descriptor for the default {@link GPUQueue}.""" + +[structs.BufferDescriptor] +doc = """Descriptor for creating a GPUBuffer. + +Used as the descriptor argument of the GPUDevice.create_buffer() method. +""" +fields.label.doc = """A human-readable label for the buffer, used in debugging and error messages.""" +fields.size.doc = """The size of the buffer in bytes.""" +fields.usage.doc = """The allowed usages for the buffer.""" +fields.mapped_at_creation.doc = """If `true` creates the buffer in an already mapped state, allowing +{@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set +{@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} +does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be +used to set the buffer's initial data. +Guarantees that even if the buffer creation eventually fails, it will still appear as if the +mapped range can be written/read to until it is unmapped. +""" + +[structs.TextureDescriptor] +doc = """Descriptor for creating a GPUTexture. + +Used as the descriptor argument of the GPUDevice.create_texture() method. +""" +fields.label.doc = """A human-readable label for the texture, used in debugging and error messages.""" +fields.size.doc = """The width, height, and depth or layer count of the texture.""" +fields.mip_level_count.doc = """The number of mip levels the texture will contain.""" +fields.sample_count.doc = """The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates +a multisampled texture. +""" +fields.dimension.doc = """Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.""" +fields.format.doc = """The format of the texture.""" +fields.usage.doc = """The allowed usages for the texture.""" +fields.view_formats.doc = """Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling +{@link GPUTexture#createView} on this texture (in addition to the texture's actual +{@link GPUTextureDescriptor#format}). +
+Adding a format to this list may have a significant performance impact, so it is best +to avoid adding formats unnecessarily. +The actual performance impact is highly dependent on the target system; developers must +test various systems to find out the impact on their particular application. +For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or +{@link GPUTextureDescriptor#viewFormats} entry including +{@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a +{@link GPUTextureFormat} `"rgba8unorm"` texture which does not. +Similar caveats exist for other formats and pairs of formats on other systems. +
+Formats in this list must be texture view format compatible with the texture format. +
+Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: +- `format` equals `viewFormat`, or +- `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. +
+""" +fields.texture_binding_view_dimension.doc = """
+On devices without {@link GPUFeatureName} `"core-features-and-limits"`, +views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. +If not specified, a default is chosen. +
+On devices with {@link GPUFeatureName} `"core-features-and-limits"`, +this is ignored, and there is no such restriction. +""" + +[structs.TextureViewDescriptor] +doc = """Descriptor for creating a GPUTextureView. + +Used as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields +get a default derived from the texture, so by default the view covers the whole texture. +""" +fields.label.doc = """A human-readable label for the texture view, used in debugging and error messages.""" +fields.format.doc = """The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the +texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. +""" +fields.dimension.doc = """The dimension to view the texture as.""" +fields.usage.doc = """The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the +{@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of +{@link GPUTexture#usage} flags of the texture. +Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the +texture's {@link GPUTextureDescriptor#usage}s, the default will fail, +and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. +""" +fields.aspect.doc = """Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.""" +fields.base_mip_level.doc = """The first (most detailed) mipmap level accessible to the texture view.""" +fields.mip_level_count.doc = """How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to +the texture view. +""" +fields.base_array_layer.doc = """The index of the first array layer accessible to the texture view.""" +fields.array_layer_count.doc = """How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible +to the texture view. +""" +fields.swizzle.doc = """A string of length four, with each character mapping to the texture view's red/green/blue/alpha +channels, respectively. +When accessed by a shader, the red/green/blue/alpha channels are replaced by the value +corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and +`swizzle[3]`, respectively: +- `"r"`: Take its value from the red channel of the texture. +- `"g"`: Take its value from the green channel of the texture. +- `"b"`: Take its value from the blue channel of the texture. +- `"a"`: Take its value from the alpha channel of the texture. +- `"0"`: Force its value to 0. +- `"1"`: Force its value to 1. +Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. +""" + +[structs.ExternalTextureDescriptor] +doc = """Descriptor for importing an external texture, such as a video frame. + +Used as the descriptor argument of the GPUDevice.import_external_texture() method. +""" +fields.label.doc = """A human-readable label for the external texture, used in debugging and error messages.""" +fields.source.doc = """The video source to import the external texture from. Source size is determined as described +by the external source dimensions table. +""" +fields.color_space.doc = """The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be +converted into when reading. +""" + +[structs.SamplerDescriptor] +doc = """Descriptor for creating a GPUSampler. + +Used as the descriptor argument of the GPUDevice.create_sampler() method. +""" +fields.label.doc = """A human-readable label for the sampler, used in debugging and error messages.""" +fields.address_mode_u.doc = """How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge.""" +fields.address_mode_v.doc = """How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge.""" +fields.address_mode_w.doc = """Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth +coordinates, respectively. +""" +fields.mag_filter.doc = """Specifies the sampling behavior when the sampled area is smaller than or equal to one +texel. +""" +fields.min_filter.doc = """Specifies the sampling behavior when the sampled area is larger than one texel.""" +fields.mipmap_filter.doc = """Specifies behavior for sampling between mipmap levels.""" +fields.lod_min_clamp.doc = """The minimum level of detail used when sampling. Defaults to 0.""" +fields.lod_max_clamp.doc = """Specifies the minimum and maximum levels of detail, respectively, used internally when +sampling a texture. +""" +fields.compare.doc = """When provided the sampler will be a comparison sampler with the specified +{@link GPUCompareFunction}. +Note: Comparison samplers may use filtering, but the sampling results will be +implementation-dependent and may differ from the normal filtering rules. +""" +fields.max_anisotropy.doc = """Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is +enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. +Anisotropic filtering improves the image quality of textures sampled at oblique viewing +angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of +anisotropy supported when filtering. +
+Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range +between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} +will be clamped to the maximum value that the platform supports. +The precise filtering behavior is implementation-dependent. +
+""" + +[structs.BindGroupLayoutDescriptor] +doc = """Descriptor for creating a GPUBindGroupLayout. + +Used as the descriptor argument of the GPUDevice.create_bind_group_layout() method. +""" +fields.label.doc = """A human-readable label for the bind group layout, used in debugging and error messages.""" +fields.entries.doc = """A list of entries describing the shader resource bindings for a bind group.""" + +[structs.BindGroupLayoutEntry] +doc = """Describes a single binding in a bind group layout. + +Exactly one of buffer, sampler, texture, storage_texture and external_texture must be set, +which determines the type of resource that is bound. +""" +fields.binding.doc = """A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding +to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding +attribute in the {@link GPUShaderModule}. +""" +fields.visibility.doc = """A bitset of the members of {@link GPUShaderStage}. +Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource +will be accessible from the associated shader stage. +""" +fields.buffer.doc = """If set, a structs.BufferBindingLayout: the entry is a buffer binding.""" +fields.sampler.doc = """If set, a structs.SamplerBindingLayout: the entry is a sampler binding.""" +fields.texture.doc = """If set, a structs.TextureBindingLayout: the entry is a sampled texture binding.""" +fields.storage_texture.doc = """If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding.""" + +[structs.BufferBindingLayout] +doc = """Describes the layout of a buffer binding. + +Used in the buffer field of structs.BindGroupLayoutEntry. +""" +fields.type.doc = """Indicates the type required for buffers bound to this binding.""" +fields.has_dynamic_offset.doc = """Indicates whether this binding requires a dynamic offset.""" +fields.min_binding_size.doc = """Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. +Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. +If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] +that this value ≥ the minimum buffer binding size of the variable. +If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands +[$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} +satisfies the minimum buffer binding size of the variable. +Note: +Similar execution-time validation is theoretically possible for other +binding-related fields specified for early validation, like +{@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, +which currently can only be validated in pipeline creation. +However, such execution-time validation could be costly or unnecessarily complex, so it is +available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the +most ergonomic impact. +""" + +[structs.SamplerBindingLayout] +doc = """Describes the layout of a sampler binding. + +Used in the sampler field of structs.BindGroupLayoutEntry. +""" +fields.type.doc = """Indicates the required type of a sampler bound to this bindings.""" + +[structs.TextureBindingLayout] +doc = """Describes the layout of a sampled texture binding. + +Used in the texture field of structs.BindGroupLayoutEntry. +""" +fields.sample_type.doc = """Indicates the type required for texture views bound to this binding.""" +fields.view_dimension.doc = """Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to +this binding. +""" +fields.multisampled.doc = """Indicates whether or not texture views bound to this binding must be multisampled.""" + +[structs.StorageTextureBindingLayout] +doc = """Describes the layout of a storage texture binding. + +Used in the storage_texture field of structs.BindGroupLayoutEntry. +""" +fields.access.doc = """The access mode for this binding, indicating readability and writability.""" +fields.format.doc = """The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.""" +fields.view_dimension.doc = """Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to +this binding. +""" + +[structs.BindGroupDescriptor] +doc = """Descriptor for creating a GPUBindGroup. + +Used as the descriptor argument of the GPUDevice.create_bind_group() method. +""" +fields.label.doc = """A human-readable label for the bind group, used in debugging and error messages.""" +fields.layout.doc = """The {@link GPUBindGroupLayout} the entries of this bind group will conform to.""" +fields.entries.doc = """A list of entries describing the resources to expose to the shader for each binding +described by the {@link GPUBindGroupDescriptor#layout}. +""" + +[structs.BindGroupEntry] +doc = """A single resource binding in a bind group. + +Used in the entries field of structs.BindGroupDescriptor. +""" +fields.binding.doc = """A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a +{@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding +attribute in the {@link GPUShaderModule}. +""" +fields.resource.doc = """The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, +{@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. +""" + +[structs.BufferBinding] +doc = """Describes a range of a GPUBuffer to bind. + +Can be used as the resource field of structs.BindGroupEntry. +""" +fields.buffer.doc = """The {@link GPUBuffer} to bind.""" +fields.offset.doc = """The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the +beginning of the range exposed to the shader by the buffer binding. +""" +fields.size.doc = """The size, in bytes, of the buffer binding. +If not map/exist|provided, specifies the range starting at +{@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. +""" + +[structs.PipelineLayoutDescriptor] +doc = """Descriptor for creating a GPUPipelineLayout. + +Used as the descriptor argument of the GPUDevice.create_pipeline_layout() method. +""" +fields.label.doc = """A human-readable label for the pipeline layout, used in debugging and error messages.""" +fields.bind_group_layouts.doc = """A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds +to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding +with `@group(N)`. +""" +fields.immediate_size.doc = """The size, in bytes, of the immediate data range used by the pipeline.""" + +[structs.ShaderModuleDescriptor] +doc = """Descriptor for creating a GPUShaderModule. + +Used as the descriptor argument of the GPUDevice.create_shader_module() method. +""" +fields.label.doc = """A human-readable label for the shader module, used in debugging and error messages.""" +fields.code.doc = """The WGSL source code for the shader +module. +""" +fields.compilation_hints.doc = """A list of {@link GPUShaderModuleCompilationHint}s. +Any hint provided by an application **should** contain information about one entry point of +a pipeline that will eventually be created from the entry point. +Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} +to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. +Aside from type-checking, these hints are not validated in any way. +
+Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any +observable effect, other than performance. It may be detrimental to performance to +provide hints for pipelines that never end up being created. +Because a single shader module can hold multiple entry points, and multiple pipelines +can be created from a single shader module, it can be more performant for an +implementation to do as much compilation as possible once in +{@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to +{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. +Hints are only applied to the entry points they explicitly name. +Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, +there is no default, even if only one entry point is present in the module. +
+Note: +Hints are not validated in an observable way, but user agents **may** surface identifiable +errors (like unknown entry point names or incompatible pipeline layouts) to developers, +for example in the browser developer console. +""" + +[structs.ShaderModuleCompilationHint] +doc = """A hint for the compilation of a shader module. + +Used in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only +affect performance, not behavior. +""" +fields.entry_point.doc = """The name of the shader entry point that the hint applies to.""" +fields.layout.doc = """A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future +{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. +If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] +for the entry point associated with this hint will be used. +""" + +[structs.PipelineErrorInit] +doc = """Initialization options for a GPUPipelineError. + +Used as the options argument of the GPUPipelineError constructor. +""" +fields.reason.doc = """The reason for the error, see enums.PipelineErrorReason.""" + +[structs.ProgrammableStage] +doc = """Describes a programmable (shader) stage of a pipeline. + +This is the base for structs.VertexState, structs.FragmentState and the compute field of +structs.ComputePipelineDescriptor. +""" +fields.module.doc = """The {@link GPUShaderModule} containing the code that this programmable stage will execute.""" +fields.entry_point.doc = """The name of the function in {@link GPUProgrammableStage#module} that this stage will use to +perform its work. +NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is +not required, methods which consume a {@link GPUProgrammableStage} must use the +"[$get the entry point$]" algorithm to determine which entry point +it refers to. +""" +fields.constants.doc = """Specifies the values of pipeline-overridable constants in the shader module +{@link GPUProgrammableStage#module}. +Each such pipeline-overridable constant is uniquely identified by a single +pipeline-overridable constant identifier string, representing the pipeline +constant ID of the constant if its declaration specifies one, and otherwise the +constant's identifier name. +The key of each key-value pair must equal the +pipeline-overridable constant identifier string|identifier string +of one such constant, with the comparison performed +according to the rules for WGSL identifier comparison. +When the pipeline is executed, that constant will have the specified value. +Values are specified as GPUPipelineConstantValue, which is a `double`. +They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). +If conversion fails, a validation error is generated. +
+Pipeline-overridable constants defined in WGSL: +```wgsl +override width: f32 = 0.0; // Specifed at the API level +// using the name "width". +override depth: f32; // Specifed at the API level +// using the name "depth". +// Must be overridden. +override height = 2 * depth; // The default value +// (if not set at the API level), +// depends on another +// overridable constant. +``` +Corresponding JavaScript code, providing only the overrides which are required +(have no defaults): +```js +{ +// ... +constants: { +1300: 2.0, // "gain" +depth: -1, // "depth" +} +} +``` +Corresponding JavaScript code, overriding all constants: +```js +{ +// ... +constants: { +0: false, // "has_point_light" +1200: 3.0, // "specular_param" +1300: 2.0, // "gain" +width: 20, // "width" +depth: -1, // "depth" +height: 15, // "height" +} +} +``` +
+""" + +[structs.ComputePipelineDescriptor] +doc = """Descriptor for creating a GPUComputePipeline. + +Used as the descriptor argument of the GPUDevice.create_compute_pipeline() method. +""" +fields.label.doc = """A human-readable label for the pipeline, used in debugging and error messages.""" +fields.layout.doc = """The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader.""" +fields.compute.doc = """Describes the compute shader entry point of the pipeline.""" + +[structs.RenderPipelineDescriptor] +doc = """Descriptor for creating a GPURenderPipeline. + +Used as the descriptor argument of the GPUDevice.create_render_pipeline() method. +""" +fields.label.doc = """A human-readable label for the pipeline, used in debugging and error messages.""" +fields.layout.doc = """The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shaders.""" +fields.vertex.doc = """Describes the vertex shader entry point of the pipeline and its input buffer layouts.""" +fields.primitive.doc = """Describes the primitive-related properties of the pipeline.""" +fields.depth_stencil.doc = """Describes the optional depth-stencil properties, including the testing, operations, and bias.""" +fields.multisample.doc = """Describes the multi-sampling properties of the pipeline.""" +fields.fragment.doc = """Describes the fragment shader entry point of the pipeline and its output colors. If +not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. +""" + +[structs.PrimitiveState] +doc = """Describes how a render pipeline assembles and rasterizes primitives. + +Used in the primitive field of structs.RenderPipelineDescriptor. +""" +fields.topology.doc = """The type of primitive to be constructed from the vertex inputs.""" +fields.strip_index_format.doc = """For pipelines with strip topologies +({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), +this determines the index buffer format and primitive restart value +({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). +It is not allowed on pipelines with non-strip topologies. +Note: Some implementations require knowledge of the primitive restart value to compile +pipeline state objects. +To use a strip-topology pipeline with an indexed draw call +({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), +this must be set, and it must match the index buffer format used with the draw call +(set in {@link GPURenderCommandsMixin#setIndexBuffer}). +See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. +""" +fields.front_face.doc = """Defines which polygons are considered front-facing.""" +fields.cull_mode.doc = """Defines which polygon orientation will be culled, if any.""" +fields.unclipped_depth.doc = """If true, indicates that depth clipping is disabled. +Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. +""" + +[structs.MultisampleState] +doc = """Describes the multisampling of a render pipeline. + +Used in the multisample field of structs.RenderPipelineDescriptor. +""" +fields.count.doc = """Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only +with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} +and {@link GPURenderPassDescriptor#depthStencilAttachment}) +with matching {@link GPUTextureDescriptor#sampleCount}s. +""" +fields.mask.doc = """Mask determining which samples are written to.""" +fields.alpha_to_coverage_enabled.doc = """When `true` indicates that a fragment's alpha channel should be used to generate a sample +coverage mask. +""" + +[structs.FragmentState] +doc = """Describes the fragment shader stage and render targets of a render pipeline. + +Used in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. +""" +fields.module.doc = """The GPUShaderModule containing the fragment shader code.""" +fields.entry_point.doc = """The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point.""" +fields.constants.doc = """A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use.""" +fields.targets.doc = """A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets +this pipeline writes to. +""" + +[structs.ColorTargetState] +doc = """Describes a color render target of a render pipeline. + +Used in the targets field of structs.FragmentState. +""" +fields.format.doc = """The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with +{@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the +corresponding color attachment. +""" +fields.blend.doc = """The blending behavior for this color target. If left undefined, disables blending for this +color target. +""" +fields.write_mask.doc = """Bitmask controlling which channels are are written to when drawing to this color target.""" + +[structs.BlendState] +doc = """Describes how blending is performed for a color target. + +Used in the blend field of structs.ColorTargetState. +""" +fields.color.doc = """Defines the blending behavior of the corresponding render target for color channels.""" +fields.alpha.doc = """Defines the blending behavior of the corresponding render target for the alpha channel.""" + +[structs.BlendComponent] +doc = """Describes how the blending of a single component (color or alpha) is performed. + +The result is: operation(src * src_factor, dst * dst_factor). +""" +fields.operation.doc = """Defines the {@link GPUBlendOperation} used to calculate the values written to the target +attachment components. +""" +fields.src_factor.doc = """Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.""" +fields.dst_factor.doc = """Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.""" + +[structs.DepthStencilState] +doc = """Describes the depth and stencil state of a render pipeline. + +Used in the depth_stencil field of structs.RenderPipelineDescriptor. +""" +fields.format.doc = """The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} +this {@link GPURenderPipeline} will be compatible with. +""" +fields.depth_write_enabled.doc = """Indicates if this {@link GPURenderPipeline} can modify +{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. +""" +fields.depth_compare.doc = """The comparison operation used to test fragment depths against +{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. +""" +fields.stencil_front.doc = """Defines how stencil comparisons and operations are performed for front-facing primitives.""" +fields.stencil_back.doc = """Defines how stencil comparisons and operations are performed for back-facing primitives.""" +fields.stencil_read_mask.doc = """Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value +bits are read when performing stencil comparison tests. +""" +fields.stencil_write_mask.doc = """Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value +bits are written to when performing stencil operations. +""" +fields.depth_bias.doc = """Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.""" +fields.depth_bias_slope_scale.doc = """Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.""" +fields.depth_bias_clamp.doc = """The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.""" + +[structs.StencilFaceState] +doc = """Describes the stencil operations for one face (front or back) of primitives. + +Used in the stencil_front and stencil_back fields of structs.DepthStencilState. +""" +fields.compare.doc = """The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value +against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. +""" +fields.fail_op.doc = """The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by +{@link GPUStencilFaceState#compare} fails. +""" +fields.depth_fail_op.doc = """The {@link GPUStencilOperation} performed if the fragment depth comparison described by +{@link GPUDepthStencilState#depthCompare} fails. +""" +fields.pass_op.doc = """The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by +{@link GPUStencilFaceState#compare} passes. +""" + +[structs.VertexState] +doc = """Describes the vertex shader stage and vertex buffers of a render pipeline. + +Used in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. +""" +fields.module.doc = """The GPUShaderModule containing the vertex shader code.""" +fields.entry_point.doc = """The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point.""" +fields.constants.doc = """A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use.""" +fields.buffers.doc = """A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a +vertex buffer used by this pipeline. +""" + +[structs.VertexBufferLayout] +doc = """Describes the layout of a vertex buffer. + +Used in the buffers field of structs.VertexState. +""" +fields.array_stride.doc = """The stride, in bytes, between elements of this array.""" +fields.step_mode.doc = """Whether each element of this array represents per-vertex data or per-instance data""" +fields.attributes.doc = """An array defining the layout of the vertex attributes within each element.""" + +[structs.VertexAttribute] +doc = """Describes a single vertex attribute within a vertex buffer. + +Used in the attributes field of structs.VertexBufferLayout. +""" +fields.format.doc = """The {@link GPUVertexFormat} of the attribute.""" +fields.offset.doc = """The offset, in bytes, from the beginning of the element to the data for the attribute.""" +fields.shader_location.doc = """The numeric location associated with this attribute, which will correspond with a +"@location" attribute +declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. +""" + +[structs.TexelCopyBufferLayout] +doc = """Describes the layout of texel data in a buffer or in a block of memory. + +Used as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo. +""" +fields.offset.doc = """The offset, in bytes, from the beginning of the texel data source (such as a +{@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data +within that source. +""" +fields.bytes_per_row.doc = """The stride, in bytes, between the beginning of each texel block row and the subsequent +texel block row. +Required if there are multiple texel block rows (i.e. the copy height or depth is more +than one block). +""" +fields.rows_per_image.doc = """Number of texel block rows per single texel image of the texture. +{@link GPUTexelCopyBufferLayout#rowsPerImage} × +{@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each +texel image of data and the subsequent texel image. +Required if there are multiple texel images (i.e. the copy depth is more than one). +""" + +[structs.TexelCopyBufferInfo] +doc = """Describes a buffer and the layout of texel data in it. + +Used as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer(). +Extends structs.TexelCopyBufferLayout. +""" +fields.offset.doc = """The offset in bytes into the buffer where the texel data starts. Defaults to 0.""" +fields.bytes_per_row.doc = """The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256.""" +fields.rows_per_image.doc = """The number of rows per image (layer or slice). Required if there is more than one image.""" +fields.buffer.doc = """A buffer which either contains texel data to be copied or will store the texel data being +copied, depending on the method it is being passed to. +""" + +[structs.TexelCopyTextureInfo] +doc = """Describes a texture and the part of it that is the source or destination of a copy. + +Used in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(), +GPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture(). +""" +fields.texture.doc = """Texture to copy to/from.""" +fields.mip_level.doc = """Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.""" +fields.origin.doc = """Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. +Together with `copySize`, defines the full copy sub-region. +""" +fields.aspect.doc = """Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.""" + +[structs.CommandBufferDescriptor] +doc = """Descriptor for a GPUCommandBuffer. + +Used as the descriptor argument of the GPUCommandEncoder.finish() method. +""" +fields.label.doc = """A human-readable label for the command buffer, used in debugging and error messages.""" + +[structs.CommandEncoderDescriptor] +doc = """Descriptor for creating a GPUCommandEncoder. + +Used as the descriptor argument of the GPUDevice.create_command_encoder() method. +""" +fields.label.doc = """A human-readable label for the command encoder, used in debugging and error messages.""" + +[structs.ComputePassTimestampWrites] +doc = """Describes where to write timestamps for a compute pass. + +Used in the timestamp_writes field of structs.ComputePassDescriptor. Requires feature timestamp_query. +""" +fields.query_set.doc = """The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be +written to. +""" +fields.beginning_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the beginning of the compute pass will be written. +""" +fields.end_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the end of the compute pass will be written. +""" + +[structs.ComputePassDescriptor] +doc = """Descriptor for beginning a compute pass. + +Used as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method. +""" +fields.label.doc = """A human-readable label for the compute pass, used in debugging and error messages.""" +fields.timestamp_writes.doc = """Defines which timestamp values will be written for this pass, and where to write them to.""" + +[structs.RenderPassTimestampWrites] +doc = """Describes where to write timestamps for a render pass. + +Used in the timestamp_writes field of structs.RenderPassDescriptor. Requires feature timestamp_query. +""" +fields.query_set.doc = """The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be +written to. +""" +fields.beginning_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the beginning of the render pass will be written. +""" +fields.end_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into +which the timestamp at the end of the render pass will be written. +""" + +[structs.RenderPassDescriptor] +doc = """Descriptor for beginning a render pass. + +Used as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method. +""" +fields.label.doc = """A human-readable label for the render pass, used in debugging and error messages.""" +fields.color_attachments.doc = """The set of {@link GPURenderPassColorAttachment} values in this sequence defines which +color attachments will be output to when executing this render pass. +Due to compatible usage list|usage compatibility, no color attachment +may alias another attachment or any resource used inside the render pass. +""" +fields.depth_stencil_attachment.doc = """The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil +attachment that will be output to and tested against when executing this render pass. +Due to compatible usage list|usage compatibility, no writable depth/stencil attachment +may alias another attachment or any resource used inside the render pass. +""" +fields.occlusion_query_set.doc = """The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.""" +fields.timestamp_writes.doc = """Defines which timestamp values will be written for this pass, and where to write them to.""" +fields.max_draw_count.doc = """The maximum number of draw calls that will be done in the render pass. Used by some +implementations to size work injected before the render pass. Keeping the default value +is a good default, unless it is known that more draw calls will be done. +""" + +[structs.RenderPassColorAttachment] +doc = """Describes a color attachment of a render pass. + +Used in the color_attachments field of structs.RenderPassDescriptor. +""" +fields.view.doc = """Describes the texture subresource that will be output to for this color attachment. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). +""" +fields.depth_slice.doc = """Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} +that will be output to for this color attachment. +""" +fields.resolve_target.doc = """Describes the texture subresource that will receive the resolved output for this color +attachment if {@link GPURenderPassColorAttachment#view} is multisampled. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). +""" +fields.clear_value.doc = """Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the +render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored +if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. +The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. +They are converted [$to a texel value of texture format$] matching the render attachment. +If conversion fails, a validation error is generated. +""" +fields.load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to +executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +""" +fields.store_op.doc = """The store operation to perform on {@link GPURenderPassColorAttachment#view} +after executing the render pass. +""" + +[structs.RenderPassDepthStencilAttachment] +doc = """Describes the depth-stencil attachment of a render pass. + +Used in the depth_stencil_attachment field of structs.RenderPassDescriptor. +""" +fields.view.doc = """Describes the texture subresource that will be output to and read from for this +depth/stencil attachment. +The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). +""" +fields.depth_clear_value.doc = """Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component +to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} +is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. + +""" +fields.depth_load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +depth component prior to executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +""" +fields.depth_store_op.doc = """The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +depth component after executing the render pass. +""" +fields.depth_read_only.doc = """Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} +is read only. +""" +fields.stencil_clear_value.doc = """Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component +to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} +is not {@link GPULoadOp} `"clear"`. +The value will be converted to the type of the stencil aspect of `view` by taking the same +number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. +""" +fields.stencil_load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +stencil component prior to executing the render pass. +Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. +""" +fields.stencil_store_op.doc = """The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s +stencil component after executing the render pass. +""" +fields.stencil_read_only.doc = """Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} +is read only. +""" + +[structs.RenderPassLayout] +doc = """Describes the attachment formats of a render pass or render bundle. + +This is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with +passes (or bundles) whose layout is compatible with the pipeline. +""" +fields.label.doc = """A human-readable label, used in debugging and error messages.""" +fields.color_formats.doc = """A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.""" +fields.depth_stencil_format.doc = """The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.""" +fields.sample_count.doc = """Number of samples per pixel in the attachments for this pass or bundle.""" + +[structs.RenderBundleDescriptor] +doc = """Descriptor for a GPURenderBundle. + +Used as the descriptor argument of the GPURenderBundleEncoder.finish() method. +""" +fields.label.doc = """A human-readable label for the render bundle, used in debugging and error messages.""" + +[structs.RenderBundleEncoderDescriptor] +doc = """Descriptor for creating a GPURenderBundleEncoder. + +Used as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method. +Extends structs.RenderPassLayout. +""" +fields.label.doc = """A human-readable label for the render bundle encoder, used in debugging and error messages.""" +fields.color_formats.doc = """A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with.""" +fields.depth_stencil_format.doc = """The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any.""" +fields.sample_count.doc = """The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1.""" +fields.depth_read_only.doc = """If `true`, indicates that the render bundle does not modify the depth component of the +{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed +in. +See read-only depth-stencil. +""" +fields.stencil_read_only.doc = """If `true`, indicates that the render bundle does not modify the stencil component of the +{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed +in. +See read-only depth-stencil. +""" + +[structs.QueueDescriptor] +doc = """Descriptor for a GPUQueue. + +Used in the default_queue field of structs.DeviceDescriptor. +""" +fields.label.doc = """A human-readable label for the queue, used in debugging and error messages.""" + +[structs.QuerySetDescriptor] +doc = """Descriptor for creating a GPUQuerySet. + +Used as the descriptor argument of the GPUDevice.create_query_set() method. +""" +fields.label.doc = """A human-readable label for the query set, used in debugging and error messages.""" +fields.type.doc = """The type of queries managed by {@link GPUQuerySet}.""" +fields.count.doc = """The number of queries managed by {@link GPUQuerySet}.""" + +[structs.CanvasToneMapping] +doc = """Describes the tone mapping of a canvas. + +Used in the tone_mapping field of structs.CanvasConfiguration. +""" +fields.mode.doc = """The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard.""" + +[structs.CanvasConfiguration] +doc = """Configuration for a GPUCanvasContext. + +Used as the configuration argument of the GPUCanvasContext.configure() method. +""" +fields.device.doc = """The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be +compatible with. +""" +fields.format.doc = """The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. +Must be one of the Supported context formats. +""" +fields.usage.doc = """The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. +{@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included +if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} +when setting a custom usage if you wish to use textures returned by +{@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. +""" +fields.view_formats.doc = """The formats that views created from textures returned by +{@link GPUCanvasContext#getCurrentTexture} may use. +""" +fields.color_space.doc = """The color space that values written into textures returned by +{@link GPUCanvasContext#getCurrentTexture} should be displayed with. +""" +fields.tone_mapping.doc = """The tone mapping determines how the content of textures returned by +{@link GPUCanvasContext#getCurrentTexture} are to be displayed. +
+This is a required feature, but user agents might not yet implement it, +effectively supporting only the default {@link GPUCanvasToneMapping}. +In such implementations, this member **should not** exist in its implementation of +{@link GPUCanvasConfiguration}, to make feature detection possible using +{@link GPUCanvasContext#getConfiguration}. +This is especially important in implementations which otherwise have HDR capabilities +(where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be +exposed). +If an implementation exposes this member and a `high` dynamic range, it **should** render the +canvas as an HDR element, not clamp values to the SDR range of the HDR display. +
+""" +fields.alpha_mode.doc = """Determines the effect that alpha values will have on the content of textures returned by +{@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. +""" + +[structs.UncapturedErrorEventInit] +doc = """Initialization data for an uncaptured error event. + +The event is passed to the callback set via the onuncapturederror property of GPUDevice. +""" +fields.error.doc = """The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope.""" + +[structs.Color] +doc = """An RGBA color with floating point components. + +Can also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment. +""" +fields.r.doc = """The red component.""" +fields.g.doc = """The green component.""" +fields.b.doc = """The blue component.""" +fields.a.doc = """The alpha component.""" + +[structs.Origin2D] +doc = """A 2D origin (offset) in a texture or image, in texels. + +Can also be given as a tuple (x, y). +""" +fields.x.doc = """The x coordinate (horizontal). Defaults to 0.""" +fields.y.doc = """The y coordinate (vertical). Defaults to 0.""" + +[structs.Origin3D] +doc = """A 3D origin (offset) in a texture, in texels. + +Can also be given as a tuple (x, y, z). +""" +fields.x.doc = """The x coordinate (horizontal). Defaults to 0.""" +fields.y.doc = """The y coordinate (vertical). Defaults to 0.""" +fields.z.doc = """The z coordinate (depth, or array layer). Defaults to 0.""" + +[structs.Extent3D] +doc = """A 3D size (extent) of a texture, in texels. + +Can also be given as a tuple (width, height, depth_or_array_layers). +""" +fields.width.doc = """The width of the extent.""" +fields.height.doc = """The height of the extent. Defaults to 1.""" +fields.depth_or_array_layers.doc = """The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1.""" + +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +[classes] + +[classes.GPUObjectBase] +doc = """The base class of all GPU objects. + +It provides the label property that is shared by all objects in the API. +""" +properties.label.doc = """A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it.""" +[classes.GPUObjectBase.methods] + +[classes.GPUAdapterInfo] +doc = """Information about a physical adapter (GPU). + +An instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice. +The values are strings that are possibly empty if the information is not available. +""" +properties.vendor.doc = """The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'.""" +properties.architecture.doc = """The name of the family or class of GPUs the adapter belongs to.""" +properties.device.doc = """A vendor-specific identifier of the adapter.""" +properties.description.doc = """A human-readable description of the adapter, e.g. the name of the GPU.""" +properties.subgroup_min_size.doc = """The minimum supported subgroup size of the adapter.""" +properties.subgroup_max_size.doc = """The maximum supported subgroup size of the adapter.""" +properties.is_fallback_adapter.doc = """Whether this is a fallback adapter, e.g. a software renderer.""" +[classes.GPUAdapterInfo.methods] + +[classes.GPU] +doc = """The entry point of the API. + +It is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu. +""" +properties.wgsl_language_features.doc = """The set of WGSL language features that are supported by the implementation.""" +[classes.GPU.methods] +[classes.GPU.methods.request_adapter] +doc = """Requests an adapter from the user agent. +The user agent chooses whether to return an adapter, and, if so, +chooses according to the provided options. +""" +returns.doc = """A GPUAdapter, or None if no suitable adapter was found.""" +args.options.doc = """Criteria used to select the adapter.""" +[classes.GPU.methods.get_preferred_canvas_format] +doc = """Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range +content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or +{@link GPUTextureFormat} `"bgra8unorm"`. +The returned value can be passed as the {@link GPUCanvasConfiguration#format} to +{@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated +canvas is able to display its contents efficiently. +Note: Canvases which are not displayed to the screen may or may not benefit from using this +format. +""" +returns.doc = """An enums.TextureFormat, either rgba8unorm or bgra8unorm.""" + +[classes.GPUAdapter] +doc = """Represents a physical GPU (or a software implementation of one). + +An adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice, +which is used to do actual work. Adapters are obtained via GPU.request_adapter(). +""" +properties.features.doc = """The set of enums.FeatureName that the adapter supports.""" +properties.limits.doc = """A mapping of limit names to the maximum values supported by the adapter.""" +properties.info.doc = """A GPUAdapterInfo with information about the adapter.""" +[classes.GPUAdapter.methods] +[classes.GPUAdapter.methods.request_device] +doc = """Requests a device from the adapter. +This is a one-time action: if a device is returned successfully, +the adapter becomes {@link adapter#[[state]]#"consumed"}. +""" +returns.doc = """A GPUDevice.""" +args.descriptor.doc = """Description of the {@link GPUDevice} to request.""" + +[classes.GPUDevice] +doc = """The main object that is used to create GPU resources and to submit work. + +A device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue +(the queue property) which is used to submit work to the GPU. Most resources +(buffers, textures, pipelines, etc.) are created using the create_* methods of the device. +""" +properties.features.doc = """The set of enums.FeatureName that are enabled on the device.""" +properties.limits.doc = """A mapping of limit names to the values that are in effect for the device.""" +properties.adapter_info.doc = """A GPUAdapterInfo with information about the adapter that this device was created from.""" +properties.queue.doc = """The default GPUQueue of the device.""" +properties.lost.doc = """A promise or future that resolves to a GPUDeviceLostInfo when the device is lost.""" +properties.onuncapturederror.doc = """A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope.""" +[classes.GPUDevice.methods] +[classes.GPUDevice.methods.destroy] +doc = """Destroys the device, preventing further operations on it. +Outstanding asynchronous operations will fail. +Note: It is valid to destroy a device multiple times. +Note: Since no further operations can be enqueued on this device, implementations can abort +outstanding asynchronous operations immediately and free resource allocations, including +mapped memory that was just unmapped. +""" +returns.doc = """None.""" +[classes.GPUDevice.methods.create_buffer] +doc = """Creates a {@link GPUBuffer}.""" +returns.doc = """A GPUBuffer.""" +args.descriptor.doc = """Description of the {@link GPUBuffer} to create.""" +[classes.GPUDevice.methods.create_texture] +doc = """Creates a {@link GPUTexture}.""" +returns.doc = """A GPUTexture.""" +args.descriptor.doc = """Description of the {@link GPUTexture} to create.""" +[classes.GPUDevice.methods.create_sampler] +doc = """Creates a {@link GPUSampler}.""" +returns.doc = """A GPUSampler.""" +args.descriptor.doc = """Description of the {@link GPUSampler} to create.""" +[classes.GPUDevice.methods.create_bind_group_layout] +doc = """Creates a {@link GPUBindGroupLayout}.""" +returns.doc = """A GPUBindGroupLayout.""" +args.descriptor.doc = """Description of the {@link GPUBindGroupLayout} to create.""" +[classes.GPUDevice.methods.create_pipeline_layout] +doc = """Creates a {@link GPUPipelineLayout}.""" +returns.doc = """A GPUPipelineLayout.""" +args.descriptor.doc = """Description of the {@link GPUPipelineLayout} to create.""" +[classes.GPUDevice.methods.create_bind_group] +doc = """Creates a {@link GPUBindGroup}.""" +returns.doc = """A GPUBindGroup.""" +args.descriptor.doc = """Description of the {@link GPUBindGroup} to create.""" +[classes.GPUDevice.methods.create_shader_module] +doc = """Creates a {@link GPUShaderModule}.""" +returns.doc = """A GPUShaderModule.""" +args.descriptor.doc = """Description of the {@link GPUShaderModule} to create.""" +[classes.GPUDevice.methods.create_compute_pipeline] +doc = """Creates a {@link GPUComputePipeline} using immediate pipeline creation.""" +returns.doc = """A GPUComputePipeline.""" +args.descriptor.doc = """Description of the {@link GPUComputePipeline} to create.""" +[classes.GPUDevice.methods.create_render_pipeline] +doc = """Creates a {@link GPURenderPipeline} using immediate pipeline creation.""" +returns.doc = """A GPURenderPipeline.""" +args.descriptor.doc = """Description of the {@link GPURenderPipeline} to create.""" +[classes.GPUDevice.methods.create_compute_pipeline_async] +doc = """Creates a {@link GPUComputePipeline} using async pipeline creation. +The returned Promise resolves when the created pipeline +is ready to be used without additional delay. +If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. +(A {@link GPUError} is not dispatched to the device.) +Note: Use of this method is preferred whenever possible, as it prevents blocking the +queue timeline work on pipeline compilation. +""" +returns.doc = """A GPUComputePipeline (awaitable).""" +args.descriptor.doc = """Description of the {@link GPUComputePipeline} to create.""" +[classes.GPUDevice.methods.create_render_pipeline_async] +doc = """Creates a {@link GPURenderPipeline} using async pipeline creation. +The returned Promise resolves when the created pipeline +is ready to be used without additional delay. +If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. +(A {@link GPUError} is not dispatched to the device.) +Note: Use of this method is preferred whenever possible, as it prevents blocking the +queue timeline work on pipeline compilation. +""" +returns.doc = """A GPURenderPipeline (awaitable).""" +args.descriptor.doc = """Description of the {@link GPURenderPipeline} to create.""" +[classes.GPUDevice.methods.create_command_encoder] +doc = """Creates a {@link GPUCommandEncoder}.""" +returns.doc = """A GPUCommandEncoder.""" +args.descriptor.doc = """Description of the {@link GPUCommandEncoder} to create.""" +[classes.GPUDevice.methods.create_render_bundle_encoder] +doc = """Creates a {@link GPURenderBundleEncoder}.""" +returns.doc = """A GPURenderBundleEncoder.""" +args.descriptor.doc = """Description of the {@link GPURenderBundleEncoder} to create.""" +[classes.GPUDevice.methods.create_query_set] +doc = """Creates a {@link GPUQuerySet}.""" +returns.doc = """A GPUQuerySet.""" +args.descriptor.doc = """Description of the {@link GPUQuerySet} to create.""" +[classes.GPUDevice.methods.push_error_scope] +doc = """Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.""" +returns.doc = """None.""" +args.filter.doc = """Which class of errors this error scope observes.""" +[classes.GPUDevice.methods.pop_error_scope] +doc = """Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` +and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. +There is no guarantee of the ordering of promise resolution. +""" +returns.doc = """A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured.""" + +[classes.GPUBuffer] +doc = """A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage. + +Buffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or +copy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the +buffer cannot be used by the GPU while it is mapped. +""" +properties.size.doc = """The size of the buffer in bytes.""" +properties.usage.doc = """The usage of the buffer, a combination of flags.BufferUsage.""" +properties.map_state.doc = """The current mapping state of the buffer, see enums.BufferMapState.""" +[classes.GPUBuffer.methods] +[classes.GPUBuffer.methods.map_async] +doc = """Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the +{@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. +The resolution of the returned Promise **only** indicates that the buffer has been mapped. +It does not guarantee the completion of any other operations visible to the content timeline, +and in particular does not imply that any other Promise returned from +{@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s +have resolved. +The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} +**does** imply the completion of +{@link GPUBuffer#mapAsync} calls made prior to that call, +on {@link GPUBuffer}s last used exclusively on that queue. +""" +returns.doc = """None (awaitable); resolves when the buffer is mapped.""" +args.mode.doc = """Whether the buffer should be mapped for reading or writing.""" +args.offset.doc = """Offset in bytes into the buffer to the start of the range to map.""" +args.size.doc = """Size in bytes of the range to map.""" +[classes.GPUBuffer.methods.get_mapped_range] +doc = """Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.""" +returns.doc = """A writable memory view (e.g. a memoryview) on the mapped range.""" +args.offset.doc = """Offset in bytes into the buffer to return buffer contents from.""" +args.size.doc = """Size in bytes of the ArrayBuffer to return.""" +[classes.GPUBuffer.methods.unmap] +doc = """Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the +GPU again. +""" +returns.doc = """None.""" +[classes.GPUBuffer.methods.destroy] +doc = """Destroys the {@link GPUBuffer}. +Note: It is valid to destroy a buffer multiple times. +Note: Since no further operations can be enqueued using this buffer, implementations can +free resource allocations, including mapped memory that was just unmapped. +""" +returns.doc = """None.""" + +[classes.GPUTexture] +doc = """An image resource of one, two or three dimensions, optionally with mip levels and array layers. + +Textures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render +attachment, create a GPUTextureView with create_view(). +""" +properties.width.doc = """The width of the texture in texels.""" +properties.height.doc = """The height of the texture in texels.""" +properties.depth_or_array_layers.doc = """The depth (for 3D textures) or the number of array layers of the texture.""" +properties.mip_level_count.doc = """The number of mip levels of the texture.""" +properties.sample_count.doc = """The number of samples per pixel of the texture (1 unless multisampled).""" +properties.dimension.doc = """The dimensionality of the texture, see enums.TextureDimension.""" +properties.format.doc = """The pixel format of the texture, see enums.TextureFormat.""" +properties.usage.doc = """The allowed usages of the texture, a combination of flags.TextureUsage.""" +properties.texture_binding_view_dimension.doc = """Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding.""" +[classes.GPUTexture.methods] +[classes.GPUTexture.methods.create_view] +doc = """Creates a {@link GPUTextureView}.""" +returns.doc = """A GPUTextureView.""" +args.descriptor.doc = """Description of the {@link GPUTextureView} to create.""" +[classes.GPUTexture.methods.destroy] +doc = """Destroys the {@link GPUTexture}.""" +returns.doc = """None.""" + +[classes.GPUTextureView] +doc = """A view on (a part of) a GPUTexture. + +Texture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry) +and as render pass attachments (see structs.RenderPassColorAttachment). +""" +[classes.GPUTextureView.methods] + +[classes.GPUSampler] +doc = """Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture. + +Samplers are created with GPUDevice.create_sampler(). +""" +[classes.GPUSampler.methods] + +[classes.GPUBindGroupLayout] +doc = """Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup. + +Bind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline +via GPUPipelineBase.get_bind_group_layout(). +""" +[classes.GPUBindGroupLayout.methods] + +[classes.GPUBindGroup] +doc = """A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout. + +Bind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group(). +""" +[classes.GPUBindGroup.methods] + +[classes.GPUPipelineLayout] +doc = """Describes the bind group layouts (and immediate data size) that a pipeline uses. + +Pipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto. +""" +[classes.GPUPipelineLayout.methods] + +[classes.GPUShaderModule] +doc = """A compiled piece of shader code (WGSL), containing one or more entry points. + +Shader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage). +""" +[classes.GPUShaderModule.methods] +[classes.GPUShaderModule.methods.get_compilation_info] +doc = """Returns any messages generated during the {@link GPUShaderModule}'s compilation. +The locations, order, and contents of messages are implementation-defined. +In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. +""" +returns.doc = """A GPUCompilationInfo (awaitable) with the list of messages.""" + +[classes.GPUCompilationMessage] +doc = """A single diagnostic message produced when compiling a shader module. + +The messages are available via the messages property of GPUCompilationInfo. +""" +properties.message.doc = """The human-readable text of the message.""" +properties.type.doc = """The severity of the message, see enums.CompilationMessageType.""" +properties.line_num.doc = """The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line.""" +properties.line_pos.doc = """The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position.""" +properties.offset.doc = """The offset in the shader code (in UTF-16 code units) that the message refers to.""" +properties.length.doc = """The length (in UTF-16 code units) of the span in the shader code that the message refers to.""" +[classes.GPUCompilationMessage.methods] + +[classes.GPUCompilationInfo] +doc = """The diagnostic messages produced when compiling a shader module. + +Obtained from GPUShaderModule.get_compilation_info(). +""" +properties.messages.doc = """A list of GPUCompilationMessage objects.""" +[classes.GPUCompilationInfo.methods] + +[classes.GPUPipelineError] +doc = """The error that is raised when asynchronous pipeline creation fails. + +Raised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async(). +""" +properties.reason.doc = """The reason for the failure, see enums.PipelineErrorReason.""" +[classes.GPUPipelineError.methods] +[classes.GPUPipelineError.methods.constructor] +doc = """Create a GPUPipelineError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = """A GPUPipelineError.""" +args.message.doc = """The human-readable error message.""" +args.options.doc = """A structs.PipelineErrorInit with the reason of the error.""" + +[classes.GPUPipelineBase] +doc = """The base class for GPUComputePipeline and GPURenderPipeline. + +It provides access to the bind group layouts of the pipeline. +""" +[classes.GPUPipelineBase.methods] +[classes.GPUPipelineBase.methods.get_bind_group_layout] +doc = """Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s +{@link GPUBindGroupLayout} at `index`. +""" +returns.doc = """A GPUBindGroupLayout.""" +args.index.doc = """Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` sequence.""" + +[classes.GPUComputePipeline] +doc = """A pipeline that describes a compute shader and its resources. + +Created with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline(). +""" +[classes.GPUComputePipeline.methods] + +[classes.GPURenderPipeline] +doc = """A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending. + +Created with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline(). +""" +[classes.GPURenderPipeline.methods] + +[classes.GPUCommandBuffer] +doc = """A recorded list of GPU commands, ready to be submitted. + +Obtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once. +""" +[classes.GPUCommandBuffer.methods] + +[classes.GPUCommandsMixin] +doc = """A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +It has no methods of its own in the current version of the API. +""" +[classes.GPUCommandsMixin.methods] + +[classes.GPUCommandEncoder] +doc = """Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer. + +Create one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit(). +Only one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands. +""" +[classes.GPUCommandEncoder.methods] +[classes.GPUCommandEncoder.methods.begin_render_pass] +doc = """Begins encoding a render pass described by `descriptor`.""" +returns.doc = """A GPURenderPassEncoder.""" +args.descriptor.doc = """Description of the {@link GPURenderPassEncoder} to create.""" +[classes.GPUCommandEncoder.methods.begin_compute_pass] +doc = """Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with. + +The pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again. +""" +returns.doc = """A GPUComputePassEncoder.""" +args.descriptor.doc = """A structs.ComputePassDescriptor. Optional.""" +[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] +doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a +{@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. +""" +returns.doc = """None.""" +args.source.doc = """The {@link GPUBuffer} to copy from.""" +args.source_offset.doc = """Offset in bytes into `source` to begin copying from.""" +args.destination.doc = """The {@link GPUBuffer} to copy to.""" +args.destination_offset.doc = """Offset in bytes into `destination` to place the copied data.""" +args.size.doc = """Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.""" +[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] +doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a +{@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. +""" +returns.doc = """None.""" +args.source.doc = """Combined with `copySize`, defines the region of the source buffer.""" +args.destination.doc = """Combined with `copySize`, defines the region of the destination texture subresource. `copySize`:""" +args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" +[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] +doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or +multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. +""" +returns.doc = """None.""" +args.source.doc = """Combined with `copySize`, defines the region of the source texture subresources.""" +args.destination.doc = """Combined with `copySize`, defines the region of the destination buffer. `copySize`:""" +args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" +[classes.GPUCommandEncoder.methods.copy_texture_to_texture] +doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one +or multiple contiguous texture subresources to another sub-region of one or +multiple continuous texture subresources. +""" +returns.doc = """None.""" +args.source.doc = """Combined with `copySize`, defines the region of the source texture subresources.""" +args.destination.doc = """Combined with `copySize`, defines the region of the destination texture subresources. `copySize`:""" +args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" +[classes.GPUCommandEncoder.methods.clear_buffer] +doc = """Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a +{@link GPUBuffer} with zeros. +""" +returns.doc = """None.""" +args.buffer.doc = """The {@link GPUBuffer} to clear.""" +args.offset.doc = """Offset in bytes into `buffer` where the sub-region to clear begins.""" +args.size.doc = """Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.""" +[classes.GPUCommandEncoder.methods.resolve_query_set] +doc = """Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. + querySet: + firstQuery: + queryCount: + destination: + destinationOffset: +""" +returns.doc = """None.""" +args.query_set.doc = """The GPUQuerySet to read results from.""" +args.first_query.doc = """The index of the first query to resolve.""" +args.query_count.doc = """The number of queries to resolve.""" +args.destination.doc = """The GPUBuffer to write the results to.""" +args.destination_offset.doc = """The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256.""" +[classes.GPUCommandEncoder.methods.finish] +doc = """Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. + descriptor: +""" +returns.doc = """A GPUCommandBuffer.""" +args.descriptor.doc = """A structs.CommandBufferDescriptor. Optional.""" + +[classes.GPUBindingCommandsMixin] +doc = """A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +It provides methods to set bind groups and immediate data. +""" +[classes.GPUBindingCommandsMixin.methods] +[classes.GPUBindingCommandsMixin.methods.set_bind_group] +doc = """Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset +of a Uint32Array. +""" +returns.doc = """None.""" +args.index.doc = """The index to set the bind group at.""" +args.bind_group.doc = """Bind group to use for subsequent render or compute commands.""" +args.dynamic_offsets_data.doc = """Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.""" +args.dynamic_offsets_data_start.doc = """Offset in elements into `dynamicOffsetsData` where the buffer offset data begins.""" +args.dynamic_offsets_data_length.doc = """Number of buffer offsets to read from `dynamicOffsetsData`.""" +[classes.GPUBindingCommandsMixin.methods.set_immediates] +doc = """Sets immediate data for subsequent render or compute commands.""" +returns.doc = """None.""" +args.range_offset.doc = """Offset in bytes into the immediate data range to begin writing at.""" +args.data.doc = """Data to write into the immediate data range.""" +args.data_offset.doc = """Offset into `data` to begin writing from. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.""" +args.data_size.doc = """Size of content to write from `data`. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.""" + +[classes.GPUDebugCommandsMixin] +doc = """A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. + +Debug groups and markers show up in debugging tools and in error messages. +""" +[classes.GPUDebugCommandsMixin.methods] +[classes.GPUDebugCommandsMixin.methods.push_debug_group] +doc = """Begins a labeled debug group containing subsequent commands.""" +returns.doc = """None.""" +args.group_label.doc = """The label for the command group.""" +[classes.GPUDebugCommandsMixin.methods.pop_debug_group] +doc = """Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.""" +returns.doc = """None.""" +[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] +doc = """Marks a point in a stream of commands with a label.""" +returns.doc = """None.""" +args.marker_label.doc = """The label to insert.""" + +[classes.GPUComputePassEncoder] +doc = """Records the commands of a compute pass. + +Created with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work, +and finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin. +""" +[classes.GPUComputePassEncoder.methods] +[classes.GPUComputePassEncoder.methods.set_pipeline] +doc = """Sets the current {@link GPUComputePipeline}.""" +returns.doc = """None.""" +args.pipeline.doc = """The compute pipeline to use for subsequent dispatch commands.""" +[classes.GPUComputePassEncoder.methods.dispatch_workgroups] +doc = """Dispatch work to be performed with the current {@link GPUComputePipeline}. +See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. +""" +returns.doc = """None.""" +args.workgroup_count_x.doc = """X dimension of the grid of workgroups to dispatch.""" +args.workgroup_count_y.doc = """Y dimension of the grid of workgroups to dispatch.""" +args.workgroup_count_z.doc = """Z dimension of the grid of workgroups to dispatch.""" +[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] +doc = """Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read +from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. +packed block of **three 32-bit unsigned integer values (12 bytes total)**, +given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. +For example: +""" +returns.doc = """None.""" +args.indirect_buffer.doc = """Buffer containing the indirect dispatch parameters.""" +args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the dispatch data begins.""" +[classes.GPUComputePassEncoder.methods.end] +doc = """Completes recording of the compute pass commands sequence.""" +returns.doc = """None.""" + +[classes.GPURenderPassEncoder] +doc = """Records the commands of a render pass. + +Created with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers, +draw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin. +""" +[classes.GPURenderPassEncoder.methods] +[classes.GPURenderPassEncoder.methods.set_viewport] +doc = """Sets the viewport used during the rasterization stage to linearly map from +NDC|normalized device coordinates to viewport coordinates. +""" +returns.doc = """None.""" +args.x.doc = """Minimum X value of the viewport in pixels.""" +args.y.doc = """Minimum Y value of the viewport in pixels.""" +args.width.doc = """Width of the viewport in pixels.""" +args.height.doc = """Height of the viewport in pixels.""" +args.min_depth.doc = """Minimum depth value of the viewport.""" +args.max_depth.doc = """Maximum depth value of the viewport.""" +[classes.GPURenderPassEncoder.methods.set_scissor_rect] +doc = """Sets the scissor rectangle used during the rasterization stage. +After transformation into viewport coordinates any fragments which fall outside the scissor +rectangle will be discarded. +""" +returns.doc = """None.""" +args.x.doc = """Minimum X value of the scissor rectangle in pixels.""" +args.y.doc = """Minimum Y value of the scissor rectangle in pixels.""" +args.width.doc = """Width of the scissor rectangle in pixels.""" +args.height.doc = """Height of the scissor rectangle in pixels.""" +[classes.GPURenderPassEncoder.methods.set_blend_constant] +doc = """Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` +and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. +""" +returns.doc = """None.""" +args.color.doc = """The color to use when blending.""" +[classes.GPURenderPassEncoder.methods.set_stencil_reference] +doc = """Sets the RenderState.`[[stencilReference]]` value used during stencil tests with +the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. +""" +returns.doc = """None.""" +args.reference.doc = """The new stencil reference value.""" +[classes.GPURenderPassEncoder.methods.begin_occlusion_query] +doc = """Begin an occlusion query, which counts the samples that pass the depth and stencil tests. + +The result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor). +End the query with end_occlusion_query(). +""" +returns.doc = """None.""" +args.query_index.doc = """The index of the query in the query set.""" +[classes.GPURenderPassEncoder.methods.end_occlusion_query] +doc = """End the occlusion query that was started with begin_occlusion_query(). +""" +returns.doc = """None.""" +[classes.GPURenderPassEncoder.methods.execute_bundles] +doc = """Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of +this render pass. +When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind +groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render +pass's pipeline, bind group, and vertex/index buffer state is cleared +(to the initial, empty values). +Note: The state is cleared, not restored to the previous state. +This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. +""" +returns.doc = """None.""" +args.bundles.doc = """List of render bundles to execute.""" +[classes.GPURenderPassEncoder.methods.end] +doc = """Completes recording of the render pass commands sequence.""" +returns.doc = """None.""" + +[classes.GPURenderCommandsMixin] +doc = """A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder. + +It provides methods to set the pipeline, vertex and index buffers, and to draw. +""" +[classes.GPURenderCommandsMixin.methods] +[classes.GPURenderCommandsMixin.methods.set_pipeline] +doc = """Sets the current {@link GPURenderPipeline}.""" +returns.doc = """None.""" +args.pipeline.doc = """The render pipeline to use for subsequent drawing commands.""" +[classes.GPURenderCommandsMixin.methods.set_index_buffer] +doc = """Sets the current index buffer.""" +returns.doc = """None.""" +args.buffer.doc = """Buffer containing index data to use for subsequent drawing commands.""" +args.index_format.doc = """Format of the index data contained in `buffer`.""" +args.offset.doc = """Offset in bytes into `buffer` where the index data begins. Defaults to `0`.""" +args.size.doc = """Size in bytes of the index data in `buffer`. Defaults to the size of the buffer minus the offset.""" +[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] +doc = """Sets the current vertex buffer for the given slot.""" +returns.doc = """None.""" +args.slot.doc = """The vertex buffer slot to set the vertex buffer for.""" +args.buffer.doc = """Buffer containing vertex data to use for subsequent drawing commands.""" +args.offset.doc = """Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.""" +args.size.doc = """Size in bytes of the vertex data in `buffer`. Defaults to the size of the buffer minus the offset.""" +[classes.GPURenderCommandsMixin.methods.draw] +doc = """Draws primitives. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +""" +returns.doc = """None.""" +args.vertex_count.doc = """The number of vertices to draw.""" +args.instance_count.doc = """The number of instances to draw.""" +args.first_vertex.doc = """Offset into the vertex buffers, in vertices, to begin drawing from.""" +args.first_instance.doc = """First instance to draw.""" +[classes.GPURenderCommandsMixin.methods.draw_indexed] +doc = """Draws indexed primitives. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +""" +returns.doc = """None.""" +args.index_count.doc = """The number of indices to draw.""" +args.instance_count.doc = """The number of instances to draw.""" +args.first_index.doc = """Offset into the index buffer, in indices, begin drawing from.""" +args.base_vertex.doc = """Added to each index value before indexing into the vertex buffers.""" +args.first_instance.doc = """First instance to draw.""" +[classes.GPURenderCommandsMixin.methods.draw_indirect] +doc = """Draws primitives using parameters read from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same +order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: +""" +returns.doc = """None.""" +args.indirect_buffer.doc = """Buffer containing the indirect draw parameters.""" +args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the drawing data begins.""" +[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] +doc = """Draws indexed primitives using parameters read from a {@link GPUBuffer}. +See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. +tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in +the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: +""" +returns.doc = """None.""" +args.indirect_buffer.doc = """Buffer containing the indirect drawIndexed parameters.""" +args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the drawing data begins.""" + +[classes.GPURenderBundle] +doc = """A pre-recorded sequence of render commands that can be executed in render passes. + +Obtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles(). +""" +[classes.GPURenderBundle.methods] + +[classes.GPURenderBundleEncoder] +doc = """Records render commands into a GPURenderBundle, which can be replayed in multiple render passes. + +Created with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin, +GPUDebugCommandsMixin and GPURenderCommandsMixin. +""" +[classes.GPURenderBundleEncoder.methods] +[classes.GPURenderBundleEncoder.methods.finish] +doc = """Completes recording of the render bundle commands sequence. + descriptor: +""" +returns.doc = """A GPURenderBundle.""" +args.descriptor.doc = """A structs.RenderBundleDescriptor. Optional.""" + +[classes.GPUQueue] +doc = """The queue on which work is submitted to the GPU. + +Each GPUDevice has a default queue, available via the queue property of GPUDevice. +It is used to submit command buffers and to upload data to buffers and textures. +""" +[classes.GPUQueue.methods] +[classes.GPUQueue.methods.submit] +doc = """Schedules the execution of the command buffers by the GPU on this queue. +Submitted command buffers cannot be used again. + `commandBuffers`: +""" +returns.doc = """None.""" +args.command_buffers.doc = """A list of GPUCommandBuffer objects, executed in order.""" +[classes.GPUQueue.methods.on_submitted_work_done] +doc = """Returns a Promise that resolves once this queue finishes processing all the work submitted +up to this moment. +Resolution of this Promise implies the completion of +{@link GPUBuffer#mapAsync} calls made prior to that call, +on {@link GPUBuffer}s last used exclusively on that queue. +""" +returns.doc = """None (awaitable); resolves when the submitted work is done.""" +[classes.GPUQueue.methods.write_buffer] +doc = """Issues a write operation of the provided data into a {@link GPUBuffer}.""" +returns.doc = """None.""" +args.buffer.doc = """The buffer to write to.""" +args.buffer_offset.doc = """Offset in bytes into `buffer` to begin writing at.""" +args.data.doc = """Data to write into `buffer`.""" +args.data_offset.doc = """Offset in into `data` to begin writing from. Given in elements if `data` is a `TypedArray` and bytes otherwise.""" +args.size.doc = """Size of content to write from `data` to `buffer`. Given in elements if `data` is a `TypedArray` and bytes otherwise.""" +[classes.GPUQueue.methods.write_texture] +doc = """Issues a write operation of the provided data into a {@link GPUTexture}.""" +returns.doc = """None.""" +args.destination.doc = """The texture subresource and origin to write to.""" +args.data.doc = """Data to write into `destination`.""" +args.data_layout.doc = """Layout of the content in `data`.""" +args.size.doc = """Extents of the content to write from `data` to `destination`.""" + +[classes.GPUQuerySet] +doc = """A set of queries that hold results such as occlusion counts or timestamps. + +Created with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving +them into a buffer with GPUCommandEncoder.resolve_query_set(). +""" +properties.type.doc = """The type of queries in the set, see enums.QueryType.""" +properties.count.doc = """The number of queries in the set.""" +[classes.GPUQuerySet.methods] +[classes.GPUQuerySet.methods.destroy] +doc = """Destroys the {@link GPUQuerySet}.""" +returns.doc = """None.""" + +[classes.GPUCanvasContext] +doc = """The connection between a canvas (or window) and the GPU, used to present rendered images. + +Configure it with configure(), then each frame obtain a texture with get_current_texture(), +render to it, and submit the work. The result is presented when the frame ends. +""" +properties.canvas.doc = """The canvas (or window/surface object) that this context belongs to.""" +[classes.GPUCanvasContext.methods] +[classes.GPUCanvasContext.methods.configure] +doc = """Configures the context for this canvas. +This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). +See {@link GPUCanvasContext#getConfiguration} for information on feature detection. +""" +returns.doc = """None.""" +args.configuration.doc = """Desired configuration for the context.""" +[classes.GPUCanvasContext.methods.unconfigure] +doc = """Removes the context configuration. Destroys any textures produced while configured.""" +returns.doc = """None.""" +[classes.GPUCanvasContext.methods.get_configuration] +doc = """Returns the context configuration, or `null` if the context is not configured. +Note: +This method exists primarily for feature detection of members (and sub-members) of +{@link GPUCanvasConfiguration}; see those members for details. +For supported members, it returns the originally-supplied values. +""" +returns.doc = """The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured.""" +[classes.GPUCanvasContext.methods.get_current_texture] +doc = """Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} +next. +Note: The same {@link GPUTexture} object will be returned by every +call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" +runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. +""" +returns.doc = """A GPUTexture.""" + +[classes.GPUDeviceLostInfo] +doc = """Information about why a GPUDevice was lost. + +Available via the lost property of GPUDevice. +""" +properties.reason.doc = """The reason the device was lost, see enums.DeviceLostReason.""" +properties.message.doc = """A human-readable message with details about why the device was lost.""" +[classes.GPUDeviceLostInfo.methods] + +[classes.GPUError] +doc = """The base class of errors that are generated by the GPU API. + +Subclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError. +Errors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice. +""" +properties.message.doc = """A human-readable description of the error.""" +[classes.GPUError.methods] + +[classes.GPUValidationError] +doc = """An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage. + +Captured by error scopes with enums.ErrorFilter.validation. +""" +[classes.GPUValidationError.methods] +[classes.GPUValidationError.methods.constructor] +doc = """Create a GPUValidationError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = """A GPUValidationError.""" +args.message.doc = """The human-readable error message.""" + +[classes.GPUOutOfMemoryError] +doc = """An error that signals that there was not enough memory to complete an operation. + +Captured by error scopes with enums.ErrorFilter.out_of_memory. +""" +[classes.GPUOutOfMemoryError.methods] +[classes.GPUOutOfMemoryError.methods.constructor] +doc = """Create a GPUOutOfMemoryError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = """A GPUOutOfMemoryError.""" +args.message.doc = """The human-readable error message.""" + +[classes.GPUInternalError] +doc = """An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit. + +Captured by error scopes with enums.ErrorFilter.internal. +""" +[classes.GPUInternalError.methods] +[classes.GPUInternalError.methods.constructor] +doc = """Create a GPUInternalError. + +Normally these are created by the implementation rather than by user code. +""" +returns.doc = """A GPUInternalError.""" +args.message.doc = """The human-readable error message.""" diff --git a/apigen/download.py b/apigen/download.py new file mode 100644 index 00000000..21daf913 --- /dev/null +++ b/apigen/download.py @@ -0,0 +1,40 @@ +import urllib.request +from apigen_utils import DEFINITIONS_DIR + + +def download_idl(): + url = ( + "https://raw.githubusercontent.com/gpuweb/gpuweb/refs/heads/gh-pages/webgpu.idl" + ) + + with urllib.request.urlopen(url, timeout=10) as response: + data = response.read() + + filename = DEFINITIONS_DIR / "webgpu.idl" + + with open(filename, "wb") as f: + f.write(data) + + print(f"Wrote to {filename}") + + +def download_ts(): + # Typescript type definition with docs + url = ( + "https://raw.githubusercontent.com/gpuweb/types/refs/heads/main/dist/index.d.ts" + ) + + with urllib.request.urlopen(url, timeout=10) as response: + data = response.read() + + filename = DEFINITIONS_DIR / "index.d.ts" + + with open(filename, "wb") as f: + f.write(data) + + print(f"Wrote to {filename}") + + +if __name__ == "__main__": + # download_idl() + download_ts() diff --git a/apigen/parse_idl.py b/apigen/parse_idl.py new file mode 100644 index 00000000..a3d0a4ab --- /dev/null +++ b/apigen/parse_idl.py @@ -0,0 +1,609 @@ +""" Parse the webgpu.idl to create wgpu_api_web.toml""" + +from typing import Literal + +from apigen_utils import read_file, read_definition_file, DEFINITIONS_DIR, to_snake_case + + +def parse_idl_to_toml(): + """Parse the IDL specification to a structured form in toml.""" + + # TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure + + # Get the source, and parse into a structure. + source = read_file("apigen", "definitions", "webgpu.idl") + parser = IdlParser(source) + parser.parse() + + # Generate TOML + + fname = "wgpu_api_web.toml" + hline = "# " + '-' * 80 + hline3 = "\n" + hline + "\n" + hline + "\n" + hline + + toml_lines = [ + f"# {fname}: Python-flavored WebGPU API, generated from 'webgpu.idl'.", + "# All types are converted to the Python equivalents.", + "# All names are made Pythonic snake_case.", + "# Methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly.", + ] + toml_lines.append(hline3) + toml_lines.append("[flags]") + for flag_name, d in parser.flags.items(): + toml_lines.append(f"\n[flags.{flag_name}]") + for k, v in d.items(): + toml_lines.append(f"fields.{k} = {{ value = {v!r} }}") + + toml_lines.append(hline3) + toml_lines.append("[enums]") + for enum_name, d in parser.enums.items(): + toml_lines.append(f"\n[enums.{enum_name}]") + for k, v in d.items(): + toml_lines.append(f"fields.{k} = {{ value = {v!r} }}") + + toml_lines.append(hline3) + toml_lines.append("[structs]") + for struct_name, d in parser.structs.items(): + toml_lines.append(f"\n[structs.{struct_name}]") + for att in d.values(): + toml_lines.append(f"fields.{att.py_name} = {att.to_toml()}") + + toml_lines.append(hline3) + toml_lines.append("[classes]") + for class_name, interface in parser.classes.items(): + toml_lines.append(f"\n[classes.{class_name}]") + toml_lines.append(f"bases = {interface.bases!r}") + for prop_name, attr_type in interface.properties.items(): + toml_lines.append(f"properties.{prop_name} = {{ type = {attr_type!r} }}") + toml_lines.append(f"[classes.{class_name}.methods]") + for func in interface.methods.values(): + toml_lines.append(f"[classes.{class_name}.methods.{func.py_name}]") + toml_lines.append(f"returns = {{ type = '{func.return_type}' }}") + for attribute in func.args: + toml_lines.append(f"args.{attribute.py_name} = {attribute.to_toml()}") + + # Write + + toml_lines.append("") + toml = "\n".join(toml_lines) + + + with open(DEFINITIONS_DIR / fname, "wb") as f: + f.write(toml.encode()) + + # Check that file is correct toml and structure + read_definition_file(fname) + + +class Attribute: + """A little object to hold a function argument or struct field.""" + + def __init__(self, line: str, source: Literal["struct", "param"]): + self.line = line.strip().strip(",;").strip() + self.source = source + + # Detect default value + default = None + arg = self.line + if "=" in arg: + arg, default = arg.rsplit("=", 1) + arg, default = arg.strip(), default.strip() + if default and default in ["false", "true"]: + default = default.capitalize() + arg_type, arg_name = arg.strip().rsplit(" ", 1) + + # Handling required vs optional differs between structs fields and function params. + # Struct fields are optional unless marked as required, see https://webidl.spec.whatwg.org/#required-dictionary-member + # Function params are required unless marked as optional, see https://webidl.spec.whatwg.org/#dfn-optional-argument + if source == "struct": + if arg_type.startswith("required "): + required = True + arg_type = arg_type.split(" ", 1)[1] + # required args should not have a default + assert default is None + else: + required = False + # default could still be None, i.e. struct field can be omitted + elif source == "param": + if arg_type.startswith("optional "): + required = False + arg_type = arg_type.split(" ", 1)[1] + default = default or "None" + else: + # but otherwise they are required + required = True + assert default is None + else: + raise RuntimeError(f"Invalid Attribute source: {source!r}") + + self.name = arg_name + self.py_name = None + self.idl_type = arg_type + self.py_type = "unresolved_type!" + self.default = default + self.required = required + + def __repr__(self): + return f"" + + def to_str(self) -> str: + return self.line + + def to_toml(self) -> str: + return f"{{ type = '{self.py_type}', default = '{self.default}', required = {repr(self.required).lower()} }}" + + +class Interface: + """A class definition, or a flag/bitmask during parsing.""" + + def __init__(self, name, bases): + self.bases = bases + self.constants = {} + self.properties = {} # name -> type + self.methods = {} + + +class Function: + """A function definition.""" + def __init__(self, name, line): + self.name = name + self.line = line + self.py_name = None + self.args = None + self.return_type = None + + +class IdlParser: + """An object that can be used to walk over a str in an easy way. + + This parser has the following attributes: + + * flags: a dict mapping the (neutral) flag name to a dict of field-value pairs. + * enums: a dict mapping the (Pythonic) enum name to a dict of field-value pairs. + * structs: a dict mapping the (Pythonic) struct name to a dict of Attribute + objects. + * classes: a dict mapping the (normalized) class name an Interface object. + + """ + + def __init__(self, source): + self.source = self._pre_process(source) + self._length = len(self.source) + self._pos = 0 + + def _reset(self): + self._pos = 0 + + def _end_reached(self): + return self._pos >= self._length + + def _read_until(self, char): + start = self._pos + while self._pos < self._length: + c = self.source[self._pos] + self._pos += 1 + if c == char: + return self.source[start : self._pos] + return "" + + def _read_line(self): + return self._read_until("\n") + + def _peek_line(self): + char = "\n" + start = pos = self._pos + while pos < self._length: + c = self.source[pos] + pos += 1 + if c == char: + return self.source[start:pos] + return "" + + def parse(self, verbose=True): + """Parse the IDL file and build up an internal structure. + """ + self._interfaces = {} + self.classes = {} + self.structs = {} + self.flags = {} + self.enums = {} + + self.typedefs = {} + + self._reset() + self._parse() + self._post_process() + + if verbose: + f_count = sum(len(cls.methods) for cls in self.classes.values()) + print( + f"The webgpu.idl defines {len(self.classes)} classes with {f_count} methods" + ) + keys = "flags", "enums", "structs" + stats = ", ".join(f"{len(getattr(self, key))} {key}" for key in keys) + print("The webgpu.idl defines " + stats) + + def _pre_process(self, text): + """Pre-process the text to make it a bit easier to parse. + Be careful to keep line numbers the same + """ + text = text.replace("\n[\n", "\n\n[").replace("\n]\n", "]\n\n") + text = text.replace("[ ", "[") + text = self._remove_comments(text) + return text + + def _remove_comments(self, text): + lines = [] + in_multiline_comment = False + for line in text.splitlines(): + if in_multiline_comment: + if "*/" in line: + _, _, line = line.partition("//") + if "//" in line: + line, _, _ = line.partition("//") + lines.append(line if line.strip() else "") + in_multiline_comment = False + else: + lines.append("") + else: + if "//" in line: + line, _, _ = line.partition("//") + lines.append(line if line.strip() else "") + elif "/*" in line: + line, _, _ = line.partition("/*") + lines.append(line if line.strip() else "") + in_multiline_comment = True + else: + lines.append(line) + return "\n".join(lines) + + def _parse(self): + while not self._end_reached(): + line = self._read_line() + + if not line.strip(): + pass + elif line.startswith("typedef "): + # Get the important bit + value = line.split(" ", 1)[-1] + if value.startswith("["): + value = value.split("]")[-1] + # Parse + if value.startswith("("): # Union type + while ")" not in value: + value = value.rstrip() + " " + self._read_line().lstrip() + assert value.count("(") == 1 and value.count(")") == 1 + value = value.split("(")[1] + val, _, key = value.partition(")") + else: # Singleton type + val, _, key = value.rpartition(" ") + key = key.strip().strip(";").strip() + self.typedefs[key] = val.strip() + elif line.startswith(("namespace ", "interface ", "partial interface ")): + # A class or a set of flags, we don't know yet, and resolve it during post-processing + # Collect lines that define this interface + while "{" not in line: + line = line.rstrip() + " " + self._read_line().lstrip() + lines = [line] + while not line.startswith("};"): + line = self._read_line() + lines.append(line) + classname_raw, _, base_raw = lines[0].split("{")[0].partition(":") + classname = classname_raw.split()[-1] + # Collect base classes + based_on = list(base_raw.split()) + while self._peek_line().startswith(classname + " includes "): + line = self._read_line() + based_on.append(line.split()[-1].rstrip(";")) + # Create / get interface object + if classname not in self._interfaces: + self._interfaces[classname] = Interface(classname, based_on) + interface = self._interfaces[classname] + # Parse members + line_index = 0 + while line_index < len(lines) - 1: + line_index += 1 + line = lines[line_index].strip() + if not line: + continue + elif line.startswith("[Exposed="): + continue + elif line.startswith("const "): + parts = line.strip(";").split() + assert len(parts) == 5 + assert parts[-2] == "=" + name = parts[2] + val = int(parts[-1], 16) + interface.constants[name] = val + elif "attribute " in line: + subline = line.partition("attribute")[2].strip().strip(";") + name = subline.split()[-1] + type = subline.split(name)[0].strip() + interface.properties[name] = type + elif "(" in line: + line = lines[line_index] + while line.count("(") > line.count(")"): + line_index += 1 + line += lines[line_index] + assert line.count("(") == line.count(")") + line = line.strip() + line.replace("\n", " ") + for c in (" ", " ", " "): + line = line.replace(c, " ") + assert line.endswith(";") + funcname = line.split("(")[0].split()[-1] + line = ( + line.replace("\n", " ") + .replace(" ", " ") + .replace(" ", " ") + ) + interface.methods[funcname] = Function(funcname, line) + elif " includes " in line: + # Definition of class inheretance + parts = line.strip(";").split() + assert len(parts) == 3 and parts[1] == "includes" + classname, _, base = parts + if classname not in self._interfaces: + self._interfaces[classname] = Interface(classname, []) + self._interfaces[classname].bases.append(parts[2]) + elif line.startswith("enum "): + # Enums + line += self._read_until("}") + self._read_line() + lines = line.strip().split("\n") + name = lines[0].split(" ", 1)[1].strip("{ \t\r\n") + d = {} + for i, line in enumerate(lines[1:-1]): + line = line.strip() + if not line or line.startswith("//"): + continue + key = val = line.strip('", \t') + for i1, i2 in [ + ("-", "_"), + ("1d", "d1"), + ("2d", "d2"), + ("3d", "d3"), + ]: + key = key.replace(i1, i2) + d[key] = val + self.enums[name] = d + elif line.startswith("dictionary "): + # Structs / descriptors + while "{" not in line: + line = line.rstrip() + self._read_line() + assert line.count("{") == 1 and line.count("}") == 0 + lines = [line] + while not line.startswith("};"): + line = self._read_line() + lines.append(line) + name = lines[0].split(" ", 1)[1].strip("{ \t\r\n") + if ":" in name: + name, _, base = name.partition(":") + name, base = name.strip(), base.strip() + if base not in self.structs: + # print(f"dict {name} has unknown base dict {base}") + d = {} + else: + d = self.structs[base].copy() + else: + d = {} + for line in lines[1:-1]: + line = line.split("//")[0].strip() + if not line: + continue + assert line.endswith(";") + + attribute = Attribute(line, "struct") + d[attribute.name] = attribute + self.structs[name] = d + elif line.startswith(("[Exposed=", "[Serializable]")): + pass + else: + raise RuntimeError("Unknown line:", line.rstrip()) + + def _post_process(self): + """We don't do any name format normalization in the parser code itself; + we do that here. + """ + + # Drop some toplevel names + # TODO: drop in apidiff + for name in [ + "NavigatorGPU", + "GPUSupportedLimits", + "GPUSupportedFeatures", + "WGSLLanguageFeatures", + "GPUUncapturedErrorEvent", + "GPUExternalTexture", + ]: + self._interfaces.pop(name, None) + + # Divide flags and class definitions + for name, interface in self._interfaces.items(): + if interface.constants: + self.flags[name] = interface.constants + elif name in ("Navigator", "WorkerNavigator"): + pass + else: + delattr(interface, "constants") + self.classes[name] = interface + + # Remove GPU prefix + for d in (self.structs, self.flags, self.enums): + for name in list(d.keys()): + assert name.startswith("GPU") + new_name = name[3:] + if new_name.endswith("Dict"): + new_name = new_name[:-4] + d[new_name] = d.pop(name) + + # Remove (abstract) base structs + for name in list(self.structs): + if name.endswith("Base"): + self.structs.pop(name) + + # Resolve struct types + for name, args in self.structs.items(): + for _fieldname, arg in args.items(): + arg.py_type = self.resolve_type(arg.idl_type) + arg.py_name = to_snake_case(arg.name) + + # Resolve classes: attribyte types and method signatures + for classname, interface in self.classes.items(): + for idl_prop_name in list(interface.properties.keys()): + py_prop_name = to_snake_case(idl_prop_name) + interface.properties[py_prop_name] = self.resolve_type(interface.properties.pop(idl_prop_name)) + + for funcname in list(interface.methods.keys()): + func = interface.methods[funcname] + args, return_type = self._resolve_signature(classname, funcname, func.line) + if return_type: + return_type = self.resolve_type(return_type) + if funcname.lower().endswith("async"): # TODO: doesn't the type handle this already? + return_type = f"GPUPromise[{return_type}]" + for arg in args: + arg.py_name = to_snake_case(arg.name) + arg.py_type = self.resolve_type(arg.idl_type) + func.py_name = to_snake_case(func.name) + func.return_type = return_type + func.args = args + + def resolve_type(self, typename) -> str: + """Resolve a type to a suitable name that is also valid so that the linter + won't complain when this is used as a type annotation. + """ + + name = typename.strip().strip("?") + + # We want the flag, not the type that is an alias for int + name = name[:-5] if name.endswith("Flags") else name + + # First resolve using typedefs that we found in the IDL + while name in self.typedefs: + new_name = self.typedefs[name] + if new_name == name: + break + name = new_name + + # Resolve to a Python type (maybe) + pythonmap = { + "DOMString": "str", + "DOMString?": "str", + "USVString": "str", + "long": "int", + "unsigned long": "int", + "unsigned long long": "int", + "[Clamp] unsigned short": "int", + "unsigned short": "int", + "GPUIntegerCoordinate": "int", + "GPUSampleMask": "int", + "GPUFenceValue": "int", + "GPUSize64": "int", + "GPUSize32": "int", + "GPUIndex32": "int", + "double": "float", + "boolean": "bool", + "object": "dict", + "ImageBitmap": "ArrayLike", + "ImageData": "ArrayLike", + "VideoFrame": "ArrayLike", + "AllowSharedBufferSource": "ArrayLike", + "[AllowShared] Uint32Array": "ArrayLike", + "GPUPipelineConstantValue": "float", + "GPUExternalTexture": "object", + "undefined": "None", + "ArrayBuffer": "ArrayLike", + "WGSLLanguageFeatures": "set", + "GPUSupportedFeatures": "set", + "GPUSupportedLimits": "dict", + "EventHandler": "None", + "HTMLCanvasElement": "CanvasLike", + "OffscreenCanvas": "CanvasLike", + } + name = pythonmap.get(name, name) + + # Is this a case for which we need to recurse? + if ( + name.startswith("sequence<") or name.startswith("FrozenArray<") + ) and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + name = self.resolve_type(name).strip("'") + return f"list[{name}]" + elif name.startswith("record<") and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + names = [self.resolve_type(t).strip("'") for t in name.split(",")] + return f"dict[{', '.join(names)}]" + elif " or " in name: + # Clean + name = name.strip("()") + names = [self.resolve_type(t).strip("'") for t in name.split(" or ")] + names = set(names) # de-dupe + has_none = "None" in names + names.discard("None") + names = sorted(names) + if has_none: + names.append("None") + # Triage + if len(names) == 1: + return names[0] + if ( + len(names) == 2 + and names[0] in ("list[int]", "list[float]") + and names[1].endswith("Struct") + and names[1].startswith( + ("structs.Origin", "structs.Extent", "structs.Color") + ) + ): + if names[1].endswith("ColorStruct"): + names[0] = "tuple[float, float, float, float]" + elif names[1].endswith("2DStruct"): + names[0] = "tuple[int, int]" + elif names[1].endswith("3DStruct"): + names[0] = "tuple[int, int, int]" + return " | ".join(names) + if name.startswith("Promise<") and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + # recursive call if there are any of the above situations? + return self.resolve_type(name) + + # Triage + if name in __builtins__.__dict__: + return name # ok + elif name in ["ArrayLike", "CanvasLike"]: + return name # virtual types + elif name in self.classes: + return name + elif name.startswith("HTML"): + return "object" # anything, we ignore this stuff anyway + elif name in ["PredefinedColorSpace"]: + return "str" + else: + assert name.startswith("GPU"), f"Unknown type: {name}" + name = name[3:] + name = name[:-4] if name.endswith("Dict") else name + if name in self.flags: + return f"flags.{name}Flags" + elif name in self.enums: + return f"enums.{name}Enum" + elif name in self.structs: + return f"structs.{name}Struct" + else: + # When this happens, update the code above or the pythonmap + raise RuntimeError("Encountered unknown IDL type: ", name) + + def _resolve_signature(self, classname, methodname, idl_line): + # Get arg names and types + args = idl_line.split("(", 1)[1].split(")", 1)[0].split(",") + args = [Attribute(arg, "param") for arg in args if arg.strip()] + return_type = idl_line.split()[0] + if return_type.startswith("[NewObject]"): + # [NewObject] can be skipped: https://webidl.spec.whatwg.org/#NewObject + return_type = idl_line.split()[1] + if return_type.startswith("constructor"): + # this means __init__ which essentially returns None (used with Error Messages) + return_type = None + + return args, return_type + + +if __name__ == "__main__": + parse_idl_to_toml() diff --git a/apigen/parse_ts.py b/apigen/parse_ts.py new file mode 100644 index 00000000..3afc8b49 --- /dev/null +++ b/apigen/parse_ts.py @@ -0,0 +1,332 @@ +"""Parse the WebGPU Typescript type definitions (index.d.ts) to extract docs for most objects.""" + +import re + +from apigen_utils import read_file, read_definition_file, DEFINITIONS_DIR, to_snake_case + +KINDS = [ + "flag", + "flagfield", + "enum", + "enumfield", + "struct", + "structfield", + "class", + "property", + "method", + "arg", + "returns", +] +OPEN, CLOSE = "([{<", ")]}>" + + +def parse_ts_to_toml(): + """Parse the typescript file to a TOML structure.""" + source = read_file("apigen", "definitions", "index.d.ts") + docs = parse(source) + + flat = {"flags": {}, "enums": {}, "structs": {}, "classes": {}} + + category_map = { + "flag": "flags", + "flagfield": "flags", + "enum": "enums", + "enumfield": "enums", + "struct": "structs", + "structfield": "structs", + "class": "classes", + "property": "classes", + "method": "classes", + "arg": "classes", + "returns": "classes", + } + + # First we flatten the docs + for category, d in docs.items(): + for k, v in d.items(): + section = category_map[category] + target_dict = flat[section] + name_parts = k.split(".") + if category in ("structfield", "property", "method", "arg", "returns"): + name_parts[1] = to_snake_case(name_parts[1]) + if category in ("arg", ): + name_parts[-1] = to_snake_case(name_parts[-1]) + if category.endswith("field"): + name_parts.insert(1, "fields") + if category == "returns": + name_parts.append("returns") + if category == "arg": + name_parts.insert(-1, "args") + if category in ("property", "method", "arg", "returns"): + name_parts.insert(1, "methods") + if section != "classes" and name_parts[0].startswith("GPU"): + name_parts[0] = name_parts[0][3:] + name_parts.append("doc") + key = ".".join(name_parts) + target_dict[key] = v + + # Generate TOML + + fname = "docs_ts.toml" + hline = "# " + "-" * 80 + hline3 = "\n" + hline + "\n" + hline + "\n" + hline + + toml_lines = [ + f"# {fname}: Docs generated from 'index.d.ts'.", + ] + for section_name, d in flat.items(): + toml_lines.append(hline3) + toml_lines.append(f"[{section_name}]") + keys = sorted(d.keys()) + prev_prefix = "" + for key in keys: + doc = d[key] + if doc: + prefix = key.split(".")[0] + if prefix != prev_prefix: + toml_lines.append("") + prev_prefix = prefix + if "\n" not in doc: + toml_lines.append(f"{key} = {doc!r}") + else: + toml_lines.append(f"{key} = '''\n{doc}\n'''") + + # Write + + toml_lines.append("") + toml = "\n".join(toml_lines) + + with open(DEFINITIONS_DIR / fname, "wb") as f: + f.write(toml.encode()) + + # Check that file is correct toml and structure + read_definition_file(fname) + + +def clean_doc(raw): + """'/** ... */' -> plain text lines.""" + body = re.sub(r"^\s*/\*\*", "", raw) + body = re.sub(r"\*/\s*$", "", body) + lines = [re.sub(r"^\s*\*? ?", "", l).rstrip() for l in body.split("\n")] + return "\n".join(lines).strip() + + +def split_doc(doc): + """-> (description, {param: text}, returns_text)""" + desc, params, ret = [], {}, "" + cur = None + for line in doc.split("\n"): + m = re.match(r"@param\s+(?:\{[^}]*\}\s*)?(\w+)\s*-?\s*(.*)", line) + if m: + cur = m.group(1) + params[cur] = m.group(2) + continue + if line.startswith("@") and not line.startswith("@deprecated"): + cur = None + continue + if cur and line and not line.startswith("@"): + params[cur] += " " + line.strip() + else: + cur = None + desc.append(line) + d = "\n".join(desc).strip() + m = re.search(r"\*\*Returns:\*\*\s*(.*)", d) + if m: + ret = re.sub(r"]*>", "", m.group(1)).strip() + return d, params, ret + + +def scan_balanced(s, i): + """s[i] is an opener; return index just past its matching closer. + '=>' and '>' inside arrows are not treated as closers of '<'.""" + depth = 0 + while i < len(s): + c = s[i] + if c in "([{<": + depth += 1 + elif c in ")]}": + depth -= 1 + elif c == ">" and s[i - 1] != "=": + depth -= 1 + if depth == 0: + return i + 1 + i += 1 + return i + + +def block_end(s, i): + """s[i] == '{'; return index past the matching '}', skipping comments/strings.""" + depth, n = 0, len(s) + while i < n: + if s.startswith("/*", i): + i = s.index("*/", i) + 2 + continue + if s.startswith("//", i): + nl = s.find("\n", i) + i = n if nl < 0 else nl + continue + c = s[i] + if c in "\"'`": + j = i + 1 + while j < n and s[j] != c: + j += 2 if s[j] == "\\" else 1 + i = j + 1 + continue + if c == "{": + depth += 1 + elif c == "}": + depth -= 1 + if depth == 0: + return i + 1 + i += 1 + return n + + +def split_top(s, sep=","): + out, depth, cur = [], 0, [] + for i, c in enumerate(s): + if c in "([{<": + depth += 1 + elif c in ")]}" or (c == ">" and s[i - 1] != "="): + depth -= 1 + if c == sep and depth == 0: + out.append("".join(cur)) + cur = [] + else: + cur.append(c) + if "".join(cur).strip(): + out.append("".join(cur)) + return out + + +def tokenize_members(body): + """Yield (doc_or_None, member_text) from an interface body.""" + i, n = 0, len(body) + doc = None + while i < n: + if body[i].isspace(): + i += 1 + continue + if body.startswith("/**", i): + j = body.index("*/", i) + 2 + doc = clean_doc(body[i:j]) + i = j + continue + if body.startswith("/*", i): + i = body.index("*/", i) + 2 + continue + if body.startswith("//", i): + nl = body.find("\n", i) + i = n if nl < 0 else nl + continue + # member: runs to ';' at depth 0 + j, depth = i, 0 + while j < n: + c = body[j] + if c in "([{<": + depth += 1 + elif c in ")]}" or (c == ">" and body[j - 1] != "="): + depth -= 1 + elif c == ";" and depth == 0: + break + j += 1 + yield doc, re.sub(r"\s+", " ", body[i:j]).strip() + doc = None + i = j + 1 + + +def parse_member(text): + """-> dict(name, is_method, params[list of names], ret) or None""" + m = re.match(r"(?:readonly\s+)?(?:\[(\w+)[^\]]*\]|(\w+))\s*(\?)?\s*", text) + if not m: + return None + name = m.group(2) or m.group(1) + rest = text[m.end() :] + if rest.startswith("<"): # generics on a method + rest = rest[scan_balanced(rest, 0) :].lstrip() + if rest.startswith("("): + end = scan_balanced(rest, 0) + plist = rest[1 : end - 1] + params = [] + for p in split_top(plist): + pm = re.match(r"\s*(?:\.\.\.)?(\w+)", p) + if pm: + params.append(pm.group(1)) + ret = rest[end:].lstrip(": ").strip() + return dict(name=name, method=True, params=params, ret=ret) + ty = rest.lstrip(": ").strip() + return dict(name=name, method=False, ty=ty) + + +def parse(src): + out = {k: {} for k in KINDS} + + def put(kind, key, val): + if val or key not in out[kind]: + out[kind][key] = val if val else out[kind].get(key, "") + + # statements at top level + pos, n = 0, len(src) + pending_doc = None + stmt_re = re.compile(r"^(?:declare\s+)?(interface|type)\s+(\w+)", re.M) + while True: + m = stmt_re.search(src, pos) + if not m: + break + # doc comment immediately before? + before = src[: m.start()].rstrip() + pending_doc = None + if before.endswith("*/"): + st = before.rfind("/**") + if st >= 0 and "*/" not in before[st:-2]: + pending_doc = clean_doc(before[st:]) + kind, name = m.group(1), m.group(2) + if kind == "type": + end = src.index(";", m.end()) + while src[end - 1] == "\\": + end = src.index(";", end + 1) + body = src[m.end() : end] + lits = re.findall(r'^\s*\|\s*"([^"]*)"', body, re.M) + if lits and re.fullmatch(r'\s*=\s*(\|\s*"[^"]*"\s*)+', body): + put("enum", name, split_doc(pending_doc)[0] if pending_doc else "") + for v in lits: + put("enumfield", f"{name}.{v}", "") + pos = end + 1 + continue + # interface + ob = src.index("{", m.end()) + cb = block_end(src, ob) + body = src[ob + 1 : cb - 1] + pos = cb + members = [(d, parse_member(t)) for d, t in tokenize_members(body)] + members = [(d, p) for d, p in members if p] + idoc = split_doc(pending_doc)[0] if pending_doc else "" + if not members: + continue + if all((not p["method"]) and p["ty"] == "GPUFlagsConstant" for _, p in members): + put("flag", name, idoc) + for d, p in members: + put("flagfield", f"{name}.{p['name']}", split_doc(d)[0] if d else "") + elif any(p["name"] == "__brand" or p["method"] for _, p in members): + put("class", name, idoc) + for d, p in members: + if p["name"] == "__brand": + continue + if p["method"]: + desc, pdocs, ret = split_doc(d) if d else ("", {}, "") + key = f"{name}.{p['name']}" + put("method", key, desc) + for a in p["params"]: + put("arg", f"{key}.{a}", pdocs.get(a, "")) + put("returns", key, ret) + else: + put("property", f"{name}.{p['name']}", split_doc(d)[0] if d else "") + else: + put("struct", name, idoc) + for d, p in members: + put("structfield", f"{name}.{p['name']}", split_doc(d)[0] if d else "") + return out + + +if __name__ == "__main__": + parse_ts_to_toml() diff --git a/apigen/tests/test_structures.py b/apigen/tests/test_structures.py new file mode 100644 index 00000000..66ac7169 --- /dev/null +++ b/apigen/tests/test_structures.py @@ -0,0 +1,14 @@ +import os +import tomllib + +from apigen_utils import DEFINITIONS_DIR, read_file + +FILES = [fname for fname in os.listdir(DEFINITIONS_DIR) if fname.endswith(".toml")] +BACKEND_FILES = ["diff_backend_pyodide.toml", "diff_backend_wgpu.toml"] + + +def check_all_definition_files(): + + for fname in FILES: + source = read_file("apigen", "definitions", fname) + s = tomllib.loads(source) diff --git a/apigen/unite.py b/apigen/unite.py new file mode 100644 index 00000000..b0da06e4 --- /dev/null +++ b/apigen/unite.py @@ -0,0 +1,158 @@ +"""Unite/merge the structure definitions into more final definitions. """ + +from apigen_utils import read_definition_file, dict_deep_merge, DEFINITIONS_DIR + + +def unite_toml_files(): + unite_base_api() + unite_docs() + + +def unite_base_api(): + + # Read + api_web = read_definition_file("wgpu_api_web.toml") + diff_base = read_definition_file("diff_base.toml") + + # Combine + api = dict_deep_merge(api_web, diff_base) + + # Generate toml + # We generate the whole structure, but ignore "do"" fields, assuming they are handled separately. + + fname = "wgpu_api.toml" + hline = "# " + '-' * 80 + hline3 = "\n" + hline + "\n" + hline + "\n" + hline + + toml_lines = [ + f"# {fname}: the base wgpu-py API, generated from 'wgpu_api_web.toml' and 'diff_base.toml'." + ] + + toml_lines.append(hline3) + toml_lines.append("[flags]") + for flag_name, flag_dict in api["flags"].items(): + toml_lines.append(f"\n[flags.{flag_name}]") + for k, d in flag_dict['fields'].items(): + toml_lines.append(f"fields.{k} = {{ value = {d['value']!r} }}") + + toml_lines.append(hline3) + toml_lines.append("[enums]") + for enum_name, enum_dict in api["enums"].items(): + toml_lines.append(f"\n[enums.{enum_name}]") + for k, d in enum_dict['fields'].items(): + toml_lines.append(f"fields.{k} = {{ value = '{d['value']}' }}") + + toml_lines.append(hline3) + toml_lines.append("[structs]") + for struct_name, struct_dict in api["structs"].items(): + toml_lines.append(f"\n[structs.{struct_name}]") + for k, d in struct_dict.get('fields', {}).items(): + toml_lines.append(f"fields.{k} = {{ type = {d['type']!r}, default = '{d['default']}', required = {repr(d['required']).lower()} }}") + + toml_lines.append(hline3) + toml_lines.append("[classes]") + for class_name, class_dict in api["classes"].items(): + toml_lines.append(f"\n[classes.{class_name}]") + toml_lines.append(f"bases = {class_dict['bases']!r}") + for prop_name, d in class_dict.get('properties', {}).items(): + toml_lines.append(f"properties.{prop_name} = {{ type = {d['type']!r} }}") + toml_lines.append(f"[classes.{class_name}.methods]") + for method_name, method_dict in class_dict['methods'].items(): + toml_lines.append(f"[classes.{class_name}.methods.{method_name}]") + toml_lines.append(f"returns = {{ type = '{method_dict['returns']['type']}' }}") + for arg_name, d in method_dict.get('args', {}).items(): + toml_lines.append(f"args.{arg_name} = {{ type = {d['type']!r}, default = '{d['default']}', required = {repr(d['required']).lower()} }}") + + # Write + + toml_lines.append("") + toml = "\n".join(toml_lines) + + with open(DEFINITIONS_DIR / fname, "wb") as f: + f.write(toml.encode()) + + # Check that file is correct toml and structure + read_definition_file(fname) + + +def unite_docs(): + + # Read definitions + api = read_definition_file("wgpu_api.toml") + docs_ai = read_definition_file("docs_ai.toml") + docs_ts = read_definition_file("docs_ts.toml") + docs_dev = read_definition_file("docs_dev.toml") + + # Combine into api. Only add docs for stuff that's actually in the API + docs = api + docs = dict_deep_merge(docs, docs_ai, allow_add=False) + docs = dict_deep_merge(docs, docs_ts, allow_add=False) + docs = dict_deep_merge(docs, docs_dev, allow_add=False) + + # Generate toml, only the doc fields. We assume that there is a doc + # field for every leaf node. If not, add it to docs_dev.toml! + + fname = "wgpu_docs.toml" + hline = "# " + '-' * 80 + hline3 = "\n" + hline + "\n" + hline + "\n" + hline + + toml_lines = [ + f"# {fname}", + "# Documentation for the wgpu-py API, composed from 'docs_ai.toml', 'docs_ts.toml', and 'docs_dev.toml'", + ] + + toml_lines.append(hline3) + toml_lines.append("[flags]") + for flag_name, flag_dict in docs["flags"].items(): + toml_lines.append(f"\n[flags.{flag_name}]") + toml_lines.append(f'doc = """{flag_dict["doc"]}"""') + for k, d in flag_dict['fields'].items(): + toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') + + toml_lines.append(hline3) + toml_lines.append("[enums]") + for enum_name, enum_dict in docs["enums"].items(): + toml_lines.append(f"\n[enums.{enum_name}]") + toml_lines.append(f'doc = """{enum_dict["doc"]}"""') + for k, d in enum_dict['fields'].items(): + toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') + + toml_lines.append(hline3) + toml_lines.append("[structs]") + for struct_name, struct_dict in docs["structs"].items(): + toml_lines.append(f"\n[structs.{struct_name}]") + toml_lines.append(f'doc = """{struct_dict["doc"]}"""') + for k, d in struct_dict.get('fields', {}).items(): + toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') + + toml_lines.append(hline3) + toml_lines.append("[classes]") + for class_name, class_dict in docs["classes"].items(): + toml_lines.append(f"\n[classes.{class_name}]") + toml_lines.append(f'doc = """{class_dict["doc"]}"""') + for prop_name, d in class_dict.get('properties', {}).items(): + toml_lines.append(f'properties.{prop_name}.doc = """{d["doc"]}"""') + toml_lines.append(f"[classes.{class_name}.methods]") + for method_name, method_dict in class_dict['methods'].items(): + toml_lines.append(f'[classes.{class_name}.methods.{method_name}]') + toml_lines.append(f'doc = """{method_dict["doc"]}"""') + toml_lines.append(f'returns.doc = """{method_dict["returns"]["doc"]}"""') + for arg_name, d in method_dict.get('args', {}).items(): + toml_lines.append(f'args.{arg_name}.doc = """{d["doc"]}"""') + + + # Write + + toml_lines.append("") + toml = "\n".join(toml_lines) + + with open(DEFINITIONS_DIR / fname, "wb") as f: + f.write(toml.encode()) + + # Check that file is correct toml and structure + read_definition_file(fname) + + + +if __name__ == "__main__": + unite_toml_files() diff --git a/apigen/write_flags_enums_structs.py b/apigen/write_flags_enums_structs.py new file mode 100644 index 00000000..ab9d0926 --- /dev/null +++ b/apigen/write_flags_enums_structs.py @@ -0,0 +1,83 @@ +""" Generate the simple API from the definitions. """ + +from apigen_utils import read_definition_file, read_file, write_file, dict_deep_merge, format_code, indent + + +def write_api(): + api_without_docs = read_definition_file("wgpu_api.toml") + docs = read_definition_file("wgpu_docs.toml") + + api = dict_deep_merge(api_without_docs, docs, allow_add=False) + + print(t1-t0) + write_flags(api['flags']) + write_enums(api['enums']) + + +def write_flags(flags_dict): + # Get preamble + pylines = [] + for line in read_file("wgpu", "flags.py").splitlines(): + pylines.append(line) + if "AUTOGENERATED" in line: + pylines += ["", ""] + break + + # List'm + n = len(flags_dict) + pylines.append(f"# There are {n} flags\n") + pylines.append("__all__ = [") + for name in sorted(flags_dict.keys()): + pylines.append(f' "{name}",') + pylines.append("]\n\n") + + # The flags definitions + for name, flag_dict in flags_dict.items(): + # Generate Code + pylines.append(f"{name}Flags = int | str\n\n") + pylines.append(f"class {name}(Flags):\n") + pylines.append(f' """{indent(flag_dict["doc"])}"""') + for field_name, field_dict in flag_dict['fields'].items(): + pylines.append(f" {field_name} = {field_dict['value']!r} #: {field_dict['doc']}") # note: can add docs using "#: " + pylines.append("\n") + + # Write + code = format_code("\n".join(pylines)) + write_file(code, "wgpu", "flags.py") + print(f"Wrote {n} flags to flags.py") + + +def write_enums(enums_dict): + # Get preamble + pylines = [] + for line in read_file("wgpu", "flags.py").splitlines(): + pylines.append(line) + if "AUTOGENERATED" in line: + pylines += ["", ""] + break + + # List'm + n = len(flags_dict) + pylines.append(f"# There are {n} flags\n") + pylines.append("__all__ = [") + for name in sorted(flags_dict.keys()): + pylines.append(f' "{name}",') + pylines.append("]\n\n") + + # The flags definitions + for name, flag_dict in flags_dict.items(): + # Generate Code + pylines.append(f"{name}Flags = int | str\n\n") + pylines.append(f"class {name}(Flags):\n") + pylines.append(f' """{indent(flag_dict["doc"])}"""') + for field_name, field_dict in flag_dict['fields'].items(): + pylines.append(f" {field_name} = {field_dict['value']!r} #: {field_dict['doc']}") # note: can add docs using "#: " + pylines.append("\n") + + # Write + code = format_code("\n".join(pylines)) + write_file(code, "wgpu", "flags.py") + print(f"Wrote {n} flags to flags.py") + +if __name__ == "__main__": + write_api() From ad334e12c68fa202baafa3135cbd7ebd33676651 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 15 Oct 2026 15:48:22 +0200 Subject: [PATCH 02/10] refactoring --- .gitignore | 1 + apigen/README.md | 199 +- apigen/__init__.py | 10 +- apigen/__main__.py | 43 +- apigen/apigen_utils.py | 75 +- apigen/definitions/diff_backend_pyodide.json | 7 + apigen/definitions/diff_backend_pyodide.toml | 4 - apigen/definitions/diff_backend_wgpu.json | 7 + apigen/definitions/diff_backend_wgpu.toml | 5 - apigen/definitions/diff_base.json | 29 + apigen/definitions/diff_base.toml | 15 - apigen/definitions/docs_ai.json | 1826 ++++++++ apigen/definitions/docs_ai.toml | 2277 ---------- apigen/definitions/docs_dev.json | 7 + apigen/definitions/docs_dev.toml | 3 - apigen/definitions/docs_ts.toml | 1400 ------- apigen/definitions/index.d.ts | 3420 --------------- apigen/definitions/test.json | 69 + apigen/definitions/wgpu_api.json | 3930 ++++++++++++++++++ apigen/definitions/wgpu_api.toml | 1190 ------ apigen/definitions/wgpu_api_web.json | 1716 ++++++++ apigen/definitions/wgpu_api_web.toml | 1217 ------ apigen/definitions/wgpu_docs.toml | 2413 ----------- apigen/{download.py => download_idl.py} | 23 +- apigen/{parse_idl.py => extract_idl.py} | 124 +- apigen/format_json.py | 19 + apigen/merge_json.py | 30 + apigen/parse_ts.py | 332 -- apigen/tests/test_structures.py | 5 +- apigen/unite.py | 158 - apigen/write_api.py | 193 + apigen/write_flags_enums_structs.py | 83 - docs/conf.py | 10 +- 33 files changed, 8099 insertions(+), 12741 deletions(-) create mode 100644 apigen/definitions/diff_backend_pyodide.json delete mode 100644 apigen/definitions/diff_backend_pyodide.toml create mode 100644 apigen/definitions/diff_backend_wgpu.json delete mode 100644 apigen/definitions/diff_backend_wgpu.toml create mode 100644 apigen/definitions/diff_base.json delete mode 100644 apigen/definitions/diff_base.toml create mode 100644 apigen/definitions/docs_ai.json delete mode 100644 apigen/definitions/docs_ai.toml create mode 100644 apigen/definitions/docs_dev.json delete mode 100644 apigen/definitions/docs_dev.toml delete mode 100644 apigen/definitions/docs_ts.toml delete mode 100644 apigen/definitions/index.d.ts create mode 100644 apigen/definitions/test.json create mode 100644 apigen/definitions/wgpu_api.json delete mode 100644 apigen/definitions/wgpu_api.toml create mode 100644 apigen/definitions/wgpu_api_web.json delete mode 100644 apigen/definitions/wgpu_api_web.toml delete mode 100644 apigen/definitions/wgpu_docs.toml rename apigen/{download.py => download_idl.py} (50%) rename apigen/{parse_idl.py => extract_idl.py} (88%) create mode 100644 apigen/format_json.py create mode 100644 apigen/merge_json.py delete mode 100644 apigen/parse_ts.py delete mode 100644 apigen/unite.py create mode 100644 apigen/write_api.py delete mode 100644 apigen/write_flags_enums_structs.py diff --git a/.gitignore b/.gitignore index d8ea74d1..89ae94bb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ examples/screenshots/diffs docs/gallery/ docs/_static/*.whl docs/sg_execution_times.rst +.zed # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/apigen/README.md b/apigen/README.md index cbf2f8e5..20eb1f2d 100644 --- a/apigen/README.md +++ b/apigen/README.md @@ -1,131 +1,114 @@ -## The API format structure +# wgpu APIGEN -The API is stored in a "json-able" data structure that can be easily loaded and manipulated. -This allows generating an API definition that is precise and sort of human readable, plus -we can easily combine multiple structures, e.g. diff definitions, backend-specific additions, -and docs from multiple sources. +## Introduction -The structure has some two dozen leaf nodes: -``` -flags.SomeFlag.doc : str -flags.SomeFlag.fields.SOME_FIELD.doc : str -flags.SomeFlag.fields.SOME_FIELD.value : int - -enums.SomeEnum.doc : str -enums.SomeEnum.fields.some_field.doc : str -enums.SomeEnum.fields.some_field.value : str - -structs.SomeStruct.doc : str -structs.SomeStruct.fields.some_field.doc : str -structs.SomeStruct.fields.some_field.type : str -structs.SomeStruct.fields.some_field.default : str -structs.SomeStruct.fields.some_field.required : bool - -classes.GPUSomeClass.doc : str -classes.GPUSomeClass.bases : list[str] - -classes.GPUSomeClass.properties.some_prop.doc : str -classes.GPUSomeClass.properties.some_prop.type : str - -classes.GPUSomeClass.methods.some_method.doc : str -classes.GPUSomeClass.methods.some_method.returns.doc : str -classes.GPUSomeClass.methods.some_method.returns.type : str -classes.GPUSomeClass.methods.some_method.args.some_arg.doc : str -classes.GPUSomeClass.methods.some_method.args.some_arg.type : str -classes.GPUSomeClass.methods.some_method.args.some_arg.default : str -classes.GPUSomeClass.methods.some_method.args.some_arg.required : bool -``` +The purpose of this code is to generate the wgpu-py base API, and the API of its backends. +The API is derived from the official WebGPU spec (webgpu.idl), but changed a bit to make it +fit Python better. -As a structure, this looks a bit look this: +The API is stored in a structured data format (see below). This makes it straightforward to produce, +and also to generate the actual Python API from it. -``` -flags = { - - SomeFlag: { - doc = "" - fields = { - SOME_FIELD = { - doc = "" - value = 1 - } - ... - } - } - ... -} +Documentation is also present for every object in the API. +Each backend can define additional API surface, but uses suffixes for anything that is added. -enums = { - SomeEnum: { - doc = "" - fields = { - some_field = { - doc = "" - value = "some-field" - } - ... - } - } - ... -} +## Code organization +This module consists of one utility modules and then one module for each action. +These modules can be executed as a script, which is handy during development. +There is also a CLI for ease of use, and to run the whole codegen pipeline with one command. -structs = { - SomeStruct: { - doc = "" - fields = { - some_field = { - doc = "" - type = "int" - default = "0" - required = False - } - ... - } - } - ... -} +## The steps that this code offers + +* download: download the latest webgpu.idl, this is only done manually from time to time. +* extract_idl: parse the IDL to produce 'wgpu_api_web.json'. +* format: formats the static definitions. +* merge: combines multiple definitions files into 'wgpu_api.json'. +* write_api: produce API for flags, enums and structs. +* patch_api: produce the classes and functions in _classes.py and all backends. + + +## The API format structure +The API is stored in a "json-able" data structure that can be easily loaded and manipulated. +This allows generating an API definition that is precise and sort of human readable, plus +we can easily combine multiple structures, e.g. diff definitions, backend-specific additions, +and docs from multiple sources. -classes = { +The structure has some two dozen leaf nodes and looks a bit like this: - GPUSomeClass = { - doc = "" - bases = ["GPUObject"] - properties = { - some_prop = { - doc = "" - type = "int" +``` +{ + "flags": { + "SomeFlag": { + "doc": "", + "fields": { + "SOME_FIELD": { + "doc": "", + "value": 1 + } + } + } + }, + + "enums": { + "SomeEnum": { + "doc": "", + "fields": { + "some_field": { + "doc": "", + "value": "some-field" + } } - ... } - methods = { - some_method = { - doc = "" - returns = { - doc = "" - type = "None" + }, + + "structs": { + "SomeStruct": { + "doc": "", + "fields": { + "some_field": { + "doc": "", + "type": "int", + "default": 0, + "required": false } - args = { - some_arg { - doc = "" - type = "" - default = "" - required = True - } - ... + } + } + }, + + "classes": { + "GPUSomeClass": { + "doc": "", + "bases": ["GPUObject"], + "properties": { + "some_prop": { + "doc": "", + "type": "int" + } + }, + "methods": { + "some_method": { + "doc": "", + "returns": { + "doc": "", + "type": "None" + }, + "args": { + "some_arg": { + "doc": "", + "type": "", + "default": "", + "required": true + } + } } } - ... } - } - ... } ``` - -We could have used JSON to store these data formats, but we use TOML -because it makes it more readable and the use of sections allows for more concise definitions. diff --git a/apigen/__init__.py b/apigen/__init__.py index c88ad595..c5119cc0 100644 --- a/apigen/__init__.py +++ b/apigen/__init__.py @@ -1,4 +1,10 @@ """ Code to generate the wgpu-py API. """ -from .download import download_idl -from .parse_idl import parse_idl_to_toml + +from download_idl import download_idl +from extract_idl import extract_idl +from format_json import format_json +from merge_json import merge_json +from write_api import write_api + +actions = [download_idl, extract_idl, format_json, merge_json, write_api] diff --git a/apigen/__main__.py b/apigen/__main__.py index 6b76b0a1..2947fd05 100644 --- a/apigen/__main__.py +++ b/apigen/__main__.py @@ -7,34 +7,41 @@ import sys from argparse import ArgumentParser +from apigen import actions -parser = ArgumentParser(description="Run code generation and patching.") +parser = ArgumentParser(description="apigen - run code generation and patching.") +for func in actions: + parser.add_argument( + "--" + func.__name__.replace("_", "-"), + action="store_true", + dest=func.__name__, + help=func.__doc__, + ) parser.add_argument( - "--download-idl", + "--all", action="store_true", - dest="download_idl", - help="Download the latest webgpu.idl", + dest="all", + help="Run all steps of the codegen (except download).", ) - # Little trick to allow running this file as a script sys.path.insert(0, os.path.abspath(os.path.join(__file__, "..", ".."))) -from apigen import download_idl - - if __name__ == "__main__": args = parser.parse_args() - if args.download_idl: - print("Hey") - download_idl() - elif False: - pass - # main(do_api=args.api, do_wgpu_native=args.wgpu_native, do_js=args.js) - # main() - # file_cache.write_changed_files_to_disk() - else: + enabled = [k for k, v in vars(args).items() if v is True] + + if not enabled: parser.print_help() - sys.exit(0) + elif "all" in enabled: + for func in actions: + if func.__name__ == "download": + continue + func() + else: + for name in enabled: + for func in actions: + if name == func.__name__: + func() diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py index 9322faf4..218e2ef9 100644 --- a/apigen/apigen_utils.py +++ b/apigen/apigen_utils.py @@ -1,9 +1,8 @@ -import sys -import tomllib +import json import subprocess +import sys from pathlib import Path - DEFINITIONS_DIR = Path(__file__).parent.absolute() / "definitions" ROOT_DIR = Path(__file__).parents[1].absolute() @@ -136,21 +135,73 @@ def indent(text: str, indent=4) -> str: return "\n".join(lines) +def write_definition_file(structure: dict, fname: str) -> None: + """Write an API definition to disk. The structure is serialized to json, indented, but with singular and small leaf nodes single-lined.""" + + def _is_leaf(obj): + values = obj.values() if isinstance(obj, dict) else obj + return not any(isinstance(v, (dict, list)) for v in values) + + def dumps(obj, indent=2, level=0, max_len=100, **kw): + if not isinstance(obj, (dict, list)): + return json.dumps(obj, **kw) + + if _is_leaf(obj): + flat = json.dumps(obj, **kw).strip("{}") + if len(obj) <= 1 or len(flat) < max_len: + if isinstance(obj, list): + return "[ " + flat.strip("[]") + " ]" + else: + return "{ " + flat.strip("{}") + " }" + + pad = " " * (indent * (level + 1)) + end = " " * (indent * level) + sub = dict(indent=indent, level=level + 1, max_len=max_len, **kw) + + if isinstance(obj, dict): + if not obj: + return "{}" + body = ",\n".join( + f"{pad}{json.dumps(k, **kw)}: {dumps(v, **sub)}" for k, v in obj.items() + ) + return "{\n" + body + "\n" + end + "}" + else: # list + if not obj: + return "[]" + body = ",\n".join(pad + dumps(v, **sub) for v in obj) + return "[\n" + body + "\n" + end + "]" + + text = dumps(structure) + write_file(text, "apigen", "definitions", fname) + + def read_definition_file(fname: str) -> dict: - """Read a TOML API definition file and check that the structure is correct. + """Read an API definition from disk and check that the structure is correct. Returns the structure as a dict. """ source = read_file("apigen", "definitions", fname) - structure = tomllib.loads(source) + structure = json.loads(source) + possible_default_types = (None.__class__, int, float, str, list, dict) diff_actions = ("REMOVE", ) + assert ( + "meta" in structure + and "filename" in structure["meta"] + and fname == structure["meta"]["filename"] + ) + # The code below is just a tedious traversing of the structure that checks each leaf node. for section, section_dict in structure.items(): - assert section in ("flags", "enums", "structs", "classes") + assert section in ("meta", "flags", "enums", "structs", "classes") assert isinstance(section_dict, dict) + if section == "meta": + for k, v in section_dict.items(): + assert k in ("filename", "description", "notes") + assert isinstance(v, str) + if section == "flags": for flag_name, flag_dict in structure[section].items(): assert "_" not in flag_name @@ -223,7 +274,9 @@ def read_definition_file(fname: str) -> dict: elif field_dict_key == "type": assert isinstance(field_dict_val, str) elif field_dict_key == "default": - assert isinstance(field_dict_val, str) + assert isinstance( + field_dict_val, possible_default_types + ) elif field_dict_key == "required": assert isinstance(field_dict_val, bool) else: @@ -287,11 +340,13 @@ def read_definition_file(fname: str) -> dict: elif arg_dict_key == "diff": assert arg_dict_val in diff_actions elif arg_dict_key == "type": - assert isinstance(arg_dict_val, str) + assert isinstance(arg_dict_val, str) elif arg_dict_key == "default": - assert isinstance(arg_dict_val, str) + assert isinstance( + arg_dict_val, possible_default_types + ) elif arg_dict_key == "required": - assert isinstance(arg_dict_val, bool) + assert isinstance(arg_dict_val, bool) else: raise RuntimeError(f"Invalid method arg dict key {arg_dict_key!r}") else: diff --git a/apigen/definitions/diff_backend_pyodide.json b/apigen/definitions/diff_backend_pyodide.json new file mode 100644 index 00000000..562296b2 --- /dev/null +++ b/apigen/definitions/diff_backend_pyodide.json @@ -0,0 +1,7 @@ +{ + "meta": { + "filename": "diff_backend_pyodide.json", + "description": "Defines how the Pyodide API differs from the base API.", + "notes": "We could use this to bring back e.g. external textures." + } +} diff --git a/apigen/definitions/diff_backend_pyodide.toml b/apigen/definitions/diff_backend_pyodide.toml deleted file mode 100644 index a0b482f9..00000000 --- a/apigen/definitions/diff_backend_pyodide.toml +++ /dev/null @@ -1,4 +0,0 @@ -# diff_backend_pyodide.toml -# -# Defines how the Pyodide API differs from the base API. -# We could use this to bring back e.g. external textures. diff --git a/apigen/definitions/diff_backend_wgpu.json b/apigen/definitions/diff_backend_wgpu.json new file mode 100644 index 00000000..1fdfa692 --- /dev/null +++ b/apigen/definitions/diff_backend_wgpu.json @@ -0,0 +1,7 @@ +{ + "meta": { + "filename": "diff_backend_wgpu.json", + "description": "Defines how the native/desktop API differs from the base API.", + "notes": "Code that uses any of these cannot run on the web. Therefore we make this extra API explicit by using a suffix for everything that is added." + } +} diff --git a/apigen/definitions/diff_backend_wgpu.toml b/apigen/definitions/diff_backend_wgpu.toml deleted file mode 100644 index d7f65257..00000000 --- a/apigen/definitions/diff_backend_wgpu.toml +++ /dev/null @@ -1,5 +0,0 @@ -# diff_backend_wgpu.toml -# -# Defines how the native/desktop API differs from the base API. -# Code that uses any of these cannot run on the web. Therefore we make this extra API -# explicit by using a suffix for everything that is added. diff --git a/apigen/definitions/diff_base.json b/apigen/definitions/diff_base.json new file mode 100644 index 00000000..c8f71191 --- /dev/null +++ b/apigen/definitions/diff_base.json @@ -0,0 +1,29 @@ +{ + "meta": { + "filename": "diff_base.json", + "description": "Defines how our wgpu-py base API differs from the web-api (the one derived from webgpu.idl).", + "notes": "We mostly *remove* things that we cannot replicate on desktop. So that we get an API surface that is the intersection of what we can use on desktop and web." + }, + "classes": { + "GPUQueue": { + "methods": { + "copy_external_image_to_texture": { "diff": "REMOVE" } + } + }, + "GPUDevice": { + "methods": { + "import_external_texture": { "diff": "REMOVE" } + } + } + }, + "structs": { + "ExternalTextureBindingLayout": { "diff": "REMOVE" }, + "CopyExternalImageDestInfo": { "diff": "REMOVE" }, + "CopyExternalImageSourceInfo": { "diff": "REMOVE" }, + "BindGroupLayoutEntry": { + "fields": { + "external_texture": { "diff": "REMOVE" } + } + } + } +} diff --git a/apigen/definitions/diff_base.toml b/apigen/definitions/diff_base.toml deleted file mode 100644 index ee0f3641..00000000 --- a/apigen/definitions/diff_base.toml +++ /dev/null @@ -1,15 +0,0 @@ -# diff_base.toml -# -# Defines how our wgpu-py base API differs from the web-api (the one derived from webgpu.idl). -# We mostly *remove* things that we cannot replicate on desktop. So that we can an API surface that is the -# intersection of what we can use on desktop and web. - -# Remove things related to external textures -[classes] -GPUQueue.methods.copy_external_image_to_texture = {diff="REMOVE"} -GPUDevice.methods.import_external_texture = {diff="REMOVE"} -[structs] -ExternalTextureBindingLayout = {diff="REMOVE"} -CopyExternalImageDestInfo = {diff="REMOVE"} -CopyExternalImageSourceInfo = {diff="REMOVE"} -BindGroupLayoutEntry.fields.external_texture = {diff="REMOVE"} diff --git a/apigen/definitions/docs_ai.json b/apigen/definitions/docs_ai.json new file mode 100644 index 00000000..87f91f75 --- /dev/null +++ b/apigen/definitions/docs_ai.json @@ -0,0 +1,1826 @@ +{ + "meta": { + "filename": "docs_ai.json", + "description": "Complete documentation for the wgpu API, generated by Claude.", + "notes": "Claude was fed the Typescript definition ('index.d.ts', which includes docstrings) as input." + }, + "flags": { + "BufferUsage": { + "doc": "Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator.\n\nThe usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards.\nUsing a buffer in a way that was not declared here results in a validation error.\n", + "fields": { + "MAP_READ": { "doc": "The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST." }, + "MAP_WRITE": { "doc": "The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC." }, + "COPY_SRC": { "doc": "The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer()." }, + "COPY_DST": { "doc": "The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer()." }, + "INDEX": { "doc": "The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer()." }, + "VERTEX": { "doc": "The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer()." }, + "UNIFORM": { "doc": "The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform." }, + "STORAGE": { "doc": "The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage." }, + "INDIRECT": { "doc": "The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect()." }, + "QUERY_RESOLVE": { "doc": "The buffer can be the destination of GPUCommandEncoder.resolve_query_set()." } + } + }, + "MapMode": { + "doc": "Bit flags that specify whether a buffer is mapped for reading or writing.\n\nUsed in the mode argument of the GPUBuffer.map_async() method. The mode must match the\nflags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE.\n", + "fields": { + "READ": { "doc": "Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ." }, + "WRITE": { "doc": "Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE." } + } + }, + "TextureUsage": { + "doc": "Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator.\n\nThe usage is set when creating the texture (see the usage field of structs.TextureDescriptor).\nTexture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor).\n", + "fields": { + "COPY_SRC": { "doc": "The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer()." }, + "COPY_DST": { "doc": "The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture()." }, + "TEXTURE_BINDING": { "doc": "The texture can be bound for sampling in a shader, see structs.TextureBindingLayout." }, + "STORAGE_BINDING": { "doc": "The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout." }, + "RENDER_ATTACHMENT": { "doc": "The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor." }, + "TRANSIENT_ATTACHMENT": { "doc": "The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard." } + } + }, + "ShaderStage": { + "doc": "Bit flags that specify in which shader stages a resource is visible.\n\nUsed in the visibility field of structs.BindGroupLayoutEntry.\n", + "fields": { + "VERTEX": { "doc": "The vertex shader stage." }, + "FRAGMENT": { "doc": "The fragment shader stage." }, + "COMPUTE": { "doc": "The compute shader stage." } + } + }, + "ColorWrite": { + "doc": "Bit flags that specify which color channels of a render target are written to.\n\nUsed in the write_mask field of structs.ColorTargetState.\n", + "fields": { + "RED": { "doc": "Write the red channel." }, + "GREEN": { "doc": "Write the green channel." }, + "BLUE": { "doc": "Write the blue channel." }, + "ALPHA": { "doc": "Write the alpha channel." }, + "ALL": { "doc": "Write all channels (RED, GREEN, BLUE and ALPHA)." } + } + } + }, + "enums": { + "PowerPreference": { + "doc": "Hint for which kind of adapter to select.\n\nUsed in the power_preference field of structs.RequestAdapterOptions. This is only a hint;\nthe implementation may ignore it.\n", + "fields": { + "low_power": { "doc": "Prefer an adapter that uses little power, e.g. an integrated GPU." }, + "high_performance": { "doc": "Prefer an adapter with the highest performance, e.g. a discrete GPU." } + } + }, + "FeatureName": { + "doc": "Names of optional features that an adapter may support and a device may request.\n\nAvailable features can be inspected via the features property of GPUAdapter. Features\nare enabled by listing them in the required_features field of structs.DeviceDescriptor.\nThe features of the device are available via the features property of GPUDevice.\n", + "fields": { + "core_features_and_limits": { "doc": "Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode)." }, + "depth_clip_control": { "doc": "Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState." }, + "depth32float_stencil8": { "doc": "Enables enums.TextureFormat.depth32float_stencil8." }, + "texture_compression_bc": { "doc": "Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm." }, + "texture_compression_bc_sliced_d3": { "doc": "Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires enums.FeatureName.texture_compression_bc." }, + "texture_compression_etc2": { "doc": "Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm." }, + "texture_compression_astc": { "doc": "Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm." }, + "texture_compression_astc_sliced_d3": { "doc": "Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires enums.FeatureName.texture_compression_astc." }, + "timestamp_query": { "doc": "Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites." }, + "indirect_first_instance": { "doc": "Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect()." }, + "shader_f16": { "doc": "Allows the use of the f16 type in WGSL shaders (the enable f16 directive)." }, + "rg11b10ufloat_renderable": { "doc": "Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling." }, + "bgra8unorm_storage": { "doc": "Allows enums.TextureFormat.bgra8unorm to be used as a storage texture." }, + "float32_filterable": { "doc": "Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler." }, + "float32_blendable": { "doc": "Allows 32-bit float color attachments to be used with blending." }, + "clip_distances": { "doc": "Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes." }, + "dual_source_blending": { "doc": "Allows blending with a second fragment shader output, see enums.BlendFactor.src1." }, + "subgroups": { "doc": "Allows the use of subgroup operations in WGSL shaders." }, + "texture_formats_tier1": { "doc": "Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats." }, + "texture_formats_tier2": { "doc": "Enables further texture format capabilities, such as read-write storage access for more formats. Requires enums.FeatureName.texture_formats_tier1." }, + "primitive_index": { "doc": "Allows the primitive_index built-in in WGSL fragment shaders." }, + "texture_component_swizzle": { "doc": "Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor." } + } + }, + "BufferMapState": { + "doc": "The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer.\n", + "fields": { + "unmapped": { "doc": "The buffer is not mapped; it can be used by the GPU." }, + "pending": { "doc": "A GPUBuffer.map_async() call is in progress but has not yet completed." }, + "mapped": { "doc": "The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range()." } + } + }, + "TextureDimension": { + "doc": "The dimensionality of a GPUTexture.\n\nUsed in the dimension field of structs.TextureDescriptor.\n", + "fields": { + "d1": { "doc": "A one-dimensional texture, with only a width." }, + "d2": { "doc": "A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers)." }, + "d3": { "doc": "A three-dimensional (volume) texture, with width, height and depth." } + } + }, + "TextureViewDimension": { + "doc": "The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader.\n\nUsed in the dimension field of structs.TextureViewDescriptor and the view_dimension field of\nstructs.TextureBindingLayout and structs.StorageTextureBindingLayout.\n", + "fields": { + "d1": { "doc": "A one-dimensional view; corresponds to texture_1d in WGSL." }, + "d2": { "doc": "A two-dimensional view of a single layer; corresponds to texture_2d in WGSL." }, + "d2_array": { "doc": "A view of an array of 2D layers; corresponds to texture_2d_array in WGSL." }, + "cube": { "doc": "A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL." }, + "cube_array": { "doc": "A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL." }, + "d3": { "doc": "A three-dimensional view; corresponds to texture_3d in WGSL." } + } + }, + "TextureAspect": { + "doc": "Which aspect (part) of a texture a view or copy operation refers to.\n\nThis is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects.\n", + "fields": { + "all": { "doc": "All available aspects of the texture format." }, + "stencil_only": { "doc": "Only the stencil aspect of a depth-stencil format." }, + "depth_only": { "doc": "Only the depth aspect of a depth-stencil format." } + } + }, + "TextureFormat": { + "doc": "The pixel format of a GPUTexture.\n\nNames are of the form: channels, bit size per channel, and a type suffix.\nThe suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1),\nuint/sint = unsigned/signed integer, float = floating point, and srgb = the color\nis stored in sRGB and automatically converted to linear when sampled (and back when written).\nSome formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage).\n", + "fields": { + "r8unorm": { "doc": "One channel (red), 8-bit unsigned normalized." }, + "r8snorm": { "doc": "One channel (red), 8-bit signed normalized." }, + "r8uint": { "doc": "One channel (red), 8-bit unsigned integer." }, + "r8sint": { "doc": "One channel (red), 8-bit signed integer." }, + "r16unorm": { "doc": "One channel (red), 16-bit unsigned normalized. Requires enums.FeatureName.texture_formats_tier1." }, + "r16snorm": { "doc": "One channel (red), 16-bit signed normalized. Requires enums.FeatureName.texture_formats_tier1." }, + "r16uint": { "doc": "One channel (red), 16-bit unsigned integer." }, + "r16sint": { "doc": "One channel (red), 16-bit signed integer." }, + "r16float": { "doc": "One channel (red), 16-bit floating point." }, + "rg8unorm": { "doc": "Two channels (red, green), 8-bit unsigned normalized each." }, + "rg8snorm": { "doc": "Two channels (red, green), 8-bit signed normalized each." }, + "rg8uint": { "doc": "Two channels (red, green), 8-bit unsigned integer each." }, + "rg8sint": { "doc": "Two channels (red, green), 8-bit signed integer each." }, + "r32uint": { "doc": "One channel (red), 32-bit unsigned integer." }, + "r32sint": { "doc": "One channel (red), 32-bit signed integer." }, + "r32float": { "doc": "One channel (red), 32-bit floating point." }, + "rg16unorm": { "doc": "Two channels (red, green), 16-bit unsigned normalized each. Requires enums.FeatureName.texture_formats_tier1." }, + "rg16snorm": { "doc": "Two channels (red, green), 16-bit signed normalized each. Requires enums.FeatureName.texture_formats_tier1." }, + "rg16uint": { "doc": "Two channels (red, green), 16-bit unsigned integer each." }, + "rg16sint": { "doc": "Two channels (red, green), 16-bit signed integer each." }, + "rg16float": { "doc": "Two channels (red, green), 16-bit floating point each." }, + "rgba8unorm": { "doc": "Four channels (red, green, blue, alpha), 8-bit unsigned normalized each." }, + "rgba8unorm_srgb": { "doc": "Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels." }, + "rgba8snorm": { "doc": "Four channels (RGBA), 8-bit signed normalized each." }, + "rgba8uint": { "doc": "Four channels (RGBA), 8-bit unsigned integer each." }, + "rgba8sint": { "doc": "Four channels (RGBA), 8-bit signed integer each." }, + "bgra8unorm": { "doc": "Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format()." }, + "bgra8unorm_srgb": { "doc": "Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels." }, + "rgb9e5ufloat": { "doc": "Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable." }, + "rgb10a2uint": { "doc": "Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha." }, + "rgb10a2unorm": { "doc": "Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha." }, + "rg11b10ufloat": { "doc": "Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with enums.FeatureName.rg11b10ufloat_renderable." }, + "rg32uint": { "doc": "Two channels (red, green), 32-bit unsigned integer each." }, + "rg32sint": { "doc": "Two channels (red, green), 32-bit signed integer each." }, + "rg32float": { "doc": "Two channels (red, green), 32-bit floating point each." }, + "rgba16unorm": { "doc": "Four channels (RGBA), 16-bit unsigned normalized each. Requires enums.FeatureName.texture_formats_tier1." }, + "rgba16snorm": { "doc": "Four channels (RGBA), 16-bit signed normalized each. Requires enums.FeatureName.texture_formats_tier1." }, + "rgba16uint": { "doc": "Four channels (RGBA), 16-bit unsigned integer each." }, + "rgba16sint": { "doc": "Four channels (RGBA), 16-bit signed integer each." }, + "rgba16float": { "doc": "Four channels (RGBA), 16-bit floating point each." }, + "rgba32uint": { "doc": "Four channels (RGBA), 32-bit unsigned integer each." }, + "rgba32sint": { "doc": "Four channels (RGBA), 32-bit signed integer each." }, + "rgba32float": { "doc": "Four channels (RGBA), 32-bit floating point each." }, + "stencil8": { "doc": "A stencil-only format with 8 bits per pixel." }, + "depth16unorm": { "doc": "A depth-only format with 16-bit unsigned normalized depth." }, + "depth24plus": { "doc": "A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer." }, + "depth24plus_stencil8": { "doc": "A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer." }, + "depth32float": { "doc": "A depth-only format with 32-bit floating point depth." }, + "depth32float_stencil8": { "doc": "A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires enums.FeatureName.depth32float_stencil8." }, + "bc1_rgba_unorm": { "doc": "BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires enums.FeatureName.texture_compression_bc." }, + "bc1_rgba_unorm_srgb": { "doc": "BC1 (DXT1) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." }, + "bc2_rgba_unorm": { "doc": "BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires enums.FeatureName.texture_compression_bc." }, + "bc2_rgba_unorm_srgb": { "doc": "BC2 (DXT3) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." }, + "bc3_rgba_unorm": { "doc": "BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires enums.FeatureName.texture_compression_bc." }, + "bc3_rgba_unorm_srgb": { "doc": "BC3 (DXT5) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." }, + "bc4_r_unorm": { "doc": "BC4 compressed single channel, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." }, + "bc4_r_snorm": { "doc": "BC4 compressed single channel, signed normalized. Requires enums.FeatureName.texture_compression_bc." }, + "bc5_rg_unorm": { "doc": "BC5 compressed two channels, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." }, + "bc5_rg_snorm": { "doc": "BC5 compressed two channels, signed normalized. Requires enums.FeatureName.texture_compression_bc." }, + "bc6h_rgb_ufloat": { "doc": "BC6H compressed HDR RGB, unsigned float. Requires enums.FeatureName.texture_compression_bc." }, + "bc6h_rgb_float": { "doc": "BC6H compressed HDR RGB, signed float. Requires enums.FeatureName.texture_compression_bc." }, + "bc7_rgba_unorm": { "doc": "BC7 compressed RGBA, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." }, + "bc7_rgba_unorm_srgb": { "doc": "BC7 compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." }, + "etc2_rgb8unorm": { "doc": "ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." }, + "etc2_rgb8unorm_srgb": { "doc": "ETC2 compressed RGB with sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." }, + "etc2_rgb8a1unorm": { "doc": "ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." }, + "etc2_rgb8a1unorm_srgb": { "doc": "ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." }, + "etc2_rgba8unorm": { "doc": "ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." }, + "etc2_rgba8unorm_srgb": { "doc": "ETC2 compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." }, + "eac_r11unorm": { "doc": "EAC compressed single channel, 11-bit unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." }, + "eac_r11snorm": { "doc": "EAC compressed single channel, 11-bit signed normalized. Requires enums.FeatureName.texture_compression_etc2." }, + "eac_rg11unorm": { "doc": "EAC compressed two channels, 11-bit unsigned normalized each. Requires enums.FeatureName.texture_compression_etc2." }, + "eac_rg11snorm": { "doc": "EAC compressed two channels, 11-bit signed normalized each. Requires enums.FeatureName.texture_compression_etc2." }, + "astc_4x4_unorm": { "doc": "ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_4x4_unorm_srgb": { "doc": "ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_5x4_unorm": { "doc": "ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_5x4_unorm_srgb": { "doc": "ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_5x5_unorm": { "doc": "ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_5x5_unorm_srgb": { "doc": "ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_6x5_unorm": { "doc": "ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_6x5_unorm_srgb": { "doc": "ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_6x6_unorm": { "doc": "ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_6x6_unorm_srgb": { "doc": "ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x5_unorm": { "doc": "ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x5_unorm_srgb": { "doc": "ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x6_unorm": { "doc": "ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x6_unorm_srgb": { "doc": "ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x8_unorm": { "doc": "ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_8x8_unorm_srgb": { "doc": "ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x5_unorm": { "doc": "ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x5_unorm_srgb": { "doc": "ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x6_unorm": { "doc": "ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x6_unorm_srgb": { "doc": "ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x8_unorm": { "doc": "ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x8_unorm_srgb": { "doc": "ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x10_unorm": { "doc": "ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_10x10_unorm_srgb": { "doc": "ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_12x10_unorm": { "doc": "ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_12x10_unorm_srgb": { "doc": "ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." }, + "astc_12x12_unorm": { "doc": "ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." }, + "astc_12x12_unorm_srgb": { "doc": "ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." } + } + }, + "AddressMode": { + "doc": "How a sampler handles texture coordinates outside the 0..1 range, per axis.\n\nUsed in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor.\n", + "fields": { + "clamp_to_edge": { "doc": "Coordinates are clamped to the range 0..1, so the edge texels are repeated." }, + "repeat": { "doc": "The texture tiles: only the fractional part of the coordinate is used." }, + "mirror_repeat": { "doc": "The texture tiles, but is mirrored every other repetition." } + } + }, + "FilterMode": { + "doc": "How a sampler filters texels when a texture is magnified or minified.\n\nUsed in the mag_filter and min_filter fields of structs.SamplerDescriptor.\n", + "fields": { + "nearest": { "doc": "Use the value of the nearest texel." }, + "linear": { "doc": "Linearly interpolate between the nearest texels." } + } + }, + "MipmapFilterMode": { + "doc": "How a sampler filters between mip levels.\n\nUsed in the mipmap_filter field of structs.SamplerDescriptor.\n", + "fields": { + "nearest": { "doc": "Use the nearest mip level." }, + "linear": { "doc": "Linearly interpolate between the two nearest mip levels." } + } + }, + "CompareFunction": { + "doc": "A comparison function, used for depth testing, stencil testing and comparison samplers.\n\nThe comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to\nthe existing value. If the comparison is true, the test passes.\n", + "fields": { + "never": { "doc": "The comparison never passes." }, + "less": { "doc": "Passes if the new value is less than the existing value." }, + "equal": { "doc": "Passes if the new value is equal to the existing value." }, + "less_equal": { "doc": "Passes if the new value is less than or equal to the existing value." }, + "greater": { "doc": "Passes if the new value is greater than the existing value." }, + "not_equal": { "doc": "Passes if the new value is not equal to the existing value." }, + "greater_equal": { "doc": "Passes if the new value is greater than or equal to the existing value." }, + "always": { "doc": "The comparison always passes." } + } + }, + "BufferBindingType": { + "doc": "The type of a buffer binding in a bind group layout.\n\nUsed in the type field of structs.BufferBindingLayout.\n", + "fields": { + "uniform": { "doc": "A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM." }, + "storage": { "doc": "A read-write storage buffer. Requires flags.BufferUsage.STORAGE." }, + "read_only_storage": { "doc": "A read-only storage buffer. Requires flags.BufferUsage.STORAGE." } + } + }, + "SamplerBindingType": { + "doc": "The type of a sampler binding in a bind group layout.\n\nUsed in the type field of structs.SamplerBindingLayout.\n", + "fields": { + "filtering": { "doc": "A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float." }, + "non_filtering": { "doc": "A sampler that only uses nearest filtering. Can be used with any float texture." }, + "comparison": { "doc": "A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor)." } + } + }, + "TextureSampleType": { + "doc": "The type of values that is returned when sampling a texture in a shader.\n\nUsed in the sample_type field of structs.TextureBindingLayout.\n", + "fields": { + "float": { "doc": "Floating point values; the texture can be sampled with a filtering sampler." }, + "unfilterable_float": { "doc": "Floating point values, but the texture cannot be filtered (e.g. 32-bit float without enums.FeatureName.float32_filterable)." }, + "depth": { "doc": "Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler." }, + "sint": { "doc": "Signed integer values." }, + "uint": { "doc": "Unsigned integer values." } + } + }, + "StorageTextureAccess": { + "doc": "How a storage texture can be accessed by a shader.\n\nUsed in the access field of structs.StorageTextureBindingLayout.\n", + "fields": { + "write_only": { "doc": "The shader can only write to the texture." }, + "read_only": { "doc": "The shader can only read from the texture." }, + "read_write": { "doc": "The shader can both read from and write to the texture." } + } + }, + "CompilationMessageType": { + "doc": "The severity of a GPUCompilationMessage.\n", + "fields": { + "error": { "doc": "An error; the shader module is invalid." }, + "warning": { "doc": "A warning; the shader module is valid but something may be wrong." }, + "info": { "doc": "An informational message." } + } + }, + "PipelineErrorReason": { + "doc": "The reason for a GPUPipelineError.\n\nAvailable via the reason property of GPUPipelineError.\n", + "fields": { + "validation": { "doc": "The pipeline failed validation, e.g. because of an invalid descriptor or shader." }, + "internal": { "doc": "An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend." } + } + }, + "AutoLayoutMode": { + "doc": "Indicates that a pipeline layout should be derived automatically from the shader code.\n\nUsed as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor.\nThe resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout().\n", + "fields": { + "auto": { "doc": "Derive the pipeline layout from the shader." } + } + }, + "PrimitiveTopology": { + "doc": "How vertices are assembled into primitives.\n\nUsed in the topology field of structs.PrimitiveState.\n", + "fields": { + "point_list": { "doc": "Each vertex defines a point." }, + "line_list": { "doc": "Each pair of vertices defines a separate line." }, + "line_strip": { "doc": "Each vertex after the first defines a line to the previous vertex." }, + "triangle_list": { "doc": "Each triple of vertices defines a separate triangle." }, + "triangle_strip": { "doc": "Each vertex after the first two defines a triangle with the previous two vertices." } + } + }, + "FrontFace": { + "doc": "Defines which winding order of a triangle is considered front-facing.\n\nUsed in the front_face field of structs.PrimitiveState.\n", + "fields": { + "ccw": { "doc": "Triangles with counter-clockwise vertices (in framebuffer space) are front-facing." }, + "cw": { "doc": "Triangles with clockwise vertices (in framebuffer space) are front-facing." } + } + }, + "CullMode": { + "doc": "Defines which faces of triangles are culled (not drawn).\n\nUsed in the cull_mode field of structs.PrimitiveState.\n", + "fields": { + "none": { "doc": "No faces are culled." }, + "front": { "doc": "Front-facing triangles are culled." }, + "back": { "doc": "Back-facing triangles are culled." } + } + }, + "BlendFactor": { + "doc": "A factor that is multiplied with the source or destination color or alpha in blending.\n\nUsed in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions,\nsrc is the output of the fragment shader and dst is the existing value in the render target.\n", + "fields": { + "zero": { "doc": "Factor 0." }, + "one": { "doc": "Factor 1." }, + "src": { "doc": "The source color, per component." }, + "one_minus_src": { "doc": "One minus the source color, per component." }, + "src_alpha": { "doc": "The source alpha." }, + "one_minus_src_alpha": { "doc": "One minus the source alpha." }, + "dst": { "doc": "The destination color, per component." }, + "one_minus_dst": { "doc": "One minus the destination color, per component." }, + "dst_alpha": { "doc": "The destination alpha." }, + "one_minus_dst_alpha": { "doc": "One minus the destination alpha." }, + "src_alpha_saturated": { "doc": "The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha." }, + "constant": { "doc": "The blend constant color, see GPURenderPassEncoder.set_blend_constant()." }, + "one_minus_constant": { "doc": "One minus the blend constant color." }, + "src1": { "doc": "The second source color output of the fragment shader. Requires enums.FeatureName.dual_source_blending." }, + "one_minus_src1": { "doc": "One minus the second source color. Requires enums.FeatureName.dual_source_blending." }, + "src1_alpha": { "doc": "The second source alpha. Requires enums.FeatureName.dual_source_blending." }, + "one_minus_src1_alpha": { "doc": "One minus the second source alpha. Requires enums.FeatureName.dual_source_blending." } + } + }, + "BlendOperation": { + "doc": "The operation used to combine the scaled source and destination values in blending.\n\nUsed in the operation field of structs.BlendComponent.\n", + "fields": { + "add": { "doc": "Result is source plus destination." }, + "subtract": { "doc": "Result is source minus destination." }, + "reverse_subtract": { "doc": "Result is destination minus source." }, + "min": { "doc": "Result is the minimum of source and destination (blend factors are ignored)." }, + "max": { "doc": "Result is the maximum of source and destination (blend factors are ignored)." } + } + }, + "StencilOperation": { + "doc": "The operation performed on the stencil buffer value after a stencil or depth test.\n\nUsed in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState.\n", + "fields": { + "keep": { "doc": "Keep the current stencil value." }, + "zero": { "doc": "Set the stencil value to zero." }, + "replace": { "doc": "Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference()." }, + "invert": { "doc": "Bitwise invert the current stencil value." }, + "increment_clamp": { "doc": "Increment the stencil value, clamping to the maximum." }, + "decrement_clamp": { "doc": "Decrement the stencil value, clamping to zero." }, + "increment_wrap": { "doc": "Increment the stencil value, wrapping to zero on overflow." }, + "decrement_wrap": { "doc": "Decrement the stencil value, wrapping to the maximum on underflow." } + } + }, + "IndexFormat": { + "doc": "The data type of the indices in an index buffer.\n\nUsed in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method\nand the strip_index_format field of structs.PrimitiveState.\n", + "fields": { + "uint16": { "doc": "Indices are 16-bit unsigned integers." }, + "uint32": { "doc": "Indices are 32-bit unsigned integers." } + } + }, + "VertexFormat": { + "doc": "The format of a vertex attribute in a vertex buffer.\n\nUsed in the format field of structs.VertexAttribute. The name consists of the component type and\nbit size, optionally followed by xN for the number of components. The shader sees the data as\nfloat (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components.\n", + "fields": { + "uint8": { "doc": "One 8-bit unsigned integer." }, + "uint8x2": { "doc": "Two 8-bit unsigned integers." }, + "uint8x4": { "doc": "Four 8-bit unsigned integers." }, + "sint8": { "doc": "One 8-bit signed integer." }, + "sint8x2": { "doc": "Two 8-bit signed integers." }, + "sint8x4": { "doc": "Four 8-bit signed integers." }, + "unorm8": { "doc": "One 8-bit unsigned normalized value (0..1)." }, + "unorm8x2": { "doc": "Two 8-bit unsigned normalized values (0..1)." }, + "unorm8x4": { "doc": "Four 8-bit unsigned normalized values (0..1)." }, + "snorm8": { "doc": "One 8-bit signed normalized value (-1..1)." }, + "snorm8x2": { "doc": "Two 8-bit signed normalized values (-1..1)." }, + "snorm8x4": { "doc": "Four 8-bit signed normalized values (-1..1)." }, + "uint16": { "doc": "One 16-bit unsigned integer." }, + "uint16x2": { "doc": "Two 16-bit unsigned integers." }, + "uint16x4": { "doc": "Four 16-bit unsigned integers." }, + "sint16": { "doc": "One 16-bit signed integer." }, + "sint16x2": { "doc": "Two 16-bit signed integers." }, + "sint16x4": { "doc": "Four 16-bit signed integers." }, + "unorm16": { "doc": "One 16-bit unsigned normalized value (0..1)." }, + "unorm16x2": { "doc": "Two 16-bit unsigned normalized values (0..1)." }, + "unorm16x4": { "doc": "Four 16-bit unsigned normalized values (0..1)." }, + "snorm16": { "doc": "One 16-bit signed normalized value (-1..1)." }, + "snorm16x2": { "doc": "Two 16-bit signed normalized values (-1..1)." }, + "snorm16x4": { "doc": "Four 16-bit signed normalized values (-1..1)." }, + "float16": { "doc": "One 16-bit float." }, + "float16x2": { "doc": "Two 16-bit floats." }, + "float16x4": { "doc": "Four 16-bit floats." }, + "float32": { "doc": "One 32-bit float." }, + "float32x2": { "doc": "Two 32-bit floats." }, + "float32x3": { "doc": "Three 32-bit floats." }, + "float32x4": { "doc": "Four 32-bit floats." }, + "uint32": { "doc": "One 32-bit unsigned integer." }, + "uint32x2": { "doc": "Two 32-bit unsigned integers." }, + "uint32x3": { "doc": "Three 32-bit unsigned integers." }, + "uint32x4": { "doc": "Four 32-bit unsigned integers." }, + "sint32": { "doc": "One 32-bit signed integer." }, + "sint32x2": { "doc": "Two 32-bit signed integers." }, + "sint32x3": { "doc": "Three 32-bit signed integers." }, + "sint32x4": { "doc": "Four 32-bit signed integers." }, + "unorm10_10_10_2": { "doc": "A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float." }, + "unorm8x4_bgra": { "doc": "Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order." } + } + }, + "VertexStepMode": { + "doc": "How often a vertex buffer is advanced.\n\nUsed in the step_mode field of structs.VertexBufferLayout.\n", + "fields": { + "vertex": { "doc": "The buffer is advanced for each vertex." }, + "instance": { "doc": "The buffer is advanced for each instance." } + } + }, + "LoadOp": { + "doc": "What happens to the contents of an attachment at the start of a render pass.\n\nUsed in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment.\n", + "fields": { + "load": { "doc": "Keep the existing contents of the attachment." }, + "clear": { "doc": "Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment). Clearing is preferred over load when the old contents are not needed; it can be faster, especially on tiled GPUs." } + } + }, + "StoreOp": { + "doc": "What happens to the contents of an attachment at the end of a render pass.\n\nUsed in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment.\n", + "fields": { + "store": { "doc": "Store the results of the render pass in the attachment." }, + "discard": { "doc": "Discard the results; the contents of the attachment become undefined (zero-initialized when next used)." } + } + }, + "QueryType": { + "doc": "The type of queries in a GPUQuerySet.\n\nUsed in the type field of structs.QuerySetDescriptor.\n", + "fields": { + "occlusion": { "doc": "Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query()." }, + "timestamp": { "doc": "Timestamp queries record GPU timestamps. Requires enums.FeatureName.timestamp_query." } + } + }, + "CanvasAlphaMode": { + "doc": "How the alpha channel of a canvas texture is interpreted when compositing with the page or window.\n\nUsed in the alpha_mode field of structs.CanvasConfiguration.\n", + "fields": { + "opaque": { "doc": "The alpha channel is ignored and the canvas is treated as fully opaque." }, + "premultiplied": { "doc": "The color channels are expected to be premultiplied by the alpha channel." } + } + }, + "CanvasToneMappingMode": { + "doc": "How the content of a canvas is tone mapped when displayed.\n\nUsed in the mode field of structs.CanvasToneMapping.\n", + "fields": { + "standard": { "doc": "Color values are clamped to the standard dynamic range (SDR) of the display." }, + "extended": { "doc": "Color values may exceed the SDR range, up to the dynamic range of the display (HDR)." } + } + }, + "DeviceLostReason": { + "doc": "The reason a GPUDevice was lost.\n\nAvailable via the reason property of GPUDeviceLostInfo.\n", + "fields": { + "unknown": { "doc": "The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal." }, + "destroyed": { "doc": "The device was lost because GPUDevice.destroy() was called." } + } + }, + "ErrorFilter": { + "doc": "The type of error that is captured by an error scope.\n\nUsed in the filter argument of the GPUDevice.push_error_scope() method.\n", + "fields": { + "validation": { "doc": "Captures GPUValidationError errors, which signal incorrect API usage." }, + "out_of_memory": { "doc": "Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation." }, + "internal": { "doc": "Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits)." } + } + } + }, + "structs": { + "RequestAdapterOptions": { + "doc": "Options for requesting an adapter.\n\nUsed as the options argument of the GPU.request_adapter() method.\n", + "fields": { + "feature_level": { "doc": "The feature level to request: 'core' (default) or 'compatibility'. Core implies the default limits and enums.FeatureName.core_features_and_limits; compatibility has stricter, more widely supported defaults and no features. If the implementation cannot enforce the compatibility rules it treats the request as core. If the level is not supported, no adapter is returned." }, + "power_preference": { "doc": "Hint for the kind of adapter to select, see enums.PowerPreference. It may influence which adapter is chosen (mainly in multi-GPU systems), but never whether an adapter is returned." }, + "force_fallback_adapter": { "doc": "If true, only a fallback adapter may be returned (no adapter if unsupported). If false, a fallback adapter may still be returned; check the is_fallback_adapter property of GPUAdapterInfo to avoid it." }, + "xr_compatible": { "doc": "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." } + } + }, + "DeviceDescriptor": { + "doc": "Descriptor for requesting a device.\n\nUsed as the descriptor argument of the GPUAdapter.request_device() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the device, used in debugging and error messages." }, + "required_features": { "doc": "A list of enums.FeatureName that the device must support. The request fails if the adapter cannot provide them. Exactly this set of features, no more and no less, is allowed on the resulting device." }, + "required_limits": { "doc": "A mapping of limit names to the values the device requires; the request fails if the adapter cannot provide them. Unspecified limits get their default value. Validation on the device uses these exact limits, not the (possibly higher) limits of the adapter." }, + "default_queue": { "doc": "A structs.QueueDescriptor with options for the default queue of the device." } + } + }, + "BufferDescriptor": { + "doc": "Descriptor for creating a GPUBuffer.\n\nUsed as the descriptor argument of the GPUDevice.create_buffer() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the buffer, used in debugging and error messages." }, + "size": { "doc": "The size of the buffer in bytes." }, + "usage": { "doc": "The allowed usages of the buffer, a combination of flags.BufferUsage." }, + "mapped_at_creation": { "doc": "If true, the buffer is created in a mapped state so GPUBuffer.get_mapped_range() can be called immediately, which is useful to set initial data. This is allowed even without flags.BufferUsage.MAP_READ or flags.BufferUsage.MAP_WRITE. The size must then be a multiple of 4." } + } + }, + "TextureDescriptor": { + "doc": "Descriptor for creating a GPUTexture.\n\nUsed as the descriptor argument of the GPUDevice.create_texture() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the texture, used in debugging and error messages." }, + "size": { "doc": "The size of the texture as a structs.Extent3D, or a tuple of (width, height, depth_or_array_layers). Height and depth default to 1." }, + "mip_level_count": { "doc": "The number of mip levels. Defaults to 1." }, + "sample_count": { "doc": "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." }, + "dimension": { "doc": "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." }, + "format": { "doc": "The pixel format of the texture, see enums.TextureFormat." }, + "usage": { "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." }, + "view_formats": { "doc": "Additional enums.TextureFormat values that views of this texture may use in GPUTexture.create_view(). They must be view-compatible with the texture format: equal, or (on devices with enums.FeatureName.core_features_and_limits) differing only in sRGB-ness. Adding formats can hurt performance on some systems, so only add what is needed." }, + "texture_binding_view_dimension": { "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. A default is chosen if omitted. Ignored on core devices." } + } + }, + "TextureViewDescriptor": { + "doc": "Descriptor for creating a GPUTextureView.\n\nUsed as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields\nget a default derived from the texture, so by default the view covers the whole texture.\n", + "fields": { + "label": { "doc": "A human-readable label for the texture view, used in debugging and error messages." }, + "format": { "doc": "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." }, + "dimension": { "doc": "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." }, + "usage": { "doc": "The usages the view will be used for, a subset of the usage of the texture (see flags.TextureUsage). If 0 or omitted, defaults to all usages of the texture; this fails if the view format does not support all of them, in which case set it explicitly." }, + "aspect": { "doc": "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." }, + "base_mip_level": { "doc": "The first mip level accessible via the view. Defaults to 0." }, + "mip_level_count": { "doc": "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." }, + "base_array_layer": { "doc": "The first array layer accessible via the view. Defaults to 0." }, + "array_layer_count": { "doc": "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." }, + "swizzle": { "doc": "A string of four characters (default 'rgba') that defines how the components of the view are mapped, e.g. 'bgra'. Allowed characters are r, g, b, a, 0 and 1. Requires enums.FeatureName.texture_component_swizzle." } + } + }, + "ExternalTextureDescriptor": { + "doc": "Descriptor for importing an external texture, such as a video frame.\n\nUsed as the descriptor argument of the GPUDevice.import_external_texture() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the external texture, used in debugging and error messages." }, + "source": { "doc": "The source of the image data, e.g. a video element or video frame. Only meaningful in browser environments." }, + "color_space": { "doc": "The color space of the source image, e.g. 'srgb'. Defaults to 'srgb'." } + } + }, + "SamplerDescriptor": { + "doc": "Descriptor for creating a GPUSampler.\n\nUsed as the descriptor argument of the GPUDevice.create_sampler() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the sampler, used in debugging and error messages." }, + "address_mode_u": { "doc": "How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, + "address_mode_v": { "doc": "How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, + "address_mode_w": { "doc": "How to handle texture coordinates outside 0..1 along the w (z) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, + "mag_filter": { "doc": "The filter used when the sampled area is smaller than or equal to one texel (magnification), see enums.FilterMode. Defaults to nearest." }, + "min_filter": { "doc": "The filter used when the sampled area is larger than one texel (minification), see enums.FilterMode. Defaults to nearest." }, + "mipmap_filter": { "doc": "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." }, + "lod_min_clamp": { "doc": "The minimum level of detail used when sampling. Defaults to 0." }, + "lod_max_clamp": { "doc": "The maximum level of detail used when sampling. Defaults to 32." }, + "compare": { "doc": "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures. Filtering results of comparison samplers are implementation-dependent." }, + "max_anisotropy": { "doc": "The maximum anisotropy for anisotropic filtering: 1 (default) disables it. Values above 1 require all filters to be linear. The value is clamped to the platform maximum (typically 16)." } + } + }, + "BindGroupLayoutDescriptor": { + "doc": "Descriptor for creating a GPUBindGroupLayout.\n\nUsed as the descriptor argument of the GPUDevice.create_bind_group_layout() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the bind group layout, used in debugging and error messages." }, + "entries": { "doc": "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." } + } + }, + "BindGroupLayoutEntry": { + "doc": "Describes a single binding in a bind group layout.\n\nExactly one of buffer, sampler, texture, storage_texture and external_texture must be set,\nwhich determines the type of resource that is bound.\n", + "fields": { + "binding": { "doc": "The binding number, matching the @binding attribute in the shader." }, + "visibility": { "doc": "The shader stages in which the resource is visible, a combination of flags.ShaderStage." }, + "buffer": { "doc": "If set, a structs.BufferBindingLayout: the entry is a buffer binding." }, + "sampler": { "doc": "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." }, + "texture": { "doc": "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." }, + "storage_texture": { "doc": "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." }, + "external_texture": { "doc": "If set, a structs.ExternalTextureBindingLayout: the entry is an external texture binding." } + } + }, + "BufferBindingLayout": { + "doc": "Describes the layout of a buffer binding.\n\nUsed in the buffer field of structs.BindGroupLayoutEntry.\n", + "fields": { + "type": { "doc": "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." }, + "has_dynamic_offset": { "doc": "If true, an offset can be given in GPUBindingCommandsMixin.set_bind_group() when binding. Defaults to false." }, + "min_binding_size": { "doc": "The minimum size in bytes of a buffer bound to this entry; bindings are always validated against it in GPUDevice.create_bind_group(). If non-zero, pipeline creation also checks it against the minimum binding size of the shader variable. If 0 (default), that check is skipped at pipeline creation and done at draw/dispatch time instead." } + } + }, + "SamplerBindingLayout": { + "doc": "Describes the layout of a sampler binding.\n\nUsed in the sampler field of structs.BindGroupLayoutEntry.\n", + "fields": { + "type": { "doc": "The type of sampler binding, see enums.SamplerBindingType. Defaults to filtering." } + } + }, + "TextureBindingLayout": { + "doc": "Describes the layout of a sampled texture binding.\n\nUsed in the texture field of structs.BindGroupLayoutEntry.\n", + "fields": { + "sample_type": { "doc": "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." }, + "view_dimension": { "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." }, + "multisampled": { "doc": "If true, the bound texture must be multisampled. Defaults to false." } + } + }, + "StorageTextureBindingLayout": { + "doc": "Describes the layout of a storage texture binding.\n\nUsed in the storage_texture field of structs.BindGroupLayoutEntry.\n", + "fields": { + "access": { "doc": "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." }, + "format": { "doc": "The enums.TextureFormat that the bound texture view must have." }, + "view_dimension": { "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." } + } + }, + "ExternalTextureBindingLayout": { "doc": "Describes the layout of an external texture binding.\n\nUsed in the external_texture field of structs.BindGroupLayoutEntry. It has no fields.\n" }, + "BindGroupDescriptor": { + "doc": "Descriptor for creating a GPUBindGroup.\n\nUsed as the descriptor argument of the GPUDevice.create_bind_group() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the bind group, used in debugging and error messages." }, + "layout": { "doc": "The GPUBindGroupLayout that this bind group conforms to." }, + "entries": { "doc": "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." } + } + }, + "BindGroupEntry": { + "doc": "A single resource binding in a bind group.\n\nUsed in the entries field of structs.BindGroupDescriptor.\n", + "fields": { + "binding": { "doc": "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." }, + "resource": { "doc": "The resource to bind: a GPUSampler, GPUTexture (as its default view), GPUTextureView, GPUBuffer (the whole buffer), structs.BufferBinding, or GPUExternalTexture. Must match the type in the corresponding layout entry." } + } + }, + "BufferBinding": { + "doc": "Describes a range of a GPUBuffer to bind.\n\nCan be used as the resource field of structs.BindGroupEntry.\n", + "fields": { + "buffer": { "doc": "The GPUBuffer to bind." }, + "offset": { "doc": "The offset in bytes into the buffer where the binding starts. Defaults to 0." }, + "size": { "doc": "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." } + } + }, + "PipelineLayoutDescriptor": { + "doc": "Descriptor for creating a GPUPipelineLayout.\n\nUsed as the descriptor argument of the GPUDevice.create_pipeline_layout() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the pipeline layout, used in debugging and error messages." }, + "bind_group_layouts": { "doc": "A list of GPUBindGroupLayout (or None for unused groups) used by the pipeline. The Nth element corresponds to @group(N) in the shader." }, + "immediate_size": { "doc": "The size in bytes of the immediate data (small data set with GPUBindingCommandsMixin.set_immediates()). Defaults to 0." } + } + }, + "ShaderModuleDescriptor": { + "doc": "Descriptor for creating a GPUShaderModule.\n\nUsed as the descriptor argument of the GPUDevice.create_shader_module() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the shader module, used in debugging and error messages." }, + "code": { "doc": "The shader source code, in WGSL." }, + "compilation_hints": { "doc": "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile early. Hints only affect performance, are not validated, and only apply to the entry points they name (there is no default entry point)." } + } + }, + "ShaderModuleCompilationHint": { + "doc": "A hint for the compilation of a shader module.\n\nUsed in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only\naffect performance, not behavior.\n", + "fields": { + "entry_point": { "doc": "The name of the shader entry point that the hint applies to." }, + "layout": { "doc": "The GPUPipelineLayout that the entry point will be used with, or enums.AutoLayoutMode.auto (the default pipeline layout for that entry point)." } + } + }, + "PipelineErrorInit": { + "doc": "Initialization options for a GPUPipelineError.\n\nUsed as the options argument of the GPUPipelineError constructor.\n", + "fields": { + "reason": { "doc": "The reason for the error, see enums.PipelineErrorReason." } + } + }, + "ProgrammableStage": { + "doc": "Describes a programmable (shader) stage of a pipeline.\n\nThis is the base for structs.VertexState, structs.FragmentState and the compute field of\nstructs.ComputePipelineDescriptor.\n", + "fields": { + "module": { "doc": "The GPUShaderModule containing the shader code." }, + "entry_point": { "doc": "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." }, + "constants": { "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." } + } + }, + "ComputePipelineDescriptor": { + "doc": "Descriptor for creating a GPUComputePipeline.\n\nUsed as the descriptor argument of the GPUDevice.create_compute_pipeline() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the pipeline, used in debugging and error messages." }, + "layout": { "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." }, + "compute": { "doc": "A structs.ProgrammableStage describing the compute shader." } + } + }, + "RenderPipelineDescriptor": { + "doc": "Descriptor for creating a GPURenderPipeline.\n\nUsed as the descriptor argument of the GPUDevice.create_render_pipeline() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the pipeline, used in debugging and error messages." }, + "layout": { "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." }, + "vertex": { "doc": "A structs.VertexState describing the vertex shader and vertex buffers." }, + "primitive": { "doc": "A structs.PrimitiveState describing how primitives are assembled and rasterized." }, + "depth_stencil": { "doc": "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." }, + "multisample": { "doc": "A structs.MultisampleState describing multisampling." }, + "fragment": { "doc": "An optional structs.FragmentState describing the fragment shader and render targets. If omitted, the pipeline has no color output (e.g. for depth-only passes)." } + } + }, + "PrimitiveState": { + "doc": "Describes how a render pipeline assembles and rasterizes primitives.\n\nUsed in the primitive field of structs.RenderPipelineDescriptor.\n", + "fields": { + "topology": { "doc": "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." }, + "strip_index_format": { "doc": "The enums.IndexFormat of the index buffer, which sets the primitive restart value (0xFFFF for uint16, 0xFFFFFFFF for uint32). Only allowed for strip topologies, where it is required for indexed draws and must match the format given to GPURenderCommandsMixin.set_index_buffer()." }, + "front_face": { "doc": "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." }, + "cull_mode": { "doc": "Which faces to cull, see enums.CullMode. Defaults to none." }, + "unclipped_depth": { "doc": "If true, primitives are not clipped by the near and far planes. Requires enums.FeatureName.depth_clip_control." } + } + }, + "MultisampleState": { + "doc": "Describes the multisampling of a render pipeline.\n\nUsed in the multisample field of structs.RenderPipelineDescriptor.\n", + "fields": { + "count": { "doc": "The number of samples per pixel. Must be 1 or 4. The pipeline is only compatible with attachments that have a matching sample count. Defaults to 1." }, + "mask": { "doc": "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." }, + "alpha_to_coverage_enabled": { "doc": "If true, the alpha output of the fragment shader is used to generate a coverage mask. Defaults to false." } + } + }, + "FragmentState": { + "doc": "Describes the fragment shader stage and render targets of a render pipeline.\n\nUsed in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage.\n", + "fields": { + "module": { "doc": "The GPUShaderModule containing the fragment shader code." }, + "entry_point": { "doc": "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." }, + "constants": { "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, + "targets": { "doc": "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." } + } + }, + "ColorTargetState": { + "doc": "Describes a color render target of a render pipeline.\n\nUsed in the targets field of structs.FragmentState.\n", + "fields": { + "format": { "doc": "The enums.TextureFormat of this color target. The pipeline is only compatible with render passes that use a view of this format in the corresponding color attachment." }, + "blend": { "doc": "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." }, + "write_mask": { "doc": "Which channels are written, a combination of flags.ColorWrite. Defaults to ALL." } + } + }, + "BlendState": { + "doc": "Describes how blending is performed for a color target.\n\nUsed in the blend field of structs.ColorTargetState.\n", + "fields": { + "color": { "doc": "A structs.BlendComponent for the color (RGB) channels." }, + "alpha": { "doc": "A structs.BlendComponent for the alpha channel." } + } + }, + "BlendComponent": { + "doc": "Describes how the blending of a single component (color or alpha) is performed.\n\nThe result is: operation(src * src_factor, dst * dst_factor).\n", + "fields": { + "operation": { "doc": "The enums.BlendOperation used to combine the scaled values. Defaults to add." }, + "src_factor": { "doc": "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." }, + "dst_factor": { "doc": "The enums.BlendFactor applied to the destination (existing target value). Defaults to zero." } + } + }, + "DepthStencilState": { + "doc": "Describes the depth and stencil state of a render pipeline.\n\nUsed in the depth_stencil field of structs.RenderPipelineDescriptor.\n", + "fields": { + "format": { "doc": "The enums.TextureFormat of the depth-stencil attachment that this pipeline is compatible with." }, + "depth_write_enabled": { "doc": "If true, depth values of fragments that pass the depth test are written to the attachment." }, + "depth_compare": { "doc": "The enums.CompareFunction used for the depth test." }, + "stencil_front": { "doc": "A structs.StencilFaceState for front-facing primitives." }, + "stencil_back": { "doc": "A structs.StencilFaceState for back-facing primitives." }, + "stencil_read_mask": { "doc": "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." }, + "stencil_write_mask": { "doc": "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." }, + "depth_bias": { "doc": "A constant depth value added to each fragment. Defaults to 0." }, + "depth_bias_slope_scale": { "doc": "A depth bias that scales with the slope of the primitive. Defaults to 0." }, + "depth_bias_clamp": { "doc": "The maximum (or minimum, if negative) depth bias of a fragment. Defaults to 0." } + } + }, + "StencilFaceState": { + "doc": "Describes the stencil operations for one face (front or back) of primitives.\n\nUsed in the stencil_front and stencil_back fields of structs.DepthStencilState.\n", + "fields": { + "compare": { "doc": "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." }, + "fail_op": { "doc": "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." }, + "depth_fail_op": { "doc": "The enums.StencilOperation performed if the stencil test passes but the depth test fails. Defaults to keep." }, + "pass_op": { "doc": "The enums.StencilOperation performed if both the stencil and depth tests pass. Defaults to keep." } + } + }, + "VertexState": { + "doc": "Describes the vertex shader stage and vertex buffers of a render pipeline.\n\nUsed in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage.\n", + "fields": { + "module": { "doc": "The GPUShaderModule containing the vertex shader code." }, + "entry_point": { "doc": "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." }, + "constants": { "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, + "buffers": { "doc": "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." } + } + }, + "VertexBufferLayout": { + "doc": "Describes the layout of a vertex buffer.\n\nUsed in the buffers field of structs.VertexState.\n", + "fields": { + "array_stride": { "doc": "The stride in bytes between consecutive elements in the buffer." }, + "step_mode": { "doc": "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." }, + "attributes": { "doc": "A list of structs.VertexAttribute describing the attributes in each element." } + } + }, + "VertexAttribute": { + "doc": "Describes a single vertex attribute within a vertex buffer.\n\nUsed in the attributes field of structs.VertexBufferLayout.\n", + "fields": { + "format": { "doc": "The enums.VertexFormat of the attribute." }, + "offset": { "doc": "The offset in bytes of the attribute from the start of an element in the buffer." }, + "shader_location": { "doc": "The location number of the attribute in the vertex shader (the @location attribute)." } + } + }, + "TexelCopyBufferLayout": { + "doc": "Describes the layout of texel data in a buffer or in a block of memory.\n\nUsed as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo.\n", + "fields": { + "offset": { "doc": "The offset in bytes into the data where the texel data starts. Defaults to 0." }, + "bytes_per_row": { "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row of texel blocks. Must be a multiple of 256 for buffer copies (not for GPUQueue.write_texture())." }, + "rows_per_image": { "doc": "The number of rows of texel blocks per image (layer or slice); times bytes_per_row it is the stride between images. Required if the copy has more than one image." } + } + }, + "TexelCopyBufferInfo": { + "doc": "Describes a buffer and the layout of texel data in it.\n\nUsed as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer().\nExtends structs.TexelCopyBufferLayout.\n", + "fields": { + "offset": { "doc": "The offset in bytes into the buffer where the texel data starts. Defaults to 0." }, + "bytes_per_row": { "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row. Must be a multiple of 256." }, + "rows_per_image": { "doc": "The number of rows of texel blocks per image (layer or slice). Required if the copy has more than one image." }, + "buffer": { "doc": "The GPUBuffer that contains (or will contain) the texel data." } + } + }, + "TexelCopyTextureInfo": { + "doc": "Describes a texture and the part of it that is the source or destination of a copy.\n\nUsed in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(),\nGPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture().\n", + "fields": { + "texture": { "doc": "The GPUTexture to copy to or from." }, + "mip_level": { "doc": "The mip level to copy to or from. Defaults to 0." }, + "origin": { "doc": "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." }, + "aspect": { "doc": "Which aspect of the texture to copy, see enums.TextureAspect. Defaults to all." } + } + }, + "CopyExternalImageDestInfo": { + "doc": "Describes the destination texture of GPUQueue.copy_external_image_to_texture().\n\nExtends structs.TexelCopyTextureInfo with color space information.\n", + "fields": { + "texture": { "doc": "The GPUTexture to copy to." }, + "mip_level": { "doc": "The mip level to copy to. Defaults to 0." }, + "origin": { "doc": "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." }, + "aspect": { "doc": "Which aspect of the texture to copy to, see enums.TextureAspect. Defaults to all." }, + "color_space": { "doc": "The color space to encode the copied image data in, e.g. 'srgb'. Defaults to 'srgb'." }, + "premultiplied_alpha": { "doc": "If true, the color channels are premultiplied by the alpha channel when written. Defaults to false." } + } + }, + "CopyExternalImageSourceInfo": { + "doc": "Describes the source of GPUQueue.copy_external_image_to_texture().\n\nUsed as the source argument of that method.\n", + "fields": { + "source": { "doc": "The image source, e.g. an image, canvas or video frame. The data is captured when GPUQueue.copy_external_image_to_texture() is called. Only meaningful in browser environments (in Python, e.g. an array or PIL image may be supported)." }, + "origin": { "doc": "The origin in the source image to start copying from, as a structs.Origin2D or a tuple (x, y). Defaults to (0, 0)." }, + "flip_y": { "doc": "If true, the image is flipped vertically: the bottom row of the source region is copied to the first row of the destination region. The origin field is still relative to the top-left corner. Defaults to false." } + } + }, + "CommandBufferDescriptor": { + "doc": "Descriptor for a GPUCommandBuffer.\n\nUsed as the descriptor argument of the GPUCommandEncoder.finish() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the command buffer, used in debugging and error messages." } + } + }, + "CommandEncoderDescriptor": { + "doc": "Descriptor for creating a GPUCommandEncoder.\n\nUsed as the descriptor argument of the GPUDevice.create_command_encoder() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the command encoder, used in debugging and error messages." } + } + }, + "ComputePassTimestampWrites": { + "doc": "Describes where to write timestamps for a compute pass.\n\nUsed in the timestamp_writes field of structs.ComputePassDescriptor. Requires enums.FeatureName.timestamp_query.\n", + "fields": { + "query_set": { "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, + "beginning_of_pass_write_index": { "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, + "end_of_pass_write_index": { "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } + } + }, + "ComputePassDescriptor": { + "doc": "Descriptor for beginning a compute pass.\n\nUsed as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the compute pass, used in debugging and error messages." }, + "timestamp_writes": { "doc": "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." } + } + }, + "RenderPassTimestampWrites": { + "doc": "Describes where to write timestamps for a render pass.\n\nUsed in the timestamp_writes field of structs.RenderPassDescriptor. Requires enums.FeatureName.timestamp_query.\n", + "fields": { + "query_set": { "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, + "beginning_of_pass_write_index": { "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, + "end_of_pass_write_index": { "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } + } + }, + "RenderPassDescriptor": { + "doc": "Descriptor for beginning a render pass.\n\nUsed as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the render pass, used in debugging and error messages." }, + "color_attachments": { "doc": "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to. Attachments may not alias each other or any resource used inside the pass." }, + "depth_stencil_attachment": { "doc": "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." }, + "occlusion_query_set": { "doc": "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." }, + "timestamp_writes": { "doc": "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." }, + "max_draw_count": { "doc": "A hint for the maximum number of draw calls in the pass, used by some implementations to size internal work. The default is fine unless more draws are expected. Defaults to 50000000." } + } + }, + "RenderPassColorAttachment": { + "doc": "Describes a color attachment of a render pass.\n\nUsed in the color_attachments field of structs.RenderPassDescriptor.\n", + "fields": { + "view": { "doc": "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, + "depth_slice": { "doc": "For 3D textures, the index of the depth slice to render to." }, + "resolve_target": { "doc": "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." }, + "clear_value": { "doc": "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." }, + "load_op": { "doc": "What to do with the existing contents at the start of the pass, see enums.LoadOp." }, + "store_op": { "doc": "What to do with the results at the end of the pass, see enums.StoreOp." } + } + }, + "RenderPassDepthStencilAttachment": { + "doc": "Describes the depth-stencil attachment of a render pass.\n\nUsed in the depth_stencil_attachment field of structs.RenderPassDescriptor.\n", + "fields": { + "view": { "doc": "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, + "depth_clear_value": { "doc": "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." }, + "depth_load_op": { "doc": "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." }, + "depth_store_op": { "doc": "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." }, + "depth_read_only": { "doc": "If true, the depth aspect is read-only in the pass (it is not written to). Defaults to false." }, + "stencil_clear_value": { "doc": "The value to clear the stencil aspect to if stencil_load_op is clear. Truncated to the bit size of the stencil aspect (the least significant bits are kept). Defaults to 0." }, + "stencil_load_op": { "doc": "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." }, + "stencil_store_op": { "doc": "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." }, + "stencil_read_only": { "doc": "If true, the stencil aspect is read-only in the pass (it is not written to). Defaults to false." } + } + }, + "RenderPassLayout": { + "doc": "Describes the attachment formats of a render pass or render bundle.\n\nThis is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with\npasses (or bundles) whose layout is compatible with the pipeline.\n", + "fields": { + "label": { "doc": "A human-readable label, used in debugging and error messages." }, + "color_formats": { "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments." }, + "depth_stencil_format": { "doc": "The enums.TextureFormat of the depth-stencil attachment, if any." }, + "sample_count": { "doc": "The number of samples per pixel of the attachments. Defaults to 1." } + } + }, + "RenderBundleDescriptor": { + "doc": "Descriptor for a GPURenderBundle.\n\nUsed as the descriptor argument of the GPURenderBundleEncoder.finish() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the render bundle, used in debugging and error messages." } + } + }, + "RenderBundleEncoderDescriptor": { + "doc": "Descriptor for creating a GPURenderBundleEncoder.\n\nUsed as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method.\nExtends structs.RenderPassLayout.\n", + "fields": { + "label": { "doc": "A human-readable label for the render bundle encoder, used in debugging and error messages." }, + "color_formats": { "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." }, + "depth_stencil_format": { "doc": "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." }, + "sample_count": { "doc": "The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1." }, + "depth_read_only": { "doc": "If true, the bundle does not write to the depth aspect. Defaults to false." }, + "stencil_read_only": { "doc": "If true, the bundle does not write to the stencil aspect. Defaults to false." } + } + }, + "QueueDescriptor": { + "doc": "Descriptor for a GPUQueue.\n\nUsed in the default_queue field of structs.DeviceDescriptor.\n", + "fields": { + "label": { "doc": "A human-readable label for the queue, used in debugging and error messages." } + } + }, + "QuerySetDescriptor": { + "doc": "Descriptor for creating a GPUQuerySet.\n\nUsed as the descriptor argument of the GPUDevice.create_query_set() method.\n", + "fields": { + "label": { "doc": "A human-readable label for the query set, used in debugging and error messages." }, + "type": { "doc": "The type of queries in the set, see enums.QueryType." }, + "count": { "doc": "The number of queries in the set." } + } + }, + "CanvasToneMapping": { + "doc": "Describes the tone mapping of a canvas.\n\nUsed in the tone_mapping field of structs.CanvasConfiguration.\n", + "fields": { + "mode": { "doc": "The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard." } + } + }, + "CanvasConfiguration": { + "doc": "Configuration for a GPUCanvasContext.\n\nUsed as the configuration argument of the GPUCanvasContext.configure() method.\n", + "fields": { + "device": { "doc": "The GPUDevice that the canvas textures will be used with." }, + "format": { "doc": "The enums.TextureFormat of the canvas textures; must be one of the supported canvas formats. Use GPU.get_preferred_canvas_format() for the best choice." }, + "usage": { "doc": "The usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT, but that is not added automatically when usage is set explicitly, so include it to render to the canvas texture." }, + "view_formats": { "doc": "Additional enums.TextureFormat values that views of the canvas texture may use." }, + "color_space": { "doc": "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." }, + "tone_mapping": { "doc": "A structs.CanvasToneMapping that describes how the canvas content is tone mapped. May not be supported everywhere; detect support with GPUCanvasContext.get_configuration()." }, + "alpha_mode": { "doc": "How the alpha channel of the canvas is interpreted, see enums.CanvasAlphaMode. Defaults to opaque." } + } + }, + "UncapturedErrorEventInit": { + "doc": "Initialization data for an uncaptured error event.\n\nThe event is passed to the callback set via the onuncapturederror property of GPUDevice.\n", + "fields": { + "error": { "doc": "The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope." } + } + }, + "Color": { + "doc": "An RGBA color with floating point components.\n\nCan also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment.\n", + "fields": { + "r": { "doc": "The red component." }, + "g": { "doc": "The green component." }, + "b": { "doc": "The blue component." }, + "a": { "doc": "The alpha component." } + } + }, + "Origin2D": { + "doc": "A 2D origin (offset) in a texture or image, in texels.\n\nCan also be given as a tuple (x, y).\n", + "fields": { + "x": { "doc": "The x coordinate (horizontal). Defaults to 0." }, + "y": { "doc": "The y coordinate (vertical). Defaults to 0." } + } + }, + "Origin3D": { + "doc": "A 3D origin (offset) in a texture, in texels.\n\nCan also be given as a tuple (x, y, z).\n", + "fields": { + "x": { "doc": "The x coordinate (horizontal). Defaults to 0." }, + "y": { "doc": "The y coordinate (vertical). Defaults to 0." }, + "z": { "doc": "The z coordinate (depth, or array layer). Defaults to 0." } + } + }, + "Extent3D": { + "doc": "A 3D size (extent) of a texture, in texels.\n\nCan also be given as a tuple (width, height, depth_or_array_layers).\n", + "fields": { + "width": { "doc": "The width of the extent." }, + "height": { "doc": "The height of the extent. Defaults to 1." }, + "depth_or_array_layers": { "doc": "The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1." } + } + } + }, + "classes": { + "GPUObjectBase": { + "doc": "The base class of all GPU objects.\n\nIt provides the label property that is shared by all objects in the API.\n", + "properties": { + "label": { "doc": "A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it." } + }, + "methods": { } + }, + "GPUAdapterInfo": { + "doc": "Information about a physical adapter (GPU).\n\nAn instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice.\nThe values are strings that are possibly empty if the information is not available.\n", + "properties": { + "vendor": { "doc": "The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'." }, + "architecture": { "doc": "The name of the family or class of GPUs the adapter belongs to." }, + "device": { "doc": "A vendor-specific identifier for the type of adapter (e.g. a PCI device id), if available. It does not uniquely identify a piece of hardware like a serial number." }, + "description": { "doc": "A human-readable description of the adapter as reported by the driver, e.g. the name of the GPU. Not formatted in any standard way, so parsing it is not recommended; prefer the other fields." }, + "subgroup_min_size": { "doc": "The minimum supported subgroup size of the adapter. Only available if enums.FeatureName.subgroups is supported." }, + "subgroup_max_size": { "doc": "The maximum supported subgroup size of the adapter. Only available if enums.FeatureName.subgroups is supported." }, + "is_fallback_adapter": { "doc": "Whether this is a fallback adapter, e.g. a software renderer." } + }, + "methods": { } + }, + "GPU": { + "doc": "The entry point of the API.\n\nIt is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu.\n", + "properties": { + "wgsl_language_features": { "doc": "The set of WGSL language features that are supported by the implementation." } + }, + "methods": { + "request_adapter": { + "doc": "Request a GPUAdapter, which represents a physical GPU (or a software equivalent).\n\nThe adapter can be used to inspect the capabilities (features and limits) of the GPU,\nand to request a GPUDevice. If no suitable adapter is available, None is returned.\n", + "returns": { "doc": "A GPUAdapter, or None if no suitable adapter was found." }, + "args": { + "options": { "doc": "A structs.RequestAdapterOptions with options for selecting the adapter." } + } + }, + "get_preferred_canvas_format": { + "doc": "Get the preferred texture format for presenting to a canvas.\n\nUsing this format for the format field of structs.CanvasConfiguration avoids a conversion when presenting.\n", + "returns": { "doc": "An enums.TextureFormat, either rgba8unorm or bgra8unorm." } + } + } + }, + "GPUAdapter": { + "doc": "Represents a physical GPU (or a software implementation of one).\n\nAn adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice,\nwhich is used to do actual work. Adapters are obtained via GPU.request_adapter().\n", + "properties": { + "features": { "doc": "The set of enums.FeatureName that the adapter supports." }, + "limits": { "doc": "A mapping of limit names to the maximum values supported by the adapter." }, + "info": { "doc": "A GPUAdapterInfo with information about the adapter. The values are constant over time." } + }, + "methods": { + "request_device": { + "doc": "Request a GPUDevice from the adapter.\n\nThe device is the main object used to create resources and to submit work. An adapter can\nonly provide a single device; if it was already used, or if the requested features or limits\nare not supported, the request fails.\n", + "returns": { "doc": "A GPUDevice." }, + "args": { + "descriptor": { "doc": "A structs.DeviceDescriptor with the required features and limits." } + } + } + } + }, + "GPUDevice": { + "doc": "The main object that is used to create GPU resources and to submit work.\n\nA device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue\n(the queue property) which is used to submit work to the GPU. Most resources\n(buffers, textures, pipelines, etc.) are created using the create_* methods of the device.\n", + "properties": { + "features": { "doc": "The set of enums.FeatureName that are enabled on the device (exactly those it was created with)." }, + "limits": { "doc": "A mapping of limit names to the values that are in effect for the device (exactly those it was created with)." }, + "adapter_info": { "doc": "A GPUAdapterInfo with information about the adapter that this device was created from. The values are constant over time." }, + "queue": { "doc": "The default GPUQueue of the device." }, + "lost": { "doc": "A promise or future that stays pending for the lifetime of the device and resolves to a GPUDeviceLostInfo when the device is lost." }, + "onuncapturederror": { "doc": "A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope." } + }, + "methods": { + "destroy": { + "doc": "Destroy the device, preventing further operations on it.\n\nOutstanding asynchronous operations fail. The device is lost with the reason enums.DeviceLostReason.destroyed, and all resources\ncreated by the device become unusable. Destroying a device multiple times is allowed.\n", + "returns": { "doc": "None." } + }, + "create_buffer": { + "doc": "Create a GPUBuffer, a block of memory that can be used by the GPU.\n\nData can be written to the buffer using GPUQueue.write_buffer(), copy commands, or by mapping it (see GPUBuffer.map_async()).\n", + "returns": { "doc": "A GPUBuffer." }, + "args": { + "descriptor": { "doc": "A structs.BufferDescriptor describing the buffer." } + } + }, + "create_texture": { + "doc": "Create a GPUTexture, an image resource (1D, 2D or 3D) that can be sampled or rendered to.\n\nTextures are not accessed directly by shaders; use GPUTexture.create_view() to obtain a GPUTextureView.\n", + "returns": { "doc": "A GPUTexture." }, + "args": { + "descriptor": { "doc": "A structs.TextureDescriptor describing the texture." } + } + }, + "create_sampler": { + "doc": "Create a GPUSampler, which defines how a texture is sampled (filtering and addressing) in a shader.\n", + "returns": { "doc": "A GPUSampler." }, + "args": { + "descriptor": { "doc": "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." } + } + }, + "import_external_texture": { + "doc": "Import an external image source, such as a video frame, as a texture that can be sampled in a shader.\n\nThe resulting object is only valid for a short time (until the end of the current frame/task), after which it must be re-imported.\nThis is mostly relevant in browser environments.\n", + "returns": { "doc": "A GPUExternalTexture." }, + "args": { + "descriptor": { "doc": "A structs.ExternalTextureDescriptor describing the source." } + } + }, + "create_bind_group_layout": { + "doc": "Create a GPUBindGroupLayout, which describes the types and visibility of the resources in a bind group.\n\nA bind group layout is used in create_bind_group() and create_pipeline_layout().\n", + "returns": { "doc": "A GPUBindGroupLayout." }, + "args": { + "descriptor": { "doc": "A structs.BindGroupLayoutDescriptor describing the entries of the layout." } + } + }, + "create_pipeline_layout": { + "doc": "Create a GPUPipelineLayout, which describes all bind groups (and immediate data) used by a pipeline.\n", + "returns": { "doc": "A GPUPipelineLayout." }, + "args": { + "descriptor": { "doc": "A structs.PipelineLayoutDescriptor describing the bind group layouts." } + } + }, + "create_bind_group": { + "doc": "Create a GPUBindGroup, which binds actual resources (buffers, textures, samplers) to the slots described by a layout.\n\nBind groups are set on a pass encoder with GPUBindingCommandsMixin.set_bind_group().\n", + "returns": { "doc": "A GPUBindGroup." }, + "args": { + "descriptor": { "doc": "A structs.BindGroupDescriptor with the layout and the resources to bind." } + } + }, + "create_shader_module": { + "doc": "Create a GPUShaderModule from shader source code (WGSL).\n\nCompilation errors do not raise immediately; use GPUShaderModule.get_compilation_info() to inspect messages,\nor use error scopes (see push_error_scope()).\n", + "returns": { "doc": "A GPUShaderModule." }, + "args": { + "descriptor": { "doc": "A structs.ShaderModuleDescriptor containing the shader code." } + } + }, + "create_compute_pipeline": { + "doc": "Create a GPUComputePipeline, which describes a compute shader and its resources.\n\nThe pipeline is created immediately, which may block while the shader is compiled. Prefer create_compute_pipeline_async() when possible.\n", + "returns": { "doc": "A GPUComputePipeline." }, + "args": { + "descriptor": { "doc": "A structs.ComputePipelineDescriptor describing the pipeline." } + } + }, + "create_render_pipeline": { + "doc": "Create a GPURenderPipeline, which describes the full state of the graphics pipeline: shaders, vertex layout, rasterization, depth/stencil, blending and render targets.\n\nThe pipeline is created immediately, which may block while the shaders are compiled. Prefer create_render_pipeline_async() when possible.\n", + "returns": { "doc": "A GPURenderPipeline." }, + "args": { + "descriptor": { "doc": "A structs.RenderPipelineDescriptor describing the pipeline." } + } + }, + "create_compute_pipeline_async": { + "doc": "Asynchronous version of create_compute_pipeline().\n\nThe result is ready to be used without additional delay once the promise (or future) resolves. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device.\nUsing this method is preferred whenever possible, as it avoids blocking queue work on pipeline compilation.\n", + "returns": { "doc": "A GPUComputePipeline (awaitable)." }, + "args": { + "descriptor": { "doc": "A structs.ComputePipelineDescriptor describing the pipeline." } + } + }, + "create_render_pipeline_async": { + "doc": "Asynchronous version of create_render_pipeline().\n\nThe result is ready to be used without additional delay once the promise (or future) resolves. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device.\nUsing this method is preferred whenever possible, as it avoids blocking queue work on pipeline compilation.\n", + "returns": { "doc": "A GPURenderPipeline (awaitable)." }, + "args": { + "descriptor": { "doc": "A structs.RenderPipelineDescriptor describing the pipeline." } + } + }, + "create_command_encoder": { + "doc": "Create a GPUCommandEncoder, used to record GPU commands (passes and copies).\n\nFinish the encoder with GPUCommandEncoder.finish() and submit the result with GPUQueue.submit().\n", + "returns": { "doc": "A GPUCommandEncoder." }, + "args": { + "descriptor": { "doc": "A structs.CommandEncoderDescriptor. Optional." } + } + }, + "create_render_bundle_encoder": { + "doc": "Create a GPURenderBundleEncoder, used to pre-record a sequence of render commands that can be replayed in many render passes.\n\nThe attachment formats given in the descriptor determine in which render passes the resulting bundle can be used.\n", + "returns": { "doc": "A GPURenderBundleEncoder." }, + "args": { + "descriptor": { "doc": "A structs.RenderBundleEncoderDescriptor describing the attachment formats." } + } + }, + "create_query_set": { + "doc": "Create a GPUQuerySet, a set of queries that hold e.g. occlusion or timestamp results.\n\nResults are written during passes and can be retrieved with GPUCommandEncoder.resolve_query_set().\n", + "returns": { "doc": "A GPUQuerySet." }, + "args": { + "descriptor": { "doc": "A structs.QuerySetDescriptor describing the type and count of queries." } + } + }, + "push_error_scope": { + "doc": "Push a new error scope onto the device's error scope stack.\n\nWhile the scope is active, errors of the given type that are generated by operations on this device are\ncaptured by the scope (instead of triggering the onuncapturederror callback). Retrieve them with pop_error_scope().\n", + "returns": { "doc": "None." }, + "args": { + "filter": { "doc": "The type of error to capture, see enums.ErrorFilter." } + } + }, + "pop_error_scope": { + "doc": "Pop the most recent error scope from the stack and return an error observed by it.\n\nFails if there is no error scope to pop. Errors are only reported once all operations in the scope have been processed.\n", + "returns": { "doc": "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." } + } + } + }, + "GPUBuffer": { + "doc": "A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage.\n\nBuffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or\ncopy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the\nbuffer cannot be used by the GPU while it is mapped.\n", + "properties": { + "size": { "doc": "The size of the buffer in bytes." }, + "usage": { "doc": "The usage of the buffer, a combination of flags.BufferUsage." }, + "map_state": { "doc": "The current mapping state of the buffer, see enums.BufferMapState." } + }, + "methods": { + "map_async": { + "doc": "Map (a part of) the buffer so its memory can be accessed by the CPU.\n\nThe returned promise or future resolves when the buffer is mapped. Once mapped, use get_mapped_range()\nto access the data, and call unmap() when done to give the buffer back to the GPU.\nResolving only indicates that this buffer is mapped, not that other work has completed. However, when GPUQueue.on_submitted_work_done()\nresolves, earlier map_async() calls on buffers last used exclusively on that queue have completed.\n", + "returns": { "doc": "None (awaitable); resolves when the buffer is mapped." }, + "args": { + "mode": { "doc": "Whether to map for reading or writing, see flags.MapMode." }, + "offset": { "doc": "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." }, + "size": { "doc": "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } + } + }, + "get_mapped_range": { + "doc": "Get a view on the memory of a mapped part of the buffer.\n\nThe buffer must be mapped (see map_async() or the mapped_at_creation field of structs.BufferDescriptor).\nThe returned memory becomes invalid when the buffer is unmapped.\n", + "returns": { "doc": "A writable memory view (e.g. a memoryview) on the mapped range." }, + "args": { + "offset": { "doc": "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." }, + "size": { "doc": "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." } + } + }, + "unmap": { + "doc": "Unmap the buffer, making any mapped memory invalid, and handing the buffer back to the GPU.\n\nIf the buffer was mapped for writing, the written data becomes visible to the GPU.\n", + "returns": { "doc": "None." } + }, + "destroy": { + "doc": "Destroy the buffer and free its memory.\n\nThe buffer can no longer be used. Calling this multiple times is allowed.\n", + "returns": { "doc": "None." } + } + } + }, + "GPUTexture": { + "doc": "An image resource of one, two or three dimensions, optionally with mip levels and array layers.\n\nTextures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render\nattachment, create a GPUTextureView with create_view().\n", + "properties": { + "width": { "doc": "The width of the texture in texels." }, + "height": { "doc": "The height of the texture in texels." }, + "depth_or_array_layers": { "doc": "The depth (for 3D textures) or the number of array layers of the texture." }, + "mip_level_count": { "doc": "The number of mip levels of the texture." }, + "sample_count": { "doc": "The number of samples per pixel of the texture (1 unless multisampled)." }, + "dimension": { "doc": "The dimensionality of the texture, see enums.TextureDimension." }, + "format": { "doc": "The pixel format of the texture, see enums.TextureFormat." }, + "usage": { "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." }, + "texture_binding_view_dimension": { "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. None on core devices." } + }, + "methods": { + "create_view": { + "doc": "Create a GPUTextureView, a specific view of (part of) the texture.\n\nThe view is what gets bound to shaders or used as a render attachment.\n", + "returns": { "doc": "A GPUTextureView." }, + "args": { + "descriptor": { "doc": "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." } + } + }, + "destroy": { + "doc": "Destroy the texture and free its memory.\n\nThe texture can no longer be used. Calling this multiple times is allowed.\n", + "returns": { "doc": "None." } + } + } + }, + "GPUTextureView": { + "doc": "A view on (a part of) a GPUTexture.\n\nTexture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry)\nand as render pass attachments (see structs.RenderPassColorAttachment).\n", + "methods": { } + }, + "GPUSampler": { + "doc": "Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture.\n\nSamplers are created with GPUDevice.create_sampler().\n", + "methods": { } + }, + "GPUBindGroupLayout": { + "doc": "Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup.\n\nBind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline\nvia GPUPipelineBase.get_bind_group_layout().\n", + "methods": { } + }, + "GPUBindGroup": { + "doc": "A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout.\n\nBind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group().\n", + "methods": { } + }, + "GPUPipelineLayout": { + "doc": "Describes the bind group layouts (and immediate data size) that a pipeline uses.\n\nPipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto.\n", + "methods": { } + }, + "GPUShaderModule": { + "doc": "A compiled piece of shader code (WGSL), containing one or more entry points.\n\nShader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage).\n", + "methods": { + "get_compilation_info": { + "doc": "Get diagnostic messages (errors, warnings, info) produced when compiling the shader.\n\nThe locations, order and contents of the messages are implementation-defined; in particular, they are not necessarily ordered by line number.\n", + "returns": { "doc": "A GPUCompilationInfo (awaitable) with the list of messages." } + } + } + }, + "GPUCompilationMessage": { + "doc": "A single diagnostic message produced when compiling a shader module.\n\nThe messages are available via the messages property of GPUCompilationInfo.\n", + "properties": { + "message": { "doc": "The human-readable text of the message." }, + "type": { "doc": "The severity of the message, see enums.CompilationMessageType." }, + "line_num": { "doc": "The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line." }, + "line_pos": { "doc": "The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position." }, + "offset": { "doc": "The offset in the shader code (in UTF-16 code units) that the message refers to." }, + "length": { "doc": "The length (in UTF-16 code units) of the span in the shader code that the message refers to." } + }, + "methods": { } + }, + "GPUCompilationInfo": { + "doc": "The diagnostic messages produced when compiling a shader module.\n\nObtained from GPUShaderModule.get_compilation_info().\n", + "properties": { + "messages": { "doc": "A list of GPUCompilationMessage objects." } + }, + "methods": { } + }, + "GPUPipelineError": { + "doc": "The error that is raised when asynchronous pipeline creation fails.\n\nRaised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async().\n", + "properties": { + "reason": { "doc": "The reason for the failure, see enums.PipelineErrorReason." } + }, + "methods": { + "constructor": { + "doc": "Create a GPUPipelineError.\n\nNormally these are created by the implementation rather than by user code.\n", + "returns": { "doc": "A GPUPipelineError." }, + "args": { + "message": { "doc": "The human-readable error message." }, + "options": { "doc": "A structs.PipelineErrorInit with the reason of the error." } + } + } + } + }, + "GPUPipelineBase": { + "doc": "The base class for GPUComputePipeline and GPURenderPipeline.\n\nIt provides access to the bind group layouts of the pipeline.\n", + "methods": { + "get_bind_group_layout": { + "doc": "Get the GPUBindGroupLayout of the pipeline for the given bind group index.\n\nThis is especially useful for pipelines created with enums.AutoLayoutMode.auto, where the layouts are derived from the shader.\n", + "returns": { "doc": "A GPUBindGroupLayout." }, + "args": { + "index": { "doc": "The index of the bind group (the @group number in the shader)." } + } + } + } + }, + "GPUComputePipeline": { + "doc": "A pipeline that describes a compute shader and its resources.\n\nCreated with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline().\n", + "methods": { } + }, + "GPURenderPipeline": { + "doc": "A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending.\n\nCreated with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline().\n", + "methods": { } + }, + "GPUCommandBuffer": { + "doc": "A recorded list of GPU commands, ready to be submitted.\n\nObtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once.\n", + "methods": { } + }, + "GPUCommandsMixin": { + "doc": "A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt has no methods of its own in the current version of the API.\n", + "methods": { } + }, + "GPUCommandEncoder": { + "doc": "Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer.\n\nCreate one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit().\nOnly one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands.\n", + "methods": { + "begin_render_pass": { + "doc": "Begin a render pass, returning a GPURenderPassEncoder to record draw commands with.\n\nThe pass must be ended with GPURenderPassEncoder.end() before the encoder can be used again.\n", + "returns": { "doc": "A GPURenderPassEncoder." }, + "args": { + "descriptor": { "doc": "A structs.RenderPassDescriptor describing the attachments of the pass." } + } + }, + "begin_compute_pass": { + "doc": "Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with.\n\nThe pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again.\n", + "returns": { "doc": "A GPUComputePassEncoder." }, + "args": { + "descriptor": { "doc": "A structs.ComputePassDescriptor. Optional." } + } + }, + "copy_buffer_to_buffer": { + "doc": "Copy data from one GPUBuffer to another.\n\nThe source needs flags.BufferUsage.COPY_SRC and the destination flags.BufferUsage.COPY_DST.\nOffsets and size must be multiples of 4, and the ranges must not overlap if the buffers are the same.\n", + "returns": { "doc": "None." }, + "args": { + "source": { "doc": "The GPUBuffer to copy from." }, + "source_offset": { "doc": "The offset in bytes in the source buffer where the copy starts." }, + "destination": { "doc": "The GPUBuffer to copy to." }, + "destination_offset": { "doc": "The offset in bytes in the destination buffer where the data is written." }, + "size": { "doc": "The number of bytes to copy. Defaults to the size of the source buffer minus the source_offset argument of this method." } + } + }, + "copy_buffer_to_texture": { + "doc": "Copy data from a GPUBuffer to a GPUTexture.\n\nThe source buffer needs flags.BufferUsage.COPY_SRC and the texture flags.TextureUsage.COPY_DST.\n", + "returns": { "doc": "None." }, + "args": { + "source": { "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." }, + "destination": { "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." }, + "copy_size": { "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } + } + }, + "copy_texture_to_buffer": { + "doc": "Copy data from a GPUTexture to a GPUBuffer.\n\nThe texture needs flags.TextureUsage.COPY_SRC and the destination buffer flags.BufferUsage.COPY_DST.\n", + "returns": { "doc": "None." }, + "args": { + "source": { "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." }, + "destination": { "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." }, + "copy_size": { "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } + } + }, + "copy_texture_to_texture": { + "doc": "Copy data from one GPUTexture to another.\n\nThe source needs flags.TextureUsage.COPY_SRC and the destination flags.TextureUsage.COPY_DST.\nThe formats must be compatible, and the sample counts equal.\n", + "returns": { "doc": "None." }, + "args": { + "source": { "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." }, + "destination": { "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." }, + "copy_size": { "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } + } + }, + "clear_buffer": { + "doc": "Fill (a part of) a GPUBuffer with zeros.\n\nThe buffer needs flags.BufferUsage.COPY_DST.\n", + "returns": { "doc": "None." }, + "args": { + "buffer": { "doc": "The GPUBuffer to clear." }, + "offset": { "doc": "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." }, + "size": { "doc": "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } + } + }, + "resolve_query_set": { + "doc": "Resolve the results of queries in a GPUQuerySet into a GPUBuffer.\n\nThe destination buffer needs flags.BufferUsage.QUERY_RESOLVE. Each result is written as a 64-bit unsigned integer.\n", + "returns": { "doc": "None." }, + "args": { + "query_set": { "doc": "The GPUQuerySet to read results from." }, + "first_query": { "doc": "The index of the first query to resolve." }, + "query_count": { "doc": "The number of queries to resolve." }, + "destination": { "doc": "The GPUBuffer to write the results to." }, + "destination_offset": { "doc": "The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256." } + } + }, + "finish": { + "doc": "Finish recording and return a GPUCommandBuffer.\n\nThe command buffer can be submitted with GPUQueue.submit(). The encoder cannot be used after this call.\n", + "returns": { "doc": "A GPUCommandBuffer." }, + "args": { + "descriptor": { "doc": "A structs.CommandBufferDescriptor. Optional." } + } + } + } + }, + "GPUBindingCommandsMixin": { + "doc": "A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt provides methods to set bind groups and immediate data.\n", + "methods": { + "set_bind_group": { + "doc": "Set a GPUBindGroup for the given bind group index, to be used by subsequent draw or dispatch commands.\n\nThe bind group must be compatible with the layout of the pipeline. If the layout has entries with\ndynamic offsets (see the has_dynamic_offset field of structs.BufferBindingLayout), offsets must be provided.\nThe dynamic offsets can be given as a list, or as a range of an array (using the start and length arguments).\n", + "returns": { "doc": "None." }, + "args": { + "index": { "doc": "The index of the bind group (the @group number in the shader)." }, + "bind_group": { "doc": "The GPUBindGroup to set, or None to unset it." }, + "dynamic_offsets_data": { "doc": "A list or array of offsets in bytes, one for each dynamic buffer binding, in order of binding number." }, + "dynamic_offsets_data_start": { "doc": "If dynamic_offsets_data is an array, the index of the first offset to use." }, + "dynamic_offsets_data_length": { "doc": "If dynamic_offsets_data is an array, the number of offsets to use." } + } + }, + "set_immediates": { + "doc": "Set immediate data: a small amount of data (typically a few hundred bytes at most) that is passed to shaders directly without a buffer.\n\nThe size of the immediate data is determined by the immediate_size field of structs.PipelineLayoutDescriptor.\n", + "returns": { "doc": "None." }, + "args": { + "range_offset": { "doc": "The offset in bytes in the immediate data range where the data is written. Must be a multiple of 4." }, + "data": { "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, + "data_offset": { "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, + "data_size": { "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } + } + } + } + }, + "GPUDebugCommandsMixin": { + "doc": "A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nDebug groups and markers show up in debugging tools and in error messages.\n", + "methods": { + "push_debug_group": { + "doc": "Begin a labeled debug group. Every call must be matched with a call to pop_debug_group().\n", + "returns": { "doc": "None." }, + "args": { + "group_label": { "doc": "The label of the debug group." } + } + }, + "pop_debug_group": { + "doc": "End the most recent debug group that was started with push_debug_group().\n", + "returns": { "doc": "None." } + }, + "insert_debug_marker": { + "doc": "Insert a single labeled marker into the command stream.\n", + "returns": { "doc": "None." }, + "args": { + "marker_label": { "doc": "The label of the marker." } + } + } + } + }, + "GPUComputePassEncoder": { + "doc": "Records the commands of a compute pass.\n\nCreated with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work,\nand finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin.\n", + "methods": { + "set_pipeline": { + "doc": "Set the GPUComputePipeline to use for subsequent dispatch commands.\n", + "returns": { "doc": "None." }, + "args": { + "pipeline": { "doc": "The GPUComputePipeline to use." } + } + }, + "dispatch_workgroups": { + "doc": "Run the compute shader of the current pipeline for a grid of workgroups.\n\nThe total number of invocations is the number of workgroups times the workgroup size defined in the shader.\n", + "returns": { "doc": "None." }, + "args": { + "workgroup_count_x": { "doc": "The number of workgroups in the x dimension." }, + "workgroup_count_y": { "doc": "The number of workgroups in the y dimension. Defaults to 1." }, + "workgroup_count_z": { "doc": "The number of workgroups in the z dimension. Defaults to 1." } + } + }, + "dispatch_workgroups_indirect": { + "doc": "Like dispatch_workgroups(), but the workgroup counts are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain three consecutive 32-bit unsigned integers (x, y, z) at the given offset.\n", + "returns": { "doc": "None." }, + "args": { + "indirect_buffer": { "doc": "The GPUBuffer that contains the workgroup counts." }, + "indirect_offset": { "doc": "The offset in bytes in the buffer where the counts start. Must be a multiple of 4." } + } + }, + "end": { + "doc": "End the compute pass. The encoder can no longer be used afterwards.\n", + "returns": { "doc": "None." } + } + } + }, + "GPURenderPassEncoder": { + "doc": "Records the commands of a render pass.\n\nCreated with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers,\ndraw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin.\n", + "methods": { + "set_viewport": { + "doc": "Set the viewport: the region of the attachments that the clip-space output is mapped to.\n\nDefaults to the full size of the attachments.\n", + "returns": { "doc": "None." }, + "args": { + "x": { "doc": "The x coordinate of the top-left corner of the viewport, in pixels." }, + "y": { "doc": "The y coordinate of the top-left corner of the viewport, in pixels." }, + "width": { "doc": "The width of the viewport, in pixels." }, + "height": { "doc": "The height of the viewport, in pixels." }, + "min_depth": { "doc": "The minimum depth value of the viewport (between 0 and 1)." }, + "max_depth": { "doc": "The maximum depth value of the viewport (between 0 and 1)." } + } + }, + "set_scissor_rect": { + "doc": "Set the scissor rectangle: fragments outside of this rectangle are discarded.\n\nDefaults to the full size of the attachments.\n", + "returns": { "doc": "None." }, + "args": { + "x": { "doc": "The x coordinate of the top-left corner of the rectangle, in pixels." }, + "y": { "doc": "The y coordinate of the top-left corner of the rectangle, in pixels." }, + "width": { "doc": "The width of the rectangle, in pixels." }, + "height": { "doc": "The height of the rectangle, in pixels." } + } + }, + "set_blend_constant": { + "doc": "Set the blend constant color, used by blend factors enums.BlendFactor.constant and enums.BlendFactor.one_minus_constant.\n\nDefaults to transparent black (0, 0, 0, 0).\n", + "returns": { "doc": "None." }, + "args": { + "color": { "doc": "The color, as a structs.Color or a tuple (r, g, b, a)." } + } + }, + "set_stencil_reference": { + "doc": "Set the stencil reference value, used in stencil comparisons and by enums.StencilOperation.replace.\n\nDefaults to 0.\n", + "returns": { "doc": "None." }, + "args": { + "reference": { "doc": "The stencil reference value (an unsigned integer)." } + } + }, + "begin_occlusion_query": { + "doc": "Begin an occlusion query, which counts the samples that pass the depth and stencil tests.\n\nThe result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor).\nEnd the query with end_occlusion_query().\n", + "returns": { "doc": "None." }, + "args": { + "query_index": { "doc": "The index in the query set where the result is stored." } + } + }, + "end_occlusion_query": { + "doc": "End the occlusion query that was started with begin_occlusion_query().\n", + "returns": { "doc": "None." } + }, + "execute_bundles": { + "doc": "Execute pre-recorded GPURenderBundle objects as part of this pass.\n\nBundles do not inherit the pipeline, bind groups or vertex/index buffers of the pass. After executing bundles (even zero of them),\nthat state is cleared, not restored, so it needs to be set again.\n", + "returns": { "doc": "None." }, + "args": { + "bundles": { "doc": "A list of GPURenderBundle objects to execute, in order." } + } + }, + "end": { + "doc": "End the render pass. The encoder can no longer be used afterwards.\n", + "returns": { "doc": "None." } + } + } + }, + "GPURenderCommandsMixin": { + "doc": "A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt provides methods to set the pipeline, vertex and index buffers, and to draw.\n", + "methods": { + "set_pipeline": { + "doc": "Set the GPURenderPipeline to use for subsequent draw commands.\n", + "returns": { "doc": "None." }, + "args": { + "pipeline": { "doc": "The GPURenderPipeline to use." } + } + }, + "set_index_buffer": { + "doc": "Set the index buffer to use for subsequent indexed draw commands.\n\nThe buffer needs flags.BufferUsage.INDEX.\n", + "returns": { "doc": "None." }, + "args": { + "buffer": { "doc": "The GPUBuffer that contains the indices." }, + "index_format": { "doc": "The data type of the indices, see enums.IndexFormat." }, + "offset": { "doc": "The offset in bytes in the buffer where the indices start. Defaults to 0." }, + "size": { "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } + } + }, + "set_vertex_buffer": { + "doc": "Set a vertex buffer for the given slot, to be used by subsequent draw commands.\n\nThe buffer needs flags.BufferUsage.VERTEX. The layout is defined by the buffers field of structs.VertexState.\n", + "returns": { "doc": "None." }, + "args": { + "slot": { "doc": "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." }, + "buffer": { "doc": "The GPUBuffer that contains the vertex data, or None to unset the slot." }, + "offset": { "doc": "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." }, + "size": { "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } + } + }, + "draw": { + "doc": "Draw primitives using the current pipeline and vertex buffers.\n", + "returns": { "doc": "None." }, + "args": { + "vertex_count": { "doc": "The number of vertices to draw." }, + "instance_count": { "doc": "The number of instances to draw. Defaults to 1." }, + "first_vertex": { "doc": "The index of the first vertex to draw (the offset into the vertex buffers, in vertices). Defaults to 0." }, + "first_instance": { "doc": "The instance index of the first instance to draw. Defaults to 0." } + } + }, + "draw_indexed": { + "doc": "Draw primitives using the current pipeline, vertex buffers and index buffer (see set_index_buffer()).\n", + "returns": { "doc": "None." }, + "args": { + "index_count": { "doc": "The number of indices to draw." }, + "instance_count": { "doc": "The number of instances to draw. Defaults to 1." }, + "first_index": { "doc": "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." }, + "base_vertex": { "doc": "A value added to each index before looking up the vertex. Defaults to 0." }, + "first_instance": { "doc": "The instance index of the first instance to draw. Defaults to 0." } + } + }, + "draw_indirect": { + "doc": "Like draw(), but the parameters are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain a tightly packed block of four 32-bit unsigned integers (16 bytes)\nat the given offset: vertex_count, instance_count, first_vertex and first_instance.\nA non-zero first_instance requires enums.FeatureName.indirect_first_instance.\n", + "returns": { "doc": "None." }, + "args": { + "indirect_buffer": { "doc": "The GPUBuffer that contains the draw parameters." }, + "indirect_offset": { "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." } + } + }, + "draw_indexed_indirect": { + "doc": "Like draw_indexed(), but the parameters are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain a tightly packed block of five 32-bit values (20 bytes) at the given offset:\nindex_count, instance_count, first_index, base_vertex and first_instance.\nA non-zero first_instance requires enums.FeatureName.indirect_first_instance.\n", + "returns": { "doc": "None." }, + "args": { + "indirect_buffer": { "doc": "The GPUBuffer that contains the draw parameters." }, + "indirect_offset": { "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." } + } + } + } + }, + "GPURenderBundle": { + "doc": "A pre-recorded sequence of render commands that can be executed in render passes.\n\nObtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles().\n", + "methods": { } + }, + "GPURenderBundleEncoder": { + "doc": "Records render commands into a GPURenderBundle, which can be replayed in multiple render passes.\n\nCreated with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin,\nGPUDebugCommandsMixin and GPURenderCommandsMixin.\n", + "methods": { + "finish": { + "doc": "Finish recording and return a GPURenderBundle.\n\nThe encoder cannot be used after this call.\n", + "returns": { "doc": "A GPURenderBundle." }, + "args": { + "descriptor": { "doc": "A structs.RenderBundleDescriptor. Optional." } + } + } + } + }, + "GPUQueue": { + "doc": "The queue on which work is submitted to the GPU.\n\nEach GPUDevice has a default queue, available via the queue property of GPUDevice.\nIt is used to submit command buffers and to upload data to buffers and textures.\n", + "methods": { + "submit": { + "doc": "Submit a list of command buffers for execution on the GPU.\n\nEach command buffer can only be submitted once.\n", + "returns": { "doc": "None." }, + "args": { + "command_buffers": { "doc": "A list of GPUCommandBuffer objects, executed in order." } + } + }, + "on_submitted_work_done": { + "doc": "Wait until all work that was submitted so far has been completed by the GPU.\n\nResolving also implies completion of earlier GPUBuffer.map_async() calls on buffers last used exclusively on this queue.\n", + "returns": { "doc": "None (awaitable); resolves when the submitted work is done." } + }, + "write_buffer": { + "doc": "Write data to a GPUBuffer.\n\nThis is a convenient way to upload data. The buffer needs flags.BufferUsage.COPY_DST.\nThe size of the data to write and the offset must be multiples of 4.\n", + "returns": { "doc": "None." }, + "args": { + "buffer": { "doc": "The GPUBuffer to write to." }, + "buffer_offset": { "doc": "The offset in bytes in the buffer where the data is written." }, + "data": { "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, + "data_offset": { "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, + "size": { "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } + } + }, + "write_texture": { + "doc": "Write data to a GPUTexture.\n\nThis is a convenient way to upload texture data. The texture needs flags.TextureUsage.COPY_DST.\n", + "returns": { "doc": "None." }, + "args": { + "destination": { "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to write to." }, + "data": { "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, + "data_layout": { "doc": "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." }, + "size": { "doc": "A structs.Extent3D (or tuple) with the size of the region to write, in texels." } + } + }, + "copy_external_image_to_texture": { + "doc": "Copy an external image (e.g. an image, canvas or video frame) to a GPUTexture.\n\nThe texture needs flags.TextureUsage.COPY_DST and flags.TextureUsage.RENDER_ATTACHMENT. The data is color-encoded into the destination\naccording to the destination info (see structs.CopyExternalImageDestInfo). Copying into an sRGB texture results in the same bytes\n(not the same decoded values) as copying into the corresponding non-sRGB format, so sampling the result differs between the two.\n", + "returns": { "doc": "None." }, + "args": { + "source": { "doc": "A structs.CopyExternalImageSourceInfo describing the image to copy from." }, + "destination": { "doc": "A structs.CopyExternalImageDestInfo describing the part of the texture to copy to." }, + "copy_size": { "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } + } + } + } + }, + "GPUQuerySet": { + "doc": "A set of queries that hold results such as occlusion counts or timestamps.\n\nCreated with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving\nthem into a buffer with GPUCommandEncoder.resolve_query_set().\n", + "properties": { + "type": { "doc": "The type of queries in the set, see enums.QueryType." }, + "count": { "doc": "The number of queries in the set." } + }, + "methods": { + "destroy": { + "doc": "Destroy the query set and free its resources.\n\nThe query set can no longer be used. Calling this multiple times is allowed.\n", + "returns": { "doc": "None." } + } + } + }, + "GPUCanvasContext": { + "doc": "The connection between a canvas (or window) and the GPU, used to present rendered images.\n\nConfigure it with configure(), then each frame obtain a texture with get_current_texture(),\nrender to it, and submit the work. The result is presented when the frame ends.\n", + "properties": { + "canvas": { "doc": "The canvas (or window/surface object) that this context belongs to." } + }, + "methods": { + "configure": { + "doc": "Configure the context for use with a device, so that textures can be obtained from it.\n\nCalling this again replaces the previous configuration. It also clears the drawing buffer to transparent black.\nUse get_configuration() to detect support for optional configuration members.\n", + "returns": { "doc": "None." }, + "args": { + "configuration": { "doc": "A structs.CanvasConfiguration with the device, format and other settings." } + } + }, + "unconfigure": { + "doc": "Remove the configuration and destroy any textures produced while configured.\n\nAfter this, get_current_texture() cannot be used until the context is configured again.\n", + "returns": { "doc": "None." } + }, + "get_configuration": { + "doc": "Get the current configuration of the context, or None if it is not configured.\n\nThis is mainly useful for feature detection of optional members of structs.CanvasConfiguration; for supported members it returns the originally supplied values.\n", + "returns": { "doc": "The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured." } + }, + "get_current_texture": { + "doc": "Get the GPUTexture to render to for the current frame.\n\nThe texture has the size of the canvas, and is the texture that will be composited to the canvas next. The same GPUTexture object is returned\nuntil the frame is presented (even if it was destroyed or failed validation); a new one is returned for the next frame.\n", + "returns": { "doc": "A GPUTexture." } + } + } + }, + "GPUDeviceLostInfo": { + "doc": "Information about why a GPUDevice was lost.\n\nAvailable via the lost property of GPUDevice.\n", + "properties": { + "reason": { "doc": "The reason the device was lost, see enums.DeviceLostReason." }, + "message": { "doc": "A human-readable message with details about why the device was lost." } + }, + "methods": { } + }, + "GPUError": { + "doc": "The base class of errors that are generated by the GPU API.\n\nSubclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError.\nErrors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice.\n", + "properties": { + "message": { "doc": "A human-readable description of the error, meant for developers (debugging, bug reports) and not for end users. Do not try to parse it." } + }, + "methods": { } + }, + "GPUValidationError": { + "doc": "An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage.\n\nCaptured by error scopes with enums.ErrorFilter.validation.\n", + "methods": { + "constructor": { + "doc": "Create a GPUValidationError.\n\nNormally these are created by the implementation rather than by user code.\n", + "returns": { "doc": "A GPUValidationError." }, + "args": { + "message": { "doc": "The human-readable error message." } + } + } + } + }, + "GPUOutOfMemoryError": { + "doc": "An error that signals that there was not enough memory to complete an operation.\n\nCaptured by error scopes with enums.ErrorFilter.out_of_memory.\n", + "methods": { + "constructor": { + "doc": "Create a GPUOutOfMemoryError.\n\nNormally these are created by the implementation rather than by user code.\n", + "returns": { "doc": "A GPUOutOfMemoryError." }, + "args": { + "message": { "doc": "The human-readable error message." } + } + } + } + }, + "GPUInternalError": { + "doc": "An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit.\n\nCaptured by error scopes with enums.ErrorFilter.internal.\n", + "methods": { + "constructor": { + "doc": "Create a GPUInternalError.\n\nNormally these are created by the implementation rather than by user code.\n", + "returns": { "doc": "A GPUInternalError." }, + "args": { + "message": { "doc": "The human-readable error message." } + } + } + } + } + } +} diff --git a/apigen/definitions/docs_ai.toml b/apigen/definitions/docs_ai.toml deleted file mode 100644 index 353daf73..00000000 --- a/apigen/definitions/docs_ai.toml +++ /dev/null @@ -1,2277 +0,0 @@ -# docs_ai.toml -# -# Documentation for the base wgpu API, generated by Claude Sonnet 5.5 at 13-10-2026. -# -# Cross-reference conventions used in these docs: -# - Classes are referred to by name, e.g. GPUBuffer. -# - Flags, enums and structs use a prefix, e.g. flags.BufferUsage, enums.TextureFormat, structs.BufferDescriptor. -# - Fields and arguments are referred to like "the usage field of structs.BufferDescriptor" -# or "the mode argument of the GPUBuffer.map_async() method". - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[flags] - -[flags.BufferUsage] -doc = """ -Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator. - -The usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards. -Using a buffer in a way that was not declared here results in a validation error. -""" -fields.MAP_READ.doc = "The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST." -fields.MAP_WRITE.doc = "The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC." -fields.COPY_SRC.doc = "The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer()." -fields.COPY_DST.doc = "The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer()." -fields.INDEX.doc = "The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer()." -fields.VERTEX.doc = "The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer()." -fields.UNIFORM.doc = "The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform." -fields.STORAGE.doc = "The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage." -fields.INDIRECT.doc = "The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect()." -fields.QUERY_RESOLVE.doc = "The buffer can be the destination of GPUCommandEncoder.resolve_query_set()." - -[flags.MapMode] -doc = """ -Bit flags that specify whether a buffer is mapped for reading or writing. - -Used in the mode argument of the GPUBuffer.map_async() method. The mode must match the -flags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE. -""" -fields.READ.doc = "Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ." -fields.WRITE.doc = "Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE." - -[flags.TextureUsage] -doc = """ -Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator. - -The usage is set when creating the texture (see the usage field of structs.TextureDescriptor). -Texture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor). -""" -fields.COPY_SRC.doc = "The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer()." -fields.COPY_DST.doc = "The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture()." -fields.TEXTURE_BINDING.doc = "The texture can be bound for sampling in a shader, see structs.TextureBindingLayout." -fields.STORAGE_BINDING.doc = "The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout." -fields.RENDER_ATTACHMENT.doc = "The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor." -fields.TRANSIENT_ATTACHMENT.doc = "The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard." - -[flags.ShaderStage] -doc = """ -Bit flags that specify in which shader stages a resource is visible. - -Used in the visibility field of structs.BindGroupLayoutEntry. -""" -fields.VERTEX.doc = "The vertex shader stage." -fields.FRAGMENT.doc = "The fragment shader stage." -fields.COMPUTE.doc = "The compute shader stage." - -[flags.ColorWrite] -doc = """ -Bit flags that specify which color channels of a render target are written to. - -Used in the write_mask field of structs.ColorTargetState. -""" -fields.RED.doc = "Write the red channel." -fields.GREEN.doc = "Write the green channel." -fields.BLUE.doc = "Write the blue channel." -fields.ALPHA.doc = "Write the alpha channel." -fields.ALL.doc = "Write all channels (RED, GREEN, BLUE and ALPHA)." - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[enums] - -[enums.PowerPreference] -doc = """ -Hint for which kind of adapter to select. - -Used in the power_preference field of structs.RequestAdapterOptions. This is only a hint; -the implementation may ignore it. -""" -fields.low_power.doc = "Prefer an adapter that uses little power, e.g. an integrated GPU." -fields.high_performance.doc = "Prefer an adapter with the highest performance, e.g. a discrete GPU." - -[enums.FeatureName] -doc = """ -Names of optional features that an adapter may support and a device may request. - -Available features can be inspected via the features property of GPUAdapter. Features -are enabled by listing them in the required_features field of structs.DeviceDescriptor. -The features of the device are available via the features property of GPUDevice. -""" -fields.core_features_and_limits.doc = "Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode)." -fields.depth_clip_control.doc = "Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState." -fields.depth32float_stencil8.doc = "Enables enums.TextureFormat.depth32float_stencil8." -fields.texture_compression_bc.doc = "Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm." -fields.texture_compression_bc_sliced_d3.doc = "Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_bc." -fields.texture_compression_etc2.doc = "Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm." -fields.texture_compression_astc.doc = "Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm." -fields.texture_compression_astc_sliced_d3.doc = "Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_astc." -fields.timestamp_query.doc = "Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites." -fields.indirect_first_instance.doc = "Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect()." -fields.shader_f16.doc = "Allows the use of the f16 type in WGSL shaders (the enable f16 directive)." -fields.rg11b10ufloat_renderable.doc = "Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling." -fields.bgra8unorm_storage.doc = "Allows enums.TextureFormat.bgra8unorm to be used as a storage texture." -fields.float32_filterable.doc = "Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler." -fields.float32_blendable.doc = "Allows 32-bit float color attachments to be used with blending." -fields.clip_distances.doc = "Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes." -fields.dual_source_blending.doc = "Allows blending with a second fragment shader output, see enums.BlendFactor.src1." -fields.subgroups.doc = "Allows the use of subgroup operations in WGSL shaders." -fields.texture_formats_tier1.doc = "Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats." -fields.texture_formats_tier2.doc = "Enables further texture format capabilities, such as read-write storage access for more formats. Requires texture_formats_tier1." -fields.primitive_index.doc = "Allows the primitive_index built-in in WGSL fragment shaders." -fields.texture_component_swizzle.doc = "Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor." - -[enums.BufferMapState] -doc = """ -The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer. -""" -fields.unmapped.doc = "The buffer is not mapped; it can be used by the GPU." -fields.pending.doc = "A GPUBuffer.map_async() call is in progress but has not yet completed." -fields.mapped.doc = "The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range()." - -[enums.TextureDimension] -doc = """ -The dimensionality of a GPUTexture. - -Used in the dimension field of structs.TextureDescriptor. -""" -fields.d1.doc = "A one-dimensional texture, with only a width." -fields.d2.doc = "A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers)." -fields.d3.doc = "A three-dimensional (volume) texture, with width, height and depth." - -[enums.TextureViewDimension] -doc = """ -The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader. - -Used in the dimension field of structs.TextureViewDescriptor and the view_dimension field of -structs.TextureBindingLayout and structs.StorageTextureBindingLayout. -""" -fields.d1.doc = "A one-dimensional view; corresponds to texture_1d in WGSL." -fields.d2.doc = "A two-dimensional view of a single layer; corresponds to texture_2d in WGSL." -fields.d2_array.doc = "A view of an array of 2D layers; corresponds to texture_2d_array in WGSL." -fields.cube.doc = "A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL." -fields.cube_array.doc = "A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL." -fields.d3.doc = "A three-dimensional view; corresponds to texture_3d in WGSL." - -[enums.TextureAspect] -doc = """ -Which aspect (part) of a texture a view or copy operation refers to. - -This is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects. -""" -fields.all.doc = "All available aspects of the texture format." -fields.stencil_only.doc = "Only the stencil aspect of a depth-stencil format." -fields.depth_only.doc = "Only the depth aspect of a depth-stencil format." - -[enums.TextureFormat] -doc = """ -The pixel format of a GPUTexture. - -Names are of the form: channels, bit size per channel, and a type suffix. -The suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1), -uint/sint = unsigned/signed integer, float = floating point, and srgb = the color -is stored in sRGB and automatically converted to linear when sampled (and back when written). -Some formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage). -""" -fields.r8unorm.doc = "One channel (red), 8-bit unsigned normalized." -fields.r8snorm.doc = "One channel (red), 8-bit signed normalized." -fields.r8uint.doc = "One channel (red), 8-bit unsigned integer." -fields.r8sint.doc = "One channel (red), 8-bit signed integer." -fields.r16unorm.doc = "One channel (red), 16-bit unsigned normalized. Requires feature texture_formats_tier1." -fields.r16snorm.doc = "One channel (red), 16-bit signed normalized. Requires feature texture_formats_tier1." -fields.r16uint.doc = "One channel (red), 16-bit unsigned integer." -fields.r16sint.doc = "One channel (red), 16-bit signed integer." -fields.r16float.doc = "One channel (red), 16-bit floating point." -fields.rg8unorm.doc = "Two channels (red, green), 8-bit unsigned normalized each." -fields.rg8snorm.doc = "Two channels (red, green), 8-bit signed normalized each." -fields.rg8uint.doc = "Two channels (red, green), 8-bit unsigned integer each." -fields.rg8sint.doc = "Two channels (red, green), 8-bit signed integer each." -fields.r32uint.doc = "One channel (red), 32-bit unsigned integer." -fields.r32sint.doc = "One channel (red), 32-bit signed integer." -fields.r32float.doc = "One channel (red), 32-bit floating point." -fields.rg16unorm.doc = "Two channels (red, green), 16-bit unsigned normalized each. Requires feature texture_formats_tier1." -fields.rg16snorm.doc = "Two channels (red, green), 16-bit signed normalized each. Requires feature texture_formats_tier1." -fields.rg16uint.doc = "Two channels (red, green), 16-bit unsigned integer each." -fields.rg16sint.doc = "Two channels (red, green), 16-bit signed integer each." -fields.rg16float.doc = "Two channels (red, green), 16-bit floating point each." -fields.rgba8unorm.doc = "Four channels (red, green, blue, alpha), 8-bit unsigned normalized each." -fields.rgba8unorm_srgb.doc = "Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels." -fields.rgba8snorm.doc = "Four channels (RGBA), 8-bit signed normalized each." -fields.rgba8uint.doc = "Four channels (RGBA), 8-bit unsigned integer each." -fields.rgba8sint.doc = "Four channels (RGBA), 8-bit signed integer each." -fields.bgra8unorm.doc = "Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format()." -fields.bgra8unorm_srgb.doc = "Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels." -fields.rgb9e5ufloat.doc = "Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable." -fields.rgb10a2uint.doc = "Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha." -fields.rgb10a2unorm.doc = "Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha." -fields.rg11b10ufloat.doc = "Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with feature rg11b10ufloat_renderable." -fields.rg32uint.doc = "Two channels (red, green), 32-bit unsigned integer each." -fields.rg32sint.doc = "Two channels (red, green), 32-bit signed integer each." -fields.rg32float.doc = "Two channels (red, green), 32-bit floating point each." -fields.rgba16unorm.doc = "Four channels (RGBA), 16-bit unsigned normalized each. Requires feature texture_formats_tier1." -fields.rgba16snorm.doc = "Four channels (RGBA), 16-bit signed normalized each. Requires feature texture_formats_tier1." -fields.rgba16uint.doc = "Four channels (RGBA), 16-bit unsigned integer each." -fields.rgba16sint.doc = "Four channels (RGBA), 16-bit signed integer each." -fields.rgba16float.doc = "Four channels (RGBA), 16-bit floating point each." -fields.rgba32uint.doc = "Four channels (RGBA), 32-bit unsigned integer each." -fields.rgba32sint.doc = "Four channels (RGBA), 32-bit signed integer each." -fields.rgba32float.doc = "Four channels (RGBA), 32-bit floating point each." -fields.stencil8.doc = "A stencil-only format with 8 bits per pixel." -fields.depth16unorm.doc = "A depth-only format with 16-bit unsigned normalized depth." -fields.depth24plus.doc = "A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer." -fields.depth24plus_stencil8.doc = "A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer." -fields.depth32float.doc = "A depth-only format with 32-bit floating point depth." -fields.depth32float_stencil8.doc = "A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires feature depth32float_stencil8." -fields.bc1_rgba_unorm.doc = "BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires feature texture_compression_bc." -fields.bc1_rgba_unorm_srgb.doc = "BC1 (DXT1) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." -fields.bc2_rgba_unorm.doc = "BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc." -fields.bc2_rgba_unorm_srgb.doc = "BC2 (DXT3) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." -fields.bc3_rgba_unorm.doc = "BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc." -fields.bc3_rgba_unorm_srgb.doc = "BC3 (DXT5) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." -fields.bc4_r_unorm.doc = "BC4 compressed single channel, unsigned normalized. Requires feature texture_compression_bc." -fields.bc4_r_snorm.doc = "BC4 compressed single channel, signed normalized. Requires feature texture_compression_bc." -fields.bc5_rg_unorm.doc = "BC5 compressed two channels, unsigned normalized. Requires feature texture_compression_bc." -fields.bc5_rg_snorm.doc = "BC5 compressed two channels, signed normalized. Requires feature texture_compression_bc." -fields.bc6h_rgb_ufloat.doc = "BC6H compressed HDR RGB, unsigned float. Requires feature texture_compression_bc." -fields.bc6h_rgb_float.doc = "BC6H compressed HDR RGB, signed float. Requires feature texture_compression_bc." -fields.bc7_rgba_unorm.doc = "BC7 compressed RGBA, unsigned normalized. Requires feature texture_compression_bc." -fields.bc7_rgba_unorm_srgb.doc = "BC7 compressed RGBA with sRGB encoding. Requires feature texture_compression_bc." -fields.etc2_rgb8unorm.doc = "ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2." -fields.etc2_rgb8unorm_srgb.doc = "ETC2 compressed RGB with sRGB encoding. Requires feature texture_compression_etc2." -fields.etc2_rgb8a1unorm.doc = "ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires feature texture_compression_etc2." -fields.etc2_rgb8a1unorm_srgb.doc = "ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires feature texture_compression_etc2." -fields.etc2_rgba8unorm.doc = "ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2." -fields.etc2_rgba8unorm_srgb.doc = "ETC2 compressed RGBA with sRGB encoding. Requires feature texture_compression_etc2." -fields.eac_r11unorm.doc = "EAC compressed single channel, 11-bit unsigned normalized. Requires feature texture_compression_etc2." -fields.eac_r11snorm.doc = "EAC compressed single channel, 11-bit signed normalized. Requires feature texture_compression_etc2." -fields.eac_rg11unorm.doc = "EAC compressed two channels, 11-bit unsigned normalized each. Requires feature texture_compression_etc2." -fields.eac_rg11snorm.doc = "EAC compressed two channels, 11-bit signed normalized each. Requires feature texture_compression_etc2." -fields.astc_4x4_unorm.doc = "ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_4x4_unorm_srgb.doc = "ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_5x4_unorm.doc = "ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_5x4_unorm_srgb.doc = "ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_5x5_unorm.doc = "ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_5x5_unorm_srgb.doc = "ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_6x5_unorm.doc = "ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_6x5_unorm_srgb.doc = "ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_6x6_unorm.doc = "ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_6x6_unorm_srgb.doc = "ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_8x5_unorm.doc = "ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_8x5_unorm_srgb.doc = "ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_8x6_unorm.doc = "ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_8x6_unorm_srgb.doc = "ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_8x8_unorm.doc = "ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_8x8_unorm_srgb.doc = "ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_10x5_unorm.doc = "ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_10x5_unorm_srgb.doc = "ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_10x6_unorm.doc = "ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_10x6_unorm_srgb.doc = "ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_10x8_unorm.doc = "ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_10x8_unorm_srgb.doc = "ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_10x10_unorm.doc = "ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_10x10_unorm_srgb.doc = "ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_12x10_unorm.doc = "ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_12x10_unorm_srgb.doc = "ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires feature texture_compression_astc." -fields.astc_12x12_unorm.doc = "ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires feature texture_compression_astc." -fields.astc_12x12_unorm_srgb.doc = "ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires feature texture_compression_astc." - -[enums.AddressMode] -doc = """ -How a sampler handles texture coordinates outside the 0..1 range, per axis. - -Used in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor. -""" -fields.clamp_to_edge.doc = "Coordinates are clamped to the range 0..1, so the edge texels are repeated." -fields.repeat.doc = "The texture tiles: only the fractional part of the coordinate is used." -fields.mirror_repeat.doc = "The texture tiles, but is mirrored every other repetition." - -[enums.FilterMode] -doc = """ -How a sampler filters texels when a texture is magnified or minified. - -Used in the mag_filter and min_filter fields of structs.SamplerDescriptor. -""" -fields.nearest.doc = "Use the value of the nearest texel." -fields.linear.doc = "Linearly interpolate between the nearest texels." - -[enums.MipmapFilterMode] -doc = """ -How a sampler filters between mip levels. - -Used in the mipmap_filter field of structs.SamplerDescriptor. -""" -fields.nearest.doc = "Use the nearest mip level." -fields.linear.doc = "Linearly interpolate between the two nearest mip levels." - -[enums.CompareFunction] -doc = """ -A comparison function, used for depth testing, stencil testing and comparison samplers. - -The comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to -the existing value. If the comparison is true, the test passes. -""" -fields.never.doc = "The comparison never passes." -fields.less.doc = "Passes if the new value is less than the existing value." -fields.equal.doc = "Passes if the new value is equal to the existing value." -fields.less_equal.doc = "Passes if the new value is less than or equal to the existing value." -fields.greater.doc = "Passes if the new value is greater than the existing value." -fields.not_equal.doc = "Passes if the new value is not equal to the existing value." -fields.greater_equal.doc = "Passes if the new value is greater than or equal to the existing value." -fields.always.doc = "The comparison always passes." - -[enums.BufferBindingType] -doc = """ -The type of a buffer binding in a bind group layout. - -Used in the type field of structs.BufferBindingLayout. -""" -fields.uniform.doc = "A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM." -fields.storage.doc = "A read-write storage buffer. Requires flags.BufferUsage.STORAGE." -fields.read_only_storage.doc = "A read-only storage buffer. Requires flags.BufferUsage.STORAGE." - -[enums.SamplerBindingType] -doc = """ -The type of a sampler binding in a bind group layout. - -Used in the type field of structs.SamplerBindingLayout. -""" -fields.filtering.doc = "A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float." -fields.non_filtering.doc = "A sampler that only uses nearest filtering. Can be used with any float texture." -fields.comparison.doc = "A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor)." - -[enums.TextureSampleType] -doc = """ -The type of values that is returned when sampling a texture in a shader. - -Used in the sample_type field of structs.TextureBindingLayout. -""" -fields.float.doc = "Floating point values; the texture can be sampled with a filtering sampler." -fields.unfilterable_float.doc = "Floating point values, but the texture cannot be filtered (e.g. 32-bit float without the float32_filterable feature)." -fields.depth.doc = "Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler." -fields.sint.doc = "Signed integer values." -fields.uint.doc = "Unsigned integer values." - -[enums.StorageTextureAccess] -doc = """ -How a storage texture can be accessed by a shader. - -Used in the access field of structs.StorageTextureBindingLayout. -""" -fields.write_only.doc = "The shader can only write to the texture." -fields.read_only.doc = "The shader can only read from the texture." -fields.read_write.doc = "The shader can both read from and write to the texture." - -[enums.CompilationMessageType] -doc = """ -The severity of a GPUCompilationMessage. -""" -fields.error.doc = "An error; the shader module is invalid." -fields.warning.doc = "A warning; the shader module is valid but something may be wrong." -fields.info.doc = "An informational message." - -[enums.PipelineErrorReason] -doc = """ -The reason for a GPUPipelineError. - -Available via the reason property of GPUPipelineError. -""" -fields.validation.doc = "The pipeline failed validation, e.g. because of an invalid descriptor or shader." -fields.internal.doc = "An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend." - -[enums.AutoLayoutMode] -doc = """ -Indicates that a pipeline layout should be derived automatically from the shader code. - -Used as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor. -The resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout(). -""" -fields.auto.doc = "Derive the pipeline layout from the shader." - -[enums.PrimitiveTopology] -doc = """ -How vertices are assembled into primitives. - -Used in the topology field of structs.PrimitiveState. -""" -fields.point_list.doc = "Each vertex defines a point." -fields.line_list.doc = "Each pair of vertices defines a separate line." -fields.line_strip.doc = "Each vertex after the first defines a line to the previous vertex." -fields.triangle_list.doc = "Each triple of vertices defines a separate triangle." -fields.triangle_strip.doc = "Each vertex after the first two defines a triangle with the previous two vertices." - -[enums.FrontFace] -doc = """ -Defines which winding order of a triangle is considered front-facing. - -Used in the front_face field of structs.PrimitiveState. -""" -fields.ccw.doc = "Triangles with counter-clockwise vertices (in framebuffer space) are front-facing." -fields.cw.doc = "Triangles with clockwise vertices (in framebuffer space) are front-facing." - -[enums.CullMode] -doc = """ -Defines which faces of triangles are culled (not drawn). - -Used in the cull_mode field of structs.PrimitiveState. -""" -fields.none.doc = "No faces are culled." -fields.front.doc = "Front-facing triangles are culled." -fields.back.doc = "Back-facing triangles are culled." - -[enums.BlendFactor] -doc = """ -A factor that is multiplied with the source or destination color or alpha in blending. - -Used in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions, -src is the output of the fragment shader and dst is the existing value in the render target. -""" -fields.zero.doc = "Factor 0." -fields.one.doc = "Factor 1." -fields.src.doc = "The source color, per component." -fields.one_minus_src.doc = "One minus the source color, per component." -fields.src_alpha.doc = "The source alpha." -fields.one_minus_src_alpha.doc = "One minus the source alpha." -fields.dst.doc = "The destination color, per component." -fields.one_minus_dst.doc = "One minus the destination color, per component." -fields.dst_alpha.doc = "The destination alpha." -fields.one_minus_dst_alpha.doc = "One minus the destination alpha." -fields.src_alpha_saturated.doc = "The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha." -fields.constant.doc = "The blend constant color, see GPURenderPassEncoder.set_blend_constant()." -fields.one_minus_constant.doc = "One minus the blend constant color." -fields.src1.doc = "The second source color output of the fragment shader. Requires feature dual_source_blending." -fields.one_minus_src1.doc = "One minus the second source color. Requires feature dual_source_blending." -fields.src1_alpha.doc = "The second source alpha. Requires feature dual_source_blending." -fields.one_minus_src1_alpha.doc = "One minus the second source alpha. Requires feature dual_source_blending." - -[enums.BlendOperation] -doc = """ -The operation used to combine the scaled source and destination values in blending. - -Used in the operation field of structs.BlendComponent. -""" -fields.add.doc = "Result is source plus destination." -fields.subtract.doc = "Result is source minus destination." -fields.reverse_subtract.doc = "Result is destination minus source." -fields.min.doc = "Result is the minimum of source and destination (blend factors are ignored)." -fields.max.doc = "Result is the maximum of source and destination (blend factors are ignored)." - -[enums.StencilOperation] -doc = """ -The operation performed on the stencil buffer value after a stencil or depth test. - -Used in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState. -""" -fields.keep.doc = "Keep the current stencil value." -fields.zero.doc = "Set the stencil value to zero." -fields.replace.doc = "Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference()." -fields.invert.doc = "Bitwise invert the current stencil value." -fields.increment_clamp.doc = "Increment the stencil value, clamping to the maximum." -fields.decrement_clamp.doc = "Decrement the stencil value, clamping to zero." -fields.increment_wrap.doc = "Increment the stencil value, wrapping to zero on overflow." -fields.decrement_wrap.doc = "Decrement the stencil value, wrapping to the maximum on underflow." - -[enums.IndexFormat] -doc = """ -The data type of the indices in an index buffer. - -Used in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method -and the strip_index_format field of structs.PrimitiveState. -""" -fields.uint16.doc = "Indices are 16-bit unsigned integers." -fields.uint32.doc = "Indices are 32-bit unsigned integers." - -[enums.VertexFormat] -doc = """ -The format of a vertex attribute in a vertex buffer. - -Used in the format field of structs.VertexAttribute. The name consists of the component type and -bit size, optionally followed by xN for the number of components. The shader sees the data as -float (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components. -""" -fields.uint8.doc = "One 8-bit unsigned integer." -fields.uint8x2.doc = "Two 8-bit unsigned integers." -fields.uint8x4.doc = "Four 8-bit unsigned integers." -fields.sint8.doc = "One 8-bit signed integer." -fields.sint8x2.doc = "Two 8-bit signed integers." -fields.sint8x4.doc = "Four 8-bit signed integers." -fields.unorm8.doc = "One 8-bit unsigned normalized value (0..1)." -fields.unorm8x2.doc = "Two 8-bit unsigned normalized values (0..1)." -fields.unorm8x4.doc = "Four 8-bit unsigned normalized values (0..1)." -fields.snorm8.doc = "One 8-bit signed normalized value (-1..1)." -fields.snorm8x2.doc = "Two 8-bit signed normalized values (-1..1)." -fields.snorm8x4.doc = "Four 8-bit signed normalized values (-1..1)." -fields.uint16.doc = "One 16-bit unsigned integer." -fields.uint16x2.doc = "Two 16-bit unsigned integers." -fields.uint16x4.doc = "Four 16-bit unsigned integers." -fields.sint16.doc = "One 16-bit signed integer." -fields.sint16x2.doc = "Two 16-bit signed integers." -fields.sint16x4.doc = "Four 16-bit signed integers." -fields.unorm16.doc = "One 16-bit unsigned normalized value (0..1)." -fields.unorm16x2.doc = "Two 16-bit unsigned normalized values (0..1)." -fields.unorm16x4.doc = "Four 16-bit unsigned normalized values (0..1)." -fields.snorm16.doc = "One 16-bit signed normalized value (-1..1)." -fields.snorm16x2.doc = "Two 16-bit signed normalized values (-1..1)." -fields.snorm16x4.doc = "Four 16-bit signed normalized values (-1..1)." -fields.float16.doc = "One 16-bit float." -fields.float16x2.doc = "Two 16-bit floats." -fields.float16x4.doc = "Four 16-bit floats." -fields.float32.doc = "One 32-bit float." -fields.float32x2.doc = "Two 32-bit floats." -fields.float32x3.doc = "Three 32-bit floats." -fields.float32x4.doc = "Four 32-bit floats." -fields.uint32.doc = "One 32-bit unsigned integer." -fields.uint32x2.doc = "Two 32-bit unsigned integers." -fields.uint32x3.doc = "Three 32-bit unsigned integers." -fields.uint32x4.doc = "Four 32-bit unsigned integers." -fields.sint32.doc = "One 32-bit signed integer." -fields.sint32x2.doc = "Two 32-bit signed integers." -fields.sint32x3.doc = "Three 32-bit signed integers." -fields.sint32x4.doc = "Four 32-bit signed integers." -fields.unorm10_10_10_2.doc = "A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float." -fields.unorm8x4_bgra.doc = "Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order." - -[enums.VertexStepMode] -doc = """ -How often a vertex buffer is advanced. - -Used in the step_mode field of structs.VertexBufferLayout. -""" -fields.vertex.doc = "The buffer is advanced for each vertex." -fields.instance.doc = "The buffer is advanced for each instance." - -[enums.LoadOp] -doc = """ -What happens to the contents of an attachment at the start of a render pass. - -Used in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. -""" -fields.load.doc = "Keep the existing contents of the attachment." -fields.clear.doc = "Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment)." - -[enums.StoreOp] -doc = """ -What happens to the contents of an attachment at the end of a render pass. - -Used in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. -""" -fields.store.doc = "Store the results of the render pass in the attachment." -fields.discard.doc = "Discard the results; the contents of the attachment become undefined (zero-initialized when next used)." - -[enums.QueryType] -doc = """ -The type of queries in a GPUQuerySet. - -Used in the type field of structs.QuerySetDescriptor. -""" -fields.occlusion.doc = "Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query()." -fields.timestamp.doc = "Timestamp queries record GPU timestamps. Requires feature timestamp_query." - -[enums.CanvasAlphaMode] -doc = """ -How the alpha channel of a canvas texture is interpreted when compositing with the page or window. - -Used in the alpha_mode field of structs.CanvasConfiguration. -""" -fields.opaque.doc = "The alpha channel is ignored and the canvas is treated as fully opaque." -fields.premultiplied.doc = "The color channels are expected to be premultiplied by the alpha channel." - -[enums.CanvasToneMappingMode] -doc = """ -How the content of a canvas is tone mapped when displayed. - -Used in the mode field of structs.CanvasToneMapping. -""" -fields.standard.doc = "Color values are clamped to the standard dynamic range (SDR) of the display." -fields.extended.doc = "Color values may exceed the SDR range, up to the dynamic range of the display (HDR)." - -[enums.DeviceLostReason] -doc = """ -The reason a GPUDevice was lost. - -Available via the reason property of GPUDeviceLostInfo. -""" -fields.unknown.doc = "The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal." -fields.destroyed.doc = "The device was lost because GPUDevice.destroy() was called." - -[enums.ErrorFilter] -doc = """ -The type of error that is captured by an error scope. - -Used in the filter argument of the GPUDevice.push_error_scope() method. -""" -fields.validation.doc = "Captures GPUValidationError errors, which signal incorrect API usage." -fields.out_of_memory.doc = "Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation." -fields.internal.doc = "Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits)." - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[structs] - -[structs.RequestAdapterOptions] -doc = """ -Options for requesting an adapter. - -Used as the options argument of the GPU.request_adapter() method. -""" -fields.feature_level.doc = "The feature level to request: 'core' (default) or 'compatibility', a more limited level supported by more (older) hardware." -fields.power_preference.doc = "Hint for the kind of adapter to select, see enums.PowerPreference." -fields.force_fallback_adapter.doc = "If true, only a fallback adapter (e.g. a software renderer) is returned, or no adapter if there is none." -fields.xr_compatible.doc = "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." - -[structs.DeviceDescriptor] -doc = """ -Descriptor for requesting a device. - -Used as the descriptor argument of the GPUAdapter.request_device() method. -""" -fields.label.doc = "A human-readable label for the device, used in debugging and error messages." -fields.required_features.doc = "A list of enums.FeatureName that the device must support. Requesting an unsupported feature fails." -fields.required_limits.doc = "A mapping of limit names to the values the device requires. Must not be better than what the adapter supports. Unspecified limits get their default value." -fields.default_queue.doc = "A structs.QueueDescriptor with options for the default queue of the device." - -[structs.BufferDescriptor] -doc = """ -Descriptor for creating a GPUBuffer. - -Used as the descriptor argument of the GPUDevice.create_buffer() method. -""" -fields.label.doc = "A human-readable label for the buffer, used in debugging and error messages." -fields.size.doc = "The size of the buffer in bytes." -fields.usage.doc = "The allowed usages of the buffer, a combination of flags.BufferUsage." -fields.mapped_at_creation.doc = "If true, the buffer is created in a mapped state so it can be filled right away using GPUBuffer.get_mapped_range(). The size must then be a multiple of 4." - -[structs.TextureDescriptor] -doc = """ -Descriptor for creating a GPUTexture. - -Used as the descriptor argument of the GPUDevice.create_texture() method. -""" -fields.label.doc = "A human-readable label for the texture, used in debugging and error messages." -fields.size.doc = "The size of the texture as a structs.Extent3D, or a tuple of (width, height, depth_or_array_layers). Height and depth default to 1." -fields.mip_level_count.doc = "The number of mip levels. Defaults to 1." -fields.sample_count.doc = "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." -fields.dimension.doc = "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." -fields.format.doc = "The pixel format of the texture, see enums.TextureFormat." -fields.usage.doc = "The allowed usages of the texture, a combination of flags.TextureUsage." -fields.view_formats.doc = "Additional enums.TextureFormat values that views of this texture may use. Formats that differ only in sRGB-ness from the texture format are allowed." -fields.texture_binding_view_dimension.doc = "Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding." - -[structs.TextureViewDescriptor] -doc = """ -Descriptor for creating a GPUTextureView. - -Used as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields -get a default derived from the texture, so by default the view covers the whole texture. -""" -fields.label.doc = "A human-readable label for the texture view, used in debugging and error messages." -fields.format.doc = "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." -fields.dimension.doc = "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." -fields.usage.doc = "The usages the view will be used for, a subset of the usage of the texture (see flags.TextureUsage). Defaults to all usages of the texture." -fields.aspect.doc = "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." -fields.base_mip_level.doc = "The first mip level accessible via the view. Defaults to 0." -fields.mip_level_count.doc = "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." -fields.base_array_layer.doc = "The first array layer accessible via the view. Defaults to 0." -fields.array_layer_count.doc = "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." -fields.swizzle.doc = "A string of four characters (default 'rgba') that defines how the components of the view are mapped, e.g. 'bgra'. Allowed characters are r, g, b, a, 0 and 1. Requires feature texture_component_swizzle." - -[structs.ExternalTextureDescriptor] -doc = """ -Descriptor for importing an external texture, such as a video frame. - -Used as the descriptor argument of the GPUDevice.import_external_texture() method. -""" -fields.label.doc = "A human-readable label for the external texture, used in debugging and error messages." -fields.source.doc = "The source of the image data, e.g. a video element or video frame. Only meaningful in browser environments." -fields.color_space.doc = "The color space of the source image, e.g. 'srgb'. Defaults to 'srgb'." - -[structs.SamplerDescriptor] -doc = """ -Descriptor for creating a GPUSampler. - -Used as the descriptor argument of the GPUDevice.create_sampler() method. -""" -fields.label.doc = "A human-readable label for the sampler, used in debugging and error messages." -fields.address_mode_u.doc = "How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge." -fields.address_mode_v.doc = "How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge." -fields.address_mode_w.doc = "How to handle texture coordinates outside 0..1 along the w (z) axis, see enums.AddressMode. Defaults to clamp_to_edge." -fields.mag_filter.doc = "The filter used when the texture is magnified, see enums.FilterMode. Defaults to nearest." -fields.min_filter.doc = "The filter used when the texture is minified, see enums.FilterMode. Defaults to nearest." -fields.mipmap_filter.doc = "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." -fields.lod_min_clamp.doc = "The minimum level of detail used when sampling. Defaults to 0." -fields.lod_max_clamp.doc = "The maximum level of detail used when sampling. Defaults to 32." -fields.compare.doc = "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures." -fields.max_anisotropy.doc = "The maximum anisotropic filtering level, from 1 (default, disabled) to 16. Values above 1 require all filters to be linear." - -[structs.BindGroupLayoutDescriptor] -doc = """ -Descriptor for creating a GPUBindGroupLayout. - -Used as the descriptor argument of the GPUDevice.create_bind_group_layout() method. -""" -fields.label.doc = "A human-readable label for the bind group layout, used in debugging and error messages." -fields.entries.doc = "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." - -[structs.BindGroupLayoutEntry] -doc = """ -Describes a single binding in a bind group layout. - -Exactly one of buffer, sampler, texture, storage_texture and external_texture must be set, -which determines the type of resource that is bound. -""" -fields.binding.doc = "The binding number, matching the @binding attribute in the shader." -fields.visibility.doc = "The shader stages in which the resource is visible, a combination of flags.ShaderStage." -fields.buffer.doc = "If set, a structs.BufferBindingLayout: the entry is a buffer binding." -fields.sampler.doc = "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." -fields.texture.doc = "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." -fields.storage_texture.doc = "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." -fields.external_texture.doc = "If set, a structs.ExternalTextureBindingLayout: the entry is an external texture binding." - -[structs.BufferBindingLayout] -doc = """ -Describes the layout of a buffer binding. - -Used in the buffer field of structs.BindGroupLayoutEntry. -""" -fields.type.doc = "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." -fields.has_dynamic_offset.doc = "If true, an offset can be given in GPUBindingCommandsMixin.set_bind_group() when binding. Defaults to false." -fields.min_binding_size.doc = "The minimum size in bytes of a buffer bound to this entry. Defaults to 0, in which case the size is checked at draw/dispatch time." - -[structs.SamplerBindingLayout] -doc = """ -Describes the layout of a sampler binding. - -Used in the sampler field of structs.BindGroupLayoutEntry. -""" -fields.type.doc = "The type of sampler binding, see enums.SamplerBindingType. Defaults to filtering." - -[structs.TextureBindingLayout] -doc = """ -Describes the layout of a sampled texture binding. - -Used in the texture field of structs.BindGroupLayoutEntry. -""" -fields.sample_type.doc = "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." -fields.view_dimension.doc = "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." -fields.multisampled.doc = "If true, the bound texture must be multisampled. Defaults to false." - -[structs.StorageTextureBindingLayout] -doc = """ -Describes the layout of a storage texture binding. - -Used in the storage_texture field of structs.BindGroupLayoutEntry. -""" -fields.access.doc = "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." -fields.format.doc = "The enums.TextureFormat that the bound texture view must have." -fields.view_dimension.doc = "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." - -[structs.ExternalTextureBindingLayout] -doc = """ -Describes the layout of an external texture binding. - -Used in the external_texture field of structs.BindGroupLayoutEntry. It has no fields. -""" - -[structs.BindGroupDescriptor] -doc = """ -Descriptor for creating a GPUBindGroup. - -Used as the descriptor argument of the GPUDevice.create_bind_group() method. -""" -fields.label.doc = "A human-readable label for the bind group, used in debugging and error messages." -fields.layout.doc = "The GPUBindGroupLayout that this bind group conforms to." -fields.entries.doc = "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." - -[structs.BindGroupEntry] -doc = """ -A single resource binding in a bind group. - -Used in the entries field of structs.BindGroupDescriptor. -""" -fields.binding.doc = "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." -fields.resource.doc = "The resource to bind: a GPUSampler, a GPUTextureView, a structs.BufferBinding, or a GPUBuffer (which binds the whole buffer)." - -[structs.BufferBinding] -doc = """ -Describes a range of a GPUBuffer to bind. - -Can be used as the resource field of structs.BindGroupEntry. -""" -fields.buffer.doc = "The GPUBuffer to bind." -fields.offset.doc = "The offset in bytes into the buffer where the binding starts. Defaults to 0." -fields.size.doc = "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." - -[structs.PipelineLayoutDescriptor] -doc = """ -Descriptor for creating a GPUPipelineLayout. - -Used as the descriptor argument of the GPUDevice.create_pipeline_layout() method. -""" -fields.label.doc = "A human-readable label for the pipeline layout, used in debugging and error messages." -fields.bind_group_layouts.doc = "A list of GPUBindGroupLayout objects, one for each bind group index (set) used by the pipeline." -fields.immediate_size.doc = "The size in bytes of the immediate data (small data set with GPUBindingCommandsMixin.set_immediates()). Defaults to 0." - -[structs.ShaderModuleDescriptor] -doc = """ -Descriptor for creating a GPUShaderModule. - -Used as the descriptor argument of the GPUDevice.create_shader_module() method. -""" -fields.label.doc = "A human-readable label for the shader module, used in debugging and error messages." -fields.code.doc = "The shader source code, in WGSL." -fields.compilation_hints.doc = "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile the shader early." - -[structs.ShaderModuleCompilationHint] -doc = """ -A hint for the compilation of a shader module. - -Used in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only -affect performance, not behavior. -""" -fields.entry_point.doc = "The name of the shader entry point that the hint applies to." -fields.layout.doc = "The GPUPipelineLayout (or enums.AutoLayoutMode.auto) that the entry point will be used with." - -[structs.PipelineErrorInit] -doc = """ -Initialization options for a GPUPipelineError. - -Used as the options argument of the GPUPipelineError constructor. -""" -fields.reason.doc = "The reason for the error, see enums.PipelineErrorReason." - -[structs.ProgrammableStage] -doc = """ -Describes a programmable (shader) stage of a pipeline. - -This is the base for structs.VertexState, structs.FragmentState and the compute field of -structs.ComputePipelineDescriptor. -""" -fields.module.doc = "The GPUShaderModule containing the shader code." -fields.entry_point.doc = "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." -fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." - -[structs.ComputePipelineDescriptor] -doc = """ -Descriptor for creating a GPUComputePipeline. - -Used as the descriptor argument of the GPUDevice.create_compute_pipeline() method. -""" -fields.label.doc = "A human-readable label for the pipeline, used in debugging and error messages." -fields.layout.doc = "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader." -fields.compute.doc = "A structs.ProgrammableStage describing the compute shader." - -[structs.RenderPipelineDescriptor] -doc = """ -Descriptor for creating a GPURenderPipeline. - -Used as the descriptor argument of the GPUDevice.create_render_pipeline() method. -""" -fields.label.doc = "A human-readable label for the pipeline, used in debugging and error messages." -fields.layout.doc = "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shaders." -fields.vertex.doc = "A structs.VertexState describing the vertex shader and vertex buffers." -fields.primitive.doc = "A structs.PrimitiveState describing how primitives are assembled and rasterized." -fields.depth_stencil.doc = "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." -fields.multisample.doc = "A structs.MultisampleState describing multisampling." -fields.fragment.doc = "An optional structs.FragmentState describing the fragment shader and render targets." - -[structs.PrimitiveState] -doc = """ -Describes how a render pipeline assembles and rasterizes primitives. - -Used in the primitive field of structs.RenderPipelineDescriptor. -""" -fields.topology.doc = "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." -fields.strip_index_format.doc = "The enums.IndexFormat of the index buffer. Required for strip topologies when drawing with indices." -fields.front_face.doc = "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." -fields.cull_mode.doc = "Which faces to cull, see enums.CullMode. Defaults to none." -fields.unclipped_depth.doc = "If true, primitives are not clipped by the near and far planes. Requires feature depth_clip_control." - -[structs.MultisampleState] -doc = """ -Describes the multisampling of a render pipeline. - -Used in the multisample field of structs.RenderPipelineDescriptor. -""" -fields.count.doc = "The number of samples per pixel. Must be 1 or 4, and match the attachments. Defaults to 1." -fields.mask.doc = "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." -fields.alpha_to_coverage_enabled.doc = "If true, the alpha output of the fragment shader is used to generate a coverage mask. Defaults to false." - -[structs.FragmentState] -doc = """ -Describes the fragment shader stage and render targets of a render pipeline. - -Used in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. -""" -fields.module.doc = "The GPUShaderModule containing the fragment shader code." -fields.entry_point.doc = "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." -fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." -fields.targets.doc = "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." - -[structs.ColorTargetState] -doc = """ -Describes a color render target of a render pipeline. - -Used in the targets field of structs.FragmentState. -""" -fields.format.doc = "The enums.TextureFormat of the color attachment." -fields.blend.doc = "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." -fields.write_mask.doc = "Which channels are written, a combination of flags.ColorWrite. Defaults to ALL." - -[structs.BlendState] -doc = """ -Describes how blending is performed for a color target. - -Used in the blend field of structs.ColorTargetState. -""" -fields.color.doc = "A structs.BlendComponent for the color (RGB) channels." -fields.alpha.doc = "A structs.BlendComponent for the alpha channel." - -[structs.BlendComponent] -doc = """ -Describes how the blending of a single component (color or alpha) is performed. - -The result is: operation(src * src_factor, dst * dst_factor). -""" -fields.operation.doc = "The enums.BlendOperation used to combine the scaled values. Defaults to add." -fields.src_factor.doc = "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." -fields.dst_factor.doc = "The enums.BlendFactor applied to the destination (existing target value). Defaults to zero." - -[structs.DepthStencilState] -doc = """ -Describes the depth and stencil state of a render pipeline. - -Used in the depth_stencil field of structs.RenderPipelineDescriptor. -""" -fields.format.doc = "The depth-stencil enums.TextureFormat of the attachment." -fields.depth_write_enabled.doc = "If true, depth values of fragments that pass the depth test are written to the attachment." -fields.depth_compare.doc = "The enums.CompareFunction used for the depth test." -fields.stencil_front.doc = "A structs.StencilFaceState for front-facing primitives." -fields.stencil_back.doc = "A structs.StencilFaceState for back-facing primitives." -fields.stencil_read_mask.doc = "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." -fields.stencil_write_mask.doc = "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." -fields.depth_bias.doc = "A constant depth value added to each fragment. Defaults to 0." -fields.depth_bias_slope_scale.doc = "A depth bias that scales with the slope of the primitive. Defaults to 0." -fields.depth_bias_clamp.doc = "The maximum (or minimum, if negative) depth bias of a fragment. Defaults to 0." - -[structs.StencilFaceState] -doc = """ -Describes the stencil operations for one face (front or back) of primitives. - -Used in the stencil_front and stencil_back fields of structs.DepthStencilState. -""" -fields.compare.doc = "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." -fields.fail_op.doc = "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." -fields.depth_fail_op.doc = "The enums.StencilOperation performed if the stencil test passes but the depth test fails. Defaults to keep." -fields.pass_op.doc = "The enums.StencilOperation performed if both the stencil and depth tests pass. Defaults to keep." - -[structs.VertexState] -doc = """ -Describes the vertex shader stage and vertex buffers of a render pipeline. - -Used in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. -""" -fields.module.doc = "The GPUShaderModule containing the vertex shader code." -fields.entry_point.doc = "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." -fields.constants.doc = "A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use." -fields.buffers.doc = "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." - -[structs.VertexBufferLayout] -doc = """ -Describes the layout of a vertex buffer. - -Used in the buffers field of structs.VertexState. -""" -fields.array_stride.doc = "The stride in bytes between consecutive elements in the buffer." -fields.step_mode.doc = "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." -fields.attributes.doc = "A list of structs.VertexAttribute describing the attributes in each element." - -[structs.VertexAttribute] -doc = """ -Describes a single vertex attribute within a vertex buffer. - -Used in the attributes field of structs.VertexBufferLayout. -""" -fields.format.doc = "The enums.VertexFormat of the attribute." -fields.offset.doc = "The offset in bytes of the attribute from the start of an element in the buffer." -fields.shader_location.doc = "The location number of the attribute in the vertex shader (the @location attribute)." - -[structs.TexelCopyBufferLayout] -doc = """ -Describes the layout of texel data in a buffer or in a block of memory. - -Used as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo. -""" -fields.offset.doc = "The offset in bytes into the data where the texel data starts. Defaults to 0." -fields.bytes_per_row.doc = "The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256 for buffer copies." -fields.rows_per_image.doc = "The number of rows per image (layer or slice). Required if there is more than one image." - -[structs.TexelCopyBufferInfo] -doc = """ -Describes a buffer and the layout of texel data in it. - -Used as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer(). -Extends structs.TexelCopyBufferLayout. -""" -fields.offset.doc = "The offset in bytes into the buffer where the texel data starts. Defaults to 0." -fields.bytes_per_row.doc = "The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256." -fields.rows_per_image.doc = "The number of rows per image (layer or slice). Required if there is more than one image." -fields.buffer.doc = "The GPUBuffer that contains (or will contain) the texel data." - -[structs.TexelCopyTextureInfo] -doc = """ -Describes a texture and the part of it that is the source or destination of a copy. - -Used in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(), -GPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture(). -""" -fields.texture.doc = "The GPUTexture to copy to or from." -fields.mip_level.doc = "The mip level to copy to or from. Defaults to 0." -fields.origin.doc = "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." -fields.aspect.doc = "Which aspect of the texture to copy, see enums.TextureAspect. Defaults to all." - -[structs.CopyExternalImageDestInfo] -doc = """ -Describes the destination texture of GPUQueue.copy_external_image_to_texture(). - -Extends structs.TexelCopyTextureInfo with color space information. -""" -fields.texture.doc = "The GPUTexture to copy to." -fields.mip_level.doc = "The mip level to copy to. Defaults to 0." -fields.origin.doc = "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." -fields.aspect.doc = "Which aspect of the texture to copy to, see enums.TextureAspect. Defaults to all." -fields.color_space.doc = "The color space to encode the copied image data in, e.g. 'srgb'. Defaults to 'srgb'." -fields.premultiplied_alpha.doc = "If true, the color channels are premultiplied by the alpha channel when written. Defaults to false." - -[structs.CopyExternalImageSourceInfo] -doc = """ -Describes the source of GPUQueue.copy_external_image_to_texture(). - -Used as the source argument of that method. -""" -fields.source.doc = "The image source, e.g. an image, canvas or video frame. Only meaningful in browser environments (in Python, e.g. an array or PIL image may be supported)." -fields.origin.doc = "The origin in the source image to start copying from, as a structs.Origin2D or a tuple (x, y). Defaults to (0, 0)." -fields.flip_y.doc = "If true, the source image is flipped vertically before copying. Defaults to false." - -[structs.CommandBufferDescriptor] -doc = """ -Descriptor for a GPUCommandBuffer. - -Used as the descriptor argument of the GPUCommandEncoder.finish() method. -""" -fields.label.doc = "A human-readable label for the command buffer, used in debugging and error messages." - -[structs.CommandEncoderDescriptor] -doc = """ -Descriptor for creating a GPUCommandEncoder. - -Used as the descriptor argument of the GPUDevice.create_command_encoder() method. -""" -fields.label.doc = "A human-readable label for the command encoder, used in debugging and error messages." - -[structs.ComputePassTimestampWrites] -doc = """ -Describes where to write timestamps for a compute pass. - -Used in the timestamp_writes field of structs.ComputePassDescriptor. Requires feature timestamp_query. -""" -fields.query_set.doc = "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." -fields.beginning_of_pass_write_index.doc = "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." -fields.end_of_pass_write_index.doc = "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." - -[structs.ComputePassDescriptor] -doc = """ -Descriptor for beginning a compute pass. - -Used as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method. -""" -fields.label.doc = "A human-readable label for the compute pass, used in debugging and error messages." -fields.timestamp_writes.doc = "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." - -[structs.RenderPassTimestampWrites] -doc = """ -Describes where to write timestamps for a render pass. - -Used in the timestamp_writes field of structs.RenderPassDescriptor. Requires feature timestamp_query. -""" -fields.query_set.doc = "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." -fields.beginning_of_pass_write_index.doc = "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." -fields.end_of_pass_write_index.doc = "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." - -[structs.RenderPassDescriptor] -doc = """ -Descriptor for beginning a render pass. - -Used as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method. -""" -fields.label.doc = "A human-readable label for the render pass, used in debugging and error messages." -fields.color_attachments.doc = "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to." -fields.depth_stencil_attachment.doc = "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." -fields.occlusion_query_set.doc = "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." -fields.timestamp_writes.doc = "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." -fields.max_draw_count.doc = "The maximum number of draw calls that will be done in the pass, used as a hint for the implementation. Defaults to 50000000." - -[structs.RenderPassColorAttachment] -doc = """ -Describes a color attachment of a render pass. - -Used in the color_attachments field of structs.RenderPassDescriptor. -""" -fields.view.doc = "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." -fields.depth_slice.doc = "For 3D textures, the index of the depth slice to render to." -fields.resolve_target.doc = "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." -fields.clear_value.doc = "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." -fields.load_op.doc = "What to do with the existing contents at the start of the pass, see enums.LoadOp." -fields.store_op.doc = "What to do with the results at the end of the pass, see enums.StoreOp." - -[structs.RenderPassDepthStencilAttachment] -doc = """ -Describes the depth-stencil attachment of a render pass. - -Used in the depth_stencil_attachment field of structs.RenderPassDescriptor. -""" -fields.view.doc = "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." -fields.depth_clear_value.doc = "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." -fields.depth_load_op.doc = "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." -fields.depth_store_op.doc = "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." -fields.depth_read_only.doc = "If true, the depth aspect is read-only in the pass (it is not written to). Defaults to false." -fields.stencil_clear_value.doc = "The value to clear the stencil aspect to if stencil_load_op is clear. Defaults to 0." -fields.stencil_load_op.doc = "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." -fields.stencil_store_op.doc = "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." -fields.stencil_read_only.doc = "If true, the stencil aspect is read-only in the pass (it is not written to). Defaults to false." - -[structs.RenderPassLayout] -doc = """ -Describes the attachment formats of a render pass or render bundle. - -This is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with -passes (or bundles) whose layout is compatible with the pipeline. -""" -fields.label.doc = "A human-readable label, used in debugging and error messages." -fields.color_formats.doc = "A list of enums.TextureFormat (or None for unused slots) of the color attachments." -fields.depth_stencil_format.doc = "The enums.TextureFormat of the depth-stencil attachment, if any." -fields.sample_count.doc = "The number of samples per pixel of the attachments. Defaults to 1." - -[structs.RenderBundleDescriptor] -doc = """ -Descriptor for a GPURenderBundle. - -Used as the descriptor argument of the GPURenderBundleEncoder.finish() method. -""" -fields.label.doc = "A human-readable label for the render bundle, used in debugging and error messages." - -[structs.RenderBundleEncoderDescriptor] -doc = """ -Descriptor for creating a GPURenderBundleEncoder. - -Used as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method. -Extends structs.RenderPassLayout. -""" -fields.label.doc = "A human-readable label for the render bundle encoder, used in debugging and error messages." -fields.color_formats.doc = "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." -fields.depth_stencil_format.doc = "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." -fields.sample_count.doc = "The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1." -fields.depth_read_only.doc = "If true, the bundle does not write to the depth aspect. Defaults to false." -fields.stencil_read_only.doc = "If true, the bundle does not write to the stencil aspect. Defaults to false." - -[structs.QueueDescriptor] -doc = """ -Descriptor for a GPUQueue. - -Used in the default_queue field of structs.DeviceDescriptor. -""" -fields.label.doc = "A human-readable label for the queue, used in debugging and error messages." - -[structs.QuerySetDescriptor] -doc = """ -Descriptor for creating a GPUQuerySet. - -Used as the descriptor argument of the GPUDevice.create_query_set() method. -""" -fields.label.doc = "A human-readable label for the query set, used in debugging and error messages." -fields.type.doc = "The type of queries in the set, see enums.QueryType." -fields.count.doc = "The number of queries in the set." - -[structs.CanvasToneMapping] -doc = """ -Describes the tone mapping of a canvas. - -Used in the tone_mapping field of structs.CanvasConfiguration. -""" -fields.mode.doc = "The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard." - -[structs.CanvasConfiguration] -doc = """ -Configuration for a GPUCanvasContext. - -Used as the configuration argument of the GPUCanvasContext.configure() method. -""" -fields.device.doc = "The GPUDevice that the canvas textures will be used with." -fields.format.doc = "The enums.TextureFormat of the canvas textures. Use GPU.get_preferred_canvas_format() for the best choice." -fields.usage.doc = "The allowed usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT." -fields.view_formats.doc = "Additional enums.TextureFormat values that views of the canvas texture may use." -fields.color_space.doc = "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." -fields.tone_mapping.doc = "A structs.CanvasToneMapping that describes how the canvas content is tone mapped." -fields.alpha_mode.doc = "How the alpha channel of the canvas is interpreted, see enums.CanvasAlphaMode. Defaults to opaque." - -[structs.UncapturedErrorEventInit] -doc = """ -Initialization data for an uncaptured error event. - -The event is passed to the callback set via the onuncapturederror property of GPUDevice. -""" -fields.error.doc = "The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope." - -[structs.Color] -doc = """ -An RGBA color with floating point components. - -Can also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment. -""" -fields.r.doc = "The red component." -fields.g.doc = "The green component." -fields.b.doc = "The blue component." -fields.a.doc = "The alpha component." - -[structs.Origin2D] -doc = """ -A 2D origin (offset) in a texture or image, in texels. - -Can also be given as a tuple (x, y). -""" -fields.x.doc = "The x coordinate (horizontal). Defaults to 0." -fields.y.doc = "The y coordinate (vertical). Defaults to 0." - -[structs.Origin3D] -doc = """ -A 3D origin (offset) in a texture, in texels. - -Can also be given as a tuple (x, y, z). -""" -fields.x.doc = "The x coordinate (horizontal). Defaults to 0." -fields.y.doc = "The y coordinate (vertical). Defaults to 0." -fields.z.doc = "The z coordinate (depth, or array layer). Defaults to 0." - -[structs.Extent3D] -doc = """ -A 3D size (extent) of a texture, in texels. - -Can also be given as a tuple (width, height, depth_or_array_layers). -""" -fields.width.doc = "The width of the extent." -fields.height.doc = "The height of the extent. Defaults to 1." -fields.depth_or_array_layers.doc = "The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1." - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[classes] - -[classes.GPUObjectBase] -doc = """ -The base class of all GPU objects. - -It provides the label property that is shared by all objects in the API. -""" -properties.label.doc = "A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it." -[classes.GPUObjectBase.methods] - -[classes.GPUAdapterInfo] -doc = """ -Information about a physical adapter (GPU). - -An instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice. -The values are strings that are possibly empty if the information is not available. -""" -properties.vendor.doc = "The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'." -properties.architecture.doc = "The name of the family or class of GPUs the adapter belongs to." -properties.device.doc = "A vendor-specific identifier of the adapter." -properties.description.doc = "A human-readable description of the adapter, e.g. the name of the GPU." -properties.subgroup_min_size.doc = "The minimum supported subgroup size of the adapter." -properties.subgroup_max_size.doc = "The maximum supported subgroup size of the adapter." -properties.is_fallback_adapter.doc = "Whether this is a fallback adapter, e.g. a software renderer." -[classes.GPUAdapterInfo.methods] - -[classes.GPU] -doc = """ -The entry point of the API. - -It is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu. -""" -properties.wgsl_language_features.doc = "The set of WGSL language features that are supported by the implementation." -[classes.GPU.methods] -[classes.GPU.methods.request_adapter] -doc = """ -Request a GPUAdapter, which represents a physical GPU (or a software equivalent). - -The adapter can be used to inspect the capabilities (features and limits) of the GPU, -and to request a GPUDevice. If no suitable adapter is available, None is returned. -""" -returns.doc = "A GPUAdapter, or None if no suitable adapter was found." -args.options.doc = "A structs.RequestAdapterOptions with options for selecting the adapter." -[classes.GPU.methods.get_preferred_canvas_format] -doc = """ -Get the preferred texture format for presenting to a canvas. - -Using this format for the format field of structs.CanvasConfiguration avoids a conversion when presenting. -""" -returns.doc = "An enums.TextureFormat, either rgba8unorm or bgra8unorm." - -[classes.GPUAdapter] -doc = """ -Represents a physical GPU (or a software implementation of one). - -An adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice, -which is used to do actual work. Adapters are obtained via GPU.request_adapter(). -""" -properties.features.doc = "The set of enums.FeatureName that the adapter supports." -properties.limits.doc = "A mapping of limit names to the maximum values supported by the adapter." -properties.info.doc = "A GPUAdapterInfo with information about the adapter." -[classes.GPUAdapter.methods] -[classes.GPUAdapter.methods.request_device] -doc = """ -Request a GPUDevice from the adapter. - -The device is the main object used to create resources and to submit work. An adapter can -only provide a single device; if it was already used, or if the requested features or limits -are not supported, the request fails. -""" -returns.doc = "A GPUDevice." -args.descriptor.doc = "A structs.DeviceDescriptor with the required features and limits." - -[classes.GPUDevice] -doc = """ -The main object that is used to create GPU resources and to submit work. - -A device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue -(the queue property) which is used to submit work to the GPU. Most resources -(buffers, textures, pipelines, etc.) are created using the create_* methods of the device. -""" -properties.features.doc = "The set of enums.FeatureName that are enabled on the device." -properties.limits.doc = "A mapping of limit names to the values that are in effect for the device." -properties.adapter_info.doc = "A GPUAdapterInfo with information about the adapter that this device was created from." -properties.queue.doc = "The default GPUQueue of the device." -properties.lost.doc = "A promise or future that resolves to a GPUDeviceLostInfo when the device is lost." -properties.onuncapturederror.doc = "A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope." -[classes.GPUDevice.methods] -[classes.GPUDevice.methods.destroy] -doc = """ -Destroy the device and release its resources. - -The device is lost with the reason enums.DeviceLostReason.destroyed. All resources created by the device become unusable. -""" -returns.doc = "None." -[classes.GPUDevice.methods.create_buffer] -doc = """ -Create a GPUBuffer, a block of memory that can be used by the GPU. - -Data can be written to the buffer using GPUQueue.write_buffer(), copy commands, or by mapping it (see GPUBuffer.map_async()). -""" -returns.doc = "A GPUBuffer." -args.descriptor.doc = "A structs.BufferDescriptor describing the buffer." -[classes.GPUDevice.methods.create_texture] -doc = """ -Create a GPUTexture, an image resource (1D, 2D or 3D) that can be sampled or rendered to. - -Textures are not accessed directly by shaders; use GPUTexture.create_view() to obtain a GPUTextureView. -""" -returns.doc = "A GPUTexture." -args.descriptor.doc = "A structs.TextureDescriptor describing the texture." -[classes.GPUDevice.methods.create_sampler] -doc = """ -Create a GPUSampler, which defines how a texture is sampled (filtering and addressing) in a shader. -""" -returns.doc = "A GPUSampler." -args.descriptor.doc = "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." -[classes.GPUDevice.methods.import_external_texture] -doc = """ -Import an external image source, such as a video frame, as a texture that can be sampled in a shader. - -The resulting object is only valid for a short time (until the end of the current frame/task), after which it must be re-imported. -This is mostly relevant in browser environments. -""" -returns.doc = "A GPUExternalTexture." -args.descriptor.doc = "A structs.ExternalTextureDescriptor describing the source." -[classes.GPUDevice.methods.create_bind_group_layout] -doc = """ -Create a GPUBindGroupLayout, which describes the types and visibility of the resources in a bind group. - -A bind group layout is used in create_bind_group() and create_pipeline_layout(). -""" -returns.doc = "A GPUBindGroupLayout." -args.descriptor.doc = "A structs.BindGroupLayoutDescriptor describing the entries of the layout." -[classes.GPUDevice.methods.create_pipeline_layout] -doc = """ -Create a GPUPipelineLayout, which describes all bind groups (and immediate data) used by a pipeline. -""" -returns.doc = "A GPUPipelineLayout." -args.descriptor.doc = "A structs.PipelineLayoutDescriptor describing the bind group layouts." -[classes.GPUDevice.methods.create_bind_group] -doc = """ -Create a GPUBindGroup, which binds actual resources (buffers, textures, samplers) to the slots described by a layout. - -Bind groups are set on a pass encoder with GPUBindingCommandsMixin.set_bind_group(). -""" -returns.doc = "A GPUBindGroup." -args.descriptor.doc = "A structs.BindGroupDescriptor with the layout and the resources to bind." -[classes.GPUDevice.methods.create_shader_module] -doc = """ -Create a GPUShaderModule from shader source code (WGSL). - -Compilation errors do not raise immediately; use GPUShaderModule.get_compilation_info() to inspect messages, -or use error scopes (see push_error_scope()). -""" -returns.doc = "A GPUShaderModule." -args.descriptor.doc = "A structs.ShaderModuleDescriptor containing the shader code." -[classes.GPUDevice.methods.create_compute_pipeline] -doc = """ -Create a GPUComputePipeline, which describes a compute shader and its resources. - -Shader compilation may happen synchronously; use create_compute_pipeline_async() to avoid blocking. -""" -returns.doc = "A GPUComputePipeline." -args.descriptor.doc = "A structs.ComputePipelineDescriptor describing the pipeline." -[classes.GPUDevice.methods.create_render_pipeline] -doc = """ -Create a GPURenderPipeline, which describes the full state of the graphics pipeline: shaders, vertex layout, rasterization, depth/stencil, blending and render targets. - -Shader compilation may happen synchronously; use create_render_pipeline_async() to avoid blocking. -""" -returns.doc = "A GPURenderPipeline." -args.descriptor.doc = "A structs.RenderPipelineDescriptor describing the pipeline." -[classes.GPUDevice.methods.create_compute_pipeline_async] -doc = """ -Asynchronous version of create_compute_pipeline(). - -The pipeline is created without blocking. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device. -""" -returns.doc = "A GPUComputePipeline (awaitable)." -args.descriptor.doc = "A structs.ComputePipelineDescriptor describing the pipeline." -[classes.GPUDevice.methods.create_render_pipeline_async] -doc = """ -Asynchronous version of create_render_pipeline(). - -The pipeline is created without blocking. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device. -""" -returns.doc = "A GPURenderPipeline (awaitable)." -args.descriptor.doc = "A structs.RenderPipelineDescriptor describing the pipeline." -[classes.GPUDevice.methods.create_command_encoder] -doc = """ -Create a GPUCommandEncoder, used to record GPU commands (passes and copies). - -Finish the encoder with GPUCommandEncoder.finish() and submit the result with GPUQueue.submit(). -""" -returns.doc = "A GPUCommandEncoder." -args.descriptor.doc = "A structs.CommandEncoderDescriptor. Optional." -[classes.GPUDevice.methods.create_render_bundle_encoder] -doc = """ -Create a GPURenderBundleEncoder, used to pre-record a sequence of render commands that can be replayed in many render passes. - -The attachment formats given in the descriptor determine in which render passes the resulting bundle can be used. -""" -returns.doc = "A GPURenderBundleEncoder." -args.descriptor.doc = "A structs.RenderBundleEncoderDescriptor describing the attachment formats." -[classes.GPUDevice.methods.create_query_set] -doc = """ -Create a GPUQuerySet, a set of queries that hold e.g. occlusion or timestamp results. - -Results are written during passes and can be retrieved with GPUCommandEncoder.resolve_query_set(). -""" -returns.doc = "A GPUQuerySet." -args.descriptor.doc = "A structs.QuerySetDescriptor describing the type and count of queries." -[classes.GPUDevice.methods.push_error_scope] -doc = """ -Push a new error scope onto the device's error scope stack. - -While the scope is active, errors of the given type that are generated by operations on this device are -captured by the scope (instead of triggering the onuncapturederror callback). Retrieve them with pop_error_scope(). -""" -returns.doc = "None." -args.filter.doc = "The type of error to capture, see enums.ErrorFilter." -[classes.GPUDevice.methods.pop_error_scope] -doc = """ -Pop the most recent error scope from the stack and return the first error it captured. - -Errors are only reported once all operations in the scope have been processed. -""" -returns.doc = "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." - -[classes.GPUBuffer] -doc = """ -A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage. - -Buffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or -copy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the -buffer cannot be used by the GPU while it is mapped. -""" -properties.size.doc = "The size of the buffer in bytes." -properties.usage.doc = "The usage of the buffer, a combination of flags.BufferUsage." -properties.map_state.doc = "The current mapping state of the buffer, see enums.BufferMapState." -[classes.GPUBuffer.methods] -[classes.GPUBuffer.methods.map_async] -doc = """ -Map (a part of) the buffer so its memory can be accessed by the CPU. - -The returned promise or future resolves when the buffer is mapped. Once mapped, use get_mapped_range() -to access the data, and call unmap() when done to give the buffer back to the GPU. -""" -returns.doc = "None (awaitable); resolves when the buffer is mapped." -args.mode.doc = "Whether to map for reading or writing, see flags.MapMode." -args.offset.doc = "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." -args.size.doc = "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." -[classes.GPUBuffer.methods.get_mapped_range] -doc = """ -Get a view on the memory of a mapped part of the buffer. - -The buffer must be mapped (see map_async() or the mapped_at_creation field of structs.BufferDescriptor). -The returned memory becomes invalid when the buffer is unmapped. -""" -returns.doc = "A writable memory view (e.g. a memoryview) on the mapped range." -args.offset.doc = "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." -args.size.doc = "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." -[classes.GPUBuffer.methods.unmap] -doc = """ -Unmap the buffer, making any mapped memory invalid, and handing the buffer back to the GPU. - -If the buffer was mapped for writing, the written data becomes visible to the GPU. -""" -returns.doc = "None." -[classes.GPUBuffer.methods.destroy] -doc = """ -Destroy the buffer and free its memory. - -The buffer can no longer be used. Calling this multiple times is allowed. -""" -returns.doc = "None." - -[classes.GPUTexture] -doc = """ -An image resource of one, two or three dimensions, optionally with mip levels and array layers. - -Textures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render -attachment, create a GPUTextureView with create_view(). -""" -properties.width.doc = "The width of the texture in texels." -properties.height.doc = "The height of the texture in texels." -properties.depth_or_array_layers.doc = "The depth (for 3D textures) or the number of array layers of the texture." -properties.mip_level_count.doc = "The number of mip levels of the texture." -properties.sample_count.doc = "The number of samples per pixel of the texture (1 unless multisampled)." -properties.dimension.doc = "The dimensionality of the texture, see enums.TextureDimension." -properties.format.doc = "The pixel format of the texture, see enums.TextureFormat." -properties.usage.doc = "The allowed usages of the texture, a combination of flags.TextureUsage." -properties.texture_binding_view_dimension.doc = "Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding." -[classes.GPUTexture.methods] -[classes.GPUTexture.methods.create_view] -doc = """ -Create a GPUTextureView, a specific view of (part of) the texture. - -The view is what gets bound to shaders or used as a render attachment. -""" -returns.doc = "A GPUTextureView." -args.descriptor.doc = "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." -[classes.GPUTexture.methods.destroy] -doc = """ -Destroy the texture and free its memory. - -The texture can no longer be used. Calling this multiple times is allowed. -""" -returns.doc = "None." - -[classes.GPUTextureView] -doc = """ -A view on (a part of) a GPUTexture. - -Texture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry) -and as render pass attachments (see structs.RenderPassColorAttachment). -""" -[classes.GPUTextureView.methods] - -[classes.GPUSampler] -doc = """ -Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture. - -Samplers are created with GPUDevice.create_sampler(). -""" -[classes.GPUSampler.methods] - -[classes.GPUBindGroupLayout] -doc = """ -Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup. - -Bind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline -via GPUPipelineBase.get_bind_group_layout(). -""" -[classes.GPUBindGroupLayout.methods] - -[classes.GPUBindGroup] -doc = """ -A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout. - -Bind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group(). -""" -[classes.GPUBindGroup.methods] - -[classes.GPUPipelineLayout] -doc = """ -Describes the bind group layouts (and immediate data size) that a pipeline uses. - -Pipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto. -""" -[classes.GPUPipelineLayout.methods] - -[classes.GPUShaderModule] -doc = """ -A compiled piece of shader code (WGSL), containing one or more entry points. - -Shader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage). -""" -[classes.GPUShaderModule.methods] -[classes.GPUShaderModule.methods.get_compilation_info] -doc = """ -Get diagnostic messages (errors, warnings, info) produced when compiling the shader. -""" -returns.doc = "A GPUCompilationInfo (awaitable) with the list of messages." - -[classes.GPUCompilationMessage] -doc = """ -A single diagnostic message produced when compiling a shader module. - -The messages are available via the messages property of GPUCompilationInfo. -""" -properties.message.doc = "The human-readable text of the message." -properties.type.doc = "The severity of the message, see enums.CompilationMessageType." -properties.line_num.doc = "The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line." -properties.line_pos.doc = "The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position." -properties.offset.doc = "The offset in the shader code (in UTF-16 code units) that the message refers to." -properties.length.doc = "The length (in UTF-16 code units) of the span in the shader code that the message refers to." -[classes.GPUCompilationMessage.methods] - -[classes.GPUCompilationInfo] -doc = """ -The diagnostic messages produced when compiling a shader module. - -Obtained from GPUShaderModule.get_compilation_info(). -""" -properties.messages.doc = "A list of GPUCompilationMessage objects." -[classes.GPUCompilationInfo.methods] - -[classes.GPUPipelineError] -doc = """ -The error that is raised when asynchronous pipeline creation fails. - -Raised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async(). -""" -properties.reason.doc = "The reason for the failure, see enums.PipelineErrorReason." -[classes.GPUPipelineError.methods] -[classes.GPUPipelineError.methods.constructor] -doc = """ -Create a GPUPipelineError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = "A GPUPipelineError." -args.message.doc = "The human-readable error message." -args.options.doc = "A structs.PipelineErrorInit with the reason of the error." - -[classes.GPUPipelineBase] -doc = """ -The base class for GPUComputePipeline and GPURenderPipeline. - -It provides access to the bind group layouts of the pipeline. -""" -[classes.GPUPipelineBase.methods] -[classes.GPUPipelineBase.methods.get_bind_group_layout] -doc = """ -Get the GPUBindGroupLayout of the pipeline for the given bind group index. - -This is especially useful for pipelines created with enums.AutoLayoutMode.auto, where the layouts are derived from the shader. -""" -returns.doc = "A GPUBindGroupLayout." -args.index.doc = "The index of the bind group (the @group number in the shader)." - -[classes.GPUComputePipeline] -doc = """ -A pipeline that describes a compute shader and its resources. - -Created with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline(). -""" -[classes.GPUComputePipeline.methods] - -[classes.GPURenderPipeline] -doc = """ -A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending. - -Created with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline(). -""" -[classes.GPURenderPipeline.methods] - -[classes.GPUCommandBuffer] -doc = """ -A recorded list of GPU commands, ready to be submitted. - -Obtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once. -""" -[classes.GPUCommandBuffer.methods] - -[classes.GPUCommandsMixin] -doc = """ -A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -It has no methods of its own in the current version of the API. -""" -[classes.GPUCommandsMixin.methods] - -[classes.GPUCommandEncoder] -doc = """ -Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer. - -Create one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit(). -Only one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands. -""" -[classes.GPUCommandEncoder.methods] -[classes.GPUCommandEncoder.methods.begin_render_pass] -doc = """ -Begin a render pass, returning a GPURenderPassEncoder to record draw commands with. - -The pass must be ended with GPURenderPassEncoder.end() before the encoder can be used again. -""" -returns.doc = "A GPURenderPassEncoder." -args.descriptor.doc = "A structs.RenderPassDescriptor describing the attachments of the pass." -[classes.GPUCommandEncoder.methods.begin_compute_pass] -doc = """ -Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with. - -The pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again. -""" -returns.doc = "A GPUComputePassEncoder." -args.descriptor.doc = "A structs.ComputePassDescriptor. Optional." -[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] -doc = """ -Copy data from one GPUBuffer to another. - -The source needs flags.BufferUsage.COPY_SRC and the destination flags.BufferUsage.COPY_DST. -Offsets and size must be multiples of 4, and the ranges must not overlap if the buffers are the same. -""" -returns.doc = "None." -args.source.doc = "The GPUBuffer to copy from." -args.source_offset.doc = "The offset in bytes in the source buffer where the copy starts." -args.destination.doc = "The GPUBuffer to copy to." -args.destination_offset.doc = "The offset in bytes in the destination buffer where the data is written." -args.size.doc = "The number of bytes to copy." -[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] -doc = """ -Copy data from a GPUBuffer to a GPUTexture. - -The source buffer needs flags.BufferUsage.COPY_SRC and the texture flags.TextureUsage.COPY_DST. -""" -returns.doc = "None." -args.source.doc = "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." -args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." -args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." -[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] -doc = """ -Copy data from a GPUTexture to a GPUBuffer. - -The texture needs flags.TextureUsage.COPY_SRC and the destination buffer flags.BufferUsage.COPY_DST. -""" -returns.doc = "None." -args.source.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." -args.destination.doc = "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." -args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." -[classes.GPUCommandEncoder.methods.copy_texture_to_texture] -doc = """ -Copy data from one GPUTexture to another. - -The source needs flags.TextureUsage.COPY_SRC and the destination flags.TextureUsage.COPY_DST. -The formats must be compatible, and the sample counts equal. -""" -returns.doc = "None." -args.source.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." -args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." -args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." -[classes.GPUCommandEncoder.methods.clear_buffer] -doc = """ -Fill (a part of) a GPUBuffer with zeros. - -The buffer needs flags.BufferUsage.COPY_DST. -""" -returns.doc = "None." -args.buffer.doc = "The GPUBuffer to clear." -args.offset.doc = "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." -args.size.doc = "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." -[classes.GPUCommandEncoder.methods.resolve_query_set] -doc = """ -Resolve the results of queries in a GPUQuerySet into a GPUBuffer. - -The destination buffer needs flags.BufferUsage.QUERY_RESOLVE. Each result is written as a 64-bit unsigned integer. -""" -returns.doc = "None." -args.query_set.doc = "The GPUQuerySet to read results from." -args.first_query.doc = "The index of the first query to resolve." -args.query_count.doc = "The number of queries to resolve." -args.destination.doc = "The GPUBuffer to write the results to." -args.destination_offset.doc = "The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256." -[classes.GPUCommandEncoder.methods.finish] -doc = """ -Finish recording and return a GPUCommandBuffer. - -The command buffer can be submitted with GPUQueue.submit(). The encoder cannot be used after this call. -""" -returns.doc = "A GPUCommandBuffer." -args.descriptor.doc = "A structs.CommandBufferDescriptor. Optional." - -[classes.GPUBindingCommandsMixin] -doc = """ -A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -It provides methods to set bind groups and immediate data. -""" -[classes.GPUBindingCommandsMixin.methods] -[classes.GPUBindingCommandsMixin.methods.set_bind_group] -doc = """ -Set a GPUBindGroup for the given bind group index, to be used by subsequent draw or dispatch commands. - -The bind group must be compatible with the layout of the pipeline. If the layout has entries with -dynamic offsets (see the has_dynamic_offset field of structs.BufferBindingLayout), offsets must be provided. -The dynamic offsets can be given as a list, or as a range of an array (using the start and length arguments). -""" -returns.doc = "None." -args.index.doc = "The index of the bind group (the @group number in the shader)." -args.bind_group.doc = "The GPUBindGroup to set, or None to unset it." -args.dynamic_offsets_data.doc = "A list or array of offsets in bytes, one for each dynamic buffer binding, in order of binding number." -args.dynamic_offsets_data_start.doc = "If dynamic_offsets_data is an array, the index of the first offset to use." -args.dynamic_offsets_data_length.doc = "If dynamic_offsets_data is an array, the number of offsets to use." -[classes.GPUBindingCommandsMixin.methods.set_immediates] -doc = """ -Set immediate data: a small amount of data (typically a few hundred bytes at most) that is passed to shaders directly without a buffer. - -The size of the immediate data is determined by the immediate_size field of structs.PipelineLayoutDescriptor. -""" -returns.doc = "None." -args.range_offset.doc = "The offset in bytes in the immediate data range where the data is written. Must be a multiple of 4." -args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." -args.data_offset.doc = "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." -args.data_size.doc = "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." - -[classes.GPUDebugCommandsMixin] -doc = """ -A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -Debug groups and markers show up in debugging tools and in error messages. -""" -[classes.GPUDebugCommandsMixin.methods] -[classes.GPUDebugCommandsMixin.methods.push_debug_group] -doc = """ -Begin a labeled debug group. Every call must be matched with a call to pop_debug_group(). -""" -returns.doc = "None." -args.group_label.doc = "The label of the debug group." -[classes.GPUDebugCommandsMixin.methods.pop_debug_group] -doc = """ -End the most recent debug group that was started with push_debug_group(). -""" -returns.doc = "None." -[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] -doc = """ -Insert a single labeled marker into the command stream. -""" -returns.doc = "None." -args.marker_label.doc = "The label of the marker." - -[classes.GPUComputePassEncoder] -doc = """ -Records the commands of a compute pass. - -Created with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work, -and finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin. -""" -[classes.GPUComputePassEncoder.methods] -[classes.GPUComputePassEncoder.methods.set_pipeline] -doc = """ -Set the GPUComputePipeline to use for subsequent dispatch commands. -""" -returns.doc = "None." -args.pipeline.doc = "The GPUComputePipeline to use." -[classes.GPUComputePassEncoder.methods.dispatch_workgroups] -doc = """ -Run the compute shader of the current pipeline for a grid of workgroups. - -The total number of invocations is the number of workgroups times the workgroup size defined in the shader. -""" -returns.doc = "None." -args.workgroup_count_x.doc = "The number of workgroups in the x dimension." -args.workgroup_count_y.doc = "The number of workgroups in the y dimension. Defaults to 1." -args.workgroup_count_z.doc = "The number of workgroups in the z dimension. Defaults to 1." -[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] -doc = """ -Like dispatch_workgroups(), but the workgroup counts are read from a GPUBuffer. - -The buffer must have flags.BufferUsage.INDIRECT, and contain three consecutive 32-bit unsigned integers (x, y, z) at the given offset. -""" -returns.doc = "None." -args.indirect_buffer.doc = "The GPUBuffer that contains the workgroup counts." -args.indirect_offset.doc = "The offset in bytes in the buffer where the counts start. Must be a multiple of 4." -[classes.GPUComputePassEncoder.methods.end] -doc = """ -End the compute pass. The encoder can no longer be used afterwards. -""" -returns.doc = "None." - -[classes.GPURenderPassEncoder] -doc = """ -Records the commands of a render pass. - -Created with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers, -draw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin. -""" -[classes.GPURenderPassEncoder.methods] -[classes.GPURenderPassEncoder.methods.set_viewport] -doc = """ -Set the viewport: the region of the attachments that the clip-space output is mapped to. - -Defaults to the full size of the attachments. -""" -returns.doc = "None." -args.x.doc = "The x coordinate of the top-left corner of the viewport, in pixels." -args.y.doc = "The y coordinate of the top-left corner of the viewport, in pixels." -args.width.doc = "The width of the viewport, in pixels." -args.height.doc = "The height of the viewport, in pixels." -args.min_depth.doc = "The minimum depth value of the viewport (between 0 and 1)." -args.max_depth.doc = "The maximum depth value of the viewport (between 0 and 1)." -[classes.GPURenderPassEncoder.methods.set_scissor_rect] -doc = """ -Set the scissor rectangle: fragments outside of this rectangle are discarded. - -Defaults to the full size of the attachments. -""" -returns.doc = "None." -args.x.doc = "The x coordinate of the top-left corner of the rectangle, in pixels." -args.y.doc = "The y coordinate of the top-left corner of the rectangle, in pixels." -args.width.doc = "The width of the rectangle, in pixels." -args.height.doc = "The height of the rectangle, in pixels." -[classes.GPURenderPassEncoder.methods.set_blend_constant] -doc = """ -Set the blend constant color, used by blend factors enums.BlendFactor.constant and enums.BlendFactor.one_minus_constant. - -Defaults to transparent black (0, 0, 0, 0). -""" -returns.doc = "None." -args.color.doc = "The color, as a structs.Color or a tuple (r, g, b, a)." -[classes.GPURenderPassEncoder.methods.set_stencil_reference] -doc = """ -Set the stencil reference value, used in stencil comparisons and by enums.StencilOperation.replace. - -Defaults to 0. -""" -returns.doc = "None." -args.reference.doc = "The stencil reference value (an unsigned integer)." -[classes.GPURenderPassEncoder.methods.begin_occlusion_query] -doc = """ -Begin an occlusion query, which counts the samples that pass the depth and stencil tests. - -The result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor). -End the query with end_occlusion_query(). -""" -returns.doc = "None." -args.query_index.doc = "The index in the query set where the result is stored." -[classes.GPURenderPassEncoder.methods.end_occlusion_query] -doc = """ -End the occlusion query that was started with begin_occlusion_query(). -""" -returns.doc = "None." -[classes.GPURenderPassEncoder.methods.execute_bundles] -doc = """ -Execute pre-recorded GPURenderBundle objects as part of this pass. - -After executing bundles, the pipeline, bind groups and vertex/index buffers need to be set again. -""" -returns.doc = "None." -args.bundles.doc = "A list of GPURenderBundle objects to execute, in order." -[classes.GPURenderPassEncoder.methods.end] -doc = """ -End the render pass. The encoder can no longer be used afterwards. -""" -returns.doc = "None." - -[classes.GPURenderCommandsMixin] -doc = """ -A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder. - -It provides methods to set the pipeline, vertex and index buffers, and to draw. -""" -[classes.GPURenderCommandsMixin.methods] -[classes.GPURenderCommandsMixin.methods.set_pipeline] -doc = """ -Set the GPURenderPipeline to use for subsequent draw commands. -""" -returns.doc = "None." -args.pipeline.doc = "The GPURenderPipeline to use." -[classes.GPURenderCommandsMixin.methods.set_index_buffer] -doc = """ -Set the index buffer to use for subsequent indexed draw commands. - -The buffer needs flags.BufferUsage.INDEX. -""" -returns.doc = "None." -args.buffer.doc = "The GPUBuffer that contains the indices." -args.index_format.doc = "The data type of the indices, see enums.IndexFormat." -args.offset.doc = "The offset in bytes in the buffer where the indices start. Defaults to 0." -args.size.doc = "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." -[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] -doc = """ -Set a vertex buffer for the given slot, to be used by subsequent draw commands. - -The buffer needs flags.BufferUsage.VERTEX. The layout is defined by the buffers field of structs.VertexState. -""" -returns.doc = "None." -args.slot.doc = "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." -args.buffer.doc = "The GPUBuffer that contains the vertex data, or None to unset the slot." -args.offset.doc = "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." -args.size.doc = "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." -[classes.GPURenderCommandsMixin.methods.draw] -doc = """ -Draw primitives using the current pipeline and vertex buffers. -""" -returns.doc = "None." -args.vertex_count.doc = "The number of vertices to draw." -args.instance_count.doc = "The number of instances to draw. Defaults to 1." -args.first_vertex.doc = "The index of the first vertex to draw. Defaults to 0." -args.first_instance.doc = "The instance index of the first instance to draw. Defaults to 0." -[classes.GPURenderCommandsMixin.methods.draw_indexed] -doc = """ -Draw primitives using the current pipeline, vertex buffers and index buffer (see set_index_buffer()). -""" -returns.doc = "None." -args.index_count.doc = "The number of indices to draw." -args.instance_count.doc = "The number of instances to draw. Defaults to 1." -args.first_index.doc = "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." -args.base_vertex.doc = "A value added to each index before looking up the vertex. Defaults to 0." -args.first_instance.doc = "The instance index of the first instance to draw. Defaults to 0." -[classes.GPURenderCommandsMixin.methods.draw_indirect] -doc = """ -Like draw(), but the parameters are read from a GPUBuffer. - -The buffer must have flags.BufferUsage.INDIRECT, and contain four consecutive 32-bit unsigned integers -at the given offset: vertex_count, instance_count, first_vertex and first_instance. -A non-zero first_instance requires feature indirect_first_instance. -""" -returns.doc = "None." -args.indirect_buffer.doc = "The GPUBuffer that contains the draw parameters." -args.indirect_offset.doc = "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." -[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] -doc = """ -Like draw_indexed(), but the parameters are read from a GPUBuffer. - -The buffer must have flags.BufferUsage.INDIRECT, and contain five consecutive 32-bit values at the given offset: -index_count, instance_count, first_index, base_vertex (signed) and first_instance. -A non-zero first_instance requires feature indirect_first_instance. -""" -returns.doc = "None." -args.indirect_buffer.doc = "The GPUBuffer that contains the draw parameters." -args.indirect_offset.doc = "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." - -[classes.GPURenderBundle] -doc = """ -A pre-recorded sequence of render commands that can be executed in render passes. - -Obtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles(). -""" -[classes.GPURenderBundle.methods] - -[classes.GPURenderBundleEncoder] -doc = """ -Records render commands into a GPURenderBundle, which can be replayed in multiple render passes. - -Created with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin, -GPUDebugCommandsMixin and GPURenderCommandsMixin. -""" -[classes.GPURenderBundleEncoder.methods] -[classes.GPURenderBundleEncoder.methods.finish] -doc = """ -Finish recording and return a GPURenderBundle. - -The encoder cannot be used after this call. -""" -returns.doc = "A GPURenderBundle." -args.descriptor.doc = "A structs.RenderBundleDescriptor. Optional." - -[classes.GPUQueue] -doc = """ -The queue on which work is submitted to the GPU. - -Each GPUDevice has a default queue, available via the queue property of GPUDevice. -It is used to submit command buffers and to upload data to buffers and textures. -""" -[classes.GPUQueue.methods] -[classes.GPUQueue.methods.submit] -doc = """ -Submit a list of command buffers for execution on the GPU. - -Each command buffer can only be submitted once. -""" -returns.doc = "None." -args.command_buffers.doc = "A list of GPUCommandBuffer objects, executed in order." -[classes.GPUQueue.methods.on_submitted_work_done] -doc = """ -Wait until all work that was submitted so far has been completed by the GPU. -""" -returns.doc = "None (awaitable); resolves when the submitted work is done." -[classes.GPUQueue.methods.write_buffer] -doc = """ -Write data to a GPUBuffer. - -This is a convenient way to upload data. The buffer needs flags.BufferUsage.COPY_DST. -The size of the data to write and the offset must be multiples of 4. -""" -returns.doc = "None." -args.buffer.doc = "The GPUBuffer to write to." -args.buffer_offset.doc = "The offset in bytes in the buffer where the data is written." -args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." -args.data_offset.doc = "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." -args.size.doc = "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." -[classes.GPUQueue.methods.write_texture] -doc = """ -Write data to a GPUTexture. - -This is a convenient way to upload texture data. The texture needs flags.TextureUsage.COPY_DST. -""" -returns.doc = "None." -args.destination.doc = "A structs.TexelCopyTextureInfo describing the part of the texture to write to." -args.data.doc = "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." -args.data_layout.doc = "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." -args.size.doc = "A structs.Extent3D (or tuple) with the size of the region to write, in texels." -[classes.GPUQueue.methods.copy_external_image_to_texture] -doc = """ -Copy an external image (e.g. an image, canvas or video frame) to a GPUTexture. - -The texture needs flags.TextureUsage.COPY_DST and flags.TextureUsage.RENDER_ATTACHMENT. -""" -returns.doc = "None." -args.source.doc = "A structs.CopyExternalImageSourceInfo describing the image to copy from." -args.destination.doc = "A structs.CopyExternalImageDestInfo describing the part of the texture to copy to." -args.copy_size.doc = "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." - -[classes.GPUQuerySet] -doc = """ -A set of queries that hold results such as occlusion counts or timestamps. - -Created with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving -them into a buffer with GPUCommandEncoder.resolve_query_set(). -""" -properties.type.doc = "The type of queries in the set, see enums.QueryType." -properties.count.doc = "The number of queries in the set." -[classes.GPUQuerySet.methods] -[classes.GPUQuerySet.methods.destroy] -doc = """ -Destroy the query set and free its resources. - -The query set can no longer be used. Calling this multiple times is allowed. -""" -returns.doc = "None." - -[classes.GPUCanvasContext] -doc = """ -The connection between a canvas (or window) and the GPU, used to present rendered images. - -Configure it with configure(), then each frame obtain a texture with get_current_texture(), -render to it, and submit the work. The result is presented when the frame ends. -""" -properties.canvas.doc = "The canvas (or window/surface object) that this context belongs to." -[classes.GPUCanvasContext.methods] -[classes.GPUCanvasContext.methods.configure] -doc = """ -Configure the context for use with a device, so that textures can be obtained from it. - -Calling this again replaces the previous configuration. -""" -returns.doc = "None." -args.configuration.doc = "A structs.CanvasConfiguration with the device, format and other settings." -[classes.GPUCanvasContext.methods.unconfigure] -doc = """ -Remove the configuration, releasing the textures associated with the context. - -After this, get_current_texture() cannot be used until the context is configured again. -""" -returns.doc = "None." -[classes.GPUCanvasContext.methods.get_configuration] -doc = """ -Get the current configuration of the context. -""" -returns.doc = "The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured." -[classes.GPUCanvasContext.methods.get_current_texture] -doc = """ -Get the GPUTexture to render to for the current frame. - -The texture has the size of the canvas, and is the texture that will be presented. The same texture is returned -until the frame is presented; a new one is returned for the next frame. -""" -returns.doc = "A GPUTexture." - -[classes.GPUDeviceLostInfo] -doc = """ -Information about why a GPUDevice was lost. - -Available via the lost property of GPUDevice. -""" -properties.reason.doc = "The reason the device was lost, see enums.DeviceLostReason." -properties.message.doc = "A human-readable message with details about why the device was lost." -[classes.GPUDeviceLostInfo.methods] - -[classes.GPUError] -doc = """ -The base class of errors that are generated by the GPU API. - -Subclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError. -Errors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice. -""" -properties.message.doc = "A human-readable description of the error." -[classes.GPUError.methods] - -[classes.GPUValidationError] -doc = """ -An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage. - -Captured by error scopes with enums.ErrorFilter.validation. -""" -[classes.GPUValidationError.methods] -[classes.GPUValidationError.methods.constructor] -doc = """ -Create a GPUValidationError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = "A GPUValidationError." -args.message.doc = "The human-readable error message." - -[classes.GPUOutOfMemoryError] -doc = """ -An error that signals that there was not enough memory to complete an operation. - -Captured by error scopes with enums.ErrorFilter.out_of_memory. -""" -[classes.GPUOutOfMemoryError.methods] -[classes.GPUOutOfMemoryError.methods.constructor] -doc = """ -Create a GPUOutOfMemoryError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = "A GPUOutOfMemoryError." -args.message.doc = "The human-readable error message." - -[classes.GPUInternalError] -doc = """ -An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit. - -Captured by error scopes with enums.ErrorFilter.internal. -""" -[classes.GPUInternalError.methods] -[classes.GPUInternalError.methods.constructor] -doc = """ -Create a GPUInternalError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = "A GPUInternalError." -args.message.doc = "The human-readable error message." diff --git a/apigen/definitions/docs_dev.json b/apigen/definitions/docs_dev.json new file mode 100644 index 00000000..8728e088 --- /dev/null +++ b/apigen/definitions/docs_dev.json @@ -0,0 +1,7 @@ +{ + "meta": { + "filename": "docs_dev.json", + "description": "Hand-written docs to overload the ai-generated docs where needed.", + "notes": "" + } +} diff --git a/apigen/definitions/docs_dev.toml b/apigen/definitions/docs_dev.toml deleted file mode 100644 index 5fef2a6e..00000000 --- a/apigen/definitions/docs_dev.toml +++ /dev/null @@ -1,3 +0,0 @@ -# docs_dev.toml -# -# Define hand-written docs to overload the ai-generated docs. diff --git a/apigen/definitions/docs_ts.toml b/apigen/definitions/docs_ts.toml deleted file mode 100644 index 1baa9e09..00000000 --- a/apigen/definitions/docs_ts.toml +++ /dev/null @@ -1,1400 +0,0 @@ -# doc_ts.toml: Docs generated from 'index.d.ts'. - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[flags] - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[enums] - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[structs] - -BindGroupDescriptor.fields.entries.doc = ''' -A list of entries describing the resources to expose to the shader for each binding -described by the {@link GPUBindGroupDescriptor#layout}. -''' -BindGroupDescriptor.fields.layout.doc = 'The {@link GPUBindGroupLayout} the entries of this bind group will conform to.' - -BindGroupEntry.fields.binding.doc = ''' -A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a -{@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding -attribute in the {@link GPUShaderModule}. -''' -BindGroupEntry.fields.resource.doc = ''' -The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, -{@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. -''' - -BindGroupLayoutDescriptor.fields.entries.doc = 'A list of entries describing the shader resource bindings for a bind group.' - -BindGroupLayoutEntry.fields.binding.doc = ''' -A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding -to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding -attribute in the {@link GPUShaderModule}. -''' -BindGroupLayoutEntry.fields.external_texture.doc = ''' -Exactly one of these members must be set, indicating the binding type. -The contents of the member specify options specific to that type. -The corresponding resource in {@link GPUDevice#createBindGroup} requires -the corresponding binding resource type for this binding. -''' -BindGroupLayoutEntry.fields.visibility.doc = ''' -A bitset of the members of {@link GPUShaderStage}. -Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource -will be accessible from the associated shader stage. -''' - -BlendComponent.fields.dst_factor.doc = 'Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.' -BlendComponent.fields.operation.doc = ''' -Defines the {@link GPUBlendOperation} used to calculate the values written to the target -attachment components. -''' -BlendComponent.fields.src_factor.doc = 'Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.' - -BlendState.fields.alpha.doc = 'Defines the blending behavior of the corresponding render target for the alpha channel.' -BlendState.fields.color.doc = 'Defines the blending behavior of the corresponding render target for color channels.' - -BufferBinding.fields.buffer.doc = 'The {@link GPUBuffer} to bind.' -BufferBinding.fields.offset.doc = ''' -The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the -beginning of the range exposed to the shader by the buffer binding. -''' -BufferBinding.fields.size.doc = ''' -The size, in bytes, of the buffer binding. -If not map/exist|provided, specifies the range starting at -{@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. -''' - -BufferBindingLayout.fields.has_dynamic_offset.doc = 'Indicates whether this binding requires a dynamic offset.' -BufferBindingLayout.fields.min_binding_size.doc = ''' -Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. -Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. -If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] -that this value ≥ the minimum buffer binding size of the variable. -If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands -[$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} -satisfies the minimum buffer binding size of the variable. -Note: -Similar execution-time validation is theoretically possible for other -binding-related fields specified for early validation, like -{@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, -which currently can only be validated in pipeline creation. -However, such execution-time validation could be costly or unnecessarily complex, so it is -available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the -most ergonomic impact. -''' -BufferBindingLayout.fields.type.doc = 'Indicates the type required for buffers bound to this binding.' - -BufferDescriptor.fields.mapped_at_creation.doc = ''' -If `true` creates the buffer in an already mapped state, allowing -{@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set -{@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} -does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be -used to set the buffer's initial data. -Guarantees that even if the buffer creation eventually fails, it will still appear as if the -mapped range can be written/read to until it is unmapped. -''' -BufferDescriptor.fields.size.doc = 'The size of the buffer in bytes.' -BufferDescriptor.fields.usage.doc = 'The allowed usages for the buffer.' - -CanvasConfiguration.fields.alpha_mode.doc = ''' -Determines the effect that alpha values will have on the content of textures returned by -{@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. -''' -CanvasConfiguration.fields.color_space.doc = ''' -The color space that values written into textures returned by -{@link GPUCanvasContext#getCurrentTexture} should be displayed with. -''' -CanvasConfiguration.fields.device.doc = ''' -The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be -compatible with. -''' -CanvasConfiguration.fields.format.doc = ''' -The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. -Must be one of the Supported context formats. -''' -CanvasConfiguration.fields.tone_mapping.doc = ''' -The tone mapping determines how the content of textures returned by -{@link GPUCanvasContext#getCurrentTexture} are to be displayed. -
-This is a required feature, but user agents might not yet implement it, -effectively supporting only the default {@link GPUCanvasToneMapping}. -In such implementations, this member **should not** exist in its implementation of -{@link GPUCanvasConfiguration}, to make feature detection possible using -{@link GPUCanvasContext#getConfiguration}. -This is especially important in implementations which otherwise have HDR capabilities -(where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be -exposed). -If an implementation exposes this member and a `high` dynamic range, it **should** render the -canvas as an HDR element, not clamp values to the SDR range of the HDR display. -
-''' -CanvasConfiguration.fields.usage.doc = ''' -The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. -{@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included -if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} -when setting a custom usage if you wish to use textures returned by -{@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. -''' -CanvasConfiguration.fields.view_formats.doc = ''' -The formats that views created from textures returned by -{@link GPUCanvasContext#getCurrentTexture} may use. -''' - -CanvasConfigurationOut.fields.tone_mapping.doc = '{@inheritDoc GPUCanvasConfiguration.toneMapping}' -CanvasConfigurationOut.fields.view_formats.doc = '{@inheritDoc GPUCanvasConfiguration.viewFormats}' - -ColorDict.fields.a.doc = 'The alpha channel value.' -ColorDict.fields.b.doc = 'The blue channel value.' -ColorDict.fields.g.doc = 'The green channel value.' -ColorDict.fields.r.doc = 'The red channel value.' - -ColorTargetState.fields.blend.doc = ''' -The blending behavior for this color target. If left undefined, disables blending for this -color target. -''' -ColorTargetState.fields.format.doc = ''' -The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with -{@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the -corresponding color attachment. -''' -ColorTargetState.fields.write_mask.doc = 'Bitmask controlling which channels are are written to when drawing to this color target.' - -ComputePassDescriptor.fields.timestamp_writes.doc = 'Defines which timestamp values will be written for this pass, and where to write them to.' - -ComputePassTimestampWrites.fields.beginning_of_pass_write_index.doc = ''' -If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the beginning of the compute pass will be written. -''' -ComputePassTimestampWrites.fields.end_of_pass_write_index.doc = ''' -If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the end of the compute pass will be written. -''' -ComputePassTimestampWrites.fields.query_set.doc = ''' -The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be -written to. -''' - -ComputePipelineDescriptor.fields.compute.doc = 'Describes the compute shader entry point of the pipeline.' - -CopyExternalImageDestInfo.fields.color_space.doc = ''' -Describes the color space and encoding used to encode data into the destination texture. -This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1] -being written to the target texture, if its format can represent them. -Otherwise, the results are clamped to the target texture format's range. -Note: -If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, -conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. -''' -CopyExternalImageDestInfo.fields.premultiplied_alpha.doc = ''' -Describes whether the data written into the texture should have its RGB channels -premultiplied by the alpha channel, or not. -If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also -premultiplied, the source RGB values must be preserved even if they exceed their -corresponding alpha values. -Note: -If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, -conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. -''' - -CopyExternalImageSourceInfo.fields.flip_y.doc = ''' -Describes whether the source image is vertically flipped, or not. -If this option is set to `true`, the copy is flipped vertically: the bottom row of the source -region is copied into the first row of the destination region, and so on. -The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner -of the source image, increasing downward. -''' -CopyExternalImageSourceInfo.fields.origin.doc = ''' -Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from. -Together with `copySize`, defines the full copy sub-region. -''' -CopyExternalImageSourceInfo.fields.source.doc = ''' -The source of the texel copy. The copy source data is captured at the moment that -{@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described -by the external source dimensions table. -''' - -DepthStencilState.fields.depth_bias.doc = 'Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.' -DepthStencilState.fields.depth_bias_clamp.doc = 'The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.' -DepthStencilState.fields.depth_bias_slope_scale.doc = 'Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.' -DepthStencilState.fields.depth_compare.doc = ''' -The comparison operation used to test fragment depths against -{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. -''' -DepthStencilState.fields.depth_write_enabled.doc = ''' -Indicates if this {@link GPURenderPipeline} can modify -{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. -''' -DepthStencilState.fields.format.doc = ''' -The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} -this {@link GPURenderPipeline} will be compatible with. -''' -DepthStencilState.fields.stencil_back.doc = 'Defines how stencil comparisons and operations are performed for back-facing primitives.' -DepthStencilState.fields.stencil_front.doc = 'Defines how stencil comparisons and operations are performed for front-facing primitives.' -DepthStencilState.fields.stencil_read_mask.doc = ''' -Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value -bits are read when performing stencil comparison tests. -''' -DepthStencilState.fields.stencil_write_mask.doc = ''' -Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value -bits are written to when performing stencil operations. -''' - -DeviceDescriptor.fields.default_queue.doc = 'The descriptor for the default {@link GPUQueue}.' -DeviceDescriptor.fields.required_features.doc = ''' -Specifies the features that are required by the device request. -The request will fail if the adapter cannot provide these features. -Exactly the specified set of features, and no more or less, will be allowed in validation -of API calls on the resulting device. -''' -DeviceDescriptor.fields.required_limits.doc = ''' -Specifies the limits that are required by the device request. -The request will fail if the adapter cannot provide these limits. -Each key with a non-`undefined` value must be the name of a member of supported limits. -API calls on the resulting device perform validation according to the exact limits of the -device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). - -''' - -Error.fields.message.doc = ''' -A human-readable, localizable text message providing information about the error that -occurred. -Note: This message is generally intended for application developers to debug their -applications and capture information for debug reports, not to be surfaced to end-users. -Note: User agents should not include potentially machine-parsable details in this message, -such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the -conditions under which memory was exhausted. -Note: The {@link GPUError#message} should follow the best practices for language and -direction information. This includes making use of any future standards which may emerge -regarding the reporting of string language and direction metadata. -

Editorial note: -At the time of this writing, no language/direction recommendation is available that provides -compatibility and consistency with legacy APIs, but when there is, adopt it formally. -''' - -Extent3DDict.fields.depth_or_array_layers.doc = ''' -The depth of the extent or the number of array layers it contains. -If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `"3d"` -defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension} -of {@link GPUTextureDimension} `"2d"` defines the number of array layers in the texture. -''' -Extent3DDict.fields.height.doc = 'The height of the extent.' -Extent3DDict.fields.width.doc = 'The width of the extent.' - -Extent3DDictStrict.fields.depth.doc = '@deprecated The correct name is `depthOrArrayLayers`.' - -ExternalTextureDescriptor.fields.color_space.doc = ''' -The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be -converted into when reading. -''' -ExternalTextureDescriptor.fields.source.doc = ''' -The video source to import the external texture from. Source size is determined as described -by the external source dimensions table. -''' - -FragmentState.fields.targets.doc = ''' -A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets -this pipeline writes to. -''' - -MultisampleState.fields.alpha_to_coverage_enabled.doc = ''' -When `true` indicates that a fragment's alpha channel should be used to generate a sample -coverage mask. -''' -MultisampleState.fields.count.doc = ''' -Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only -with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} -and {@link GPURenderPassDescriptor#depthStencilAttachment}) -with matching {@link GPUTextureDescriptor#sampleCount}s. -''' -MultisampleState.fields.mask.doc = 'Mask determining which samples are written to.' - -NavigatorGPU.fields.gpu.doc = 'A global singleton providing top-level entry points like {@link GPU#requestAdapter}.' - -ObjectDescriptorBase.fields.label.doc = 'The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}.' - -Origin2DDictStrict.fields.z.doc = '@deprecated Does not exist for GPUOrigin2D.' - -PipelineDescriptorBase.fields.layout.doc = ''' -The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `"auto"` to generate -the pipeline layout automatically. -Note: If {@link GPUAutoLayoutMode} `"auto"` is used the pipeline cannot share {@link GPUBindGroup}s -with any other pipelines. -''' - -PipelineLayoutDescriptor.fields.bind_group_layouts.doc = ''' -A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds -to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding -with `@group(N)`. -''' -PipelineLayoutDescriptor.fields.immediate_size.doc = 'The size, in bytes, of the immediate data range used by the pipeline.' - -PrimitiveState.fields.cull_mode.doc = 'Defines which polygon orientation will be culled, if any.' -PrimitiveState.fields.front_face.doc = 'Defines which polygons are considered front-facing.' -PrimitiveState.fields.strip_index_format.doc = ''' -For pipelines with strip topologies -({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), -this determines the index buffer format and primitive restart value -({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). -It is not allowed on pipelines with non-strip topologies. -Note: Some implementations require knowledge of the primitive restart value to compile -pipeline state objects. -To use a strip-topology pipeline with an indexed draw call -({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), -this must be set, and it must match the index buffer format used with the draw call -(set in {@link GPURenderCommandsMixin#setIndexBuffer}). -See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. -''' -PrimitiveState.fields.topology.doc = 'The type of primitive to be constructed from the vertex inputs.' -PrimitiveState.fields.unclipped_depth.doc = ''' -If true, indicates that depth clipping is disabled. -Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. -''' - -ProgrammableStage.fields.constants.doc = ''' -Specifies the values of pipeline-overridable constants in the shader module -{@link GPUProgrammableStage#module}. -Each such pipeline-overridable constant is uniquely identified by a single -pipeline-overridable constant identifier string, representing the pipeline -constant ID of the constant if its declaration specifies one, and otherwise the -constant's identifier name. -The key of each key-value pair must equal the -pipeline-overridable constant identifier string|identifier string -of one such constant, with the comparison performed -according to the rules for WGSL identifier comparison. -When the pipeline is executed, that constant will have the specified value. -Values are specified as GPUPipelineConstantValue, which is a `double`. -They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). -If conversion fails, a validation error is generated. -

-Pipeline-overridable constants defined in WGSL: -```wgsl -override width: f32 = 0.0; // Specifed at the API level -// using the name "width". -override depth: f32; // Specifed at the API level -// using the name "depth". -// Must be overridden. -override height = 2 * depth; // The default value -// (if not set at the API level), -// depends on another -// overridable constant. -``` -Corresponding JavaScript code, providing only the overrides which are required -(have no defaults): -```js -{ -// ... -constants: { -1300: 2.0, // "gain" -depth: -1, // "depth" -} -} -``` -Corresponding JavaScript code, overriding all constants: -```js -{ -// ... -constants: { -0: false, // "has_point_light" -1200: 3.0, // "specular_param" -1300: 2.0, // "gain" -width: 20, // "width" -depth: -1, // "depth" -height: 15, // "height" -} -} -``` -
-''' -ProgrammableStage.fields.entry_point.doc = ''' -The name of the function in {@link GPUProgrammableStage#module} that this stage will use to -perform its work. -NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is -not required, methods which consume a {@link GPUProgrammableStage} must use the -"[$get the entry point$]" algorithm to determine which entry point -it refers to. -''' -ProgrammableStage.fields.module.doc = 'The {@link GPUShaderModule} containing the code that this programmable stage will execute.' - -QuerySetDescriptor.fields.count.doc = 'The number of queries managed by {@link GPUQuerySet}.' -QuerySetDescriptor.fields.type.doc = 'The type of queries managed by {@link GPUQuerySet}.' - -RenderBundleEncoderDescriptor.fields.depth_read_only.doc = ''' -If `true`, indicates that the render bundle does not modify the depth component of the -{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed -in. -See read-only depth-stencil. -''' -RenderBundleEncoderDescriptor.fields.stencil_read_only.doc = ''' -If `true`, indicates that the render bundle does not modify the stencil component of the -{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed -in. -See read-only depth-stencil. -''' - -RenderPassColorAttachment.fields.clear_value.doc = ''' -Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the -render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored -if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. -The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. -They are converted [$to a texel value of texture format$] matching the render attachment. -If conversion fails, a validation error is generated. -''' -RenderPassColorAttachment.fields.depth_slice.doc = ''' -Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} -that will be output to for this color attachment. -''' -RenderPassColorAttachment.fields.load_op.doc = ''' -Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to -executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -''' -RenderPassColorAttachment.fields.resolve_target.doc = ''' -Describes the texture subresource that will receive the resolved output for this color -attachment if {@link GPURenderPassColorAttachment#view} is multisampled. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). -''' -RenderPassColorAttachment.fields.store_op.doc = ''' -The store operation to perform on {@link GPURenderPassColorAttachment#view} -after executing the render pass. -''' -RenderPassColorAttachment.fields.view.doc = ''' -Describes the texture subresource that will be output to for this color attachment. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). -''' - -RenderPassDepthStencilAttachment.fields.depth_clear_value.doc = ''' -Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component -to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} -is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. - -''' -RenderPassDepthStencilAttachment.fields.depth_load_op.doc = ''' -Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -depth component prior to executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -''' -RenderPassDepthStencilAttachment.fields.depth_read_only.doc = ''' -Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} -is read only. -''' -RenderPassDepthStencilAttachment.fields.depth_store_op.doc = ''' -The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -depth component after executing the render pass. -''' -RenderPassDepthStencilAttachment.fields.stencil_clear_value.doc = ''' -Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component -to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} -is not {@link GPULoadOp} `"clear"`. -The value will be converted to the type of the stencil aspect of `view` by taking the same -number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. -''' -RenderPassDepthStencilAttachment.fields.stencil_load_op.doc = ''' -Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -stencil component prior to executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -''' -RenderPassDepthStencilAttachment.fields.stencil_read_only.doc = ''' -Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} -is read only. -''' -RenderPassDepthStencilAttachment.fields.stencil_store_op.doc = ''' -The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -stencil component after executing the render pass. -''' -RenderPassDepthStencilAttachment.fields.view.doc = ''' -Describes the texture subresource that will be output to and read from for this -depth/stencil attachment. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). -''' - -RenderPassDescriptor.fields.color_attachments.doc = ''' -The set of {@link GPURenderPassColorAttachment} values in this sequence defines which -color attachments will be output to when executing this render pass. -Due to compatible usage list|usage compatibility, no color attachment -may alias another attachment or any resource used inside the render pass. -''' -RenderPassDescriptor.fields.depth_stencil_attachment.doc = ''' -The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil -attachment that will be output to and tested against when executing this render pass. -Due to compatible usage list|usage compatibility, no writable depth/stencil attachment -may alias another attachment or any resource used inside the render pass. -''' -RenderPassDescriptor.fields.max_draw_count.doc = ''' -The maximum number of draw calls that will be done in the render pass. Used by some -implementations to size work injected before the render pass. Keeping the default value -is a good default, unless it is known that more draw calls will be done. -''' -RenderPassDescriptor.fields.occlusion_query_set.doc = 'The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.' -RenderPassDescriptor.fields.timestamp_writes.doc = 'Defines which timestamp values will be written for this pass, and where to write them to.' - -RenderPassLayout.fields.color_formats.doc = 'A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.' -RenderPassLayout.fields.depth_stencil_format.doc = 'The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.' -RenderPassLayout.fields.sample_count.doc = 'Number of samples per pixel in the attachments for this pass or bundle.' - -RenderPassTimestampWrites.fields.beginning_of_pass_write_index.doc = ''' -If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the beginning of the render pass will be written. -''' -RenderPassTimestampWrites.fields.end_of_pass_write_index.doc = ''' -If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the end of the render pass will be written. -''' -RenderPassTimestampWrites.fields.query_set.doc = ''' -The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be -written to. -''' - -RenderPipelineDescriptor.fields.depth_stencil.doc = 'Describes the optional depth-stencil properties, including the testing, operations, and bias.' -RenderPipelineDescriptor.fields.fragment.doc = ''' -Describes the fragment shader entry point of the pipeline and its output colors. If -not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. -''' -RenderPipelineDescriptor.fields.multisample.doc = 'Describes the multi-sampling properties of the pipeline.' -RenderPipelineDescriptor.fields.primitive.doc = 'Describes the primitive-related properties of the pipeline.' -RenderPipelineDescriptor.fields.vertex.doc = 'Describes the vertex shader entry point of the pipeline and its input buffer layouts.' - -RequestAdapterOptions.fields.feature_level.doc = ''' -Requests an adapter that supports at least a particular set of capabilities. -This influences the {@link adapter#[[default feature level]]} of devices created -from this adapter. The capabilities for each level are defined below, and the exact -steps are defined in {@link GPU#requestAdapter} and "a new device". -If the implementation or system does not support all of the capabilities in the -requested feature level, {@link GPU#requestAdapter} will return `null`. -Note: -Applications should typically make a single {@link GPU#requestAdapter} call with the lowest -feature level they support, then inspect the adapter for additional capabilities they can -use optionally, and request those in {@link GPUAdapter#requestDevice}. -The allowed feature level string values are: -
-: "core" -The following set of capabilities: -- The limit/Default limits. -- {@link GPUFeatureName} `"core-features-and-limits"`. -Note: -Adapters with this {@link adapter#[[default feature level]]} may -conventionally be referred to as "Core-defaulting". -: "compatibility" -The following set of capabilities: -- The limit/Compatibility Mode Default limits. -- No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) -If the implementation cannot enforce the stricter "Compatibility Mode" -validation rules, {@link GPU#requestAdapter} will ignore this request and -treat it as a request for feature level string/"core". -Note: -Adapters with this {@link adapter#[[default feature level]]} may -conventionally be referred to as "Compatibility-defaulting". -''' -RequestAdapterOptions.fields.force_fallback_adapter.doc = ''' -When set to `true` indicates that only a fallback adapter may be returned. If the user -agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to -resolve to `null`. -Note: -{@link GPU#requestAdapter} may still return a fallback adapter if -{@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no -other appropriate adapter is available or the user agent chooses to return a -fallback adapter. Developers that wish to prevent their applications from running on -fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} -attribute prior to requesting a {@link GPUDevice}. -''' -RequestAdapterOptions.fields.power_preference.doc = ''' -Optionally provides a hint indicating what class of adapter should be selected from -the system's available adapters. -The value of this hint may influence which adapter is chosen, but it must not -influence whether an adapter is returned or not. -Note: -The primary utility of this hint is to influence which GPU is used in a multi-GPU system. -For instance, some laptops have a low-power integrated GPU and a high-performance -discrete GPU. This hint may also affect the power configuration of the selected GPU to -match the requested power preference. -Note: -Depending on the exact hardware configuration, such as battery status and attached displays -or removable GPUs, the user agent may select different adapters given the same power -preference. -Typically, given the same hardware configuration and state and -`powerPreference`, the user agent is likely to select the same adapter. -''' - -SamplerBindingLayout.fields.type.doc = 'Indicates the required type of a sampler bound to this bindings.' - -SamplerDescriptor.fields.address_mode_w.doc = ''' -Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth -coordinates, respectively. -''' -SamplerDescriptor.fields.compare.doc = ''' -When provided the sampler will be a comparison sampler with the specified -{@link GPUCompareFunction}. -Note: Comparison samplers may use filtering, but the sampling results will be -implementation-dependent and may differ from the normal filtering rules. -''' -SamplerDescriptor.fields.lod_max_clamp.doc = ''' -Specifies the minimum and maximum levels of detail, respectively, used internally when -sampling a texture. -''' -SamplerDescriptor.fields.mag_filter.doc = ''' -Specifies the sampling behavior when the sampled area is smaller than or equal to one -texel. -''' -SamplerDescriptor.fields.max_anisotropy.doc = ''' -Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is -enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. -Anisotropic filtering improves the image quality of textures sampled at oblique viewing -angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of -anisotropy supported when filtering. -
-Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range -between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} -will be clamped to the maximum value that the platform supports. -The precise filtering behavior is implementation-dependent. -
-''' -SamplerDescriptor.fields.min_filter.doc = 'Specifies the sampling behavior when the sampled area is larger than one texel.' -SamplerDescriptor.fields.mipmap_filter.doc = 'Specifies behavior for sampling between mipmap levels.' - -ShaderModuleCompilationHint.fields.layout.doc = ''' -A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future -{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. -If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] -for the entry point associated with this hint will be used. -''' - -ShaderModuleDescriptor.fields.code.doc = ''' -The WGSL source code for the shader -module. -''' -ShaderModuleDescriptor.fields.compilation_hints.doc = ''' -A list of {@link GPUShaderModuleCompilationHint}s. -Any hint provided by an application **should** contain information about one entry point of -a pipeline that will eventually be created from the entry point. -Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} -to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. -Aside from type-checking, these hints are not validated in any way. -
-Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any -observable effect, other than performance. It may be detrimental to performance to -provide hints for pipelines that never end up being created. -Because a single shader module can hold multiple entry points, and multiple pipelines -can be created from a single shader module, it can be more performant for an -implementation to do as much compilation as possible once in -{@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to -{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. -Hints are only applied to the entry points they explicitly name. -Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, -there is no default, even if only one entry point is present in the module. -
-Note: -Hints are not validated in an observable way, but user agents **may** surface identifiable -errors (like unknown entry point names or incompatible pipeline layouts) to developers, -for example in the browser developer console. -''' - -StencilFaceState.fields.compare.doc = ''' -The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value -against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. -''' -StencilFaceState.fields.depth_fail_op.doc = ''' -The {@link GPUStencilOperation} performed if the fragment depth comparison described by -{@link GPUDepthStencilState#depthCompare} fails. -''' -StencilFaceState.fields.fail_op.doc = ''' -The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by -{@link GPUStencilFaceState#compare} fails. -''' -StencilFaceState.fields.pass_op.doc = ''' -The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by -{@link GPUStencilFaceState#compare} passes. -''' - -StorageTextureBindingLayout.fields.access.doc = 'The access mode for this binding, indicating readability and writability.' -StorageTextureBindingLayout.fields.format.doc = 'The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.' -StorageTextureBindingLayout.fields.view_dimension.doc = ''' -Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to -this binding. -''' - -TexelCopyBufferInfo.fields.buffer.doc = ''' -A buffer which either contains texel data to be copied or will store the texel data being -copied, depending on the method it is being passed to. -''' - -TexelCopyBufferLayout.fields.bytes_per_row.doc = ''' -The stride, in bytes, between the beginning of each texel block row and the subsequent -texel block row. -Required if there are multiple texel block rows (i.e. the copy height or depth is more -than one block). -''' -TexelCopyBufferLayout.fields.offset.doc = ''' -The offset, in bytes, from the beginning of the texel data source (such as a -{@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data -within that source. -''' -TexelCopyBufferLayout.fields.rows_per_image.doc = ''' -Number of texel block rows per single texel image of the texture. -{@link GPUTexelCopyBufferLayout#rowsPerImage} × -{@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each -texel image of data and the subsequent texel image. -Required if there are multiple texel images (i.e. the copy depth is more than one). -''' - -TexelCopyTextureInfo.fields.aspect.doc = 'Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.' -TexelCopyTextureInfo.fields.mip_level.doc = 'Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.' -TexelCopyTextureInfo.fields.origin.doc = ''' -Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. -Together with `copySize`, defines the full copy sub-region. -''' -TexelCopyTextureInfo.fields.texture.doc = 'Texture to copy to/from.' - -TextureBindingLayout.fields.multisampled.doc = 'Indicates whether or not texture views bound to this binding must be multisampled.' -TextureBindingLayout.fields.sample_type.doc = 'Indicates the type required for texture views bound to this binding.' -TextureBindingLayout.fields.view_dimension.doc = ''' -Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to -this binding. -''' - -TextureDescriptor.fields.dimension.doc = 'Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.' -TextureDescriptor.fields.format.doc = 'The format of the texture.' -TextureDescriptor.fields.mip_level_count.doc = 'The number of mip levels the texture will contain.' -TextureDescriptor.fields.sample_count.doc = ''' -The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates -a multisampled texture. -''' -TextureDescriptor.fields.size.doc = 'The width, height, and depth or layer count of the texture.' -TextureDescriptor.fields.texture_binding_view_dimension.doc = ''' -
-On devices without {@link GPUFeatureName} `"core-features-and-limits"`, -views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. -If not specified, a default is chosen. -
-On devices with {@link GPUFeatureName} `"core-features-and-limits"`, -this is ignored, and there is no such restriction. -''' -TextureDescriptor.fields.usage.doc = 'The allowed usages for the texture.' -TextureDescriptor.fields.view_formats.doc = ''' -Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling -{@link GPUTexture#createView} on this texture (in addition to the texture's actual -{@link GPUTextureDescriptor#format}). -
-Adding a format to this list may have a significant performance impact, so it is best -to avoid adding formats unnecessarily. -The actual performance impact is highly dependent on the target system; developers must -test various systems to find out the impact on their particular application. -For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or -{@link GPUTextureDescriptor#viewFormats} entry including -{@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a -{@link GPUTextureFormat} `"rgba8unorm"` texture which does not. -Similar caveats exist for other formats and pairs of formats on other systems. -
-Formats in this list must be texture view format compatible with the texture format. -
-Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: -- `format` equals `viewFormat`, or -- `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. -
-''' - -TextureViewDescriptor.fields.array_layer_count.doc = ''' -How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible -to the texture view. -''' -TextureViewDescriptor.fields.aspect.doc = 'Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.' -TextureViewDescriptor.fields.base_array_layer.doc = 'The index of the first array layer accessible to the texture view.' -TextureViewDescriptor.fields.base_mip_level.doc = 'The first (most detailed) mipmap level accessible to the texture view.' -TextureViewDescriptor.fields.dimension.doc = 'The dimension to view the texture as.' -TextureViewDescriptor.fields.format.doc = ''' -The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the -texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. -''' -TextureViewDescriptor.fields.mip_level_count.doc = ''' -How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to -the texture view. -''' -TextureViewDescriptor.fields.swizzle.doc = ''' -A string of length four, with each character mapping to the texture view's red/green/blue/alpha -channels, respectively. -When accessed by a shader, the red/green/blue/alpha channels are replaced by the value -corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and -`swizzle[3]`, respectively: -- `"r"`: Take its value from the red channel of the texture. -- `"g"`: Take its value from the green channel of the texture. -- `"b"`: Take its value from the blue channel of the texture. -- `"a"`: Take its value from the alpha channel of the texture. -- `"0"`: Force its value to 0. -- `"1"`: Force its value to 1. -Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. -''' -TextureViewDescriptor.fields.usage.doc = ''' -The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the -{@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of -{@link GPUTexture#usage} flags of the texture. -Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the -texture's {@link GPUTextureDescriptor#usage}s, the default will fail, -and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. -''' - -VertexAttribute.fields.format.doc = 'The {@link GPUVertexFormat} of the attribute.' -VertexAttribute.fields.offset.doc = 'The offset, in bytes, from the beginning of the element to the data for the attribute.' -VertexAttribute.fields.shader_location.doc = ''' -The numeric location associated with this attribute, which will correspond with a -"@location" attribute -declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. -''' - -VertexBufferLayout.fields.array_stride.doc = 'The stride, in bytes, between elements of this array.' -VertexBufferLayout.fields.attributes.doc = 'An array defining the layout of the vertex attributes within each element.' -VertexBufferLayout.fields.step_mode.doc = 'Whether each element of this array represents per-vertex data or per-instance data' - -VertexState.fields.buffers.doc = ''' -A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a -vertex buffer used by this pipeline. -''' - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[classes] - -GPU.methods.get_preferred_canvas_format.doc = ''' -Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range -content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or -{@link GPUTextureFormat} `"bgra8unorm"`. -The returned value can be passed as the {@link GPUCanvasConfiguration#format} to -{@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated -canvas is able to display its contents efficiently. -Note: Canvases which are not displayed to the screen may or may not benefit from using this -format. -''' -GPU.methods.request_adapter.args.options.doc = 'Criteria used to select the adapter.' -GPU.methods.request_adapter.doc = ''' -Requests an adapter from the user agent. -The user agent chooses whether to return an adapter, and, if so, -chooses according to the provided options. -''' - -GPUAdapter.methods.features.doc = 'The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}.' -GPUAdapter.methods.info.doc = ''' -Information about the physical adapter underlying this {@link GPUAdapter}. -For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time. -The same object is returned each time. To create that object for the first time: -
-
-**Called on:** {@link GPUAdapter} `this`. -**Returns:** {@link GPUAdapterInfo} -Content timeline steps: -1. Return a [$new adapter info$] for `this.adapter`. -
-
-''' -GPUAdapter.methods.limits.doc = 'The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}.' -GPUAdapter.methods.request_device.args.descriptor.doc = 'Description of the {@link GPUDevice} to request.' -GPUAdapter.methods.request_device.doc = ''' -Requests a device from the adapter. -This is a one-time action: if a device is returned successfully, -the adapter becomes {@link adapter#[[state]]#"consumed"}. -''' - -GPUAdapterInfo.methods.architecture.doc = ''' -The name of the family or class of GPUs the adapter belongs to, if available. Empty -string otherwise. -''' -GPUAdapterInfo.methods.description.doc = ''' -A human readable string describing the adapter as reported by the driver, if available. -Empty string otherwise. -Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse -this value is not recommended. Applications which change their behavior based on the -{@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the -other fields when possible. -''' -GPUAdapterInfo.methods.device.doc = ''' -A vendor-specific identifier for the adapter, if available. Empty string otherwise. -Note: This is a value that represents the type of adapter. For example, it may be a -[PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of -hardware like a serial number. -''' -GPUAdapterInfo.methods.is_fallback_adapter.doc = 'Whether the adapter is a fallback adapter.' -GPUAdapterInfo.methods.subgroup_max_size.doc = ''' -If the "subgroups" feature is supported, the maximum supported subgroup size for the -adapter. - -Check support before using. (Use the non-null assertion operator `!` where needed.) -''' -GPUAdapterInfo.methods.subgroup_min_size.doc = ''' -If the "subgroups" feature is supported, the minimum supported subgroup size for the -adapter. - -Check support before using. (Use the non-null assertion operator `!` where needed.) -''' -GPUAdapterInfo.methods.vendor.doc = 'The name of the vendor of the adapter, if available. Empty string otherwise.' - -GPUBindingCommandsMixin.methods.set_bind_group.args.bind_group.doc = 'Bind group to use for subsequent render or compute commands.' -GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets.doc = 'Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.-->' -GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data.doc = 'Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.' -GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data_length.doc = 'Number of buffer offsets to read from `dynamicOffsetsData`.' -GPUBindingCommandsMixin.methods.set_bind_group.args.dynamic_offsets_data_start.doc = 'Offset in elements into `dynamicOffsetsData` where the buffer offset data begins.' -GPUBindingCommandsMixin.methods.set_bind_group.args.index.doc = 'The index to set the bind group at.' -GPUBindingCommandsMixin.methods.set_bind_group.doc = ''' -Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset -of a Uint32Array. -''' -GPUBindingCommandsMixin.methods.set_immediates.args.data.doc = 'Data to write into the immediate data range.' -GPUBindingCommandsMixin.methods.set_immediates.args.data_offset.doc = 'Offset into `data` to begin writing from. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.' -GPUBindingCommandsMixin.methods.set_immediates.args.data_size.doc = 'Size of content to write from `data`. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.' -GPUBindingCommandsMixin.methods.set_immediates.args.range_offset.doc = 'Offset in bytes into the immediate data range to begin writing at.' -GPUBindingCommandsMixin.methods.set_immediates.doc = 'Sets immediate data for subsequent render or compute commands.' - -GPUBuffer.methods.destroy.doc = ''' -Destroys the {@link GPUBuffer}. -Note: It is valid to destroy a buffer multiple times. -Note: Since no further operations can be enqueued using this buffer, implementations can -free resource allocations, including mapped memory that was just unmapped. -''' -GPUBuffer.methods.get_mapped_range.args.offset.doc = 'Offset in bytes into the buffer to return buffer contents from.' -GPUBuffer.methods.get_mapped_range.args.size.doc = 'Size in bytes of the ArrayBuffer to return.' -GPUBuffer.methods.get_mapped_range.doc = 'Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.' -GPUBuffer.methods.map_async.args.mode.doc = 'Whether the buffer should be mapped for reading or writing.' -GPUBuffer.methods.map_async.args.offset.doc = 'Offset in bytes into the buffer to the start of the range to map.' -GPUBuffer.methods.map_async.args.size.doc = 'Size in bytes of the range to map.' -GPUBuffer.methods.map_async.doc = ''' -Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the -{@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. -The resolution of the returned Promise **only** indicates that the buffer has been mapped. -It does not guarantee the completion of any other operations visible to the content timeline, -and in particular does not imply that any other Promise returned from -{@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s -have resolved. -The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} -**does** imply the completion of -{@link GPUBuffer#mapAsync} calls made prior to that call, -on {@link GPUBuffer}s last used exclusively on that queue. -''' -GPUBuffer.methods.unmap.doc = ''' -Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the -GPU again. -''' - -GPUCanvasContext.methods.canvas.doc = 'The canvas this context was created from.' -GPUCanvasContext.methods.configure.args.configuration.doc = 'Desired configuration for the context.' -GPUCanvasContext.methods.configure.doc = ''' -Configures the context for this canvas. -This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). -See {@link GPUCanvasContext#getConfiguration} for information on feature detection. -''' -GPUCanvasContext.methods.get_configuration.doc = ''' -Returns the context configuration, or `null` if the context is not configured. -Note: -This method exists primarily for feature detection of members (and sub-members) of -{@link GPUCanvasConfiguration}; see those members for details. -For supported members, it returns the originally-supplied values. -''' -GPUCanvasContext.methods.get_current_texture.doc = ''' -Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} -next. -Note: The same {@link GPUTexture} object will be returned by every -call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" -runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. -''' -GPUCanvasContext.methods.unconfigure.doc = 'Removes the context configuration. Destroys any textures produced while configured.' - -GPUCommandEncoder.methods.begin_render_pass.args.descriptor.doc = 'Description of the {@link GPURenderPassEncoder} to create.' -GPUCommandEncoder.methods.begin_render_pass.doc = 'Begins encoding a render pass described by `descriptor`.' -GPUCommandEncoder.methods.clear_buffer.args.buffer.doc = 'The {@link GPUBuffer} to clear.' -GPUCommandEncoder.methods.clear_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the sub-region to clear begins.' -GPUCommandEncoder.methods.clear_buffer.args.size.doc = 'Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.' -GPUCommandEncoder.methods.clear_buffer.doc = ''' -Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a -{@link GPUBuffer} with zeros. -''' -GPUCommandEncoder.methods.copy_buffer_to_buffer.args.destination.doc = 'The {@link GPUBuffer} to copy to.' -GPUCommandEncoder.methods.copy_buffer_to_buffer.args.destination_offset.doc = 'Offset in bytes into `destination` to place the copied data.' -GPUCommandEncoder.methods.copy_buffer_to_buffer.args.size.doc = 'Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.' -GPUCommandEncoder.methods.copy_buffer_to_buffer.args.source.doc = 'The {@link GPUBuffer} to copy from.' -GPUCommandEncoder.methods.copy_buffer_to_buffer.args.source_offset.doc = 'Offset in bytes into `source` to begin copying from.' -GPUCommandEncoder.methods.copy_buffer_to_buffer.doc = ''' -Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a -{@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. -''' -GPUCommandEncoder.methods.copy_buffer_to_texture.args.destination.doc = 'Combined with `copySize`, defines the region of the destination texture subresource. `copySize`:' -GPUCommandEncoder.methods.copy_buffer_to_texture.args.source.doc = 'Combined with `copySize`, defines the region of the source buffer.' -GPUCommandEncoder.methods.copy_buffer_to_texture.doc = ''' -Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a -{@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. -''' -GPUCommandEncoder.methods.copy_texture_to_buffer.args.destination.doc = 'Combined with `copySize`, defines the region of the destination buffer. `copySize`:' -GPUCommandEncoder.methods.copy_texture_to_buffer.args.source.doc = 'Combined with `copySize`, defines the region of the source texture subresources.' -GPUCommandEncoder.methods.copy_texture_to_buffer.doc = ''' -Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or -multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. -''' -GPUCommandEncoder.methods.copy_texture_to_texture.args.destination.doc = 'Combined with `copySize`, defines the region of the destination texture subresources. `copySize`:' -GPUCommandEncoder.methods.copy_texture_to_texture.args.source.doc = 'Combined with `copySize`, defines the region of the source texture subresources.' -GPUCommandEncoder.methods.copy_texture_to_texture.doc = ''' -Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one -or multiple contiguous texture subresources to another sub-region of one or -multiple continuous texture subresources. -''' -GPUCommandEncoder.methods.finish.doc = ''' -Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. - descriptor: -''' -GPUCommandEncoder.methods.resolve_query_set.doc = ''' -Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. - querySet: - firstQuery: - queryCount: - destination: - destinationOffset: -''' - -GPUCompilationMessage.methods.length.doc = ''' -The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message} -corresponds to. If the message does not correspond with a substring then -{@link GPUCompilationMessage#length} must be 0. -''' -GPUCompilationMessage.methods.line_num.doc = ''' -The line number in the shader {@link GPUShaderModuleDescriptor#code} the -{@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of -`1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are -delimited by line breaks. -If the {@link GPUCompilationMessage#message} corresponds to a substring this points to -the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message} -does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. -''' -GPUCompilationMessage.methods.line_pos.doc = ''' -The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum} -of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring -that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a -{@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line. -If {@link GPUCompilationMessage#message} corresponds to a substring this points to the -first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message} -does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. -''' -GPUCompilationMessage.methods.message.doc = ''' -The human-readable, localizable text for this compilation message. -Note: The {@link GPUCompilationMessage#message} should follow the best practices for language -and direction information. This includes making use of any future standards which may -emerge regarding the reporting of string language and direction metadata. -

Editorial note: -At the time of this writing, no language/direction recommendation is available that provides -compatibility and consistency with legacy APIs, but when there is, adopt it formally. -''' -GPUCompilationMessage.methods.offset.doc = ''' -The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16 -code units to the point or beginning of the substring that {@link GPUCompilationMessage#message} -corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and -{@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message} -does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. -''' -GPUCompilationMessage.methods.type.doc = ''' -The severity level of the message. -If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it -corresponds to a shader-creation error. -''' - -GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_x.doc = 'X dimension of the grid of workgroups to dispatch.' -GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_y.doc = 'Y dimension of the grid of workgroups to dispatch.' -GPUComputePassEncoder.methods.dispatch_workgroups.args.workgroup_count_z.doc = 'Z dimension of the grid of workgroups to dispatch.' -GPUComputePassEncoder.methods.dispatch_workgroups.doc = ''' -Dispatch work to be performed with the current {@link GPUComputePipeline}. -See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. -''' -GPUComputePassEncoder.methods.dispatch_workgroups_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect dispatch parameters.' -GPUComputePassEncoder.methods.dispatch_workgroups_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the dispatch data begins.' -GPUComputePassEncoder.methods.dispatch_workgroups_indirect.doc = ''' -Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read -from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. -packed block of **three 32-bit unsigned integer values (12 bytes total)**, -given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. -For example: -''' -GPUComputePassEncoder.methods.end.doc = 'Completes recording of the compute pass commands sequence.' -GPUComputePassEncoder.methods.set_pipeline.args.pipeline.doc = 'The compute pipeline to use for subsequent dispatch commands.' -GPUComputePassEncoder.methods.set_pipeline.doc = 'Sets the current {@link GPUComputePipeline}.' - -GPUDebugCommandsMixin.methods.insert_debug_marker.args.marker_label.doc = 'The label to insert.' -GPUDebugCommandsMixin.methods.insert_debug_marker.doc = 'Marks a point in a stream of commands with a label.' -GPUDebugCommandsMixin.methods.pop_debug_group.doc = 'Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.' -GPUDebugCommandsMixin.methods.push_debug_group.args.group_label.doc = 'The label for the command group.' -GPUDebugCommandsMixin.methods.push_debug_group.doc = 'Begins a labeled debug group containing subsequent commands.' - -GPUDevice.methods.adapter_info.doc = ''' -Information about the physical adapter which created the device -that this GPUDevice refers to. -For a given GPUDevice, the GPUAdapterInfo values exposed are constant -over time. -''' -GPUDevice.methods.create_bind_group.args.descriptor.doc = 'Description of the {@link GPUBindGroup} to create.' -GPUDevice.methods.create_bind_group.doc = 'Creates a {@link GPUBindGroup}.' -GPUDevice.methods.create_bind_group_layout.args.descriptor.doc = 'Description of the {@link GPUBindGroupLayout} to create.' -GPUDevice.methods.create_bind_group_layout.doc = 'Creates a {@link GPUBindGroupLayout}.' -GPUDevice.methods.create_buffer.args.descriptor.doc = 'Description of the {@link GPUBuffer} to create.' -GPUDevice.methods.create_buffer.doc = 'Creates a {@link GPUBuffer}.' -GPUDevice.methods.create_command_encoder.args.descriptor.doc = 'Description of the {@link GPUCommandEncoder} to create.' -GPUDevice.methods.create_command_encoder.doc = 'Creates a {@link GPUCommandEncoder}.' -GPUDevice.methods.create_compute_pipeline.args.descriptor.doc = 'Description of the {@link GPUComputePipeline} to create.' -GPUDevice.methods.create_compute_pipeline.doc = 'Creates a {@link GPUComputePipeline} using immediate pipeline creation.' -GPUDevice.methods.create_compute_pipeline_async.args.descriptor.doc = 'Description of the {@link GPUComputePipeline} to create.' -GPUDevice.methods.create_compute_pipeline_async.doc = ''' -Creates a {@link GPUComputePipeline} using async pipeline creation. -The returned Promise resolves when the created pipeline -is ready to be used without additional delay. -If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. -(A {@link GPUError} is not dispatched to the device.) -Note: Use of this method is preferred whenever possible, as it prevents blocking the -queue timeline work on pipeline compilation. -''' -GPUDevice.methods.create_pipeline_layout.args.descriptor.doc = 'Description of the {@link GPUPipelineLayout} to create.' -GPUDevice.methods.create_pipeline_layout.doc = 'Creates a {@link GPUPipelineLayout}.' -GPUDevice.methods.create_query_set.args.descriptor.doc = 'Description of the {@link GPUQuerySet} to create.' -GPUDevice.methods.create_query_set.doc = 'Creates a {@link GPUQuerySet}.' -GPUDevice.methods.create_render_bundle_encoder.args.descriptor.doc = 'Description of the {@link GPURenderBundleEncoder} to create.' -GPUDevice.methods.create_render_bundle_encoder.doc = 'Creates a {@link GPURenderBundleEncoder}.' -GPUDevice.methods.create_render_pipeline.args.descriptor.doc = 'Description of the {@link GPURenderPipeline} to create.' -GPUDevice.methods.create_render_pipeline.doc = 'Creates a {@link GPURenderPipeline} using immediate pipeline creation.' -GPUDevice.methods.create_render_pipeline_async.args.descriptor.doc = 'Description of the {@link GPURenderPipeline} to create.' -GPUDevice.methods.create_render_pipeline_async.doc = ''' -Creates a {@link GPURenderPipeline} using async pipeline creation. -The returned Promise resolves when the created pipeline -is ready to be used without additional delay. -If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. -(A {@link GPUError} is not dispatched to the device.) -Note: Use of this method is preferred whenever possible, as it prevents blocking the -queue timeline work on pipeline compilation. -''' -GPUDevice.methods.create_sampler.args.descriptor.doc = 'Description of the {@link GPUSampler} to create.' -GPUDevice.methods.create_sampler.doc = 'Creates a {@link GPUSampler}.' -GPUDevice.methods.create_shader_module.args.descriptor.doc = 'Description of the {@link GPUShaderModule} to create.' -GPUDevice.methods.create_shader_module.doc = 'Creates a {@link GPUShaderModule}.' -GPUDevice.methods.create_texture.args.descriptor.doc = 'Description of the {@link GPUTexture} to create.' -GPUDevice.methods.create_texture.doc = 'Creates a {@link GPUTexture}.' -GPUDevice.methods.destroy.doc = ''' -Destroys the device, preventing further operations on it. -Outstanding asynchronous operations will fail. -Note: It is valid to destroy a device multiple times. -Note: Since no further operations can be enqueued on this device, implementations can abort -outstanding asynchronous operations immediately and free resource allocations, including -mapped memory that was just unmapped. -''' -GPUDevice.methods.features.doc = ''' -A set containing the {@link GPUFeatureName} values of the features -supported by the device (i.e. the ones with which it was created). -''' -GPUDevice.methods.import_external_texture.args.descriptor.doc = 'Provides the external image source object (and any creation options).' -GPUDevice.methods.import_external_texture.doc = 'Creates a {@link GPUExternalTexture} wrapping the provided image source.' -GPUDevice.methods.limits.doc = ''' -Exposes the limits supported by the device -(which are exactly the ones with which it was created). -''' -GPUDevice.methods.lost.doc = ''' -A slot-backed attribute holding a promise which is created with the device, remains -pending for the lifetime of the device, then resolves when the device is lost. -Upon initialization, it is set to a new promise. -''' -GPUDevice.methods.onuncapturederror.doc = 'An event handler IDL attribute for the `uncapturederror` event type.' -GPUDevice.methods.pop_error_scope.doc = ''' -Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` -and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. -There is no guarantee of the ordering of promise resolution. -''' -GPUDevice.methods.push_error_scope.args.filter.doc = 'Which class of errors this error scope observes.' -GPUDevice.methods.push_error_scope.doc = 'Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.' -GPUDevice.methods.queue.doc = 'The primary {@link GPUQueue} for this device.' - -GPUPipelineBase.methods.get_bind_group_layout.args.index.doc = "Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` sequence." -GPUPipelineBase.methods.get_bind_group_layout.doc = ''' -Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s -{@link GPUBindGroupLayout} at `index`. -''' - -GPUPipelineError.methods.reason.doc = ''' -A read-only slot-backed attribute exposing the type of error encountered in pipeline creation -as a GPUPipelineErrorReason: -

    -- "validation": A [$validation error$]. -- "internal": An [$internal error$]. -
-''' - -GPUQuerySet.methods.count.doc = 'The number of queries managed by this {@link GPUQuerySet}.' -GPUQuerySet.methods.destroy.doc = 'Destroys the {@link GPUQuerySet}.' -GPUQuerySet.methods.type.doc = 'The type of the queries managed by this {@link GPUQuerySet}.' - -GPUQueue.methods.copy_external_image_to_texture.args.copy_size.doc = 'Extents of the content to write from `source` to `destination`.' -GPUQueue.methods.copy_external_image_to_texture.args.destination.doc = 'The texture subresource and origin to write to, and its encoding metadata.' -GPUQueue.methods.copy_external_image_to_texture.args.source.doc = 'source image and origin to copy to `destination`.' -GPUQueue.methods.copy_external_image_to_texture.doc = ''' -Issues a copy operation of the contents of a platform image/canvas -into the destination texture. -This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination -encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}. -Copying into a `-srgb` texture results in the same texture bytes, not the same decoded -values, as copying into the corresponding non-`-srgb` format. -Thus, after a copy operation, sampling the destination texture has -different results depending on whether its format is `-srgb`, all else unchanged. - -''' -GPUQueue.methods.on_submitted_work_done.doc = ''' -Returns a Promise that resolves once this queue finishes processing all the work submitted -up to this moment. -Resolution of this Promise implies the completion of -{@link GPUBuffer#mapAsync} calls made prior to that call, -on {@link GPUBuffer}s last used exclusively on that queue. -''' -GPUQueue.methods.submit.doc = ''' -Schedules the execution of the command buffers by the GPU on this queue. -Submitted command buffers cannot be used again. - `commandBuffers`: -''' -GPUQueue.methods.write_buffer.args.buffer.doc = 'The buffer to write to.' -GPUQueue.methods.write_buffer.args.buffer_offset.doc = 'Offset in bytes into `buffer` to begin writing at.' -GPUQueue.methods.write_buffer.args.data.doc = 'Data to write into `buffer`.' -GPUQueue.methods.write_buffer.args.data_offset.doc = 'Offset in into `data` to begin writing from. Given in elements if `data` is a `TypedArray` and bytes otherwise.' -GPUQueue.methods.write_buffer.args.size.doc = 'Size of content to write from `data` to `buffer`. Given in elements if `data` is a `TypedArray` and bytes otherwise.' -GPUQueue.methods.write_buffer.doc = 'Issues a write operation of the provided data into a {@link GPUBuffer}.' -GPUQueue.methods.write_texture.args.data.doc = 'Data to write into `destination`.' -GPUQueue.methods.write_texture.args.data_layout.doc = 'Layout of the content in `data`.' -GPUQueue.methods.write_texture.args.destination.doc = 'The texture subresource and origin to write to.' -GPUQueue.methods.write_texture.args.size.doc = 'Extents of the content to write from `data` to `destination`.' -GPUQueue.methods.write_texture.doc = 'Issues a write operation of the provided data into a {@link GPUTexture}.' - -GPURenderBundleEncoder.methods.finish.doc = ''' -Completes recording of the render bundle commands sequence. - descriptor: -''' - -GPURenderCommandsMixin.methods.draw.args.first_instance.doc = 'First instance to draw.' -GPURenderCommandsMixin.methods.draw.args.first_vertex.doc = 'Offset into the vertex buffers, in vertices, to begin drawing from.' -GPURenderCommandsMixin.methods.draw.args.instance_count.doc = 'The number of instances to draw.' -GPURenderCommandsMixin.methods.draw.args.vertex_count.doc = 'The number of vertices to draw.' -GPURenderCommandsMixin.methods.draw.doc = ''' -Draws primitives. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -''' -GPURenderCommandsMixin.methods.draw_indexed.args.base_vertex.doc = 'Added to each index value before indexing into the vertex buffers.' -GPURenderCommandsMixin.methods.draw_indexed.args.first_index.doc = 'Offset into the index buffer, in indices, begin drawing from.' -GPURenderCommandsMixin.methods.draw_indexed.args.first_instance.doc = 'First instance to draw.' -GPURenderCommandsMixin.methods.draw_indexed.args.index_count.doc = 'The number of indices to draw.' -GPURenderCommandsMixin.methods.draw_indexed.args.instance_count.doc = 'The number of instances to draw.' -GPURenderCommandsMixin.methods.draw_indexed.doc = ''' -Draws indexed primitives. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -''' -GPURenderCommandsMixin.methods.draw_indexed_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect drawIndexed parameters.' -GPURenderCommandsMixin.methods.draw_indexed_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the drawing data begins.' -GPURenderCommandsMixin.methods.draw_indexed_indirect.doc = ''' -Draws indexed primitives using parameters read from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in -the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: -''' -GPURenderCommandsMixin.methods.draw_indirect.args.indirect_buffer.doc = 'Buffer containing the indirect draw parameters.' -GPURenderCommandsMixin.methods.draw_indirect.args.indirect_offset.doc = 'Offset in bytes into `indirectBuffer` where the drawing data begins.' -GPURenderCommandsMixin.methods.draw_indirect.doc = ''' -Draws primitives using parameters read from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same -order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: -''' -GPURenderCommandsMixin.methods.set_index_buffer.args.buffer.doc = 'Buffer containing index data to use for subsequent drawing commands.' -GPURenderCommandsMixin.methods.set_index_buffer.args.index_format.doc = 'Format of the index data contained in `buffer`.' -GPURenderCommandsMixin.methods.set_index_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the index data begins. Defaults to `0`.' -GPURenderCommandsMixin.methods.set_index_buffer.args.size.doc = 'Size in bytes of the index data in `buffer`. Defaults to the size of the buffer minus the offset.' -GPURenderCommandsMixin.methods.set_index_buffer.doc = 'Sets the current index buffer.' -GPURenderCommandsMixin.methods.set_pipeline.args.pipeline.doc = 'The render pipeline to use for subsequent drawing commands.' -GPURenderCommandsMixin.methods.set_pipeline.doc = 'Sets the current {@link GPURenderPipeline}.' -GPURenderCommandsMixin.methods.set_vertex_buffer.args.buffer.doc = 'Buffer containing vertex data to use for subsequent drawing commands.' -GPURenderCommandsMixin.methods.set_vertex_buffer.args.offset.doc = 'Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.' -GPURenderCommandsMixin.methods.set_vertex_buffer.args.size.doc = 'Size in bytes of the vertex data in `buffer`. Defaults to the size of the buffer minus the offset.' -GPURenderCommandsMixin.methods.set_vertex_buffer.args.slot.doc = 'The vertex buffer slot to set the vertex buffer for.' -GPURenderCommandsMixin.methods.set_vertex_buffer.doc = 'Sets the current vertex buffer for the given slot.' - -GPURenderPassEncoder.methods.begin_occlusion_query.args.query_index.doc = 'The index of the query in the query set.' -GPURenderPassEncoder.methods.end.doc = 'Completes recording of the render pass commands sequence.' -GPURenderPassEncoder.methods.execute_bundles.args.bundles.doc = 'List of render bundles to execute.' -GPURenderPassEncoder.methods.execute_bundles.doc = ''' -Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of -this render pass. -When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind -groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render -pass's pipeline, bind group, and vertex/index buffer state is cleared -(to the initial, empty values). -Note: The state is cleared, not restored to the previous state. -This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. -''' -GPURenderPassEncoder.methods.set_blend_constant.args.color.doc = 'The color to use when blending.' -GPURenderPassEncoder.methods.set_blend_constant.doc = ''' -Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` -and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. -''' -GPURenderPassEncoder.methods.set_scissor_rect.args.height.doc = 'Height of the scissor rectangle in pixels.' -GPURenderPassEncoder.methods.set_scissor_rect.args.width.doc = 'Width of the scissor rectangle in pixels.' -GPURenderPassEncoder.methods.set_scissor_rect.args.x.doc = 'Minimum X value of the scissor rectangle in pixels.' -GPURenderPassEncoder.methods.set_scissor_rect.args.y.doc = 'Minimum Y value of the scissor rectangle in pixels.' -GPURenderPassEncoder.methods.set_scissor_rect.doc = ''' -Sets the scissor rectangle used during the rasterization stage. -After transformation into viewport coordinates any fragments which fall outside the scissor -rectangle will be discarded. -''' -GPURenderPassEncoder.methods.set_stencil_reference.args.reference.doc = 'The new stencil reference value.' -GPURenderPassEncoder.methods.set_stencil_reference.doc = ''' -Sets the RenderState.`[[stencilReference]]` value used during stencil tests with -the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. -''' -GPURenderPassEncoder.methods.set_viewport.args.height.doc = 'Height of the viewport in pixels.' -GPURenderPassEncoder.methods.set_viewport.args.max_depth.doc = 'Maximum depth value of the viewport.' -GPURenderPassEncoder.methods.set_viewport.args.min_depth.doc = 'Minimum depth value of the viewport.' -GPURenderPassEncoder.methods.set_viewport.args.width.doc = 'Width of the viewport in pixels.' -GPURenderPassEncoder.methods.set_viewport.args.x.doc = 'Minimum X value of the viewport in pixels.' -GPURenderPassEncoder.methods.set_viewport.args.y.doc = 'Minimum Y value of the viewport in pixels.' -GPURenderPassEncoder.methods.set_viewport.doc = ''' -Sets the viewport used during the rasterization stage to linearly map from -NDC|normalized device coordinates to viewport coordinates. -''' - -GPUShaderModule.methods.get_compilation_info.doc = ''' -Returns any messages generated during the {@link GPUShaderModule}'s compilation. -The locations, order, and contents of messages are implementation-defined. -In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. -''' - -GPUSupportedLimits.methods.max_storage_buffers_in_fragment_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' -GPUSupportedLimits.methods.max_storage_buffers_in_vertex_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' -GPUSupportedLimits.methods.max_storage_textures_in_fragment_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' -GPUSupportedLimits.methods.max_storage_textures_in_vertex_stage.doc = 'Check support before using. (Use the non-null assertion operator `!` where needed.)' - -GPUTexture.methods.create_view.args.descriptor.doc = 'Description of the {@link GPUTextureView} to create.' -GPUTexture.methods.create_view.doc = 'Creates a {@link GPUTextureView}.' -GPUTexture.methods.depth_or_array_layers.doc = 'The depth or layer count of this {@link GPUTexture}.' -GPUTexture.methods.destroy.doc = 'Destroys the {@link GPUTexture}.' -GPUTexture.methods.dimension.doc = "The dimension of the set of texel for each of this {@link GPUTexture}'s subresources." -GPUTexture.methods.format.doc = 'The format of this {@link GPUTexture}.' -GPUTexture.methods.height.doc = 'The height of this {@link GPUTexture}.' -GPUTexture.methods.mip_level_count.doc = 'The number of mip levels of this {@link GPUTexture}.' -GPUTexture.methods.sample_count.doc = 'The number of sample count of this {@link GPUTexture}.' -GPUTexture.methods.texture_binding_view_dimension.doc = ''' -On devices without "core-features-and-limits", views created from this -texture must have this as their dimension. - -On devices with "core-features-and-limits", this is undefined, and there is -no such restriction. - -It is safe to access on any browser, as it will just (correctly) return -`undefined` if not implemented. Note, depending on the device, `undefined` -is a valid value even in browsers that implement this attribute. (So be -careful if using the non-null assertion operator `!` on this.) -''' -GPUTexture.methods.usage.doc = 'The allowed usages for this {@link GPUTexture}.' -GPUTexture.methods.width.doc = 'The width of this {@link GPUTexture}.' - -GPUUncapturedErrorEvent.methods.error.doc = ''' -A slot-backed attribute holding an object representing the error that was uncaptured. -This has the same type as errors returned by {@link GPUDevice#popErrorScope}. -''' diff --git a/apigen/definitions/index.d.ts b/apigen/definitions/index.d.ts deleted file mode 100644 index ddd9ca28..00000000 --- a/apigen/definitions/index.d.ts +++ /dev/null @@ -1,3420 +0,0 @@ -// ********************************************************************************************* -// This file is manually-edited by diffing against an autogenerated file. See README.md. -// ********************************************************************************************* - -// ********************************************************************************************* -// Manually-written - auto copied from extra.d.ts -// ********************************************************************************************* - -// AllowSharedBufferSource wasn't introduced until TypeScript 5.2. -// But it also didn't include SharedArrayBuffer in the union. -// This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't. -// So, we use our own definition for AllowSharedBufferSource. - -type GPUAllowSharedBufferSource = - - | BufferSource - | SharedArrayBuffer; - -// Stronger typing for getContext() - -interface HTMLCanvasElement { - getContext( - contextId: - | "webgpu" - ): GPUCanvasContext | null; -} -interface OffscreenCanvas { - getContext( - contextId: - | "webgpu" - ): GPUCanvasContext | null; -} - -// Defined as an empty interface here to prevent errors when using these types in a worker. - -interface HTMLVideoElement {} - -// Strict types defined to help developers catch a common class of errors. -// This interface defines depth as an undefined, which will cause a type check failure if someone -// attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.) - -type GPUOrigin2DStrict = - - | Iterable - | GPUOrigin2DDictStrict; -interface GPUOrigin2DDictStrict - extends GPUOrigin2DDict { - /** @deprecated Does not exist for GPUOrigin2D. */ - z?: undefined; -} -type GPUExtent3DStrict = - - | Iterable - | GPUExtent3DDictStrict; -interface GPUExtent3DDictStrict - extends GPUExtent3DDict { - /** @deprecated The correct name is `depthOrArrayLayers`. */ - depth?: undefined; -} - -// Stronger typing for event listeners. - -/** @internal */ -interface __GPUDeviceEventMap { - uncapturederror: GPUUncapturedErrorEvent; -} - -// Extensions to the generated definition below. -interface GPUDevice { - addEventListener< - K extends keyof __GPUDeviceEventMap - >( - type: K, - listener: ( - this: GPUDevice, - ev: __GPUDeviceEventMap[K] - ) => any, - options?: - | boolean - | AddEventListenerOptions - ): void; - addEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: - | boolean - | AddEventListenerOptions - ): void; - removeEventListener< - K extends keyof __GPUDeviceEventMap - >( - type: K, - listener: ( - this: GPUDevice, - ev: __GPUDeviceEventMap[K] - ) => any, - options?: - | boolean - | EventListenerOptions - ): void; - removeEventListener( - type: string, - listener: EventListenerOrEventListenerObject, - options?: - | boolean - | EventListenerOptions - ): void; -} - -interface GPUCanvasConfigurationOut - extends Required< - Omit< - GPUCanvasConfiguration, - "toneMapping" - > - > { - /** {@inheritDoc GPUCanvasConfiguration.viewFormats} */ - viewFormats: GPUTextureFormat[]; - /** - * {@inheritDoc GPUCanvasConfiguration.toneMapping} - */ - toneMapping?: GPUCanvasToneMapping; -} - -/** @deprecated Use {@link GPUTexelCopyBufferLayout} */ -type GPUImageDataLayout = - GPUTexelCopyBufferLayout; -/** @deprecated Use {@link GPUTexelCopyBufferInfo} */ -type GPUImageCopyBuffer = - GPUTexelCopyBufferInfo; -/** @deprecated Use {@link GPUTexelCopyTextureInfo} */ -type GPUImageCopyTexture = - GPUTexelCopyTextureInfo; -/** @deprecated Use {@link GPUCopyExternalImageDestInfo} */ -type GPUImageCopyTextureTagged = - GPUCopyExternalImageDestInfo; -/** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */ -type GPUImageCopyExternalImage = - GPUCopyExternalImageSourceInfo; -/** @deprecated Use {@link GPUCopyExternalImageSource} */ -type GPUImageCopyExternalImageSource = - GPUCopyExternalImageSource; - -// ********************************************************************************************* -// Semi-auto-generated (by manual diff with autogenerated types) -// ********************************************************************************************* - -type GPUBindingResource = - - | GPUSampler - | GPUTexture - | GPUTextureView - | GPUBuffer - | GPUBufferBinding - | GPUExternalTexture; -type GPUBufferDynamicOffset = - number; -type GPUBufferUsageFlags = - number; -type GPUColor = - - | Iterable - | GPUColorDict; -type GPUColorWriteFlags = - number; -type GPUCopyExternalImageSource = - - | ImageBitmap - | ImageData - | HTMLImageElement - | HTMLVideoElement - | VideoFrame - | HTMLCanvasElement - | OffscreenCanvas; -type GPUDepthBias = - number; -type GPUExtent3D = - - | Iterable - | GPUExtent3DDict; -type GPUFlagsConstant = - number; -type GPUIndex32 = - number; -type GPUIntegerCoordinate = - number; -type GPUIntegerCoordinateOut = - number; -type GPUMapModeFlags = - number; -type GPUOrigin2D = - - | Iterable - | GPUOrigin2DDict; -type GPUOrigin3D = - - | Iterable - | GPUOrigin3DDict; -type GPUPipelineConstantValue = - number; -type GPUSampleMask = - number; -type GPUShaderStageFlags = - number; -type GPUSignedOffset32 = - number; -type GPUSize32 = - number; -type GPUSize32Out = - number; -type GPUSize64 = - number; -type GPUSize64Out = - number; -type GPUStencilValue = - number; -type GPUTextureUsageFlags = - number; -type GPUAddressMode = - - | "clamp-to-edge" - | "repeat" - | "mirror-repeat"; -type GPUAutoLayoutMode = - "auto"; -type GPUBlendFactor = - - | "zero" - | "one" - | "src" - | "one-minus-src" - | "src-alpha" - | "one-minus-src-alpha" - | "dst" - | "one-minus-dst" - | "dst-alpha" - | "one-minus-dst-alpha" - | "src-alpha-saturated" - | "constant" - | "one-minus-constant" - | "src1" - | "one-minus-src1" - | "src1-alpha" - | "one-minus-src1-alpha"; -type GPUBlendOperation = - - | "add" - | "subtract" - | "reverse-subtract" - | "min" - | "max"; -type GPUBufferBindingType = - - | "uniform" - | "storage" - | "read-only-storage"; -type GPUBufferMapState = - - | "unmapped" - | "pending" - | "mapped"; -type GPUCanvasAlphaMode = - - | "opaque" - | "premultiplied"; -type GPUCanvasToneMappingMode = - - | "standard" - | "extended"; -type GPUCompareFunction = - - | "never" - | "less" - | "equal" - | "less-equal" - | "greater" - | "not-equal" - | "greater-equal" - | "always"; -type GPUCompilationMessageType = - - | "error" - | "warning" - | "info"; -type GPUCullMode = - - | "none" - | "front" - | "back"; -type GPUDeviceLostReason = - - | "unknown" - | "destroyed"; -type GPUErrorFilter = - - | "validation" - | "out-of-memory" - | "internal"; -type GPUFeatureName = - - | "core-features-and-limits" - | "depth-clip-control" - | "depth32float-stencil8" - | "texture-compression-bc" - | "texture-compression-bc-sliced-3d" - | "texture-compression-etc2" - | "texture-compression-astc" - | "texture-compression-astc-sliced-3d" - | "timestamp-query" - | "indirect-first-instance" - | "shader-f16" - | "rg11b10ufloat-renderable" - | "bgra8unorm-storage" - | "float32-filterable" - | "float32-blendable" - | "clip-distances" - | "dual-source-blending" - | "subgroups" - | "texture-formats-tier1" - | "texture-formats-tier2" - | "primitive-index" - | "texture-component-swizzle" - | "subgroup-size-control" - | "texture-compression-unaligned" - | "atomic-vec2u-min-max"; -type GPUFilterMode = - - | "nearest" - | "linear"; -type GPUFrontFace = - - | "ccw" - | "cw"; -type GPUIndexFormat = - - | "uint16" - | "uint32"; -type GPULoadOp = - - | "load" - | "clear"; -type GPUMipmapFilterMode = - - | "nearest" - | "linear"; -type GPUPipelineErrorReason = - - | "validation" - | "internal"; -type GPUPowerPreference = - - | "low-power" - | "high-performance"; -type GPUPrimitiveTopology = - - | "point-list" - | "line-list" - | "line-strip" - | "triangle-list" - | "triangle-strip"; -type GPUQueryType = - - | "occlusion" - | "timestamp"; -type GPUSamplerBindingType = - - | "filtering" - | "non-filtering" - | "comparison"; -type GPUStencilOperation = - - | "keep" - | "zero" - | "replace" - | "invert" - | "increment-clamp" - | "decrement-clamp" - | "increment-wrap" - | "decrement-wrap"; -type GPUStorageTextureAccess = - - | "write-only" - | "read-only" - | "read-write"; -type GPUStoreOp = - - | "store" - | "discard"; -type GPUTextureAspect = - - | "all" - | "stencil-only" - | "depth-only"; -type GPUTextureDimension = - - | "1d" - | "2d" - | "3d"; -type GPUTextureFormat = - - | "r8unorm" - | "r8snorm" - | "r8uint" - | "r8sint" - | "r16unorm" - | "r16snorm" - | "r16uint" - | "r16sint" - | "r16float" - | "rg8unorm" - | "rg8snorm" - | "rg8uint" - | "rg8sint" - | "r32uint" - | "r32sint" - | "r32float" - | "rg16unorm" - | "rg16snorm" - | "rg16uint" - | "rg16sint" - | "rg16float" - | "rgba8unorm" - | "rgba8unorm-srgb" - | "rgba8snorm" - | "rgba8uint" - | "rgba8sint" - | "bgra8unorm" - | "bgra8unorm-srgb" - | "rgb9e5ufloat" - | "rgb10a2uint" - | "rgb10a2unorm" - | "rg11b10ufloat" - | "rg32uint" - | "rg32sint" - | "rg32float" - | "rgba16unorm" - | "rgba16snorm" - | "rgba16uint" - | "rgba16sint" - | "rgba16float" - | "rgba32uint" - | "rgba32sint" - | "rgba32float" - | "stencil8" - | "depth16unorm" - | "depth24plus" - | "depth24plus-stencil8" - | "depth32float" - | "depth32float-stencil8" - | "bc1-rgba-unorm" - | "bc1-rgba-unorm-srgb" - | "bc2-rgba-unorm" - | "bc2-rgba-unorm-srgb" - | "bc3-rgba-unorm" - | "bc3-rgba-unorm-srgb" - | "bc4-r-unorm" - | "bc4-r-snorm" - | "bc5-rg-unorm" - | "bc5-rg-snorm" - | "bc6h-rgb-ufloat" - | "bc6h-rgb-float" - | "bc7-rgba-unorm" - | "bc7-rgba-unorm-srgb" - | "etc2-rgb8unorm" - | "etc2-rgb8unorm-srgb" - | "etc2-rgb8a1unorm" - | "etc2-rgb8a1unorm-srgb" - | "etc2-rgba8unorm" - | "etc2-rgba8unorm-srgb" - | "eac-r11unorm" - | "eac-r11snorm" - | "eac-rg11unorm" - | "eac-rg11snorm" - | "astc-4x4-unorm" - | "astc-4x4-unorm-srgb" - | "astc-5x4-unorm" - | "astc-5x4-unorm-srgb" - | "astc-5x5-unorm" - | "astc-5x5-unorm-srgb" - | "astc-6x5-unorm" - | "astc-6x5-unorm-srgb" - | "astc-6x6-unorm" - | "astc-6x6-unorm-srgb" - | "astc-8x5-unorm" - | "astc-8x5-unorm-srgb" - | "astc-8x6-unorm" - | "astc-8x6-unorm-srgb" - | "astc-8x8-unorm" - | "astc-8x8-unorm-srgb" - | "astc-10x5-unorm" - | "astc-10x5-unorm-srgb" - | "astc-10x6-unorm" - | "astc-10x6-unorm-srgb" - | "astc-10x8-unorm" - | "astc-10x8-unorm-srgb" - | "astc-10x10-unorm" - | "astc-10x10-unorm-srgb" - | "astc-12x10-unorm" - | "astc-12x10-unorm-srgb" - | "astc-12x12-unorm" - | "astc-12x12-unorm-srgb"; -type GPUTextureSampleType = - - | "float" - | "unfilterable-float" - | "depth" - | "sint" - | "uint"; -type GPUTextureViewDimension = - - | "1d" - | "2d" - | "2d-array" - | "cube" - | "cube-array" - | "3d"; -type GPUVertexFormat = - - | "uint8" - | "uint8x2" - | "uint8x4" - | "sint8" - | "sint8x2" - | "sint8x4" - | "unorm8" - | "unorm8x2" - | "unorm8x4" - | "snorm8" - | "snorm8x2" - | "snorm8x4" - | "uint16" - | "uint16x2" - | "uint16x4" - | "sint16" - | "sint16x2" - | "sint16x4" - | "unorm16" - | "unorm16x2" - | "unorm16x4" - | "snorm16" - | "snorm16x2" - | "snorm16x4" - | "float16" - | "float16x2" - | "float16x4" - | "float32" - | "float32x2" - | "float32x3" - | "float32x4" - | "uint32" - | "uint32x2" - | "uint32x3" - | "uint32x4" - | "sint32" - | "sint32x2" - | "sint32x3" - | "sint32x4" - | "unorm10-10-10-2" - | "unorm8x4-bgra" - | "snorm10-10-10-2"; -type GPUVertexStepMode = - - | "vertex" - | "instance"; - -interface GPUBindGroupDescriptor - extends GPUObjectDescriptorBase { - /** - * The {@link GPUBindGroupLayout} the entries of this bind group will conform to. - */ - layout: GPUBindGroupLayout; - /** - * A list of entries describing the resources to expose to the shader for each binding - * described by the {@link GPUBindGroupDescriptor#layout}. - */ - entries: Iterable; -} - -interface GPUBindGroupEntry { - /** - * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a - * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding - * attribute in the {@link GPUShaderModule}. - */ - binding: GPUIndex32; - /** - * The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, - * {@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. - */ - resource: GPUBindingResource; -} - -interface GPUBindGroupLayoutDescriptor - extends GPUObjectDescriptorBase { - /** - * A list of entries describing the shader resource bindings for a bind group. - */ - entries: Iterable; -} - -interface GPUBindGroupLayoutEntry { - /** - * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding - * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding - * attribute in the {@link GPUShaderModule}. - */ - binding: GPUIndex32; - /** - * A bitset of the members of {@link GPUShaderStage}. - * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource - * will be accessible from the associated shader stage. - */ - visibility: GPUShaderStageFlags; - /** - */ - buffer?: GPUBufferBindingLayout; - /** - */ - sampler?: GPUSamplerBindingLayout; - /** - */ - texture?: GPUTextureBindingLayout; - /** - */ - storageTexture?: GPUStorageTextureBindingLayout; - /** - * Exactly one of these members must be set, indicating the binding type. - * The contents of the member specify options specific to that type. - * The corresponding resource in {@link GPUDevice#createBindGroup} requires - * the corresponding binding resource type for this binding. - */ - externalTexture?: GPUExternalTextureBindingLayout; -} - -interface GPUBlendComponent { - /** - * Defines the {@link GPUBlendOperation} used to calculate the values written to the target - * attachment components. - */ - operation?: GPUBlendOperation; - /** - * Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader. - */ - srcFactor?: GPUBlendFactor; - /** - * Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment. - */ - dstFactor?: GPUBlendFactor; -} - -interface GPUBlendState { - /** - * Defines the blending behavior of the corresponding render target for color channels. - */ - color: GPUBlendComponent; - /** - * Defines the blending behavior of the corresponding render target for the alpha channel. - */ - alpha: GPUBlendComponent; -} - -interface GPUBufferBinding { - /** - * The {@link GPUBuffer} to bind. - */ - buffer: GPUBuffer; - /** - * The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the - * beginning of the range exposed to the shader by the buffer binding. - */ - offset?: GPUSize64; - /** - * The size, in bytes, of the buffer binding. - * If not map/exist|provided, specifies the range starting at - * {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. - */ - size?: GPUSize64; -} - -interface GPUBufferBindingLayout { - /** - * Indicates the type required for buffers bound to this binding. - */ - type?: GPUBufferBindingType; - /** - * Indicates whether this binding requires a dynamic offset. - */ - hasDynamicOffset?: boolean; - /** - * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. - * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. - * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] - * that this value ≥ the minimum buffer binding size of the variable. - * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands - * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} - * satisfies the minimum buffer binding size of the variable. - * Note: - * Similar execution-time validation is theoretically possible for other - * binding-related fields specified for early validation, like - * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, - * which currently can only be validated in pipeline creation. - * However, such execution-time validation could be costly or unnecessarily complex, so it is - * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the - * most ergonomic impact. - */ - minBindingSize?: GPUSize64; -} - -interface GPUBufferDescriptor - extends GPUObjectDescriptorBase { - /** - * The size of the buffer in bytes. - */ - size: GPUSize64; - /** - * The allowed usages for the buffer. - */ - usage: GPUBufferUsageFlags; - /** - * If `true` creates the buffer in an already mapped state, allowing - * {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set - * {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} - * does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be - * used to set the buffer's initial data. - * Guarantees that even if the buffer creation eventually fails, it will still appear as if the - * mapped range can be written/read to until it is unmapped. - */ - mappedAtCreation?: boolean; -} - -interface GPUCanvasConfiguration { - /** - * The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be - * compatible with. - */ - device: GPUDevice; - /** - * The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. - * Must be one of the Supported context formats. - */ - format: GPUTextureFormat; - /** - * The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. - * {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included - * if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} - * when setting a custom usage if you wish to use textures returned by - * {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. - */ - usage?: GPUTextureUsageFlags; - /** - * The formats that views created from textures returned by - * {@link GPUCanvasContext#getCurrentTexture} may use. - */ - viewFormats?: Iterable; - /** - * The color space that values written into textures returned by - * {@link GPUCanvasContext#getCurrentTexture} should be displayed with. - */ - colorSpace?: PredefinedColorSpace; - /** - * The tone mapping determines how the content of textures returned by - * {@link GPUCanvasContext#getCurrentTexture} are to be displayed. - *
- * This is a required feature, but user agents might not yet implement it, - * effectively supporting only the default {@link GPUCanvasToneMapping}. - * In such implementations, this member **should not** exist in its implementation of - * {@link GPUCanvasConfiguration}, to make feature detection possible using - * {@link GPUCanvasContext#getConfiguration}. - * This is especially important in implementations which otherwise have HDR capabilities - * (where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be - * exposed). - * If an implementation exposes this member and a `high` dynamic range, it **should** render the - * canvas as an HDR element, not clamp values to the SDR range of the HDR display. - *
- */ - toneMapping?: GPUCanvasToneMapping; - /** - * Determines the effect that alpha values will have on the content of textures returned by - * {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. - */ - alphaMode?: GPUCanvasAlphaMode; -} - -interface GPUCanvasToneMapping { - mode?: GPUCanvasToneMappingMode; -} - -interface GPUColorDict { - /** - * The red channel value. - */ - r: number; - /** - * The green channel value. - */ - g: number; - /** - * The blue channel value. - */ - b: number; - /** - * The alpha channel value. - */ - a: number; -} - -interface GPUColorTargetState { - /** - * The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with - * {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the - * corresponding color attachment. - */ - format: GPUTextureFormat; - /** - * The blending behavior for this color target. If left undefined, disables blending for this - * color target. - */ - blend?: GPUBlendState; - /** - * Bitmask controlling which channels are are written to when drawing to this color target. - */ - writeMask?: GPUColorWriteFlags; -} - -type GPUCommandBufferDescriptor = - GPUObjectDescriptorBase; -type GPUCommandEncoderDescriptor = - GPUObjectDescriptorBase; - -interface GPUComputePassDescriptor - extends GPUObjectDescriptorBase { - /** - * Defines which timestamp values will be written for this pass, and where to write them to. - */ - timestampWrites?: GPUComputePassTimestampWrites; -} - -interface GPUComputePassTimestampWrites { - /** - * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be - * written to. - */ - querySet: GPUQuerySet; - /** - * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into - * which the timestamp at the beginning of the compute pass will be written. - */ - beginningOfPassWriteIndex?: GPUSize32; - /** - * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into - * which the timestamp at the end of the compute pass will be written. - */ - endOfPassWriteIndex?: GPUSize32; -} - -interface GPUComputePipelineDescriptor - extends GPUPipelineDescriptorBase { - /** - * Describes the compute shader entry point of the pipeline. - */ - compute: GPUProgrammableStage; -} - -interface GPUCopyExternalImageDestInfo - extends GPUTexelCopyTextureInfo { - /** - * Describes the color space and encoding used to encode data into the destination texture. - * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1] - * being written to the target texture, if its format can represent them. - * Otherwise, the results are clamped to the target texture format's range. - * Note: - * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, - * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. - */ - colorSpace?: PredefinedColorSpace; - /** - * Describes whether the data written into the texture should have its RGB channels - * premultiplied by the alpha channel, or not. - * If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also - * premultiplied, the source RGB values must be preserved even if they exceed their - * corresponding alpha values. - * Note: - * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, - * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}. - */ - premultipliedAlpha?: boolean; -} - -interface GPUCopyExternalImageSourceInfo { - /** - * The source of the texel copy. The copy source data is captured at the moment that - * {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described - * by the external source dimensions table. - */ - source: GPUCopyExternalImageSource; - /** - * Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from. - * Together with `copySize`, defines the full copy sub-region. - */ - origin?: GPUOrigin2D; - /** - * Describes whether the source image is vertically flipped, or not. - * If this option is set to `true`, the copy is flipped vertically: the bottom row of the source - * region is copied into the first row of the destination region, and so on. - * The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner - * of the source image, increasing downward. - */ - flipY?: boolean; -} - -interface GPUDepthStencilState { - /** - * The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} - * this {@link GPURenderPipeline} will be compatible with. - */ - format: GPUTextureFormat; - /** - * Indicates if this {@link GPURenderPipeline} can modify - * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values. - */ - depthWriteEnabled?: boolean; - /** - * The comparison operation used to test fragment depths against - * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values. - */ - depthCompare?: GPUCompareFunction; - /** - * Defines how stencil comparisons and operations are performed for front-facing primitives. - */ - stencilFront?: GPUStencilFaceState; - /** - * Defines how stencil comparisons and operations are performed for back-facing primitives. - */ - stencilBack?: GPUStencilFaceState; - /** - * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value - * bits are read when performing stencil comparison tests. - */ - stencilReadMask?: GPUStencilValue; - /** - * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value - * bits are written to when performing stencil operations. - */ - stencilWriteMask?: GPUStencilValue; - /** - * Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details. - */ - depthBias?: GPUDepthBias; - /** - * Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details. - */ - depthBiasSlopeScale?: number; - /** - * The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details. - */ - depthBiasClamp?: number; -} - -interface GPUDeviceDescriptor - extends GPUObjectDescriptorBase { - /** - * Specifies the features that are required by the device request. - * The request will fail if the adapter cannot provide these features. - * Exactly the specified set of features, and no more or less, will be allowed in validation - * of API calls on the resulting device. - */ - requiredFeatures?: Iterable; - /** - * Specifies the limits that are required by the device request. - * The request will fail if the adapter cannot provide these limits. - * Each key with a non-`undefined` value must be the name of a member of supported limits. - * API calls on the resulting device perform validation according to the exact limits of the - * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). - * - */ - requiredLimits?: Record< - string, - | GPUSize64 - | undefined - >; - /** - * The descriptor for the default {@link GPUQueue}. - */ - defaultQueue?: GPUQueueDescriptor; -} - -interface GPUExtent3DDict { - /** - * The width of the extent. - */ - width: GPUIntegerCoordinate; - /** - * The height of the extent. - */ - height?: GPUIntegerCoordinate; - /** - * The depth of the extent or the number of array layers it contains. - * If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `"3d"` - * defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension} - * of {@link GPUTextureDimension} `"2d"` defines the number of array layers in the texture. - */ - depthOrArrayLayers?: GPUIntegerCoordinate; -} - -interface GPUExternalTextureBindingLayout {} - -interface GPUExternalTextureDescriptor - extends GPUObjectDescriptorBase { - /** - * The video source to import the external texture from. Source size is determined as described - * by the external source dimensions table. - */ - source: - | HTMLVideoElement - | VideoFrame; - /** - * The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be - * converted into when reading. - */ - colorSpace?: PredefinedColorSpace; -} - -interface GPUFragmentState - extends GPUProgrammableStage { - /** - * A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets - * this pipeline writes to. - */ - targets: Iterable< - | GPUColorTargetState - | null - | undefined - >; -} - -interface GPUMultisampleState { - /** - * Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only - * with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} - * and {@link GPURenderPassDescriptor#depthStencilAttachment}) - * with matching {@link GPUTextureDescriptor#sampleCount}s. - */ - count?: GPUSize32; - /** - * Mask determining which samples are written to. - */ - mask?: GPUSampleMask; - /** - * When `true` indicates that a fragment's alpha channel should be used to generate a sample - * coverage mask. - */ - alphaToCoverageEnabled?: boolean; -} - -interface GPUObjectDescriptorBase { - /** - * The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}. - */ - label?: string; -} - -interface GPUOrigin2DDict { - x?: GPUIntegerCoordinate; - y?: GPUIntegerCoordinate; -} - -interface GPUOrigin3DDict { - x?: GPUIntegerCoordinate; - y?: GPUIntegerCoordinate; - z?: GPUIntegerCoordinate; -} - -interface GPUPipelineDescriptorBase - extends GPUObjectDescriptorBase { - /** - * The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `"auto"` to generate - * the pipeline layout automatically. - * Note: If {@link GPUAutoLayoutMode} `"auto"` is used the pipeline cannot share {@link GPUBindGroup}s - * with any other pipelines. - */ - layout: - | GPUPipelineLayout - | GPUAutoLayoutMode; -} - -interface GPUPipelineErrorInit { - reason: GPUPipelineErrorReason; -} - -interface GPUPipelineLayoutDescriptor - extends GPUObjectDescriptorBase { - /** - * A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds - * to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding - * with `@group(N)`. - */ - bindGroupLayouts: Iterable< - | GPUBindGroupLayout - | null - | undefined - >; - /** - * The size, in bytes, of the immediate data range used by the pipeline. - */ - immediateSize?: GPUSize32; -} - -interface GPUPrimitiveState { - /** - * The type of primitive to be constructed from the vertex inputs. - */ - topology?: GPUPrimitiveTopology; - /** - * For pipelines with strip topologies - * ({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), - * this determines the index buffer format and primitive restart value - * ({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). - * It is not allowed on pipelines with non-strip topologies. - * Note: Some implementations require knowledge of the primitive restart value to compile - * pipeline state objects. - * To use a strip-topology pipeline with an indexed draw call - * ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), - * this must be set, and it must match the index buffer format used with the draw call - * (set in {@link GPURenderCommandsMixin#setIndexBuffer}). - * See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. - */ - stripIndexFormat?: GPUIndexFormat; - /** - * Defines which polygons are considered front-facing. - */ - frontFace?: GPUFrontFace; - /** - * Defines which polygon orientation will be culled, if any. - */ - cullMode?: GPUCullMode; - /** - * If true, indicates that depth clipping is disabled. - * Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. - */ - unclippedDepth?: boolean; -} - -interface GPUProgrammableStage { - /** - * The {@link GPUShaderModule} containing the code that this programmable stage will execute. - */ - module: GPUShaderModule; - /** - * The name of the function in {@link GPUProgrammableStage#module} that this stage will use to - * perform its work. - * NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is - * not required, methods which consume a {@link GPUProgrammableStage} must use the - * "[$get the entry point$]" algorithm to determine which entry point - * it refers to. - */ - entryPoint?: string; - /** - * Specifies the values of pipeline-overridable constants in the shader module - * {@link GPUProgrammableStage#module}. - * Each such pipeline-overridable constant is uniquely identified by a single - * pipeline-overridable constant identifier string, representing the pipeline - * constant ID of the constant if its declaration specifies one, and otherwise the - * constant's identifier name. - * The key of each key-value pair must equal the - * pipeline-overridable constant identifier string|identifier string - * of one such constant, with the comparison performed - * according to the rules for WGSL identifier comparison. - * When the pipeline is executed, that constant will have the specified value. - * Values are specified as GPUPipelineConstantValue, which is a `double`. - * They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). - * If conversion fails, a validation error is generated. - *
- * Pipeline-overridable constants defined in WGSL: - * ```wgsl - * @id(0) override has_point_light: bool = true; // Algorithmic control. - * @id(1200) override specular_param: f32 = 2.3; // Numeric control. - * @id(1300) override gain: f32; // Must be overridden. - * override width: f32 = 0.0; // Specifed at the API level - * // using the name "width". - * override depth: f32; // Specifed at the API level - * // using the name "depth". - * // Must be overridden. - * override height = 2 * depth; // The default value - * // (if not set at the API level), - * // depends on another - * // overridable constant. - * ``` - * Corresponding JavaScript code, providing only the overrides which are required - * (have no defaults): - * ```js - * { - * // ... - * constants: { - * 1300: 2.0, // "gain" - * depth: -1, // "depth" - * } - * } - * ``` - * Corresponding JavaScript code, overriding all constants: - * ```js - * { - * // ... - * constants: { - * 0: false, // "has_point_light" - * 1200: 3.0, // "specular_param" - * 1300: 2.0, // "gain" - * width: 20, // "width" - * depth: -1, // "depth" - * height: 15, // "height" - * } - * } - * ``` - *
- */ - constants?: Record< - string, - GPUPipelineConstantValue - >; -} - -interface GPUQuerySetDescriptor - extends GPUObjectDescriptorBase { - /** - * The type of queries managed by {@link GPUQuerySet}. - */ - type: GPUQueryType; - /** - * The number of queries managed by {@link GPUQuerySet}. - */ - count: GPUSize32; -} - -type GPUQueueDescriptor = - GPUObjectDescriptorBase; -type GPURenderBundleDescriptor = - GPUObjectDescriptorBase; - -interface GPURenderBundleEncoderDescriptor - extends GPURenderPassLayout { - /** - * If `true`, indicates that the render bundle does not modify the depth component of the - * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed - * in. - * See read-only depth-stencil. - */ - depthReadOnly?: boolean; - /** - * If `true`, indicates that the render bundle does not modify the stencil component of the - * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed - * in. - * See read-only depth-stencil. - */ - stencilReadOnly?: boolean; -} - -interface GPURenderPassColorAttachment { - /** - * Describes the texture subresource that will be output to for this color attachment. - * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). - */ - view: - | GPUTexture - | GPUTextureView; - /** - * Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} - * that will be output to for this color attachment. - */ - depthSlice?: GPUIntegerCoordinate; - /** - * Describes the texture subresource that will receive the resolved output for this color - * attachment if {@link GPURenderPassColorAttachment#view} is multisampled. - * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). - */ - resolveTarget?: - | GPUTexture - | GPUTextureView; - /** - * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the - * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored - * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. - * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. - * They are converted [$to a texel value of texture format$] matching the render attachment. - * If conversion fails, a validation error is generated. - */ - clearValue?: GPUColor; - /** - * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to - * executing the render pass. - * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. - */ - loadOp: GPULoadOp; - /** - * The store operation to perform on {@link GPURenderPassColorAttachment#view} - * after executing the render pass. - */ - storeOp: GPUStoreOp; -} - -interface GPURenderPassDepthStencilAttachment { - /** - * Describes the texture subresource that will be output to and read from for this - * depth/stencil attachment. - * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). - */ - view: - | GPUTexture - | GPUTextureView; - /** - * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component - * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} - * is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. - * - */ - depthClearValue?: number; - /** - * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s - * depth component prior to executing the render pass. - * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. - */ - depthLoadOp?: GPULoadOp; - /** - * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s - * depth component after executing the render pass. - */ - depthStoreOp?: GPUStoreOp; - /** - * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} - * is read only. - */ - depthReadOnly?: boolean; - /** - * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component - * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} - * is not {@link GPULoadOp} `"clear"`. - * The value will be converted to the type of the stencil aspect of `view` by taking the same - * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. - */ - stencilClearValue?: GPUStencilValue; - /** - * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s - * stencil component prior to executing the render pass. - * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. - */ - stencilLoadOp?: GPULoadOp; - /** - * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s - * stencil component after executing the render pass. - */ - stencilStoreOp?: GPUStoreOp; - /** - * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} - * is read only. - */ - stencilReadOnly?: boolean; -} - -interface GPURenderPassDescriptor - extends GPUObjectDescriptorBase { - /** - * The set of {@link GPURenderPassColorAttachment} values in this sequence defines which - * color attachments will be output to when executing this render pass. - * Due to compatible usage list|usage compatibility, no color attachment - * may alias another attachment or any resource used inside the render pass. - */ - colorAttachments: Iterable< - | GPURenderPassColorAttachment - | null - | undefined - >; - /** - * The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil - * attachment that will be output to and tested against when executing this render pass. - * Due to compatible usage list|usage compatibility, no writable depth/stencil attachment - * may alias another attachment or any resource used inside the render pass. - */ - depthStencilAttachment?: GPURenderPassDepthStencilAttachment; - /** - * The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass. - */ - occlusionQuerySet?: GPUQuerySet; - /** - * Defines which timestamp values will be written for this pass, and where to write them to. - */ - timestampWrites?: GPURenderPassTimestampWrites; - /** - * The maximum number of draw calls that will be done in the render pass. Used by some - * implementations to size work injected before the render pass. Keeping the default value - * is a good default, unless it is known that more draw calls will be done. - */ - maxDrawCount?: GPUSize64; -} - -interface GPURenderPassLayout - extends GPUObjectDescriptorBase { - /** - * A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle. - */ - colorFormats: Iterable< - | GPUTextureFormat - | null - | undefined - >; - /** - * The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle. - */ - depthStencilFormat?: GPUTextureFormat; - /** - * Number of samples per pixel in the attachments for this pass or bundle. - */ - sampleCount?: GPUSize32; -} - -interface GPURenderPassTimestampWrites { - /** - * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be - * written to. - */ - querySet: GPUQuerySet; - /** - * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into - * which the timestamp at the beginning of the render pass will be written. - */ - beginningOfPassWriteIndex?: GPUSize32; - /** - * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into - * which the timestamp at the end of the render pass will be written. - */ - endOfPassWriteIndex?: GPUSize32; -} - -interface GPURenderPipelineDescriptor - extends GPUPipelineDescriptorBase { - /** - * Describes the vertex shader entry point of the pipeline and its input buffer layouts. - */ - vertex: GPUVertexState; - /** - * Describes the primitive-related properties of the pipeline. - */ - primitive?: GPUPrimitiveState; - /** - * Describes the optional depth-stencil properties, including the testing, operations, and bias. - */ - depthStencil?: GPUDepthStencilState; - /** - * Describes the multi-sampling properties of the pipeline. - */ - multisample?: GPUMultisampleState; - /** - * Describes the fragment shader entry point of the pipeline and its output colors. If - * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. - */ - fragment?: GPUFragmentState; -} - -interface GPURequestAdapterOptions { - /** - * Requests an adapter that supports at least a particular set of capabilities. - * This influences the {@link adapter#[[default feature level]]} of devices created - * from this adapter. The capabilities for each level are defined below, and the exact - * steps are defined in {@link GPU#requestAdapter} and "a new device". - * If the implementation or system does not support all of the capabilities in the - * requested feature level, {@link GPU#requestAdapter} will return `null`. - * Note: - * Applications should typically make a single {@link GPU#requestAdapter} call with the lowest - * feature level they support, then inspect the adapter for additional capabilities they can - * use optionally, and request those in {@link GPUAdapter#requestDevice}. - * The allowed feature level string values are: - *
- * : "core" - * The following set of capabilities: - * - The limit/Default limits. - * - {@link GPUFeatureName} `"core-features-and-limits"`. - * Note: - * Adapters with this {@link adapter#[[default feature level]]} may - * conventionally be referred to as "Core-defaulting". - * : "compatibility" - * The following set of capabilities: - * - The limit/Compatibility Mode Default limits. - * - No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) - * If the implementation cannot enforce the stricter "Compatibility Mode" - * validation rules, {@link GPU#requestAdapter} will ignore this request and - * treat it as a request for feature level string/"core". - * Note: - * Adapters with this {@link adapter#[[default feature level]]} may - * conventionally be referred to as "Compatibility-defaulting". - */ - featureLevel?: string; - /** - * Optionally provides a hint indicating what class of adapter should be selected from - * the system's available adapters. - * The value of this hint may influence which adapter is chosen, but it must not - * influence whether an adapter is returned or not. - * Note: - * The primary utility of this hint is to influence which GPU is used in a multi-GPU system. - * For instance, some laptops have a low-power integrated GPU and a high-performance - * discrete GPU. This hint may also affect the power configuration of the selected GPU to - * match the requested power preference. - * Note: - * Depending on the exact hardware configuration, such as battery status and attached displays - * or removable GPUs, the user agent may select different adapters given the same power - * preference. - * Typically, given the same hardware configuration and state and - * `powerPreference`, the user agent is likely to select the same adapter. - */ - powerPreference?: GPUPowerPreference; - /** - * When set to `true` indicates that only a fallback adapter may be returned. If the user - * agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to - * resolve to `null`. - * Note: - * {@link GPU#requestAdapter} may still return a fallback adapter if - * {@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no - * other appropriate adapter is available or the user agent chooses to return a - * fallback adapter. Developers that wish to prevent their applications from running on - * fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} - * attribute prior to requesting a {@link GPUDevice}. - */ - forceFallbackAdapter?: boolean; - xrCompatible?: boolean; -} - -interface GPUSamplerBindingLayout { - /** - * Indicates the required type of a sampler bound to this bindings. - */ - type?: GPUSamplerBindingType; -} - -interface GPUSamplerDescriptor - extends GPUObjectDescriptorBase { - /** - */ - addressModeU?: GPUAddressMode; - /** - */ - addressModeV?: GPUAddressMode; - /** - * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth - * coordinates, respectively. - */ - addressModeW?: GPUAddressMode; - /** - * Specifies the sampling behavior when the sampled area is smaller than or equal to one - * texel. - */ - magFilter?: GPUFilterMode; - /** - * Specifies the sampling behavior when the sampled area is larger than one texel. - */ - minFilter?: GPUFilterMode; - /** - * Specifies behavior for sampling between mipmap levels. - */ - mipmapFilter?: GPUMipmapFilterMode; - /** - */ - lodMinClamp?: number; - /** - * Specifies the minimum and maximum levels of detail, respectively, used internally when - * sampling a texture. - */ - lodMaxClamp?: number; - /** - * When provided the sampler will be a comparison sampler with the specified - * {@link GPUCompareFunction}. - * Note: Comparison samplers may use filtering, but the sampling results will be - * implementation-dependent and may differ from the normal filtering rules. - */ - compare?: GPUCompareFunction; - /** - * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is - * enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. - * Anisotropic filtering improves the image quality of textures sampled at oblique viewing - * angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of - * anisotropy supported when filtering. - *
- * Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range - * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} - * will be clamped to the maximum value that the platform supports. - * The precise filtering behavior is implementation-dependent. - *
- */ - maxAnisotropy?: number; -} - -interface GPUShaderModuleCompilationHint { - entryPoint: string; - /** - * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future - * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. - * If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] - * for the entry point associated with this hint will be used. - */ - layout?: - | GPUPipelineLayout - | GPUAutoLayoutMode; -} - -interface GPUShaderModuleDescriptor - extends GPUObjectDescriptorBase { - /** - * The WGSL source code for the shader - * module. - */ - code: string; - /** - * A list of {@link GPUShaderModuleCompilationHint}s. - * Any hint provided by an application **should** contain information about one entry point of - * a pipeline that will eventually be created from the entry point. - * Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} - * to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. - * Aside from type-checking, these hints are not validated in any way. - *
- * Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any - * observable effect, other than performance. It may be detrimental to performance to - * provide hints for pipelines that never end up being created. - * Because a single shader module can hold multiple entry points, and multiple pipelines - * can be created from a single shader module, it can be more performant for an - * implementation to do as much compilation as possible once in - * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to - * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. - * Hints are only applied to the entry points they explicitly name. - * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, - * there is no default, even if only one entry point is present in the module. - *
- * Note: - * Hints are not validated in an observable way, but user agents **may** surface identifiable - * errors (like unknown entry point names or incompatible pipeline layouts) to developers, - * for example in the browser developer console. - */ - compilationHints?: Iterable; -} - -interface GPUStencilFaceState { - /** - * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value - * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. - */ - compare?: GPUCompareFunction; - /** - * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by - * {@link GPUStencilFaceState#compare} fails. - */ - failOp?: GPUStencilOperation; - /** - * The {@link GPUStencilOperation} performed if the fragment depth comparison described by - * {@link GPUDepthStencilState#depthCompare} fails. - */ - depthFailOp?: GPUStencilOperation; - /** - * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by - * {@link GPUStencilFaceState#compare} passes. - */ - passOp?: GPUStencilOperation; -} - -interface GPUStorageTextureBindingLayout { - /** - * The access mode for this binding, indicating readability and writability. - */ - access?: GPUStorageTextureAccess; - /** - * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding. - */ - format: GPUTextureFormat; - /** - * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to - * this binding. - */ - viewDimension?: GPUTextureViewDimension; -} - -interface GPUTexelCopyBufferInfo - extends GPUTexelCopyBufferLayout { - /** - * A buffer which either contains texel data to be copied or will store the texel data being - * copied, depending on the method it is being passed to. - */ - buffer: GPUBuffer; -} - -interface GPUTexelCopyBufferLayout { - /** - * The offset, in bytes, from the beginning of the texel data source (such as a - * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data - * within that source. - */ - offset?: GPUSize64; - /** - * The stride, in bytes, between the beginning of each texel block row and the subsequent - * texel block row. - * Required if there are multiple texel block rows (i.e. the copy height or depth is more - * than one block). - */ - bytesPerRow?: GPUSize32; - /** - * Number of texel block rows per single texel image of the texture. - * {@link GPUTexelCopyBufferLayout#rowsPerImage} × - * {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each - * texel image of data and the subsequent texel image. - * Required if there are multiple texel images (i.e. the copy depth is more than one). - */ - rowsPerImage?: GPUSize32; -} - -interface GPUTexelCopyTextureInfo { - /** - * Texture to copy to/from. - */ - texture: GPUTexture; - /** - * Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. - */ - mipLevel?: GPUIntegerCoordinate; - /** - * Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. - * Together with `copySize`, defines the full copy sub-region. - */ - origin?: GPUOrigin3D; - /** - * Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. - */ - aspect?: GPUTextureAspect; -} - -interface GPUTextureBindingLayout { - /** - * Indicates the type required for texture views bound to this binding. - */ - sampleType?: GPUTextureSampleType; - /** - * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to - * this binding. - */ - viewDimension?: GPUTextureViewDimension; - /** - * Indicates whether or not texture views bound to this binding must be multisampled. - */ - multisampled?: boolean; -} - -interface GPUTextureDescriptor - extends GPUObjectDescriptorBase { - /** - * The width, height, and depth or layer count of the texture. - */ - size: GPUExtent3DStrict; - /** - * The number of mip levels the texture will contain. - */ - mipLevelCount?: GPUIntegerCoordinate; - /** - * The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates - * a multisampled texture. - */ - sampleCount?: GPUSize32; - /** - * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional. - */ - dimension?: GPUTextureDimension; - /** - * The format of the texture. - */ - format: GPUTextureFormat; - /** - * The allowed usages for the texture. - */ - usage: GPUTextureUsageFlags; - /** - * Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling - * {@link GPUTexture#createView} on this texture (in addition to the texture's actual - * {@link GPUTextureDescriptor#format}). - *
- * Adding a format to this list may have a significant performance impact, so it is best - * to avoid adding formats unnecessarily. - * The actual performance impact is highly dependent on the target system; developers must - * test various systems to find out the impact on their particular application. - * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or - * {@link GPUTextureDescriptor#viewFormats} entry including - * {@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a - * {@link GPUTextureFormat} `"rgba8unorm"` texture which does not. - * Similar caveats exist for other formats and pairs of formats on other systems. - *
- * Formats in this list must be texture view format compatible with the texture format. - *
- * Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: - * - `format` equals `viewFormat`, or - * - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. - *
- */ - viewFormats?: Iterable; - /** - *
- * On devices without {@link GPUFeatureName} `"core-features-and-limits"`, - * views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. - * If not specified, a default is chosen. - *
- * On devices with {@link GPUFeatureName} `"core-features-and-limits"`, - * this is ignored, and there is no such restriction. - */ - textureBindingViewDimension?: GPUTextureViewDimension; -} - -interface GPUTextureViewDescriptor - extends GPUObjectDescriptorBase { - /** - * The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the - * texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. - */ - format?: GPUTextureFormat; - /** - * The dimension to view the texture as. - */ - dimension?: GPUTextureViewDimension; - /** - * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the - * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of - * {@link GPUTexture#usage} flags of the texture. - * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the - * texture's {@link GPUTextureDescriptor#usage}s, the default will fail, - * and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. - */ - usage?: GPUTextureUsageFlags; - /** - * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view. - */ - aspect?: GPUTextureAspect; - /** - * The first (most detailed) mipmap level accessible to the texture view. - */ - baseMipLevel?: GPUIntegerCoordinate; - /** - * How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to - * the texture view. - */ - mipLevelCount?: GPUIntegerCoordinate; - /** - * The index of the first array layer accessible to the texture view. - */ - baseArrayLayer?: GPUIntegerCoordinate; - /** - * How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible - * to the texture view. - */ - arrayLayerCount?: GPUIntegerCoordinate; - /** - * A string of length four, with each character mapping to the texture view's red/green/blue/alpha - * channels, respectively. - * When accessed by a shader, the red/green/blue/alpha channels are replaced by the value - * corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and - * `swizzle[3]`, respectively: - * - `"r"`: Take its value from the red channel of the texture. - * - `"g"`: Take its value from the green channel of the texture. - * - `"b"`: Take its value from the blue channel of the texture. - * - `"a"`: Take its value from the alpha channel of the texture. - * - `"0"`: Force its value to 0. - * - `"1"`: Force its value to 1. - * Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. - */ - swizzle?: string; -} - -interface GPUUncapturedErrorEventInit - extends EventInit { - error: GPUError; -} - -interface GPUVertexAttribute { - /** - * The {@link GPUVertexFormat} of the attribute. - */ - format: GPUVertexFormat; - /** - * The offset, in bytes, from the beginning of the element to the data for the attribute. - */ - offset: GPUSize64; - /** - * The numeric location associated with this attribute, which will correspond with a - * "@location" attribute - * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. - */ - shaderLocation: GPUIndex32; -} - -interface GPUVertexBufferLayout { - /** - * The stride, in bytes, between elements of this array. - */ - arrayStride: GPUSize64; - /** - * Whether each element of this array represents per-vertex data or per-instance data - */ - stepMode?: GPUVertexStepMode; - /** - * An array defining the layout of the vertex attributes within each element. - */ - attributes: Iterable; -} - -interface GPUVertexState - extends GPUProgrammableStage { - /** - * A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a - * vertex buffer used by this pipeline. - */ - buffers?: Iterable< - | GPUVertexBufferLayout - | null - | undefined - >; -} - -interface GPUBindingCommandsMixin { - /** - * Sets the current {@link GPUBindGroup} for the given index. - * @param index - The index to set the bind group at. - * @param bindGroup - Bind group to use for subsequent render or compute commands. - * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in - * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.--> - */ - setBindGroup( - index: GPUIndex32, - bindGroup: - | GPUBindGroup - | null - | undefined, - dynamicOffsets?: Iterable - ): undefined; - /** - * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset - * of a Uint32Array. - * @param index - The index to set the bind group at. - * @param bindGroup - Bind group to use for subsequent render or compute commands. - * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in - * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}. - * @param dynamicOffsetsDataStart - Offset in elements into `dynamicOffsetsData` where the - * buffer offset data begins. - * @param dynamicOffsetsDataLength - Number of buffer offsets to read from `dynamicOffsetsData`. - */ - setBindGroup( - index: GPUIndex32, - bindGroup: - | GPUBindGroup - | null - | undefined, - dynamicOffsetsData: Uint32Array, - dynamicOffsetsDataStart: GPUSize64, - dynamicOffsetsDataLength: GPUSize32 - ): undefined; - /** - * Sets immediate data for subsequent render or compute commands. - * @param rangeOffset - Offset in bytes into the immediate data range to begin writing at. - * @param data - Data to write into the immediate data range. - * @param dataOffset - Offset into `data` to begin writing from. Given in elements if - * `data` is a {@link TypedArray} and bytes otherwise. - * @param dataSize - Size of content to write from `data`. Given in elements if - * `data` is a {@link TypedArray} and bytes otherwise. - */ - setImmediates( - rangeOffset: GPUSize32, - data: GPUAllowSharedBufferSource, - dataOffset?: GPUSize64, - dataSize?: GPUSize64 - ): undefined; -} - -interface GPUCommandsMixin {} - -interface GPUDebugCommandsMixin { - /** - * Begins a labeled debug group containing subsequent commands. - * @param groupLabel - The label for the command group. - */ - pushDebugGroup( - groupLabel: string - ): undefined; - /** - * Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}. - */ - popDebugGroup(): undefined; - /** - * Marks a point in a stream of commands with a label. - * @param markerLabel - The label to insert. - */ - insertDebugMarker( - markerLabel: string - ): undefined; -} - -interface GPUObjectBase { - label: string; -} - -interface GPUPipelineBase { - /** - * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s - * {@link GPUBindGroupLayout} at `index`. - * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` - * sequence. - */ - getBindGroupLayout( - index: number - ): GPUBindGroupLayout; -} - -interface GPURenderCommandsMixin { - /** - * Sets the current {@link GPURenderPipeline}. - * @param pipeline - The render pipeline to use for subsequent drawing commands. - */ - setPipeline( - pipeline: GPURenderPipeline - ): undefined; - /** - * Sets the current index buffer. - * @param buffer - Buffer containing index data to use for subsequent drawing commands. - * @param indexFormat - Format of the index data contained in `buffer`. - * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`. - * @param size - Size in bytes of the index data in `buffer`. - * Defaults to the size of the buffer minus the offset. - */ - setIndexBuffer( - buffer: GPUBuffer, - indexFormat: GPUIndexFormat, - offset?: GPUSize64, - size?: GPUSize64 - ): undefined; - /** - * Sets the current vertex buffer for the given slot. - * @param slot - The vertex buffer slot to set the vertex buffer for. - * @param buffer - Buffer containing vertex data to use for subsequent drawing commands. - * @param offset - Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`. - * @param size - Size in bytes of the vertex data in `buffer`. - * Defaults to the size of the buffer minus the offset. - */ - setVertexBuffer( - slot: GPUIndex32, - buffer: - | GPUBuffer - | null - | undefined, - offset?: GPUSize64, - size?: GPUSize64 - ): undefined; - /** - * Draws primitives. - * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. - * @param vertexCount - The number of vertices to draw. - * @param instanceCount - The number of instances to draw. - * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from. - * @param firstInstance - First instance to draw. - */ - draw( - vertexCount: GPUSize32, - instanceCount?: GPUSize32, - firstVertex?: GPUSize32, - firstInstance?: GPUSize32 - ): undefined; - /** - * Draws indexed primitives. - * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. - * @param indexCount - The number of indices to draw. - * @param instanceCount - The number of instances to draw. - * @param firstIndex - Offset into the index buffer, in indices, begin drawing from. - * @param baseVertex - Added to each index value before indexing into the vertex buffers. - * @param firstInstance - First instance to draw. - */ - drawIndexed( - indexCount: GPUSize32, - instanceCount?: GPUSize32, - firstIndex?: GPUSize32, - baseVertex?: GPUSignedOffset32, - firstInstance?: GPUSize32 - ): undefined; - /** - * Draws primitives using parameters read from a {@link GPUBuffer}. - * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. - * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same - * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: - * @param indirectBuffer - Buffer containing the indirect draw parameters. - * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. - */ - drawIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: GPUSize64 - ): undefined; - /** - * Draws indexed primitives using parameters read from a {@link GPUBuffer}. - * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. - * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in - * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: - * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters. - * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins. - */ - drawIndexedIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: GPUSize64 - ): undefined; -} - -interface NavigatorGPU { - /** - * A global singleton providing top-level entry points like {@link GPU#requestAdapter}. - */ - readonly gpu: GPU; -} - -interface GPU { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPU"; - /** - * Requests an adapter from the user agent. - * The user agent chooses whether to return an adapter, and, if so, - * chooses according to the provided options. - * @param options - Criteria used to select the adapter. - */ - requestAdapter( - options?: GPURequestAdapterOptions - ): Promise; - /** - * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range - * content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or - * {@link GPUTextureFormat} `"bgra8unorm"`. - * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to - * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated - * canvas is able to display its contents efficiently. - * Note: Canvases which are not displayed to the screen may or may not benefit from using this - * format. - */ - getPreferredCanvasFormat(): GPUTextureFormat; - readonly wgslLanguageFeatures: WGSLLanguageFeatures; -} - -declare var GPU: { - prototype: GPU; - new (): never; -}; - -interface GPUAdapter { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUAdapter"; - /** - * The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}. - */ - readonly features: GPUSupportedFeatures; - /** - * The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}. - */ - readonly limits: GPUSupportedLimits; - /** - * Information about the physical adapter underlying this {@link GPUAdapter}. - * For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time. - * The same object is returned each time. To create that object for the first time: - *
- *
- * **Called on:** {@link GPUAdapter} `this`. - * **Returns:** {@link GPUAdapterInfo} - * Content timeline steps: - * 1. Return a [$new adapter info$] for `this.adapter`. - *
- *
- */ - readonly info: GPUAdapterInfo; - /** - * Requests a device from the adapter. - * This is a one-time action: if a device is returned successfully, - * the adapter becomes {@link adapter#[[state]]#"consumed"}. - * @param descriptor - Description of the {@link GPUDevice} to request. - */ - requestDevice( - descriptor?: GPUDeviceDescriptor - ): Promise; -} - -declare var GPUAdapter: { - prototype: GPUAdapter; - new (): never; -}; - -interface GPUAdapterInfo { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUAdapterInfo"; - /** - * The name of the vendor of the adapter, if available. Empty string otherwise. - */ - readonly vendor: string; - /** - * The name of the family or class of GPUs the adapter belongs to, if available. Empty - * string otherwise. - */ - readonly architecture: string; - /** - * A vendor-specific identifier for the adapter, if available. Empty string otherwise. - * Note: This is a value that represents the type of adapter. For example, it may be a - * [PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of - * hardware like a serial number. - */ - readonly device: string; - /** - * A human readable string describing the adapter as reported by the driver, if available. - * Empty string otherwise. - * Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse - * this value is not recommended. Applications which change their behavior based on the - * {@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the - * other fields when possible. - */ - readonly description: string; - /** - * If the "subgroups" feature is supported, the minimum supported subgroup size for the - * adapter. - * - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly subgroupMinSize?: number; - /** - * If the "subgroups" feature is supported, the maximum supported subgroup size for the - * adapter. - * - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly subgroupMaxSize?: number; - /** - * Whether the adapter is a fallback adapter. - **/ - readonly isFallbackAdapter: boolean; -} - -declare var GPUAdapterInfo: { - prototype: GPUAdapterInfo; - new (): never; -}; - -interface GPUBindGroup - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUBindGroup"; -} - -declare var GPUBindGroup: { - prototype: GPUBindGroup; - new (): never; -}; - -interface GPUBindGroupLayout - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUBindGroupLayout"; -} - -declare var GPUBindGroupLayout: { - prototype: GPUBindGroupLayout; - new (): never; -}; - -interface GPUBuffer - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUBuffer"; - readonly size: GPUSize64Out; - readonly usage: GPUFlagsConstant; - readonly mapState: GPUBufferMapState; - /** - * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the - * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. - * The resolution of the returned Promise **only** indicates that the buffer has been mapped. - * It does not guarantee the completion of any other operations visible to the content timeline, - * and in particular does not imply that any other Promise returned from - * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s - * have resolved. - * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} - * **does** imply the completion of - * {@link GPUBuffer#mapAsync} calls made prior to that call, - * on {@link GPUBuffer}s last used exclusively on that queue. - * @param mode - Whether the buffer should be mapped for reading or writing. - * @param offset - Offset in bytes into the buffer to the start of the range to map. - * @param size - Size in bytes of the range to map. - */ - mapAsync( - mode: GPUMapModeFlags, - offset?: GPUSize64, - size?: GPUSize64 - ): Promise; - /** - * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range. - * @param offset - Offset in bytes into the buffer to return buffer contents from. - * @param size - Size in bytes of the ArrayBuffer to return. - */ - getMappedRange( - offset?: GPUSize64, - size?: GPUSize64 - ): ArrayBuffer; - /** - * Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the - * GPU again. - */ - unmap(): undefined; - /** - * Destroys the {@link GPUBuffer}. - * Note: It is valid to destroy a buffer multiple times. - * Note: Since no further operations can be enqueued using this buffer, implementations can - * free resource allocations, including mapped memory that was just unmapped. - */ - destroy(): undefined; -} - -declare var GPUBuffer: { - prototype: GPUBuffer; - new (): never; -}; - -interface GPUCanvasContext { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUCanvasContext"; - /** - * The canvas this context was created from. - */ - readonly canvas: - | HTMLCanvasElement - | OffscreenCanvas; - /** - * Configures the context for this canvas. - * This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). - * See {@link GPUCanvasContext#getConfiguration} for information on feature detection. - * @param configuration - Desired configuration for the context. - */ - configure( - configuration: GPUCanvasConfiguration - ): undefined; - /** - * Removes the context configuration. Destroys any textures produced while configured. - */ - unconfigure(): undefined; - /** - * Returns the context configuration, or `null` if the context is not configured. - * Note: - * This method exists primarily for feature detection of members (and sub-members) of - * {@link GPUCanvasConfiguration}; see those members for details. - * For supported members, it returns the originally-supplied values. - */ - getConfiguration(): GPUCanvasConfigurationOut | null; - /** - * Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} - * next. - * Note: The same {@link GPUTexture} object will be returned by every - * call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" - * runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. - */ - getCurrentTexture(): GPUTexture; -} - -declare var GPUCanvasContext: { - prototype: GPUCanvasContext; - new (): never; -}; - -interface GPUCommandBuffer - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUCommandBuffer"; -} - -declare var GPUCommandBuffer: { - prototype: GPUCommandBuffer; - new (): never; -}; - -interface GPUCommandEncoder - extends GPUObjectBase, - GPUCommandsMixin, - GPUDebugCommandsMixin { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUCommandEncoder"; - /** - * Begins encoding a render pass described by `descriptor`. - * @param descriptor - Description of the {@link GPURenderPassEncoder} to create. - */ - beginRenderPass( - descriptor: GPURenderPassDescriptor - ): GPURenderPassEncoder; - beginComputePass( - descriptor?: GPUComputePassDescriptor - ): GPUComputePassEncoder; - /** - * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}. - */ - copyBufferToBuffer( - source: GPUBuffer, - destination: GPUBuffer, - size?: GPUSize64 - ): undefined; - /** - * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a - * {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. - * @param source - The {@link GPUBuffer} to copy from. - * @param sourceOffset - Offset in bytes into `source` to begin copying from. - * @param destination - The {@link GPUBuffer} to copy to. - * @param destinationOffset - Offset in bytes into `destination` to place the copied data. - * @param size - Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`. - */ - copyBufferToBuffer( - source: GPUBuffer, - sourceOffset: GPUSize64, - destination: GPUBuffer, - destinationOffset: GPUSize64, - size?: GPUSize64 - ): undefined; - /** - * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a - * {@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. - * @param source - Combined with `copySize`, defines the region of the source buffer. - * @param destination - Combined with `copySize`, defines the region of the destination texture subresource. - * `copySize`: - */ - copyBufferToTexture( - source: GPUTexelCopyBufferInfo, - destination: GPUTexelCopyTextureInfo, - copySize: GPUExtent3DStrict - ): undefined; - /** - * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or - * multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. - * @param source - Combined with `copySize`, defines the region of the source texture subresources. - * @param destination - Combined with `copySize`, defines the region of the destination buffer. - * `copySize`: - */ - copyTextureToBuffer( - source: GPUTexelCopyTextureInfo, - destination: GPUTexelCopyBufferInfo, - copySize: GPUExtent3DStrict - ): undefined; - /** - * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one - * or multiple contiguous texture subresources to another sub-region of one or - * multiple continuous texture subresources. - * @param source - Combined with `copySize`, defines the region of the source texture subresources. - * @param destination - Combined with `copySize`, defines the region of the destination texture subresources. - * `copySize`: - */ - copyTextureToTexture( - source: GPUTexelCopyTextureInfo, - destination: GPUTexelCopyTextureInfo, - copySize: GPUExtent3DStrict - ): undefined; - /** - * Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a - * {@link GPUBuffer} with zeros. - * @param buffer - The {@link GPUBuffer} to clear. - * @param offset - Offset in bytes into `buffer` where the sub-region to clear begins. - * @param size - Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`. - */ - clearBuffer( - buffer: GPUBuffer, - offset?: GPUSize64, - size?: GPUSize64 - ): undefined; - /** - * Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. - * querySet: - * firstQuery: - * queryCount: - * destination: - * destinationOffset: - */ - resolveQuerySet( - querySet: GPUQuerySet, - firstQuery: GPUSize32, - queryCount: GPUSize32, - destination: GPUBuffer, - destinationOffset: GPUSize64 - ): undefined; - /** - * Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. - * descriptor: - */ - finish( - descriptor?: GPUCommandBufferDescriptor - ): GPUCommandBuffer; -} - -declare var GPUCommandEncoder: { - prototype: GPUCommandEncoder; - new (): never; -}; - -interface GPUCompilationInfo { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUCompilationInfo"; - readonly messages: ReadonlyArray; -} - -declare var GPUCompilationInfo: { - prototype: GPUCompilationInfo; - new (): never; -}; - -interface GPUCompilationMessage { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUCompilationMessage"; - /** - * The human-readable, localizable text for this compilation message. - * Note: The {@link GPUCompilationMessage#message} should follow the best practices for language - * and direction information. This includes making use of any future standards which may - * emerge regarding the reporting of string language and direction metadata. - *

Editorial note: - * At the time of this writing, no language/direction recommendation is available that provides - * compatibility and consistency with legacy APIs, but when there is, adopt it formally. - */ - readonly message: string; - /** - * The severity level of the message. - * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it - * corresponds to a shader-creation error. - */ - readonly type: GPUCompilationMessageType; - /** - * The line number in the shader {@link GPUShaderModuleDescriptor#code} the - * {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of - * `1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are - * delimited by line breaks. - * If the {@link GPUCompilationMessage#message} corresponds to a substring this points to - * the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message} - * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. - */ - readonly lineNum: number; - /** - * The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum} - * of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring - * that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a - * {@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line. - * If {@link GPUCompilationMessage#message} corresponds to a substring this points to the - * first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message} - * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. - */ - readonly linePos: number; - /** - * The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16 - * code units to the point or beginning of the substring that {@link GPUCompilationMessage#message} - * corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and - * {@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message} - * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}. - */ - readonly offset: number; - /** - * The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message} - * corresponds to. If the message does not correspond with a substring then - * {@link GPUCompilationMessage#length} must be 0. - */ - readonly length: number; -} - -declare var GPUCompilationMessage: { - prototype: GPUCompilationMessage; - new (): never; -}; - -interface GPUComputePassEncoder - extends GPUObjectBase, - GPUCommandsMixin, - GPUDebugCommandsMixin, - GPUBindingCommandsMixin { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUComputePassEncoder"; - /** - * Sets the current {@link GPUComputePipeline}. - * @param pipeline - The compute pipeline to use for subsequent dispatch commands. - */ - setPipeline( - pipeline: GPUComputePipeline - ): undefined; - /** - * Dispatch work to be performed with the current {@link GPUComputePipeline}. - * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. - * @param workgroupCountX - X dimension of the grid of workgroups to dispatch. - * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch. - * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch. - */ - dispatchWorkgroups( - workgroupCountX: GPUSize32, - workgroupCountY?: GPUSize32, - workgroupCountZ?: GPUSize32 - ): undefined; - /** - * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read - * from a {@link GPUBuffer}. - * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. - * packed block of **three 32-bit unsigned integer values (12 bytes total)**, - * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. - * For example: - * @param indirectBuffer - Buffer containing the indirect dispatch parameters. - * @param indirectOffset - Offset in bytes into `indirectBuffer` where the dispatch data begins. - */ - dispatchWorkgroupsIndirect( - indirectBuffer: GPUBuffer, - indirectOffset: GPUSize64 - ): undefined; - /** - * Completes recording of the compute pass commands sequence. - */ - end(): undefined; -} - -declare var GPUComputePassEncoder: { - prototype: GPUComputePassEncoder; - new (): never; -}; - -interface GPUComputePipeline - extends GPUObjectBase, - GPUPipelineBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUComputePipeline"; -} - -declare var GPUComputePipeline: { - prototype: GPUComputePipeline; - new (): never; -}; - -interface GPUDevice - extends EventTarget, - GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUDevice"; - /** - * A set containing the {@link GPUFeatureName} values of the features - * supported by the device (i.e. the ones with which it was created). - */ - readonly features: GPUSupportedFeatures; - /** - * Exposes the limits supported by the device - * (which are exactly the ones with which it was created). - */ - readonly limits: GPUSupportedLimits; - /** - * Information about the physical adapter which created the device - * that this GPUDevice refers to. - * For a given GPUDevice, the GPUAdapterInfo values exposed are constant - * over time. - */ - readonly adapterInfo: GPUAdapterInfo; - /** - * The primary {@link GPUQueue} for this device. - */ - readonly queue: GPUQueue; - /** - * Destroys the device, preventing further operations on it. - * Outstanding asynchronous operations will fail. - * Note: It is valid to destroy a device multiple times. - * Note: Since no further operations can be enqueued on this device, implementations can abort - * outstanding asynchronous operations immediately and free resource allocations, including - * mapped memory that was just unmapped. - */ - destroy(): undefined; - /** - * Creates a {@link GPUBuffer}. - * @param descriptor - Description of the {@link GPUBuffer} to create. - */ - createBuffer( - descriptor: GPUBufferDescriptor - ): GPUBuffer; - /** - * Creates a {@link GPUTexture}. - * @param descriptor - Description of the {@link GPUTexture} to create. - */ - createTexture( - descriptor: GPUTextureDescriptor - ): GPUTexture; - /** - * Creates a {@link GPUSampler}. - * @param descriptor - Description of the {@link GPUSampler} to create. - */ - createSampler( - descriptor?: GPUSamplerDescriptor - ): GPUSampler; - /** - * Creates a {@link GPUExternalTexture} wrapping the provided image source. - * @param descriptor - Provides the external image source object (and any creation options). - */ - importExternalTexture( - descriptor: GPUExternalTextureDescriptor - ): GPUExternalTexture; - /** - * Creates a {@link GPUBindGroupLayout}. - * @param descriptor - Description of the {@link GPUBindGroupLayout} to create. - */ - createBindGroupLayout( - descriptor: GPUBindGroupLayoutDescriptor - ): GPUBindGroupLayout; - /** - * Creates a {@link GPUPipelineLayout}. - * @param descriptor - Description of the {@link GPUPipelineLayout} to create. - */ - createPipelineLayout( - descriptor: GPUPipelineLayoutDescriptor - ): GPUPipelineLayout; - /** - * Creates a {@link GPUBindGroup}. - * @param descriptor - Description of the {@link GPUBindGroup} to create. - */ - createBindGroup( - descriptor: GPUBindGroupDescriptor - ): GPUBindGroup; - /** - * Creates a {@link GPUShaderModule}. - * @param descriptor - Description of the {@link GPUShaderModule} to create. - */ - createShaderModule( - descriptor: GPUShaderModuleDescriptor - ): GPUShaderModule; - /** - * Creates a {@link GPUComputePipeline} using immediate pipeline creation. - * @param descriptor - Description of the {@link GPUComputePipeline} to create. - */ - createComputePipeline( - descriptor: GPUComputePipelineDescriptor - ): GPUComputePipeline; - /** - * Creates a {@link GPURenderPipeline} using immediate pipeline creation. - * @param descriptor - Description of the {@link GPURenderPipeline} to create. - */ - createRenderPipeline( - descriptor: GPURenderPipelineDescriptor - ): GPURenderPipeline; - /** - * Creates a {@link GPUComputePipeline} using async pipeline creation. - * The returned Promise resolves when the created pipeline - * is ready to be used without additional delay. - * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. - * (A {@link GPUError} is not dispatched to the device.) - * Note: Use of this method is preferred whenever possible, as it prevents blocking the - * queue timeline work on pipeline compilation. - * @param descriptor - Description of the {@link GPUComputePipeline} to create. - */ - createComputePipelineAsync( - descriptor: GPUComputePipelineDescriptor - ): Promise; - /** - * Creates a {@link GPURenderPipeline} using async pipeline creation. - * The returned Promise resolves when the created pipeline - * is ready to be used without additional delay. - * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. - * (A {@link GPUError} is not dispatched to the device.) - * Note: Use of this method is preferred whenever possible, as it prevents blocking the - * queue timeline work on pipeline compilation. - * @param descriptor - Description of the {@link GPURenderPipeline} to create. - */ - createRenderPipelineAsync( - descriptor: GPURenderPipelineDescriptor - ): Promise; - /** - * Creates a {@link GPUCommandEncoder}. - * @param descriptor - Description of the {@link GPUCommandEncoder} to create. - */ - createCommandEncoder( - descriptor?: GPUCommandEncoderDescriptor - ): GPUCommandEncoder; - /** - * Creates a {@link GPURenderBundleEncoder}. - * @param descriptor - Description of the {@link GPURenderBundleEncoder} to create. - */ - createRenderBundleEncoder( - descriptor: GPURenderBundleEncoderDescriptor - ): GPURenderBundleEncoder; - /** - * Creates a {@link GPUQuerySet}. - * @param descriptor - Description of the {@link GPUQuerySet} to create. - */ - createQuerySet( - descriptor: GPUQuerySetDescriptor - ): GPUQuerySet; - /** - * A slot-backed attribute holding a promise which is created with the device, remains - * pending for the lifetime of the device, then resolves when the device is lost. - * Upon initialization, it is set to a new promise. - */ - readonly lost: Promise; - /** - * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`. - * @param filter - Which class of errors this error scope observes. - */ - pushErrorScope( - filter: GPUErrorFilter - ): undefined; - /** - * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` - * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. - * There is no guarantee of the ordering of promise resolution. - */ - popErrorScope(): Promise; - /** - * An event handler IDL attribute for the `uncapturederror` event type. - */ - onuncapturederror: - | (( - this: GPUDevice, - ev: GPUUncapturedErrorEvent - ) => any) - | null; -} - -declare var GPUDevice: { - prototype: GPUDevice; - new (): never; -}; - -interface GPUDeviceLostInfo { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUDeviceLostInfo"; - readonly reason: GPUDeviceLostReason; - readonly message: string; -} - -declare var GPUDeviceLostInfo: { - prototype: GPUDeviceLostInfo; - new (): never; -}; - -interface GPUError { - /** - * A human-readable, localizable text message providing information about the error that - * occurred. - * Note: This message is generally intended for application developers to debug their - * applications and capture information for debug reports, not to be surfaced to end-users. - * Note: User agents should not include potentially machine-parsable details in this message, - * such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the - * conditions under which memory was exhausted. - * Note: The {@link GPUError#message} should follow the best practices for language and - * direction information. This includes making use of any future standards which may emerge - * regarding the reporting of string language and direction metadata. - *

Editorial note: - * At the time of this writing, no language/direction recommendation is available that provides - * compatibility and consistency with legacy APIs, but when there is, adopt it formally. - */ - readonly message: string; -} - -declare var GPUError: { - prototype: GPUError; - new (): never; -}; - -interface GPUExternalTexture - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUExternalTexture"; -} - -declare var GPUExternalTexture: { - prototype: GPUExternalTexture; - new (): never; -}; - -interface GPUInternalError - extends GPUError { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUInternalError"; -} - -declare var GPUInternalError: { - prototype: GPUInternalError; - new ( - message: string - ): GPUInternalError; -}; - -interface GPUOutOfMemoryError - extends GPUError { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUOutOfMemoryError"; -} - -declare var GPUOutOfMemoryError: { - prototype: GPUOutOfMemoryError; - new ( - message: string - ): GPUOutOfMemoryError; -}; - -interface GPUPipelineError - extends DOMException { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUPipelineError"; - /** - * A read-only slot-backed attribute exposing the type of error encountered in pipeline creation - * as a GPUPipelineErrorReason: - *

    - * - "validation": A [$validation error$]. - * - "internal": An [$internal error$]. - *
- */ - readonly reason: GPUPipelineErrorReason; -} - -declare var GPUPipelineError: { - prototype: GPUPipelineError; - new ( - message: - | string - | undefined, - options: GPUPipelineErrorInit - ): GPUPipelineError; -}; - -interface GPUPipelineLayout - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUPipelineLayout"; -} - -declare var GPUPipelineLayout: { - prototype: GPUPipelineLayout; - new (): never; -}; - -interface GPUQuerySet - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUQuerySet"; - /** - * Destroys the {@link GPUQuerySet}. - */ - destroy(): undefined; - /** - * The type of the queries managed by this {@link GPUQuerySet}. - */ - readonly type: GPUQueryType; - /** - * The number of queries managed by this {@link GPUQuerySet}. - */ - readonly count: GPUSize32Out; -} - -declare var GPUQuerySet: { - prototype: GPUQuerySet; - new (): never; -}; - -interface GPUQueue - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUQueue"; - /** - * Schedules the execution of the command buffers by the GPU on this queue. - * Submitted command buffers cannot be used again. - * `commandBuffers`: - */ - submit( - commandBuffers: Iterable - ): undefined; - /** - * Returns a Promise that resolves once this queue finishes processing all the work submitted - * up to this moment. - * Resolution of this Promise implies the completion of - * {@link GPUBuffer#mapAsync} calls made prior to that call, - * on {@link GPUBuffer}s last used exclusively on that queue. - */ - onSubmittedWorkDone(): Promise; - /** - * Issues a write operation of the provided data into a {@link GPUBuffer}. - * @param buffer - The buffer to write to. - * @param bufferOffset - Offset in bytes into `buffer` to begin writing at. - * @param data - Data to write into `buffer`. - * @param dataOffset - Offset in into `data` to begin writing from. Given in elements if - * `data` is a `TypedArray` and bytes otherwise. - * @param size - Size of content to write from `data` to `buffer`. Given in elements if - * `data` is a `TypedArray` and bytes otherwise. - */ - writeBuffer( - buffer: GPUBuffer, - bufferOffset: GPUSize64, - data: GPUAllowSharedBufferSource, - dataOffset?: GPUSize64, - size?: GPUSize64 - ): undefined; - /** - * Issues a write operation of the provided data into a {@link GPUTexture}. - * @param destination - The texture subresource and origin to write to. - * @param data - Data to write into `destination`. - * @param dataLayout - Layout of the content in `data`. - * @param size - Extents of the content to write from `data` to `destination`. - */ - writeTexture( - destination: GPUTexelCopyTextureInfo, - data: GPUAllowSharedBufferSource, - dataLayout: GPUTexelCopyBufferLayout, - size: GPUExtent3DStrict - ): undefined; - /** - * Issues a copy operation of the contents of a platform image/canvas - * into the destination texture. - * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination - * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}. - * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded - * values, as copying into the corresponding non-`-srgb` format. - * Thus, after a copy operation, sampling the destination texture has - * different results depending on whether its format is `-srgb`, all else unchanged. - * - * @param source - source image and origin to copy to `destination`. - * @param destination - The texture subresource and origin to write to, and its encoding metadata. - * @param copySize - Extents of the content to write from `source` to `destination`. - */ - copyExternalImageToTexture( - source: GPUCopyExternalImageSourceInfo, - destination: GPUCopyExternalImageDestInfo, - copySize: GPUExtent3DStrict - ): undefined; -} - -declare var GPUQueue: { - prototype: GPUQueue; - new (): never; -}; - -interface GPURenderBundle - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPURenderBundle"; -} - -declare var GPURenderBundle: { - prototype: GPURenderBundle; - new (): never; -}; - -interface GPURenderBundleEncoder - extends GPUObjectBase, - GPUCommandsMixin, - GPUDebugCommandsMixin, - GPUBindingCommandsMixin, - GPURenderCommandsMixin { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPURenderBundleEncoder"; - /** - * Completes recording of the render bundle commands sequence. - * descriptor: - */ - finish( - descriptor?: GPURenderBundleDescriptor - ): GPURenderBundle; -} - -declare var GPURenderBundleEncoder: { - prototype: GPURenderBundleEncoder; - new (): never; -}; - -interface GPURenderPassEncoder - extends GPUObjectBase, - GPUCommandsMixin, - GPUDebugCommandsMixin, - GPUBindingCommandsMixin, - GPURenderCommandsMixin { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPURenderPassEncoder"; - /** - * Sets the viewport used during the rasterization stage to linearly map from - * NDC|normalized device coordinates to viewport coordinates. - * @param x - Minimum X value of the viewport in pixels. - * @param y - Minimum Y value of the viewport in pixels. - * @param width - Width of the viewport in pixels. - * @param height - Height of the viewport in pixels. - * @param minDepth - Minimum depth value of the viewport. - * @param maxDepth - Maximum depth value of the viewport. - */ - setViewport( - x: number, - y: number, - width: number, - height: number, - minDepth: number, - maxDepth: number - ): undefined; - /** - * Sets the scissor rectangle used during the rasterization stage. - * After transformation into viewport coordinates any fragments which fall outside the scissor - * rectangle will be discarded. - * @param x - Minimum X value of the scissor rectangle in pixels. - * @param y - Minimum Y value of the scissor rectangle in pixels. - * @param width - Width of the scissor rectangle in pixels. - * @param height - Height of the scissor rectangle in pixels. - */ - setScissorRect( - x: GPUIntegerCoordinate, - y: GPUIntegerCoordinate, - width: GPUIntegerCoordinate, - height: GPUIntegerCoordinate - ): undefined; - /** - * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` - * and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. - * @param color - The color to use when blending. - */ - setBlendConstant( - color: GPUColor - ): undefined; - /** - * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with - * the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. - * @param reference - The new stencil reference value. - */ - setStencilReference( - reference: GPUStencilValue - ): undefined; - /** - * @param queryIndex - The index of the query in the query set. - */ - beginOcclusionQuery( - queryIndex: GPUSize32 - ): undefined; - /** - */ - endOcclusionQuery(): undefined; - /** - * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of - * this render pass. - * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind - * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render - * pass's pipeline, bind group, and vertex/index buffer state is cleared - * (to the initial, empty values). - * Note: The state is cleared, not restored to the previous state. - * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. - * @param bundles - List of render bundles to execute. - */ - executeBundles( - bundles: Iterable - ): undefined; - /** - * Completes recording of the render pass commands sequence. - */ - end(): undefined; -} - -declare var GPURenderPassEncoder: { - prototype: GPURenderPassEncoder; - new (): never; -}; - -interface GPURenderPipeline - extends GPUObjectBase, - GPUPipelineBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPURenderPipeline"; -} - -declare var GPURenderPipeline: { - prototype: GPURenderPipeline; - new (): never; -}; - -interface GPUSampler - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUSampler"; -} - -declare var GPUSampler: { - prototype: GPUSampler; - new (): never; -}; - -interface GPUShaderModule - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUShaderModule"; - /** - * Returns any messages generated during the {@link GPUShaderModule}'s compilation. - * The locations, order, and contents of messages are implementation-defined. - * In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. - */ - getCompilationInfo(): Promise; -} - -declare var GPUShaderModule: { - prototype: GPUShaderModule; - new (): never; -}; - -type GPUSupportedFeatures = - ReadonlySet; - -interface GPUSupportedLimits { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUSupportedLimits"; - readonly maxTextureDimension1D: number; - readonly maxTextureDimension2D: number; - readonly maxTextureDimension3D: number; - readonly maxTextureArrayLayers: number; - readonly maxBindGroups: number; - readonly maxBindGroupsPlusVertexBuffers: number; - readonly maxBindingsPerBindGroup: number; - readonly maxDynamicUniformBuffersPerPipelineLayout: number; - readonly maxDynamicStorageBuffersPerPipelineLayout: number; - readonly maxSampledTexturesPerShaderStage: number; - readonly maxSamplersPerShaderStage: number; - readonly maxStorageBuffersPerShaderStage: number; - /** - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly maxStorageBuffersInVertexStage?: number; - /** - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly maxStorageBuffersInFragmentStage?: number; - readonly maxStorageTexturesPerShaderStage: number; - /** - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly maxStorageTexturesInVertexStage?: number; - /** - * @todo Temporarily optional until all browsers have implemented it. - * Check support before using. (Use the non-null assertion operator `!` where needed.) - */ - readonly maxStorageTexturesInFragmentStage?: number; - readonly maxUniformBuffersPerShaderStage: number; - readonly maxUniformBufferBindingSize: number; - readonly maxStorageBufferBindingSize: number; - readonly minUniformBufferOffsetAlignment: number; - readonly minStorageBufferOffsetAlignment: number; - readonly maxVertexBuffers: number; - readonly maxBufferSize: number; - readonly maxVertexAttributes: number; - readonly maxVertexBufferArrayStride: number; - readonly maxInterStageShaderVariables: number; - readonly maxColorAttachments: number; - readonly maxColorAttachmentBytesPerSample: number; - readonly maxComputeWorkgroupStorageSize: number; - readonly maxComputeInvocationsPerWorkgroup: number; - readonly maxComputeWorkgroupSizeX: number; - readonly maxComputeWorkgroupSizeY: number; - readonly maxComputeWorkgroupSizeZ: number; - readonly maxComputeWorkgroupsPerDimension: number; - readonly maxImmediateSize: number; -} - -declare var GPUSupportedLimits: { - prototype: GPUSupportedLimits; - new (): never; -}; - -interface GPUTexture - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUTexture"; - /** - * Creates a {@link GPUTextureView}. - * @param descriptor - Description of the {@link GPUTextureView} to create. - */ - createView( - descriptor?: GPUTextureViewDescriptor - ): GPUTextureView; - /** - * Destroys the {@link GPUTexture}. - */ - destroy(): undefined; - /** - * The width of this {@link GPUTexture}. - */ - readonly width: GPUIntegerCoordinateOut; - /** - * The height of this {@link GPUTexture}. - */ - readonly height: GPUIntegerCoordinateOut; - /** - * The depth or layer count of this {@link GPUTexture}. - */ - readonly depthOrArrayLayers: GPUIntegerCoordinateOut; - /** - * The number of mip levels of this {@link GPUTexture}. - */ - readonly mipLevelCount: GPUIntegerCoordinateOut; - /** - * The number of sample count of this {@link GPUTexture}. - */ - readonly sampleCount: GPUSize32Out; - /** - * The dimension of the set of texel for each of this {@link GPUTexture}'s subresources. - */ - readonly dimension: GPUTextureDimension; - /** - * The format of this {@link GPUTexture}. - */ - readonly format: GPUTextureFormat; - /** - * The allowed usages for this {@link GPUTexture}. - */ - readonly usage: GPUFlagsConstant; - /** - * On devices without "core-features-and-limits", views created from this - * texture must have this as their dimension. - * - * On devices with "core-features-and-limits", this is undefined, and there is - * no such restriction. - * - * @todo Temporarily optional until all browsers have implemented it. - * It is safe to access on any browser, as it will just (correctly) return - * `undefined` if not implemented. Note, depending on the device, `undefined` - * is a valid value even in browsers that implement this attribute. (So be - * careful if using the non-null assertion operator `!` on this.) - */ - readonly textureBindingViewDimension?: - | GPUTextureViewDimension - | undefined; -} - -declare var GPUTexture: { - prototype: GPUTexture; - new (): never; -}; - -interface GPUTextureView - extends GPUObjectBase { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUTextureView"; -} - -declare var GPUTextureView: { - prototype: GPUTextureView; - new (): never; -}; - -interface GPUUncapturedErrorEvent - extends Event { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUUncapturedErrorEvent"; - /** - * A slot-backed attribute holding an object representing the error that was uncaptured. - * This has the same type as errors returned by {@link GPUDevice#popErrorScope}. - */ - readonly error: GPUError; -} - -declare var GPUUncapturedErrorEvent: { - prototype: GPUUncapturedErrorEvent; - new ( - type: string, - gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit - ): GPUUncapturedErrorEvent; -}; - -interface GPUValidationError - extends GPUError { - /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */ - readonly __brand: "GPUValidationError"; -} - -declare var GPUValidationError: { - prototype: GPUValidationError; - new ( - message: string - ): GPUValidationError; -}; - -type WGSLLanguageFeatures = - ReadonlySet; - -interface Navigator - extends NavigatorGPU {} - -interface WorkerNavigator - extends NavigatorGPU {} - -interface GPUBufferUsage { - readonly MAP_READ: GPUFlagsConstant; - readonly MAP_WRITE: GPUFlagsConstant; - readonly COPY_SRC: GPUFlagsConstant; - readonly COPY_DST: GPUFlagsConstant; - readonly INDEX: GPUFlagsConstant; - readonly VERTEX: GPUFlagsConstant; - readonly UNIFORM: GPUFlagsConstant; - readonly STORAGE: GPUFlagsConstant; - readonly INDIRECT: GPUFlagsConstant; - readonly QUERY_RESOLVE: GPUFlagsConstant; -} - -declare var GPUBufferUsage: GPUBufferUsage; - -interface GPUColorWrite { - readonly RED: GPUFlagsConstant; - readonly GREEN: GPUFlagsConstant; - readonly BLUE: GPUFlagsConstant; - readonly ALPHA: GPUFlagsConstant; - readonly ALL: GPUFlagsConstant; -} - -declare var GPUColorWrite: GPUColorWrite; - -interface GPUMapMode { - readonly READ: GPUFlagsConstant; - readonly WRITE: GPUFlagsConstant; -} - -declare var GPUMapMode: GPUMapMode; - -interface GPUShaderStage { - readonly VERTEX: GPUFlagsConstant; - readonly FRAGMENT: GPUFlagsConstant; - readonly COMPUTE: GPUFlagsConstant; -} - -declare var GPUShaderStage: GPUShaderStage; - -interface GPUTextureUsage { - readonly COPY_SRC: GPUFlagsConstant; - readonly COPY_DST: GPUFlagsConstant; - readonly TEXTURE_BINDING: GPUFlagsConstant; - readonly STORAGE_BINDING: GPUFlagsConstant; - readonly RENDER_ATTACHMENT: GPUFlagsConstant; - readonly TRANSIENT_ATTACHMENT: GPUFlagsConstant; -} - -declare var GPUTextureUsage: GPUTextureUsage; diff --git a/apigen/definitions/test.json b/apigen/definitions/test.json new file mode 100644 index 00000000..18272efd --- /dev/null +++ b/apigen/definitions/test.json @@ -0,0 +1,69 @@ +{ + "flags": { + "SomeFlag": { + "doc": "", + "fields": { + "SOME_FIELD": { + "doc": "", + "value": 1 + } + } + } + }, + + "enums": { + "SomeEnum": { + "doc": "", + "fields": { + "some_field": { + "doc": "", + "value": "some-field" + } + } + } + }, + + "structs": { + "SomeStruct": { + "doc": "", + "fields": { + "some_field": { + "doc": "", + "type": "int", + "default": 0, + "required": false + } + } + } + }, + + "classes": { + "GPUSomeClass": { + "doc": "", + "bases": ["GPUObject"], + "properties": { + "some_prop": { + "doc": "", + "type": "int" + } + }, + "methods": { + "some_method": { + "doc": "", + "returns": { + "doc": "", + "type": "None" + }, + "args": { + "some_arg": { + "doc": "", + "type": "", + "default": "", + "required": true + } + } + } + } + } + } +} diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json new file mode 100644 index 00000000..4c189876 --- /dev/null +++ b/apigen/definitions/wgpu_api.json @@ -0,0 +1,3930 @@ +{ + "meta": { + "filename": "wgpu_api.json", + "description": "Definition of the base wgpu API, derived from 'wgpu_api_web.json', 'diff_base.json', 'docs_ai.json', 'docs_dev.json'.", + "notes": "The full API, including docs, in one file. This does *not* include enums/flags/structs from any of the backends." + }, + "flags": { + "BufferUsage": { + "fields": { + "MAP_READ": { + "value": 1, + "doc": "The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST." + }, + "MAP_WRITE": { + "value": 2, + "doc": "The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC." + }, + "COPY_SRC": { + "value": 4, + "doc": "The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer()." + }, + "COPY_DST": { + "value": 8, + "doc": "The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer()." + }, + "INDEX": { + "value": 16, + "doc": "The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer()." + }, + "VERTEX": { + "value": 32, + "doc": "The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer()." + }, + "UNIFORM": { + "value": 64, + "doc": "The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform." + }, + "STORAGE": { + "value": 128, + "doc": "The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage." + }, + "INDIRECT": { + "value": 256, + "doc": "The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect()." + }, + "QUERY_RESOLVE": { "value": 512, "doc": "The buffer can be the destination of GPUCommandEncoder.resolve_query_set()." } + }, + "doc": "Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator.\n\nThe usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards.\nUsing a buffer in a way that was not declared here results in a validation error.\n" + }, + "MapMode": { + "fields": { + "READ": { + "value": 1, + "doc": "Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ." + }, + "WRITE": { + "value": 2, + "doc": "Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE." + } + }, + "doc": "Bit flags that specify whether a buffer is mapped for reading or writing.\n\nUsed in the mode argument of the GPUBuffer.map_async() method. The mode must match the\nflags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE.\n" + }, + "TextureUsage": { + "fields": { + "COPY_SRC": { + "value": 1, + "doc": "The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer()." + }, + "COPY_DST": { + "value": 2, + "doc": "The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture()." + }, + "TEXTURE_BINDING": { + "value": 4, + "doc": "The texture can be bound for sampling in a shader, see structs.TextureBindingLayout." + }, + "STORAGE_BINDING": { + "value": 8, + "doc": "The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout." + }, + "RENDER_ATTACHMENT": { + "value": 16, + "doc": "The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor." + }, + "TRANSIENT_ATTACHMENT": { + "value": 32, + "doc": "The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard." + } + }, + "doc": "Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator.\n\nThe usage is set when creating the texture (see the usage field of structs.TextureDescriptor).\nTexture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor).\n" + }, + "ShaderStage": { + "fields": { + "VERTEX": { "value": 1, "doc": "The vertex shader stage." }, + "FRAGMENT": { "value": 2, "doc": "The fragment shader stage." }, + "COMPUTE": { "value": 4, "doc": "The compute shader stage." } + }, + "doc": "Bit flags that specify in which shader stages a resource is visible.\n\nUsed in the visibility field of structs.BindGroupLayoutEntry.\n" + }, + "ColorWrite": { + "fields": { + "RED": { "value": 1, "doc": "Write the red channel." }, + "GREEN": { "value": 2, "doc": "Write the green channel." }, + "BLUE": { "value": 4, "doc": "Write the blue channel." }, + "ALPHA": { "value": 8, "doc": "Write the alpha channel." }, + "ALL": { "value": 15, "doc": "Write all channels (RED, GREEN, BLUE and ALPHA)." } + }, + "doc": "Bit flags that specify which color channels of a render target are written to.\n\nUsed in the write_mask field of structs.ColorTargetState.\n" + } + }, + "enums": { + "PowerPreference": { + "fields": { + "low_power": { "value": "low-power", "doc": "Prefer an adapter that uses little power, e.g. an integrated GPU." }, + "high_performance": { + "value": "high-performance", + "doc": "Prefer an adapter with the highest performance, e.g. a discrete GPU." + } + }, + "doc": "Hint for which kind of adapter to select.\n\nUsed in the power_preference field of structs.RequestAdapterOptions. This is only a hint;\nthe implementation may ignore it.\n" + }, + "FeatureName": { + "fields": { + "core_features_and_limits": { + "value": "core-features-and-limits", + "doc": "Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode)." + }, + "depth_clip_control": { + "value": "depth-clip-control", + "doc": "Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState." + }, + "depth32float_stencil8": { "value": "depth32float-stencil8", "doc": "Enables enums.TextureFormat.depth32float_stencil8." }, + "texture_compression_bc": { + "value": "texture-compression-bc", + "doc": "Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm." + }, + "texture_compression_bc_sliced_d3": { + "value": "texture-compression-bc-sliced-3d", + "doc": "Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires enums.FeatureName.texture_compression_bc." + }, + "texture_compression_etc2": { + "value": "texture-compression-etc2", + "doc": "Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm." + }, + "texture_compression_astc": { + "value": "texture-compression-astc", + "doc": "Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm." + }, + "texture_compression_astc_sliced_d3": { + "value": "texture-compression-astc-sliced-3d", + "doc": "Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires enums.FeatureName.texture_compression_astc." + }, + "timestamp_query": { + "value": "timestamp-query", + "doc": "Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites." + }, + "indirect_first_instance": { + "value": "indirect-first-instance", + "doc": "Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect()." + }, + "shader_f16": { + "value": "shader-f16", + "doc": "Allows the use of the f16 type in WGSL shaders (the enable f16 directive)." + }, + "rg11b10ufloat_renderable": { + "value": "rg11b10ufloat-renderable", + "doc": "Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling." + }, + "bgra8unorm_storage": { + "value": "bgra8unorm-storage", + "doc": "Allows enums.TextureFormat.bgra8unorm to be used as a storage texture." + }, + "float32_filterable": { + "value": "float32-filterable", + "doc": "Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler." + }, + "float32_blendable": { + "value": "float32-blendable", + "doc": "Allows 32-bit float color attachments to be used with blending." + }, + "clip_distances": { + "value": "clip-distances", + "doc": "Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes." + }, + "dual_source_blending": { + "value": "dual-source-blending", + "doc": "Allows blending with a second fragment shader output, see enums.BlendFactor.src1." + }, + "subgroups": { "value": "subgroups", "doc": "Allows the use of subgroup operations in WGSL shaders." }, + "texture_formats_tier1": { + "value": "texture-formats-tier1", + "doc": "Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats." + }, + "texture_formats_tier2": { + "value": "texture-formats-tier2", + "doc": "Enables further texture format capabilities, such as read-write storage access for more formats. Requires enums.FeatureName.texture_formats_tier1." + }, + "primitive_index": { "value": "primitive-index", "doc": "Allows the primitive_index built-in in WGSL fragment shaders." }, + "texture_component_swizzle": { + "value": "texture-component-swizzle", + "doc": "Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor." + } + }, + "doc": "Names of optional features that an adapter may support and a device may request.\n\nAvailable features can be inspected via the features property of GPUAdapter. Features\nare enabled by listing them in the required_features field of structs.DeviceDescriptor.\nThe features of the device are available via the features property of GPUDevice.\n" + }, + "BufferMapState": { + "fields": { + "unmapped": { "value": "unmapped", "doc": "The buffer is not mapped; it can be used by the GPU." }, + "pending": { "value": "pending", "doc": "A GPUBuffer.map_async() call is in progress but has not yet completed." }, + "mapped": { + "value": "mapped", + "doc": "The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range()." + } + }, + "doc": "The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer.\n" + }, + "TextureDimension": { + "fields": { + "d1": { "value": "1d", "doc": "A one-dimensional texture, with only a width." }, + "d2": { + "value": "2d", + "doc": "A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers)." + }, + "d3": { "value": "3d", "doc": "A three-dimensional (volume) texture, with width, height and depth." } + }, + "doc": "The dimensionality of a GPUTexture.\n\nUsed in the dimension field of structs.TextureDescriptor.\n" + }, + "TextureViewDimension": { + "fields": { + "d1": { "value": "1d", "doc": "A one-dimensional view; corresponds to texture_1d in WGSL." }, + "d2": { + "value": "2d", + "doc": "A two-dimensional view of a single layer; corresponds to texture_2d in WGSL." + }, + "d2_array": { + "value": "2d-array", + "doc": "A view of an array of 2D layers; corresponds to texture_2d_array in WGSL." + }, + "cube": { + "value": "cube", + "doc": "A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL." + }, + "cube_array": { + "value": "cube-array", + "doc": "A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL." + }, + "d3": { "value": "3d", "doc": "A three-dimensional view; corresponds to texture_3d in WGSL." } + }, + "doc": "The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader.\n\nUsed in the dimension field of structs.TextureViewDescriptor and the view_dimension field of\nstructs.TextureBindingLayout and structs.StorageTextureBindingLayout.\n" + }, + "TextureAspect": { + "fields": { + "all": { "value": "all", "doc": "All available aspects of the texture format." }, + "stencil_only": { "value": "stencil-only", "doc": "Only the stencil aspect of a depth-stencil format." }, + "depth_only": { "value": "depth-only", "doc": "Only the depth aspect of a depth-stencil format." } + }, + "doc": "Which aspect (part) of a texture a view or copy operation refers to.\n\nThis is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects.\n" + }, + "TextureFormat": { + "fields": { + "r8unorm": { "value": "r8unorm", "doc": "One channel (red), 8-bit unsigned normalized." }, + "r8snorm": { "value": "r8snorm", "doc": "One channel (red), 8-bit signed normalized." }, + "r8uint": { "value": "r8uint", "doc": "One channel (red), 8-bit unsigned integer." }, + "r8sint": { "value": "r8sint", "doc": "One channel (red), 8-bit signed integer." }, + "r16unorm": { + "value": "r16unorm", + "doc": "One channel (red), 16-bit unsigned normalized. Requires enums.FeatureName.texture_formats_tier1." + }, + "r16snorm": { + "value": "r16snorm", + "doc": "One channel (red), 16-bit signed normalized. Requires enums.FeatureName.texture_formats_tier1." + }, + "r16uint": { "value": "r16uint", "doc": "One channel (red), 16-bit unsigned integer." }, + "r16sint": { "value": "r16sint", "doc": "One channel (red), 16-bit signed integer." }, + "r16float": { "value": "r16float", "doc": "One channel (red), 16-bit floating point." }, + "rg8unorm": { "value": "rg8unorm", "doc": "Two channels (red, green), 8-bit unsigned normalized each." }, + "rg8snorm": { "value": "rg8snorm", "doc": "Two channels (red, green), 8-bit signed normalized each." }, + "rg8uint": { "value": "rg8uint", "doc": "Two channels (red, green), 8-bit unsigned integer each." }, + "rg8sint": { "value": "rg8sint", "doc": "Two channels (red, green), 8-bit signed integer each." }, + "r32uint": { "value": "r32uint", "doc": "One channel (red), 32-bit unsigned integer." }, + "r32sint": { "value": "r32sint", "doc": "One channel (red), 32-bit signed integer." }, + "r32float": { "value": "r32float", "doc": "One channel (red), 32-bit floating point." }, + "rg16unorm": { + "value": "rg16unorm", + "doc": "Two channels (red, green), 16-bit unsigned normalized each. Requires enums.FeatureName.texture_formats_tier1." + }, + "rg16snorm": { + "value": "rg16snorm", + "doc": "Two channels (red, green), 16-bit signed normalized each. Requires enums.FeatureName.texture_formats_tier1." + }, + "rg16uint": { "value": "rg16uint", "doc": "Two channels (red, green), 16-bit unsigned integer each." }, + "rg16sint": { "value": "rg16sint", "doc": "Two channels (red, green), 16-bit signed integer each." }, + "rg16float": { "value": "rg16float", "doc": "Two channels (red, green), 16-bit floating point each." }, + "rgba8unorm": { + "value": "rgba8unorm", + "doc": "Four channels (red, green, blue, alpha), 8-bit unsigned normalized each." + }, + "rgba8unorm_srgb": { + "value": "rgba8unorm-srgb", + "doc": "Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels." + }, + "rgba8snorm": { "value": "rgba8snorm", "doc": "Four channels (RGBA), 8-bit signed normalized each." }, + "rgba8uint": { "value": "rgba8uint", "doc": "Four channels (RGBA), 8-bit unsigned integer each." }, + "rgba8sint": { "value": "rgba8sint", "doc": "Four channels (RGBA), 8-bit signed integer each." }, + "bgra8unorm": { + "value": "bgra8unorm", + "doc": "Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format()." + }, + "bgra8unorm_srgb": { + "value": "bgra8unorm-srgb", + "doc": "Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels." + }, + "rgb9e5ufloat": { + "value": "rgb9e5ufloat", + "doc": "Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable." + }, + "rgb10a2uint": { + "value": "rgb10a2uint", + "doc": "Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha." + }, + "rgb10a2unorm": { + "value": "rgb10a2unorm", + "doc": "Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha." + }, + "rg11b10ufloat": { + "value": "rg11b10ufloat", + "doc": "Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with enums.FeatureName.rg11b10ufloat_renderable." + }, + "rg32uint": { "value": "rg32uint", "doc": "Two channels (red, green), 32-bit unsigned integer each." }, + "rg32sint": { "value": "rg32sint", "doc": "Two channels (red, green), 32-bit signed integer each." }, + "rg32float": { "value": "rg32float", "doc": "Two channels (red, green), 32-bit floating point each." }, + "rgba16unorm": { + "value": "rgba16unorm", + "doc": "Four channels (RGBA), 16-bit unsigned normalized each. Requires enums.FeatureName.texture_formats_tier1." + }, + "rgba16snorm": { + "value": "rgba16snorm", + "doc": "Four channels (RGBA), 16-bit signed normalized each. Requires enums.FeatureName.texture_formats_tier1." + }, + "rgba16uint": { "value": "rgba16uint", "doc": "Four channels (RGBA), 16-bit unsigned integer each." }, + "rgba16sint": { "value": "rgba16sint", "doc": "Four channels (RGBA), 16-bit signed integer each." }, + "rgba16float": { "value": "rgba16float", "doc": "Four channels (RGBA), 16-bit floating point each." }, + "rgba32uint": { "value": "rgba32uint", "doc": "Four channels (RGBA), 32-bit unsigned integer each." }, + "rgba32sint": { "value": "rgba32sint", "doc": "Four channels (RGBA), 32-bit signed integer each." }, + "rgba32float": { "value": "rgba32float", "doc": "Four channels (RGBA), 32-bit floating point each." }, + "stencil8": { "value": "stencil8", "doc": "A stencil-only format with 8 bits per pixel." }, + "depth16unorm": { "value": "depth16unorm", "doc": "A depth-only format with 16-bit unsigned normalized depth." }, + "depth24plus": { + "value": "depth24plus", + "doc": "A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer." + }, + "depth24plus_stencil8": { + "value": "depth24plus-stencil8", + "doc": "A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer." + }, + "depth32float": { "value": "depth32float", "doc": "A depth-only format with 32-bit floating point depth." }, + "depth32float_stencil8": { + "value": "depth32float-stencil8", + "doc": "A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires enums.FeatureName.depth32float_stencil8." + }, + "bc1_rgba_unorm": { + "value": "bc1-rgba-unorm", + "doc": "BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires enums.FeatureName.texture_compression_bc." + }, + "bc1_rgba_unorm_srgb": { + "value": "bc1-rgba-unorm-srgb", + "doc": "BC1 (DXT1) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." + }, + "bc2_rgba_unorm": { + "value": "bc2-rgba-unorm", + "doc": "BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires enums.FeatureName.texture_compression_bc." + }, + "bc2_rgba_unorm_srgb": { + "value": "bc2-rgba-unorm-srgb", + "doc": "BC2 (DXT3) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." + }, + "bc3_rgba_unorm": { + "value": "bc3-rgba-unorm", + "doc": "BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires enums.FeatureName.texture_compression_bc." + }, + "bc3_rgba_unorm_srgb": { + "value": "bc3-rgba-unorm-srgb", + "doc": "BC3 (DXT5) compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." + }, + "bc4_r_unorm": { + "value": "bc4-r-unorm", + "doc": "BC4 compressed single channel, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." + }, + "bc4_r_snorm": { + "value": "bc4-r-snorm", + "doc": "BC4 compressed single channel, signed normalized. Requires enums.FeatureName.texture_compression_bc." + }, + "bc5_rg_unorm": { + "value": "bc5-rg-unorm", + "doc": "BC5 compressed two channels, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." + }, + "bc5_rg_snorm": { + "value": "bc5-rg-snorm", + "doc": "BC5 compressed two channels, signed normalized. Requires enums.FeatureName.texture_compression_bc." + }, + "bc6h_rgb_ufloat": { + "value": "bc6h-rgb-ufloat", + "doc": "BC6H compressed HDR RGB, unsigned float. Requires enums.FeatureName.texture_compression_bc." + }, + "bc6h_rgb_float": { + "value": "bc6h-rgb-float", + "doc": "BC6H compressed HDR RGB, signed float. Requires enums.FeatureName.texture_compression_bc." + }, + "bc7_rgba_unorm": { + "value": "bc7-rgba-unorm", + "doc": "BC7 compressed RGBA, unsigned normalized. Requires enums.FeatureName.texture_compression_bc." + }, + "bc7_rgba_unorm_srgb": { + "value": "bc7-rgba-unorm-srgb", + "doc": "BC7 compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_bc." + }, + "etc2_rgb8unorm": { + "value": "etc2-rgb8unorm", + "doc": "ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." + }, + "etc2_rgb8unorm_srgb": { + "value": "etc2-rgb8unorm-srgb", + "doc": "ETC2 compressed RGB with sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." + }, + "etc2_rgb8a1unorm": { + "value": "etc2-rgb8a1unorm", + "doc": "ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." + }, + "etc2_rgb8a1unorm_srgb": { + "value": "etc2-rgb8a1unorm-srgb", + "doc": "ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." + }, + "etc2_rgba8unorm": { + "value": "etc2-rgba8unorm", + "doc": "ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." + }, + "etc2_rgba8unorm_srgb": { + "value": "etc2-rgba8unorm-srgb", + "doc": "ETC2 compressed RGBA with sRGB encoding. Requires enums.FeatureName.texture_compression_etc2." + }, + "eac_r11unorm": { + "value": "eac-r11unorm", + "doc": "EAC compressed single channel, 11-bit unsigned normalized. Requires enums.FeatureName.texture_compression_etc2." + }, + "eac_r11snorm": { + "value": "eac-r11snorm", + "doc": "EAC compressed single channel, 11-bit signed normalized. Requires enums.FeatureName.texture_compression_etc2." + }, + "eac_rg11unorm": { + "value": "eac-rg11unorm", + "doc": "EAC compressed two channels, 11-bit unsigned normalized each. Requires enums.FeatureName.texture_compression_etc2." + }, + "eac_rg11snorm": { + "value": "eac-rg11snorm", + "doc": "EAC compressed two channels, 11-bit signed normalized each. Requires enums.FeatureName.texture_compression_etc2." + }, + "astc_4x4_unorm": { + "value": "astc-4x4-unorm", + "doc": "ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_4x4_unorm_srgb": { + "value": "astc-4x4-unorm-srgb", + "doc": "ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_5x4_unorm": { + "value": "astc-5x4-unorm", + "doc": "ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_5x4_unorm_srgb": { + "value": "astc-5x4-unorm-srgb", + "doc": "ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_5x5_unorm": { + "value": "astc-5x5-unorm", + "doc": "ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_5x5_unorm_srgb": { + "value": "astc-5x5-unorm-srgb", + "doc": "ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_6x5_unorm": { + "value": "astc-6x5-unorm", + "doc": "ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_6x5_unorm_srgb": { + "value": "astc-6x5-unorm-srgb", + "doc": "ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_6x6_unorm": { + "value": "astc-6x6-unorm", + "doc": "ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_6x6_unorm_srgb": { + "value": "astc-6x6-unorm-srgb", + "doc": "ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x5_unorm": { + "value": "astc-8x5-unorm", + "doc": "ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x5_unorm_srgb": { + "value": "astc-8x5-unorm-srgb", + "doc": "ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x6_unorm": { + "value": "astc-8x6-unorm", + "doc": "ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x6_unorm_srgb": { + "value": "astc-8x6-unorm-srgb", + "doc": "ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x8_unorm": { + "value": "astc-8x8-unorm", + "doc": "ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_8x8_unorm_srgb": { + "value": "astc-8x8-unorm-srgb", + "doc": "ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x5_unorm": { + "value": "astc-10x5-unorm", + "doc": "ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x5_unorm_srgb": { + "value": "astc-10x5-unorm-srgb", + "doc": "ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x6_unorm": { + "value": "astc-10x6-unorm", + "doc": "ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x6_unorm_srgb": { + "value": "astc-10x6-unorm-srgb", + "doc": "ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x8_unorm": { + "value": "astc-10x8-unorm", + "doc": "ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x8_unorm_srgb": { + "value": "astc-10x8-unorm-srgb", + "doc": "ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x10_unorm": { + "value": "astc-10x10-unorm", + "doc": "ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_10x10_unorm_srgb": { + "value": "astc-10x10-unorm-srgb", + "doc": "ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_12x10_unorm": { + "value": "astc-12x10-unorm", + "doc": "ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_12x10_unorm_srgb": { + "value": "astc-12x10-unorm-srgb", + "doc": "ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_12x12_unorm": { + "value": "astc-12x12-unorm", + "doc": "ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires enums.FeatureName.texture_compression_astc." + }, + "astc_12x12_unorm_srgb": { + "value": "astc-12x12-unorm-srgb", + "doc": "ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires enums.FeatureName.texture_compression_astc." + } + }, + "doc": "The pixel format of a GPUTexture.\n\nNames are of the form: channels, bit size per channel, and a type suffix.\nThe suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1),\nuint/sint = unsigned/signed integer, float = floating point, and srgb = the color\nis stored in sRGB and automatically converted to linear when sampled (and back when written).\nSome formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage).\n" + }, + "AddressMode": { + "fields": { + "clamp_to_edge": { + "value": "clamp-to-edge", + "doc": "Coordinates are clamped to the range 0..1, so the edge texels are repeated." + }, + "repeat": { "value": "repeat", "doc": "The texture tiles: only the fractional part of the coordinate is used." }, + "mirror_repeat": { "value": "mirror-repeat", "doc": "The texture tiles, but is mirrored every other repetition." } + }, + "doc": "How a sampler handles texture coordinates outside the 0..1 range, per axis.\n\nUsed in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor.\n" + }, + "FilterMode": { + "fields": { + "nearest": { "value": "nearest", "doc": "Use the value of the nearest texel." }, + "linear": { "value": "linear", "doc": "Linearly interpolate between the nearest texels." } + }, + "doc": "How a sampler filters texels when a texture is magnified or minified.\n\nUsed in the mag_filter and min_filter fields of structs.SamplerDescriptor.\n" + }, + "MipmapFilterMode": { + "fields": { + "nearest": { "value": "nearest", "doc": "Use the nearest mip level." }, + "linear": { "value": "linear", "doc": "Linearly interpolate between the two nearest mip levels." } + }, + "doc": "How a sampler filters between mip levels.\n\nUsed in the mipmap_filter field of structs.SamplerDescriptor.\n" + }, + "CompareFunction": { + "fields": { + "never": { "value": "never", "doc": "The comparison never passes." }, + "less": { "value": "less", "doc": "Passes if the new value is less than the existing value." }, + "equal": { "value": "equal", "doc": "Passes if the new value is equal to the existing value." }, + "less_equal": { + "value": "less-equal", + "doc": "Passes if the new value is less than or equal to the existing value." + }, + "greater": { "value": "greater", "doc": "Passes if the new value is greater than the existing value." }, + "not_equal": { "value": "not-equal", "doc": "Passes if the new value is not equal to the existing value." }, + "greater_equal": { + "value": "greater-equal", + "doc": "Passes if the new value is greater than or equal to the existing value." + }, + "always": { "value": "always", "doc": "The comparison always passes." } + }, + "doc": "A comparison function, used for depth testing, stencil testing and comparison samplers.\n\nThe comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to\nthe existing value. If the comparison is true, the test passes.\n" + }, + "BufferBindingType": { + "fields": { + "uniform": { + "value": "uniform", + "doc": "A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM." + }, + "storage": { "value": "storage", "doc": "A read-write storage buffer. Requires flags.BufferUsage.STORAGE." }, + "read_only_storage": { + "value": "read-only-storage", + "doc": "A read-only storage buffer. Requires flags.BufferUsage.STORAGE." + } + }, + "doc": "The type of a buffer binding in a bind group layout.\n\nUsed in the type field of structs.BufferBindingLayout.\n" + }, + "SamplerBindingType": { + "fields": { + "filtering": { + "value": "filtering", + "doc": "A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float." + }, + "non_filtering": { + "value": "non-filtering", + "doc": "A sampler that only uses nearest filtering. Can be used with any float texture." + }, + "comparison": { + "value": "comparison", + "doc": "A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor)." + } + }, + "doc": "The type of a sampler binding in a bind group layout.\n\nUsed in the type field of structs.SamplerBindingLayout.\n" + }, + "TextureSampleType": { + "fields": { + "float": { + "value": "float", + "doc": "Floating point values; the texture can be sampled with a filtering sampler." + }, + "unfilterable_float": { + "value": "unfilterable-float", + "doc": "Floating point values, but the texture cannot be filtered (e.g. 32-bit float without enums.FeatureName.float32_filterable)." + }, + "depth": { + "value": "depth", + "doc": "Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler." + }, + "sint": { "value": "sint", "doc": "Signed integer values." }, + "uint": { "value": "uint", "doc": "Unsigned integer values." } + }, + "doc": "The type of values that is returned when sampling a texture in a shader.\n\nUsed in the sample_type field of structs.TextureBindingLayout.\n" + }, + "StorageTextureAccess": { + "fields": { + "write_only": { "value": "write-only", "doc": "The shader can only write to the texture." }, + "read_only": { "value": "read-only", "doc": "The shader can only read from the texture." }, + "read_write": { "value": "read-write", "doc": "The shader can both read from and write to the texture." } + }, + "doc": "How a storage texture can be accessed by a shader.\n\nUsed in the access field of structs.StorageTextureBindingLayout.\n" + }, + "CompilationMessageType": { + "fields": { + "error": { "value": "error", "doc": "An error; the shader module is invalid." }, + "warning": { "value": "warning", "doc": "A warning; the shader module is valid but something may be wrong." }, + "info": { "value": "info", "doc": "An informational message." } + }, + "doc": "The severity of a GPUCompilationMessage.\n" + }, + "PipelineErrorReason": { + "fields": { + "validation": { + "value": "validation", + "doc": "The pipeline failed validation, e.g. because of an invalid descriptor or shader." + }, + "internal": { + "value": "internal", + "doc": "An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend." + } + }, + "doc": "The reason for a GPUPipelineError.\n\nAvailable via the reason property of GPUPipelineError.\n" + }, + "AutoLayoutMode": { + "fields": { + "auto": { "value": "auto", "doc": "Derive the pipeline layout from the shader." } + }, + "doc": "Indicates that a pipeline layout should be derived automatically from the shader code.\n\nUsed as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor.\nThe resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout().\n" + }, + "PrimitiveTopology": { + "fields": { + "point_list": { "value": "point-list", "doc": "Each vertex defines a point." }, + "line_list": { "value": "line-list", "doc": "Each pair of vertices defines a separate line." }, + "line_strip": { "value": "line-strip", "doc": "Each vertex after the first defines a line to the previous vertex." }, + "triangle_list": { "value": "triangle-list", "doc": "Each triple of vertices defines a separate triangle." }, + "triangle_strip": { + "value": "triangle-strip", + "doc": "Each vertex after the first two defines a triangle with the previous two vertices." + } + }, + "doc": "How vertices are assembled into primitives.\n\nUsed in the topology field of structs.PrimitiveState.\n" + }, + "FrontFace": { + "fields": { + "ccw": { + "value": "ccw", + "doc": "Triangles with counter-clockwise vertices (in framebuffer space) are front-facing." + }, + "cw": { "value": "cw", "doc": "Triangles with clockwise vertices (in framebuffer space) are front-facing." } + }, + "doc": "Defines which winding order of a triangle is considered front-facing.\n\nUsed in the front_face field of structs.PrimitiveState.\n" + }, + "CullMode": { + "fields": { + "none": { "value": "none", "doc": "No faces are culled." }, + "front": { "value": "front", "doc": "Front-facing triangles are culled." }, + "back": { "value": "back", "doc": "Back-facing triangles are culled." } + }, + "doc": "Defines which faces of triangles are culled (not drawn).\n\nUsed in the cull_mode field of structs.PrimitiveState.\n" + }, + "BlendFactor": { + "fields": { + "zero": { "value": "zero", "doc": "Factor 0." }, + "one": { "value": "one", "doc": "Factor 1." }, + "src": { "value": "src", "doc": "The source color, per component." }, + "one_minus_src": { "value": "one-minus-src", "doc": "One minus the source color, per component." }, + "src_alpha": { "value": "src-alpha", "doc": "The source alpha." }, + "one_minus_src_alpha": { "value": "one-minus-src-alpha", "doc": "One minus the source alpha." }, + "dst": { "value": "dst", "doc": "The destination color, per component." }, + "one_minus_dst": { "value": "one-minus-dst", "doc": "One minus the destination color, per component." }, + "dst_alpha": { "value": "dst-alpha", "doc": "The destination alpha." }, + "one_minus_dst_alpha": { "value": "one-minus-dst-alpha", "doc": "One minus the destination alpha." }, + "src_alpha_saturated": { + "value": "src-alpha-saturated", + "doc": "The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha." + }, + "constant": { + "value": "constant", + "doc": "The blend constant color, see GPURenderPassEncoder.set_blend_constant()." + }, + "one_minus_constant": { "value": "one-minus-constant", "doc": "One minus the blend constant color." }, + "src1": { + "value": "src1", + "doc": "The second source color output of the fragment shader. Requires enums.FeatureName.dual_source_blending." + }, + "one_minus_src1": { + "value": "one-minus-src1", + "doc": "One minus the second source color. Requires enums.FeatureName.dual_source_blending." + }, + "src1_alpha": { + "value": "src1-alpha", + "doc": "The second source alpha. Requires enums.FeatureName.dual_source_blending." + }, + "one_minus_src1_alpha": { + "value": "one-minus-src1-alpha", + "doc": "One minus the second source alpha. Requires enums.FeatureName.dual_source_blending." + } + }, + "doc": "A factor that is multiplied with the source or destination color or alpha in blending.\n\nUsed in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions,\nsrc is the output of the fragment shader and dst is the existing value in the render target.\n" + }, + "BlendOperation": { + "fields": { + "add": { "value": "add", "doc": "Result is source plus destination." }, + "subtract": { "value": "subtract", "doc": "Result is source minus destination." }, + "reverse_subtract": { "value": "reverse-subtract", "doc": "Result is destination minus source." }, + "min": { + "value": "min", + "doc": "Result is the minimum of source and destination (blend factors are ignored)." + }, + "max": { + "value": "max", + "doc": "Result is the maximum of source and destination (blend factors are ignored)." + } + }, + "doc": "The operation used to combine the scaled source and destination values in blending.\n\nUsed in the operation field of structs.BlendComponent.\n" + }, + "StencilOperation": { + "fields": { + "keep": { "value": "keep", "doc": "Keep the current stencil value." }, + "zero": { "value": "zero", "doc": "Set the stencil value to zero." }, + "replace": { + "value": "replace", + "doc": "Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference()." + }, + "invert": { "value": "invert", "doc": "Bitwise invert the current stencil value." }, + "increment_clamp": { "value": "increment-clamp", "doc": "Increment the stencil value, clamping to the maximum." }, + "decrement_clamp": { "value": "decrement-clamp", "doc": "Decrement the stencil value, clamping to zero." }, + "increment_wrap": { "value": "increment-wrap", "doc": "Increment the stencil value, wrapping to zero on overflow." }, + "decrement_wrap": { + "value": "decrement-wrap", + "doc": "Decrement the stencil value, wrapping to the maximum on underflow." + } + }, + "doc": "The operation performed on the stencil buffer value after a stencil or depth test.\n\nUsed in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState.\n" + }, + "IndexFormat": { + "fields": { + "uint16": { "value": "uint16", "doc": "Indices are 16-bit unsigned integers." }, + "uint32": { "value": "uint32", "doc": "Indices are 32-bit unsigned integers." } + }, + "doc": "The data type of the indices in an index buffer.\n\nUsed in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method\nand the strip_index_format field of structs.PrimitiveState.\n" + }, + "VertexFormat": { + "fields": { + "uint8": { "value": "uint8", "doc": "One 8-bit unsigned integer." }, + "uint8x2": { "value": "uint8x2", "doc": "Two 8-bit unsigned integers." }, + "uint8x4": { "value": "uint8x4", "doc": "Four 8-bit unsigned integers." }, + "sint8": { "value": "sint8", "doc": "One 8-bit signed integer." }, + "sint8x2": { "value": "sint8x2", "doc": "Two 8-bit signed integers." }, + "sint8x4": { "value": "sint8x4", "doc": "Four 8-bit signed integers." }, + "unorm8": { "value": "unorm8", "doc": "One 8-bit unsigned normalized value (0..1)." }, + "unorm8x2": { "value": "unorm8x2", "doc": "Two 8-bit unsigned normalized values (0..1)." }, + "unorm8x4": { "value": "unorm8x4", "doc": "Four 8-bit unsigned normalized values (0..1)." }, + "snorm8": { "value": "snorm8", "doc": "One 8-bit signed normalized value (-1..1)." }, + "snorm8x2": { "value": "snorm8x2", "doc": "Two 8-bit signed normalized values (-1..1)." }, + "snorm8x4": { "value": "snorm8x4", "doc": "Four 8-bit signed normalized values (-1..1)." }, + "uint16": { "value": "uint16", "doc": "One 16-bit unsigned integer." }, + "uint16x2": { "value": "uint16x2", "doc": "Two 16-bit unsigned integers." }, + "uint16x4": { "value": "uint16x4", "doc": "Four 16-bit unsigned integers." }, + "sint16": { "value": "sint16", "doc": "One 16-bit signed integer." }, + "sint16x2": { "value": "sint16x2", "doc": "Two 16-bit signed integers." }, + "sint16x4": { "value": "sint16x4", "doc": "Four 16-bit signed integers." }, + "unorm16": { "value": "unorm16", "doc": "One 16-bit unsigned normalized value (0..1)." }, + "unorm16x2": { "value": "unorm16x2", "doc": "Two 16-bit unsigned normalized values (0..1)." }, + "unorm16x4": { "value": "unorm16x4", "doc": "Four 16-bit unsigned normalized values (0..1)." }, + "snorm16": { "value": "snorm16", "doc": "One 16-bit signed normalized value (-1..1)." }, + "snorm16x2": { "value": "snorm16x2", "doc": "Two 16-bit signed normalized values (-1..1)." }, + "snorm16x4": { "value": "snorm16x4", "doc": "Four 16-bit signed normalized values (-1..1)." }, + "float16": { "value": "float16", "doc": "One 16-bit float." }, + "float16x2": { "value": "float16x2", "doc": "Two 16-bit floats." }, + "float16x4": { "value": "float16x4", "doc": "Four 16-bit floats." }, + "float32": { "value": "float32", "doc": "One 32-bit float." }, + "float32x2": { "value": "float32x2", "doc": "Two 32-bit floats." }, + "float32x3": { "value": "float32x3", "doc": "Three 32-bit floats." }, + "float32x4": { "value": "float32x4", "doc": "Four 32-bit floats." }, + "uint32": { "value": "uint32", "doc": "One 32-bit unsigned integer." }, + "uint32x2": { "value": "uint32x2", "doc": "Two 32-bit unsigned integers." }, + "uint32x3": { "value": "uint32x3", "doc": "Three 32-bit unsigned integers." }, + "uint32x4": { "value": "uint32x4", "doc": "Four 32-bit unsigned integers." }, + "sint32": { "value": "sint32", "doc": "One 32-bit signed integer." }, + "sint32x2": { "value": "sint32x2", "doc": "Two 32-bit signed integers." }, + "sint32x3": { "value": "sint32x3", "doc": "Three 32-bit signed integers." }, + "sint32x4": { "value": "sint32x4", "doc": "Four 32-bit signed integers." }, + "unorm10_10_10_2": { + "value": "unorm10-10-10-2", + "doc": "A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float." + }, + "unorm8x4_bgra": { + "value": "unorm8x4-bgra", + "doc": "Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order." + } + }, + "doc": "The format of a vertex attribute in a vertex buffer.\n\nUsed in the format field of structs.VertexAttribute. The name consists of the component type and\nbit size, optionally followed by xN for the number of components. The shader sees the data as\nfloat (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components.\n" + }, + "VertexStepMode": { + "fields": { + "vertex": { "value": "vertex", "doc": "The buffer is advanced for each vertex." }, + "instance": { "value": "instance", "doc": "The buffer is advanced for each instance." } + }, + "doc": "How often a vertex buffer is advanced.\n\nUsed in the step_mode field of structs.VertexBufferLayout.\n" + }, + "LoadOp": { + "fields": { + "load": { "value": "load", "doc": "Keep the existing contents of the attachment." }, + "clear": { + "value": "clear", + "doc": "Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment). Clearing is preferred over load when the old contents are not needed; it can be faster, especially on tiled GPUs." + } + }, + "doc": "What happens to the contents of an attachment at the start of a render pass.\n\nUsed in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment.\n" + }, + "StoreOp": { + "fields": { + "store": { "value": "store", "doc": "Store the results of the render pass in the attachment." }, + "discard": { + "value": "discard", + "doc": "Discard the results; the contents of the attachment become undefined (zero-initialized when next used)." + } + }, + "doc": "What happens to the contents of an attachment at the end of a render pass.\n\nUsed in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment.\n" + }, + "QueryType": { + "fields": { + "occlusion": { + "value": "occlusion", + "doc": "Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query()." + }, + "timestamp": { + "value": "timestamp", + "doc": "Timestamp queries record GPU timestamps. Requires enums.FeatureName.timestamp_query." + } + }, + "doc": "The type of queries in a GPUQuerySet.\n\nUsed in the type field of structs.QuerySetDescriptor.\n" + }, + "CanvasAlphaMode": { + "fields": { + "opaque": { "value": "opaque", "doc": "The alpha channel is ignored and the canvas is treated as fully opaque." }, + "premultiplied": { + "value": "premultiplied", + "doc": "The color channels are expected to be premultiplied by the alpha channel." + } + }, + "doc": "How the alpha channel of a canvas texture is interpreted when compositing with the page or window.\n\nUsed in the alpha_mode field of structs.CanvasConfiguration.\n" + }, + "CanvasToneMappingMode": { + "fields": { + "standard": { + "value": "standard", + "doc": "Color values are clamped to the standard dynamic range (SDR) of the display." + }, + "extended": { + "value": "extended", + "doc": "Color values may exceed the SDR range, up to the dynamic range of the display (HDR)." + } + }, + "doc": "How the content of a canvas is tone mapped when displayed.\n\nUsed in the mode field of structs.CanvasToneMapping.\n" + }, + "DeviceLostReason": { + "fields": { + "unknown": { + "value": "unknown", + "doc": "The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal." + }, + "destroyed": { "value": "destroyed", "doc": "The device was lost because GPUDevice.destroy() was called." } + }, + "doc": "The reason a GPUDevice was lost.\n\nAvailable via the reason property of GPUDeviceLostInfo.\n" + }, + "ErrorFilter": { + "fields": { + "validation": { + "value": "validation", + "doc": "Captures GPUValidationError errors, which signal incorrect API usage." + }, + "out_of_memory": { + "value": "out-of-memory", + "doc": "Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation." + }, + "internal": { + "value": "internal", + "doc": "Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits)." + } + }, + "doc": "The type of error that is captured by an error scope.\n\nUsed in the filter argument of the GPUDevice.push_error_scope() method.\n" + } + }, + "structs": { + "RequestAdapterOptions": { + "fields": { + "feature_level": { + "type": "str", + "default": "\"core\"", + "required": false, + "doc": "The feature level to request: 'core' (default) or 'compatibility'. Core implies the default limits and enums.FeatureName.core_features_and_limits; compatibility has stricter, more widely supported defaults and no features. If the implementation cannot enforce the compatibility rules it treats the request as core. If the level is not supported, no adapter is returned." + }, + "power_preference": { + "type": "enums.PowerPreferenceEnum", + "default": null, + "required": false, + "doc": "Hint for the kind of adapter to select, see enums.PowerPreference. It may influence which adapter is chosen (mainly in multi-GPU systems), but never whether an adapter is returned." + }, + "force_fallback_adapter": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, only a fallback adapter may be returned (no adapter if unsupported). If false, a fallback adapter may still be returned; check the is_fallback_adapter property of GPUAdapterInfo to avoid it." + }, + "xr_compatible": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." + } + }, + "doc": "Options for requesting an adapter.\n\nUsed as the options argument of the GPU.request_adapter() method.\n" + }, + "DeviceDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the device, used in debugging and error messages." + }, + "required_features": { + "type": "list[enums.FeatureNameEnum]", + "default": "[]", + "required": false, + "doc": "A list of enums.FeatureName that the device must support. The request fails if the adapter cannot provide them. Exactly this set of features, no more and no less, is allowed on the resulting device." + }, + "required_limits": { + "type": "dict[str, int | None]", + "default": "{}", + "required": false, + "doc": "A mapping of limit names to the values the device requires; the request fails if the adapter cannot provide them. Unspecified limits get their default value. Validation on the device uses these exact limits, not the (possibly higher) limits of the adapter." + }, + "default_queue": { + "type": "structs.QueueDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.QueueDescriptor with options for the default queue of the device." + } + }, + "doc": "Descriptor for requesting a device.\n\nUsed as the descriptor argument of the GPUAdapter.request_device() method.\n" + }, + "BufferDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the buffer, used in debugging and error messages." + }, + "size": { "type": "int", "default": null, "required": true, "doc": "The size of the buffer in bytes." }, + "usage": { + "type": "flags.BufferUsageFlags", + "default": null, + "required": true, + "doc": "The allowed usages of the buffer, a combination of flags.BufferUsage." + }, + "mapped_at_creation": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the buffer is created in a mapped state so GPUBuffer.get_mapped_range() can be called immediately, which is useful to set initial data. This is allowed even without flags.BufferUsage.MAP_READ or flags.BufferUsage.MAP_WRITE. The size must then be a multiple of 4." + } + }, + "doc": "Descriptor for creating a GPUBuffer.\n\nUsed as the descriptor argument of the GPUDevice.create_buffer() method.\n" + }, + "TextureDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the texture, used in debugging and error messages." + }, + "size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": null, + "required": true, + "doc": "The size of the texture as a structs.Extent3D, or a tuple of (width, height, depth_or_array_layers). Height and depth default to 1." + }, + "mip_level_count": { "type": "int", "default": "1", "required": false, "doc": "The number of mip levels. Defaults to 1." }, + "sample_count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." + }, + "dimension": { + "type": "enums.TextureDimensionEnum", + "default": "\"2d\"", + "required": false, + "doc": "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": true, + "doc": "The pixel format of the texture, see enums.TextureFormat." + }, + "usage": { + "type": "flags.TextureUsageFlags", + "default": null, + "required": true, + "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." + }, + "view_formats": { + "type": "list[enums.TextureFormatEnum]", + "default": "[]", + "required": false, + "doc": "Additional enums.TextureFormat values that views of this texture may use in GPUTexture.create_view(). They must be view-compatible with the texture format: equal, or (on devices with enums.FeatureName.core_features_and_limits) differing only in sRGB-ness. Adding formats can hurt performance on some systems, so only add what is needed." + }, + "texture_binding_view_dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": null, + "required": false, + "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. A default is chosen if omitted. Ignored on core devices." + } + }, + "doc": "Descriptor for creating a GPUTexture.\n\nUsed as the descriptor argument of the GPUDevice.create_texture() method.\n" + }, + "TextureViewDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the texture view, used in debugging and error messages." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": false, + "doc": "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." + }, + "dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": null, + "required": false, + "doc": "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." + }, + "usage": { + "type": "flags.TextureUsageFlags", + "default": "0", + "required": false, + "doc": "The usages the view will be used for, a subset of the usage of the texture (see flags.TextureUsage). If 0 or omitted, defaults to all usages of the texture; this fails if the view format does not support all of them, in which case set it explicitly." + }, + "aspect": { + "type": "enums.TextureAspectEnum", + "default": "\"all\"", + "required": false, + "doc": "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." + }, + "base_mip_level": { + "type": "int", + "default": "0", + "required": false, + "doc": "The first mip level accessible via the view. Defaults to 0." + }, + "mip_level_count": { + "type": "int", + "default": null, + "required": false, + "doc": "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." + }, + "base_array_layer": { + "type": "int", + "default": "0", + "required": false, + "doc": "The first array layer accessible via the view. Defaults to 0." + }, + "array_layer_count": { + "type": "int", + "default": null, + "required": false, + "doc": "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." + }, + "swizzle": { + "type": "str", + "default": "\"rgba\"", + "required": false, + "doc": "A string of four characters (default 'rgba') that defines how the components of the view are mapped, e.g. 'bgra'. Allowed characters are r, g, b, a, 0 and 1. Requires enums.FeatureName.texture_component_swizzle." + } + }, + "doc": "Descriptor for creating a GPUTextureView.\n\nUsed as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields\nget a default derived from the texture, so by default the view covers the whole texture.\n" + }, + "ExternalTextureDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the external texture, used in debugging and error messages." + }, + "source": { + "type": "ArrayLike | object", + "default": null, + "required": true, + "doc": "The source of the image data, e.g. a video element or video frame. Only meaningful in browser environments." + }, + "color_space": { + "type": "str", + "default": "\"srgb\"", + "required": false, + "doc": "The color space of the source image, e.g. 'srgb'. Defaults to 'srgb'." + } + }, + "doc": "Descriptor for importing an external texture, such as a video frame.\n\nUsed as the descriptor argument of the GPUDevice.import_external_texture() method.\n" + }, + "SamplerDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the sampler, used in debugging and error messages." + }, + "address_mode_u": { + "type": "enums.AddressModeEnum", + "default": "\"clamp-to-edge\"", + "required": false, + "doc": "How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge." + }, + "address_mode_v": { + "type": "enums.AddressModeEnum", + "default": "\"clamp-to-edge\"", + "required": false, + "doc": "How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge." + }, + "address_mode_w": { + "type": "enums.AddressModeEnum", + "default": "\"clamp-to-edge\"", + "required": false, + "doc": "How to handle texture coordinates outside 0..1 along the w (z) axis, see enums.AddressMode. Defaults to clamp_to_edge." + }, + "mag_filter": { + "type": "enums.FilterModeEnum", + "default": "\"nearest\"", + "required": false, + "doc": "The filter used when the sampled area is smaller than or equal to one texel (magnification), see enums.FilterMode. Defaults to nearest." + }, + "min_filter": { + "type": "enums.FilterModeEnum", + "default": "\"nearest\"", + "required": false, + "doc": "The filter used when the sampled area is larger than one texel (minification), see enums.FilterMode. Defaults to nearest." + }, + "mipmap_filter": { + "type": "enums.MipmapFilterModeEnum", + "default": "\"nearest\"", + "required": false, + "doc": "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." + }, + "lod_min_clamp": { + "type": "float", + "default": "0", + "required": false, + "doc": "The minimum level of detail used when sampling. Defaults to 0." + }, + "lod_max_clamp": { + "type": "float", + "default": "32", + "required": false, + "doc": "The maximum level of detail used when sampling. Defaults to 32." + }, + "compare": { + "type": "enums.CompareFunctionEnum", + "default": null, + "required": false, + "doc": "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures. Filtering results of comparison samplers are implementation-dependent." + }, + "max_anisotropy": { + "type": "int", + "default": "1", + "required": false, + "doc": "The maximum anisotropy for anisotropic filtering: 1 (default) disables it. Values above 1 require all filters to be linear. The value is clamped to the platform maximum (typically 16)." + } + }, + "doc": "Descriptor for creating a GPUSampler.\n\nUsed as the descriptor argument of the GPUDevice.create_sampler() method.\n" + }, + "BindGroupLayoutDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the bind group layout, used in debugging and error messages." + }, + "entries": { + "type": "list[structs.BindGroupLayoutEntryStruct]", + "default": null, + "required": true, + "doc": "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." + } + }, + "doc": "Descriptor for creating a GPUBindGroupLayout.\n\nUsed as the descriptor argument of the GPUDevice.create_bind_group_layout() method.\n" + }, + "BindGroupLayoutEntry": { + "fields": { + "binding": { + "type": "int", + "default": null, + "required": true, + "doc": "The binding number, matching the @binding attribute in the shader." + }, + "visibility": { + "type": "flags.ShaderStageFlags", + "default": null, + "required": true, + "doc": "The shader stages in which the resource is visible, a combination of flags.ShaderStage." + }, + "buffer": { + "type": "structs.BufferBindingLayoutStruct", + "default": null, + "required": false, + "doc": "If set, a structs.BufferBindingLayout: the entry is a buffer binding." + }, + "sampler": { + "type": "structs.SamplerBindingLayoutStruct", + "default": null, + "required": false, + "doc": "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." + }, + "texture": { + "type": "structs.TextureBindingLayoutStruct", + "default": null, + "required": false, + "doc": "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." + }, + "storage_texture": { + "type": "structs.StorageTextureBindingLayoutStruct", + "default": null, + "required": false, + "doc": "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." + } + }, + "doc": "Describes a single binding in a bind group layout.\n\nExactly one of buffer, sampler, texture, storage_texture and external_texture must be set,\nwhich determines the type of resource that is bound.\n" + }, + "BufferBindingLayout": { + "fields": { + "type": { + "type": "enums.BufferBindingTypeEnum", + "default": "\"uniform\"", + "required": false, + "doc": "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." + }, + "has_dynamic_offset": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, an offset can be given in GPUBindingCommandsMixin.set_bind_group() when binding. Defaults to false." + }, + "min_binding_size": { + "type": "int", + "default": "0", + "required": false, + "doc": "The minimum size in bytes of a buffer bound to this entry; bindings are always validated against it in GPUDevice.create_bind_group(). If non-zero, pipeline creation also checks it against the minimum binding size of the shader variable. If 0 (default), that check is skipped at pipeline creation and done at draw/dispatch time instead." + } + }, + "doc": "Describes the layout of a buffer binding.\n\nUsed in the buffer field of structs.BindGroupLayoutEntry.\n" + }, + "SamplerBindingLayout": { + "fields": { + "type": { + "type": "enums.SamplerBindingTypeEnum", + "default": "\"filtering\"", + "required": false, + "doc": "The type of sampler binding, see enums.SamplerBindingType. Defaults to filtering." + } + }, + "doc": "Describes the layout of a sampler binding.\n\nUsed in the sampler field of structs.BindGroupLayoutEntry.\n" + }, + "TextureBindingLayout": { + "fields": { + "sample_type": { + "type": "enums.TextureSampleTypeEnum", + "default": "\"float\"", + "required": false, + "doc": "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." + }, + "view_dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": "\"2d\"", + "required": false, + "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." + }, + "multisampled": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the bound texture must be multisampled. Defaults to false." + } + }, + "doc": "Describes the layout of a sampled texture binding.\n\nUsed in the texture field of structs.BindGroupLayoutEntry.\n" + }, + "StorageTextureBindingLayout": { + "fields": { + "access": { + "type": "enums.StorageTextureAccessEnum", + "default": "\"write-only\"", + "required": false, + "doc": "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": true, + "doc": "The enums.TextureFormat that the bound texture view must have." + }, + "view_dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": "\"2d\"", + "required": false, + "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." + } + }, + "doc": "Describes the layout of a storage texture binding.\n\nUsed in the storage_texture field of structs.BindGroupLayoutEntry.\n" + }, + "BindGroupDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the bind group, used in debugging and error messages." + }, + "layout": { + "type": "GPUBindGroupLayout", + "default": null, + "required": true, + "doc": "The GPUBindGroupLayout that this bind group conforms to." + }, + "entries": { + "type": "list[structs.BindGroupEntryStruct]", + "default": null, + "required": true, + "doc": "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." + } + }, + "doc": "Descriptor for creating a GPUBindGroup.\n\nUsed as the descriptor argument of the GPUDevice.create_bind_group() method.\n" + }, + "BindGroupEntry": { + "fields": { + "binding": { + "type": "int", + "default": null, + "required": true, + "doc": "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." + }, + "resource": { + "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", + "default": null, + "required": true, + "doc": "The resource to bind: a GPUSampler, GPUTexture (as its default view), GPUTextureView, GPUBuffer (the whole buffer), structs.BufferBinding, or GPUExternalTexture. Must match the type in the corresponding layout entry." + } + }, + "doc": "A single resource binding in a bind group.\n\nUsed in the entries field of structs.BindGroupDescriptor.\n" + }, + "BufferBinding": { + "fields": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to bind." }, + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes into the buffer where the binding starts. Defaults to 0." + }, + "size": { + "type": "int", + "default": null, + "required": false, + "doc": "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "Describes a range of a GPUBuffer to bind.\n\nCan be used as the resource field of structs.BindGroupEntry.\n" + }, + "PipelineLayoutDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the pipeline layout, used in debugging and error messages." + }, + "bind_group_layouts": { + "type": "list[GPUBindGroupLayout]", + "default": null, + "required": true, + "doc": "A list of GPUBindGroupLayout (or None for unused groups) used by the pipeline. The Nth element corresponds to @group(N) in the shader." + }, + "immediate_size": { + "type": "int", + "default": "0", + "required": false, + "doc": "The size in bytes of the immediate data (small data set with GPUBindingCommandsMixin.set_immediates()). Defaults to 0." + } + }, + "doc": "Descriptor for creating a GPUPipelineLayout.\n\nUsed as the descriptor argument of the GPUDevice.create_pipeline_layout() method.\n" + }, + "ShaderModuleDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the shader module, used in debugging and error messages." + }, + "code": { "type": "str", "default": null, "required": true, "doc": "The shader source code, in WGSL." }, + "compilation_hints": { + "type": "list[structs.ShaderModuleCompilationHintStruct]", + "default": "[]", + "required": false, + "doc": "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile early. Hints only affect performance, are not validated, and only apply to the entry points they name (there is no default entry point)." + } + }, + "doc": "Descriptor for creating a GPUShaderModule.\n\nUsed as the descriptor argument of the GPUDevice.create_shader_module() method.\n" + }, + "ShaderModuleCompilationHint": { + "fields": { + "entry_point": { + "type": "str", + "default": null, + "required": true, + "doc": "The name of the shader entry point that the hint applies to." + }, + "layout": { + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "default": null, + "required": false, + "doc": "The GPUPipelineLayout that the entry point will be used with, or enums.AutoLayoutMode.auto (the default pipeline layout for that entry point)." + } + }, + "doc": "A hint for the compilation of a shader module.\n\nUsed in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only\naffect performance, not behavior.\n" + }, + "PipelineErrorInit": { + "fields": { + "reason": { + "type": "enums.PipelineErrorReasonEnum", + "default": null, + "required": true, + "doc": "The reason for the error, see enums.PipelineErrorReason." + } + }, + "doc": "Initialization options for a GPUPipelineError.\n\nUsed as the options argument of the GPUPipelineError constructor.\n" + }, + "ProgrammableStage": { + "fields": { + "module": { + "type": "GPUShaderModule", + "default": null, + "required": true, + "doc": "The GPUShaderModule containing the shader code." + }, + "entry_point": { + "type": "str", + "default": null, + "required": false, + "doc": "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." + }, + "constants": { + "type": "dict[str, float]", + "default": "{}", + "required": false, + "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." + } + }, + "doc": "Describes a programmable (shader) stage of a pipeline.\n\nThis is the base for structs.VertexState, structs.FragmentState and the compute field of\nstructs.ComputePipelineDescriptor.\n" + }, + "ComputePipelineDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the pipeline, used in debugging and error messages." + }, + "layout": { + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "default": null, + "required": true, + "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." + }, + "compute": { + "type": "structs.ProgrammableStageStruct", + "default": null, + "required": true, + "doc": "A structs.ProgrammableStage describing the compute shader." + } + }, + "doc": "Descriptor for creating a GPUComputePipeline.\n\nUsed as the descriptor argument of the GPUDevice.create_compute_pipeline() method.\n" + }, + "RenderPipelineDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the pipeline, used in debugging and error messages." + }, + "layout": { + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "default": null, + "required": true, + "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." + }, + "vertex": { + "type": "structs.VertexStateStruct", + "default": null, + "required": true, + "doc": "A structs.VertexState describing the vertex shader and vertex buffers." + }, + "primitive": { + "type": "structs.PrimitiveStateStruct", + "default": "{}", + "required": false, + "doc": "A structs.PrimitiveState describing how primitives are assembled and rasterized." + }, + "depth_stencil": { + "type": "structs.DepthStencilStateStruct", + "default": null, + "required": false, + "doc": "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." + }, + "multisample": { + "type": "structs.MultisampleStateStruct", + "default": "{}", + "required": false, + "doc": "A structs.MultisampleState describing multisampling." + }, + "fragment": { + "type": "structs.FragmentStateStruct", + "default": null, + "required": false, + "doc": "An optional structs.FragmentState describing the fragment shader and render targets. If omitted, the pipeline has no color output (e.g. for depth-only passes)." + } + }, + "doc": "Descriptor for creating a GPURenderPipeline.\n\nUsed as the descriptor argument of the GPUDevice.create_render_pipeline() method.\n" + }, + "PrimitiveState": { + "fields": { + "topology": { + "type": "enums.PrimitiveTopologyEnum", + "default": "\"triangle-list\"", + "required": false, + "doc": "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." + }, + "strip_index_format": { + "type": "enums.IndexFormatEnum", + "default": null, + "required": false, + "doc": "The enums.IndexFormat of the index buffer, which sets the primitive restart value (0xFFFF for uint16, 0xFFFFFFFF for uint32). Only allowed for strip topologies, where it is required for indexed draws and must match the format given to GPURenderCommandsMixin.set_index_buffer()." + }, + "front_face": { + "type": "enums.FrontFaceEnum", + "default": "\"ccw\"", + "required": false, + "doc": "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." + }, + "cull_mode": { + "type": "enums.CullModeEnum", + "default": "\"none\"", + "required": false, + "doc": "Which faces to cull, see enums.CullMode. Defaults to none." + }, + "unclipped_depth": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, primitives are not clipped by the near and far planes. Requires enums.FeatureName.depth_clip_control." + } + }, + "doc": "Describes how a render pipeline assembles and rasterizes primitives.\n\nUsed in the primitive field of structs.RenderPipelineDescriptor.\n" + }, + "MultisampleState": { + "fields": { + "count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of samples per pixel. Must be 1 or 4. The pipeline is only compatible with attachments that have a matching sample count. Defaults to 1." + }, + "mask": { + "type": "int", + "default": "0xFFFFFFFF", + "required": false, + "doc": "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." + }, + "alpha_to_coverage_enabled": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the alpha output of the fragment shader is used to generate a coverage mask. Defaults to false." + } + }, + "doc": "Describes the multisampling of a render pipeline.\n\nUsed in the multisample field of structs.RenderPipelineDescriptor.\n" + }, + "FragmentState": { + "fields": { + "module": { + "type": "GPUShaderModule", + "default": null, + "required": true, + "doc": "The GPUShaderModule containing the fragment shader code." + }, + "entry_point": { + "type": "str", + "default": null, + "required": false, + "doc": "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." + }, + "constants": { + "type": "dict[str, float]", + "default": "{}", + "required": false, + "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." + }, + "targets": { + "type": "list[structs.ColorTargetStateStruct]", + "default": null, + "required": true, + "doc": "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." + } + }, + "doc": "Describes the fragment shader stage and render targets of a render pipeline.\n\nUsed in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage.\n" + }, + "ColorTargetState": { + "fields": { + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": true, + "doc": "The enums.TextureFormat of this color target. The pipeline is only compatible with render passes that use a view of this format in the corresponding color attachment." + }, + "blend": { + "type": "structs.BlendStateStruct", + "default": null, + "required": false, + "doc": "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." + }, + "write_mask": { + "type": "flags.ColorWriteFlags", + "default": "0xF", + "required": false, + "doc": "Which channels are written, a combination of flags.ColorWrite. Defaults to ALL." + } + }, + "doc": "Describes a color render target of a render pipeline.\n\nUsed in the targets field of structs.FragmentState.\n" + }, + "BlendState": { + "fields": { + "color": { + "type": "structs.BlendComponentStruct", + "default": null, + "required": true, + "doc": "A structs.BlendComponent for the color (RGB) channels." + }, + "alpha": { + "type": "structs.BlendComponentStruct", + "default": null, + "required": true, + "doc": "A structs.BlendComponent for the alpha channel." + } + }, + "doc": "Describes how blending is performed for a color target.\n\nUsed in the blend field of structs.ColorTargetState.\n" + }, + "BlendComponent": { + "fields": { + "operation": { + "type": "enums.BlendOperationEnum", + "default": "\"add\"", + "required": false, + "doc": "The enums.BlendOperation used to combine the scaled values. Defaults to add." + }, + "src_factor": { + "type": "enums.BlendFactorEnum", + "default": "\"one\"", + "required": false, + "doc": "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." + }, + "dst_factor": { + "type": "enums.BlendFactorEnum", + "default": "\"zero\"", + "required": false, + "doc": "The enums.BlendFactor applied to the destination (existing target value). Defaults to zero." + } + }, + "doc": "Describes how the blending of a single component (color or alpha) is performed.\n\nThe result is: operation(src * src_factor, dst * dst_factor).\n" + }, + "DepthStencilState": { + "fields": { + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": true, + "doc": "The enums.TextureFormat of the depth-stencil attachment that this pipeline is compatible with." + }, + "depth_write_enabled": { + "type": "bool", + "default": null, + "required": false, + "doc": "If true, depth values of fragments that pass the depth test are written to the attachment." + }, + "depth_compare": { + "type": "enums.CompareFunctionEnum", + "default": null, + "required": false, + "doc": "The enums.CompareFunction used for the depth test." + }, + "stencil_front": { + "type": "structs.StencilFaceStateStruct", + "default": "{}", + "required": false, + "doc": "A structs.StencilFaceState for front-facing primitives." + }, + "stencil_back": { + "type": "structs.StencilFaceStateStruct", + "default": "{}", + "required": false, + "doc": "A structs.StencilFaceState for back-facing primitives." + }, + "stencil_read_mask": { + "type": "int", + "default": "0xFFFFFFFF", + "required": false, + "doc": "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." + }, + "stencil_write_mask": { + "type": "int", + "default": "0xFFFFFFFF", + "required": false, + "doc": "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." + }, + "depth_bias": { + "type": "int", + "default": "0", + "required": false, + "doc": "A constant depth value added to each fragment. Defaults to 0." + }, + "depth_bias_slope_scale": { + "type": "float", + "default": "0", + "required": false, + "doc": "A depth bias that scales with the slope of the primitive. Defaults to 0." + }, + "depth_bias_clamp": { + "type": "float", + "default": "0", + "required": false, + "doc": "The maximum (or minimum, if negative) depth bias of a fragment. Defaults to 0." + } + }, + "doc": "Describes the depth and stencil state of a render pipeline.\n\nUsed in the depth_stencil field of structs.RenderPipelineDescriptor.\n" + }, + "StencilFaceState": { + "fields": { + "compare": { + "type": "enums.CompareFunctionEnum", + "default": "\"always\"", + "required": false, + "doc": "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." + }, + "fail_op": { + "type": "enums.StencilOperationEnum", + "default": "\"keep\"", + "required": false, + "doc": "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." + }, + "depth_fail_op": { + "type": "enums.StencilOperationEnum", + "default": "\"keep\"", + "required": false, + "doc": "The enums.StencilOperation performed if the stencil test passes but the depth test fails. Defaults to keep." + }, + "pass_op": { + "type": "enums.StencilOperationEnum", + "default": "\"keep\"", + "required": false, + "doc": "The enums.StencilOperation performed if both the stencil and depth tests pass. Defaults to keep." + } + }, + "doc": "Describes the stencil operations for one face (front or back) of primitives.\n\nUsed in the stencil_front and stencil_back fields of structs.DepthStencilState.\n" + }, + "VertexState": { + "fields": { + "module": { + "type": "GPUShaderModule", + "default": null, + "required": true, + "doc": "The GPUShaderModule containing the vertex shader code." + }, + "entry_point": { + "type": "str", + "default": null, + "required": false, + "doc": "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." + }, + "constants": { + "type": "dict[str, float]", + "default": "{}", + "required": false, + "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." + }, + "buffers": { + "type": "list[structs.VertexBufferLayoutStruct]", + "default": "[]", + "required": false, + "doc": "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." + } + }, + "doc": "Describes the vertex shader stage and vertex buffers of a render pipeline.\n\nUsed in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage.\n" + }, + "VertexBufferLayout": { + "fields": { + "array_stride": { + "type": "int", + "default": null, + "required": true, + "doc": "The stride in bytes between consecutive elements in the buffer." + }, + "step_mode": { + "type": "enums.VertexStepModeEnum", + "default": "\"vertex\"", + "required": false, + "doc": "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." + }, + "attributes": { + "type": "list[structs.VertexAttributeStruct]", + "default": null, + "required": true, + "doc": "A list of structs.VertexAttribute describing the attributes in each element." + } + }, + "doc": "Describes the layout of a vertex buffer.\n\nUsed in the buffers field of structs.VertexState.\n" + }, + "VertexAttribute": { + "fields": { + "format": { + "type": "enums.VertexFormatEnum", + "default": null, + "required": true, + "doc": "The enums.VertexFormat of the attribute." + }, + "offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes of the attribute from the start of an element in the buffer." + }, + "shader_location": { + "type": "int", + "default": null, + "required": true, + "doc": "The location number of the attribute in the vertex shader (the @location attribute)." + } + }, + "doc": "Describes a single vertex attribute within a vertex buffer.\n\nUsed in the attributes field of structs.VertexBufferLayout.\n" + }, + "TexelCopyBufferLayout": { + "fields": { + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes into the data where the texel data starts. Defaults to 0." + }, + "bytes_per_row": { + "type": "int", + "default": null, + "required": false, + "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row of texel blocks. Must be a multiple of 256 for buffer copies (not for GPUQueue.write_texture())." + }, + "rows_per_image": { + "type": "int", + "default": null, + "required": false, + "doc": "The number of rows of texel blocks per image (layer or slice); times bytes_per_row it is the stride between images. Required if the copy has more than one image." + } + }, + "doc": "Describes the layout of texel data in a buffer or in a block of memory.\n\nUsed as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo.\n" + }, + "TexelCopyBufferInfo": { + "fields": { + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes into the buffer where the texel data starts. Defaults to 0." + }, + "bytes_per_row": { + "type": "int", + "default": null, + "required": false, + "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row. Must be a multiple of 256." + }, + "rows_per_image": { + "type": "int", + "default": null, + "required": false, + "doc": "The number of rows of texel blocks per image (layer or slice). Required if the copy has more than one image." + }, + "buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains (or will contain) the texel data." + } + }, + "doc": "Describes a buffer and the layout of texel data in it.\n\nUsed as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer().\nExtends structs.TexelCopyBufferLayout.\n" + }, + "TexelCopyTextureInfo": { + "fields": { + "texture": { + "type": "GPUTexture", + "default": null, + "required": true, + "doc": "The GPUTexture to copy to or from." + }, + "mip_level": { + "type": "int", + "default": "0", + "required": false, + "doc": "The mip level to copy to or from. Defaults to 0." + }, + "origin": { + "type": "tuple[int, int, int] | structs.Origin3DStruct", + "default": "{}", + "required": false, + "doc": "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." + }, + "aspect": { + "type": "enums.TextureAspectEnum", + "default": "\"all\"", + "required": false, + "doc": "Which aspect of the texture to copy, see enums.TextureAspect. Defaults to all." + } + }, + "doc": "Describes a texture and the part of it that is the source or destination of a copy.\n\nUsed in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(),\nGPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture().\n" + }, + "CommandBufferDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the command buffer, used in debugging and error messages." + } + }, + "doc": "Descriptor for a GPUCommandBuffer.\n\nUsed as the descriptor argument of the GPUCommandEncoder.finish() method.\n" + }, + "CommandEncoderDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the command encoder, used in debugging and error messages." + } + }, + "doc": "Descriptor for creating a GPUCommandEncoder.\n\nUsed as the descriptor argument of the GPUDevice.create_command_encoder() method.\n" + }, + "ComputePassTimestampWrites": { + "fields": { + "query_set": { + "type": "GPUQuerySet", + "default": null, + "required": true, + "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." + }, + "beginning_of_pass_write_index": { + "type": "int", + "default": null, + "required": false, + "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." + }, + "end_of_pass_write_index": { + "type": "int", + "default": null, + "required": false, + "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." + } + }, + "doc": "Describes where to write timestamps for a compute pass.\n\nUsed in the timestamp_writes field of structs.ComputePassDescriptor. Requires enums.FeatureName.timestamp_query.\n" + }, + "ComputePassDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the compute pass, used in debugging and error messages." + }, + "timestamp_writes": { + "type": "structs.ComputePassTimestampWritesStruct", + "default": null, + "required": false, + "doc": "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." + } + }, + "doc": "Descriptor for beginning a compute pass.\n\nUsed as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method.\n" + }, + "RenderPassTimestampWrites": { + "fields": { + "query_set": { + "type": "GPUQuerySet", + "default": null, + "required": true, + "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." + }, + "beginning_of_pass_write_index": { + "type": "int", + "default": null, + "required": false, + "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." + }, + "end_of_pass_write_index": { + "type": "int", + "default": null, + "required": false, + "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." + } + }, + "doc": "Describes where to write timestamps for a render pass.\n\nUsed in the timestamp_writes field of structs.RenderPassDescriptor. Requires enums.FeatureName.timestamp_query.\n" + }, + "RenderPassDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the render pass, used in debugging and error messages." + }, + "color_attachments": { + "type": "list[structs.RenderPassColorAttachmentStruct]", + "default": null, + "required": true, + "doc": "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to. Attachments may not alias each other or any resource used inside the pass." + }, + "depth_stencil_attachment": { + "type": "structs.RenderPassDepthStencilAttachmentStruct", + "default": null, + "required": false, + "doc": "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." + }, + "occlusion_query_set": { + "type": "GPUQuerySet", + "default": null, + "required": false, + "doc": "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." + }, + "timestamp_writes": { + "type": "structs.RenderPassTimestampWritesStruct", + "default": null, + "required": false, + "doc": "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." + }, + "max_draw_count": { + "type": "int", + "default": "50000000", + "required": false, + "doc": "A hint for the maximum number of draw calls in the pass, used by some implementations to size internal work. The default is fine unless more draws are expected. Defaults to 50000000." + } + }, + "doc": "Descriptor for beginning a render pass.\n\nUsed as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method.\n" + }, + "RenderPassColorAttachment": { + "fields": { + "view": { + "type": "GPUTexture | GPUTextureView", + "default": null, + "required": true, + "doc": "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." + }, + "depth_slice": { + "type": "int", + "default": null, + "required": false, + "doc": "For 3D textures, the index of the depth slice to render to." + }, + "resolve_target": { + "type": "GPUTexture | GPUTextureView", + "default": null, + "required": false, + "doc": "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." + }, + "clear_value": { + "type": "tuple[float, float, float, float] | structs.ColorStruct", + "default": null, + "required": false, + "doc": "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." + }, + "load_op": { + "type": "enums.LoadOpEnum", + "default": null, + "required": true, + "doc": "What to do with the existing contents at the start of the pass, see enums.LoadOp." + }, + "store_op": { + "type": "enums.StoreOpEnum", + "default": null, + "required": true, + "doc": "What to do with the results at the end of the pass, see enums.StoreOp." + } + }, + "doc": "Describes a color attachment of a render pass.\n\nUsed in the color_attachments field of structs.RenderPassDescriptor.\n" + }, + "RenderPassDepthStencilAttachment": { + "fields": { + "view": { + "type": "GPUTexture | GPUTextureView", + "default": null, + "required": true, + "doc": "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." + }, + "depth_clear_value": { + "type": "float", + "default": null, + "required": false, + "doc": "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." + }, + "depth_load_op": { + "type": "enums.LoadOpEnum", + "default": null, + "required": false, + "doc": "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." + }, + "depth_store_op": { + "type": "enums.StoreOpEnum", + "default": null, + "required": false, + "doc": "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." + }, + "depth_read_only": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the depth aspect is read-only in the pass (it is not written to). Defaults to false." + }, + "stencil_clear_value": { + "type": "int", + "default": "0", + "required": false, + "doc": "The value to clear the stencil aspect to if stencil_load_op is clear. Truncated to the bit size of the stencil aspect (the least significant bits are kept). Defaults to 0." + }, + "stencil_load_op": { + "type": "enums.LoadOpEnum", + "default": null, + "required": false, + "doc": "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." + }, + "stencil_store_op": { + "type": "enums.StoreOpEnum", + "default": null, + "required": false, + "doc": "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." + }, + "stencil_read_only": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the stencil aspect is read-only in the pass (it is not written to). Defaults to false." + } + }, + "doc": "Describes the depth-stencil attachment of a render pass.\n\nUsed in the depth_stencil_attachment field of structs.RenderPassDescriptor.\n" + }, + "RenderPassLayout": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label, used in debugging and error messages." + }, + "color_formats": { + "type": "list[enums.TextureFormatEnum]", + "default": null, + "required": true, + "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments." + }, + "depth_stencil_format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": false, + "doc": "The enums.TextureFormat of the depth-stencil attachment, if any." + }, + "sample_count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of samples per pixel of the attachments. Defaults to 1." + } + }, + "doc": "Describes the attachment formats of a render pass or render bundle.\n\nThis is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with\npasses (or bundles) whose layout is compatible with the pipeline.\n" + }, + "RenderBundleDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the render bundle, used in debugging and error messages." + } + }, + "doc": "Descriptor for a GPURenderBundle.\n\nUsed as the descriptor argument of the GPURenderBundleEncoder.finish() method.\n" + }, + "RenderBundleEncoderDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the render bundle encoder, used in debugging and error messages." + }, + "color_formats": { + "type": "list[enums.TextureFormatEnum]", + "default": null, + "required": true, + "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." + }, + "depth_stencil_format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": false, + "doc": "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." + }, + "sample_count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1." + }, + "depth_read_only": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the bundle does not write to the depth aspect. Defaults to false." + }, + "stencil_read_only": { + "type": "bool", + "default": "False", + "required": false, + "doc": "If true, the bundle does not write to the stencil aspect. Defaults to false." + } + }, + "doc": "Descriptor for creating a GPURenderBundleEncoder.\n\nUsed as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method.\nExtends structs.RenderPassLayout.\n" + }, + "QueueDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the queue, used in debugging and error messages." + } + }, + "doc": "Descriptor for a GPUQueue.\n\nUsed in the default_queue field of structs.DeviceDescriptor.\n" + }, + "QuerySetDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "required": false, + "doc": "A human-readable label for the query set, used in debugging and error messages." + }, + "type": { + "type": "enums.QueryTypeEnum", + "default": null, + "required": true, + "doc": "The type of queries in the set, see enums.QueryType." + }, + "count": { "type": "int", "default": null, "required": true, "doc": "The number of queries in the set." } + }, + "doc": "Descriptor for creating a GPUQuerySet.\n\nUsed as the descriptor argument of the GPUDevice.create_query_set() method.\n" + }, + "CanvasToneMapping": { + "fields": { + "mode": { + "type": "enums.CanvasToneMappingModeEnum", + "default": "\"standard\"", + "required": false, + "doc": "The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard." + } + }, + "doc": "Describes the tone mapping of a canvas.\n\nUsed in the tone_mapping field of structs.CanvasConfiguration.\n" + }, + "CanvasConfiguration": { + "fields": { + "device": { + "type": "GPUDevice", + "default": null, + "required": true, + "doc": "The GPUDevice that the canvas textures will be used with." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": null, + "required": true, + "doc": "The enums.TextureFormat of the canvas textures; must be one of the supported canvas formats. Use GPU.get_preferred_canvas_format() for the best choice." + }, + "usage": { + "type": "flags.TextureUsageFlags", + "default": "0x10", + "required": false, + "doc": "The usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT, but that is not added automatically when usage is set explicitly, so include it to render to the canvas texture." + }, + "view_formats": { + "type": "list[enums.TextureFormatEnum]", + "default": "[]", + "required": false, + "doc": "Additional enums.TextureFormat values that views of the canvas texture may use." + }, + "color_space": { + "type": "str", + "default": "\"srgb\"", + "required": false, + "doc": "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." + }, + "tone_mapping": { + "type": "structs.CanvasToneMappingStruct", + "default": "{}", + "required": false, + "doc": "A structs.CanvasToneMapping that describes how the canvas content is tone mapped. May not be supported everywhere; detect support with GPUCanvasContext.get_configuration()." + }, + "alpha_mode": { + "type": "enums.CanvasAlphaModeEnum", + "default": "\"opaque\"", + "required": false, + "doc": "How the alpha channel of the canvas is interpreted, see enums.CanvasAlphaMode. Defaults to opaque." + } + }, + "doc": "Configuration for a GPUCanvasContext.\n\nUsed as the configuration argument of the GPUCanvasContext.configure() method.\n" + }, + "UncapturedErrorEventInit": { + "fields": { + "error": { + "type": "GPUError", + "default": null, + "required": true, + "doc": "The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope." + } + }, + "doc": "Initialization data for an uncaptured error event.\n\nThe event is passed to the callback set via the onuncapturederror property of GPUDevice.\n" + }, + "Color": { + "fields": { + "r": { "type": "float", "default": null, "required": true, "doc": "The red component." }, + "g": { "type": "float", "default": null, "required": true, "doc": "The green component." }, + "b": { "type": "float", "default": null, "required": true, "doc": "The blue component." }, + "a": { "type": "float", "default": null, "required": true, "doc": "The alpha component." } + }, + "doc": "An RGBA color with floating point components.\n\nCan also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment.\n" + }, + "Origin2D": { + "fields": { + "x": { + "type": "int", + "default": "0", + "required": false, + "doc": "The x coordinate (horizontal). Defaults to 0." + }, + "y": { + "type": "int", + "default": "0", + "required": false, + "doc": "The y coordinate (vertical). Defaults to 0." + } + }, + "doc": "A 2D origin (offset) in a texture or image, in texels.\n\nCan also be given as a tuple (x, y).\n" + }, + "Origin3D": { + "fields": { + "x": { + "type": "int", + "default": "0", + "required": false, + "doc": "The x coordinate (horizontal). Defaults to 0." + }, + "y": { + "type": "int", + "default": "0", + "required": false, + "doc": "The y coordinate (vertical). Defaults to 0." + }, + "z": { + "type": "int", + "default": "0", + "required": false, + "doc": "The z coordinate (depth, or array layer). Defaults to 0." + } + }, + "doc": "A 3D origin (offset) in a texture, in texels.\n\nCan also be given as a tuple (x, y, z).\n" + }, + "Extent3D": { + "fields": { + "width": { "type": "int", "default": null, "required": true, "doc": "The width of the extent." }, + "height": { "type": "int", "default": "1", "required": false, "doc": "The height of the extent. Defaults to 1." }, + "depth_or_array_layers": { + "type": "int", + "default": "1", + "required": false, + "doc": "The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1." + } + }, + "doc": "A 3D size (extent) of a texture, in texels.\n\nCan also be given as a tuple (width, height, depth_or_array_layers).\n" + } + }, + "classes": { + "GPUObjectBase": { + "bases": [ ], + "properties": { + "label": { + "type": "str", + "doc": "A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it." + } + }, + "methods": { }, + "doc": "The base class of all GPU objects.\n\nIt provides the label property that is shared by all objects in the API.\n" + }, + "GPUAdapterInfo": { + "bases": [ ], + "properties": { + "vendor": { "type": "str", "doc": "The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'." }, + "architecture": { "type": "str", "doc": "The name of the family or class of GPUs the adapter belongs to." }, + "device": { + "type": "str", + "doc": "A vendor-specific identifier for the type of adapter (e.g. a PCI device id), if available. It does not uniquely identify a piece of hardware like a serial number." + }, + "description": { + "type": "str", + "doc": "A human-readable description of the adapter as reported by the driver, e.g. the name of the GPU. Not formatted in any standard way, so parsing it is not recommended; prefer the other fields." + }, + "subgroup_min_size": { + "type": "int", + "doc": "The minimum supported subgroup size of the adapter. Only available if enums.FeatureName.subgroups is supported." + }, + "subgroup_max_size": { + "type": "int", + "doc": "The maximum supported subgroup size of the adapter. Only available if enums.FeatureName.subgroups is supported." + }, + "is_fallback_adapter": { "type": "bool", "doc": "Whether this is a fallback adapter, e.g. a software renderer." } + }, + "methods": { }, + "doc": "Information about a physical adapter (GPU).\n\nAn instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice.\nThe values are strings that are possibly empty if the information is not available.\n" + }, + "GPU": { + "bases": [ ], + "properties": { + "wgsl_language_features": { "type": "set", "doc": "The set of WGSL language features that are supported by the implementation." } + }, + "methods": { + "request_adapter": { + "returns": { "type": "GPUAdapter", "doc": "A GPUAdapter, or None if no suitable adapter was found." }, + "args": { + "options": { + "type": "structs.RequestAdapterOptionsStruct", + "default": "{}", + "required": false, + "doc": "A structs.RequestAdapterOptions with options for selecting the adapter." + } + }, + "doc": "Request a GPUAdapter, which represents a physical GPU (or a software equivalent).\n\nThe adapter can be used to inspect the capabilities (features and limits) of the GPU,\nand to request a GPUDevice. If no suitable adapter is available, None is returned.\n" + }, + "get_preferred_canvas_format": { + "returns": { + "type": "enums.TextureFormatEnum", + "doc": "An enums.TextureFormat, either rgba8unorm or bgra8unorm." + }, + "args": { }, + "doc": "Get the preferred texture format for presenting to a canvas.\n\nUsing this format for the format field of structs.CanvasConfiguration avoids a conversion when presenting.\n" + } + }, + "doc": "The entry point of the API.\n\nIt is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu.\n" + }, + "GPUAdapter": { + "bases": [ ], + "properties": { + "features": { "type": "set", "doc": "The set of enums.FeatureName that the adapter supports." }, + "limits": { "type": "dict", "doc": "A mapping of limit names to the maximum values supported by the adapter." }, + "info": { + "type": "GPUAdapterInfo", + "doc": "A GPUAdapterInfo with information about the adapter. The values are constant over time." + } + }, + "methods": { + "request_device": { + "returns": { "type": "GPUDevice", "doc": "A GPUDevice." }, + "args": { + "descriptor": { + "type": "structs.DeviceDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.DeviceDescriptor with the required features and limits." + } + }, + "doc": "Request a GPUDevice from the adapter.\n\nThe device is the main object used to create resources and to submit work. An adapter can\nonly provide a single device; if it was already used, or if the requested features or limits\nare not supported, the request fails.\n" + } + }, + "doc": "Represents a physical GPU (or a software implementation of one).\n\nAn adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice,\nwhich is used to do actual work. Adapters are obtained via GPU.request_adapter().\n" + }, + "GPUDevice": { + "bases": [ "EventTarget", "GPUObjectBase" ], + "properties": { + "features": { + "type": "set", + "doc": "The set of enums.FeatureName that are enabled on the device (exactly those it was created with)." + }, + "limits": { + "type": "dict", + "doc": "A mapping of limit names to the values that are in effect for the device (exactly those it was created with)." + }, + "adapter_info": { + "type": "GPUAdapterInfo", + "doc": "A GPUAdapterInfo with information about the adapter that this device was created from. The values are constant over time." + }, + "queue": { "type": "GPUQueue", "doc": "The default GPUQueue of the device." }, + "lost": { + "type": "GPUDeviceLostInfo", + "doc": "A promise or future that stays pending for the lifetime of the device and resolves to a GPUDeviceLostInfo when the device is lost." + }, + "onuncapturederror": { + "type": "None", + "doc": "A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope." + } + }, + "methods": { + "destroy": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Destroy the device, preventing further operations on it.\n\nOutstanding asynchronous operations fail. The device is lost with the reason enums.DeviceLostReason.destroyed, and all resources\ncreated by the device become unusable. Destroying a device multiple times is allowed.\n" + }, + "create_buffer": { + "returns": { "type": "GPUBuffer", "doc": "A GPUBuffer." }, + "args": { + "descriptor": { + "type": "structs.BufferDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.BufferDescriptor describing the buffer." + } + }, + "doc": "Create a GPUBuffer, a block of memory that can be used by the GPU.\n\nData can be written to the buffer using GPUQueue.write_buffer(), copy commands, or by mapping it (see GPUBuffer.map_async()).\n" + }, + "create_texture": { + "returns": { "type": "GPUTexture", "doc": "A GPUTexture." }, + "args": { + "descriptor": { + "type": "structs.TextureDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.TextureDescriptor describing the texture." + } + }, + "doc": "Create a GPUTexture, an image resource (1D, 2D or 3D) that can be sampled or rendered to.\n\nTextures are not accessed directly by shaders; use GPUTexture.create_view() to obtain a GPUTextureView.\n" + }, + "create_sampler": { + "returns": { "type": "GPUSampler", "doc": "A GPUSampler." }, + "args": { + "descriptor": { + "type": "structs.SamplerDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." + } + }, + "doc": "Create a GPUSampler, which defines how a texture is sampled (filtering and addressing) in a shader.\n" + }, + "create_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout", "doc": "A GPUBindGroupLayout." }, + "args": { + "descriptor": { + "type": "structs.BindGroupLayoutDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.BindGroupLayoutDescriptor describing the entries of the layout." + } + }, + "doc": "Create a GPUBindGroupLayout, which describes the types and visibility of the resources in a bind group.\n\nA bind group layout is used in create_bind_group() and create_pipeline_layout().\n" + }, + "create_pipeline_layout": { + "returns": { "type": "GPUPipelineLayout", "doc": "A GPUPipelineLayout." }, + "args": { + "descriptor": { + "type": "structs.PipelineLayoutDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.PipelineLayoutDescriptor describing the bind group layouts." + } + }, + "doc": "Create a GPUPipelineLayout, which describes all bind groups (and immediate data) used by a pipeline.\n" + }, + "create_bind_group": { + "returns": { "type": "GPUBindGroup", "doc": "A GPUBindGroup." }, + "args": { + "descriptor": { + "type": "structs.BindGroupDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.BindGroupDescriptor with the layout and the resources to bind." + } + }, + "doc": "Create a GPUBindGroup, which binds actual resources (buffers, textures, samplers) to the slots described by a layout.\n\nBind groups are set on a pass encoder with GPUBindingCommandsMixin.set_bind_group().\n" + }, + "create_shader_module": { + "returns": { "type": "GPUShaderModule", "doc": "A GPUShaderModule." }, + "args": { + "descriptor": { + "type": "structs.ShaderModuleDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.ShaderModuleDescriptor containing the shader code." + } + }, + "doc": "Create a GPUShaderModule from shader source code (WGSL).\n\nCompilation errors do not raise immediately; use GPUShaderModule.get_compilation_info() to inspect messages,\nor use error scopes (see push_error_scope()).\n" + }, + "create_compute_pipeline": { + "returns": { "type": "GPUComputePipeline", "doc": "A GPUComputePipeline." }, + "args": { + "descriptor": { + "type": "structs.ComputePipelineDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.ComputePipelineDescriptor describing the pipeline." + } + }, + "doc": "Create a GPUComputePipeline, which describes a compute shader and its resources.\n\nThe pipeline is created immediately, which may block while the shader is compiled. Prefer create_compute_pipeline_async() when possible.\n" + }, + "create_render_pipeline": { + "returns": { "type": "GPURenderPipeline", "doc": "A GPURenderPipeline." }, + "args": { + "descriptor": { + "type": "structs.RenderPipelineDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.RenderPipelineDescriptor describing the pipeline." + } + }, + "doc": "Create a GPURenderPipeline, which describes the full state of the graphics pipeline: shaders, vertex layout, rasterization, depth/stencil, blending and render targets.\n\nThe pipeline is created immediately, which may block while the shaders are compiled. Prefer create_render_pipeline_async() when possible.\n" + }, + "create_compute_pipeline_async": { + "returns": { "type": "GPUPromise[GPUComputePipeline]", "doc": "A GPUComputePipeline (awaitable)." }, + "args": { + "descriptor": { + "type": "structs.ComputePipelineDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.ComputePipelineDescriptor describing the pipeline." + } + }, + "doc": "Asynchronous version of create_compute_pipeline().\n\nThe result is ready to be used without additional delay once the promise (or future) resolves. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device.\nUsing this method is preferred whenever possible, as it avoids blocking queue work on pipeline compilation.\n" + }, + "create_render_pipeline_async": { + "returns": { "type": "GPUPromise[GPURenderPipeline]", "doc": "A GPURenderPipeline (awaitable)." }, + "args": { + "descriptor": { + "type": "structs.RenderPipelineDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.RenderPipelineDescriptor describing the pipeline." + } + }, + "doc": "Asynchronous version of create_render_pipeline().\n\nThe result is ready to be used without additional delay once the promise (or future) resolves. If creation fails, a GPUPipelineError is raised instead of an error being generated on the device.\nUsing this method is preferred whenever possible, as it avoids blocking queue work on pipeline compilation.\n" + }, + "create_command_encoder": { + "returns": { "type": "GPUCommandEncoder", "doc": "A GPUCommandEncoder." }, + "args": { + "descriptor": { + "type": "structs.CommandEncoderDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.CommandEncoderDescriptor. Optional." + } + }, + "doc": "Create a GPUCommandEncoder, used to record GPU commands (passes and copies).\n\nFinish the encoder with GPUCommandEncoder.finish() and submit the result with GPUQueue.submit().\n" + }, + "create_render_bundle_encoder": { + "returns": { "type": "GPURenderBundleEncoder", "doc": "A GPURenderBundleEncoder." }, + "args": { + "descriptor": { + "type": "structs.RenderBundleEncoderDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.RenderBundleEncoderDescriptor describing the attachment formats." + } + }, + "doc": "Create a GPURenderBundleEncoder, used to pre-record a sequence of render commands that can be replayed in many render passes.\n\nThe attachment formats given in the descriptor determine in which render passes the resulting bundle can be used.\n" + }, + "create_query_set": { + "returns": { "type": "GPUQuerySet", "doc": "A GPUQuerySet." }, + "args": { + "descriptor": { + "type": "structs.QuerySetDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.QuerySetDescriptor describing the type and count of queries." + } + }, + "doc": "Create a GPUQuerySet, a set of queries that hold e.g. occlusion or timestamp results.\n\nResults are written during passes and can be retrieved with GPUCommandEncoder.resolve_query_set().\n" + }, + "push_error_scope": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "filter": { + "type": "enums.ErrorFilterEnum", + "default": null, + "required": true, + "doc": "The type of error to capture, see enums.ErrorFilter." + } + }, + "doc": "Push a new error scope onto the device's error scope stack.\n\nWhile the scope is active, errors of the given type that are generated by operations on this device are\ncaptured by the scope (instead of triggering the onuncapturederror callback). Retrieve them with pop_error_scope().\n" + }, + "pop_error_scope": { + "returns": { + "type": "GPUError", + "doc": "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." + }, + "args": { }, + "doc": "Pop the most recent error scope from the stack and return an error observed by it.\n\nFails if there is no error scope to pop. Errors are only reported once all operations in the scope have been processed.\n" + } + }, + "doc": "The main object that is used to create GPU resources and to submit work.\n\nA device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue\n(the queue property) which is used to submit work to the GPU. Most resources\n(buffers, textures, pipelines, etc.) are created using the create_* methods of the device.\n" + }, + "GPUBuffer": { + "bases": [ "GPUObjectBase" ], + "properties": { + "size": { "type": "int", "doc": "The size of the buffer in bytes." }, + "usage": { "type": "int", "doc": "The usage of the buffer, a combination of flags.BufferUsage." }, + "map_state": { + "type": "enums.BufferMapStateEnum", + "doc": "The current mapping state of the buffer, see enums.BufferMapState." + } + }, + "methods": { + "map_async": { + "returns": { "type": "GPUPromise[None]", "doc": "None (awaitable); resolves when the buffer is mapped." }, + "args": { + "mode": { + "type": "flags.MapModeFlags", + "default": null, + "required": true, + "doc": "Whether to map for reading or writing, see flags.MapMode." + }, + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "Map (a part of) the buffer so its memory can be accessed by the CPU.\n\nThe returned promise or future resolves when the buffer is mapped. Once mapped, use get_mapped_range()\nto access the data, and call unmap() when done to give the buffer back to the GPU.\nResolving only indicates that this buffer is mapped, not that other work has completed. However, when GPUQueue.on_submitted_work_done()\nresolves, earlier map_async() calls on buffers last used exclusively on that queue have completed.\n" + }, + "get_mapped_range": { + "returns": { "type": "ArrayLike", "doc": "A writable memory view (e.g. a memoryview) on the mapped range." }, + "args": { + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." + } + }, + "doc": "Get a view on the memory of a mapped part of the buffer.\n\nThe buffer must be mapped (see map_async() or the mapped_at_creation field of structs.BufferDescriptor).\nThe returned memory becomes invalid when the buffer is unmapped.\n" + }, + "unmap": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Unmap the buffer, making any mapped memory invalid, and handing the buffer back to the GPU.\n\nIf the buffer was mapped for writing, the written data becomes visible to the GPU.\n" + }, + "destroy": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Destroy the buffer and free its memory.\n\nThe buffer can no longer be used. Calling this multiple times is allowed.\n" + } + }, + "doc": "A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage.\n\nBuffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or\ncopy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the\nbuffer cannot be used by the GPU while it is mapped.\n" + }, + "GPUTexture": { + "bases": [ "GPUObjectBase" ], + "properties": { + "width": { "type": "int", "doc": "The width of the texture in texels." }, + "height": { "type": "int", "doc": "The height of the texture in texels." }, + "depth_or_array_layers": { "type": "int", "doc": "The depth (for 3D textures) or the number of array layers of the texture." }, + "mip_level_count": { "type": "int", "doc": "The number of mip levels of the texture." }, + "sample_count": { "type": "int", "doc": "The number of samples per pixel of the texture (1 unless multisampled)." }, + "dimension": { + "type": "enums.TextureDimensionEnum", + "doc": "The dimensionality of the texture, see enums.TextureDimension." + }, + "format": { + "type": "enums.TextureFormatEnum", + "doc": "The pixel format of the texture, see enums.TextureFormat." + }, + "usage": { "type": "int", "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." }, + "texture_binding_view_dimension": { + "type": "enums.TextureViewDimensionEnum | None", + "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. None on core devices." + } + }, + "methods": { + "create_view": { + "returns": { "type": "GPUTextureView", "doc": "A GPUTextureView." }, + "args": { + "descriptor": { + "type": "structs.TextureViewDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." + } + }, + "doc": "Create a GPUTextureView, a specific view of (part of) the texture.\n\nThe view is what gets bound to shaders or used as a render attachment.\n" + }, + "destroy": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Destroy the texture and free its memory.\n\nThe texture can no longer be used. Calling this multiple times is allowed.\n" + } + }, + "doc": "An image resource of one, two or three dimensions, optionally with mip levels and array layers.\n\nTextures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render\nattachment, create a GPUTextureView with create_view().\n" + }, + "GPUTextureView": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "A view on (a part of) a GPUTexture.\n\nTexture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry)\nand as render pass attachments (see structs.RenderPassColorAttachment).\n" + }, + "GPUSampler": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture.\n\nSamplers are created with GPUDevice.create_sampler().\n" + }, + "GPUBindGroupLayout": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup.\n\nBind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline\nvia GPUPipelineBase.get_bind_group_layout().\n" + }, + "GPUBindGroup": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout.\n\nBind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group().\n" + }, + "GPUPipelineLayout": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "Describes the bind group layouts (and immediate data size) that a pipeline uses.\n\nPipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto.\n" + }, + "GPUShaderModule": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { + "get_compilation_info": { + "returns": { "type": "GPUCompilationInfo", "doc": "A GPUCompilationInfo (awaitable) with the list of messages." }, + "args": { }, + "doc": "Get diagnostic messages (errors, warnings, info) produced when compiling the shader.\n\nThe locations, order and contents of the messages are implementation-defined; in particular, they are not necessarily ordered by line number.\n" + } + }, + "doc": "A compiled piece of shader code (WGSL), containing one or more entry points.\n\nShader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage).\n" + }, + "GPUCompilationMessage": { + "bases": [ ], + "properties": { + "message": { "type": "str", "doc": "The human-readable text of the message." }, + "type": { + "type": "enums.CompilationMessageTypeEnum", + "doc": "The severity of the message, see enums.CompilationMessageType." + }, + "line_num": { + "type": "int", + "doc": "The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line." + }, + "line_pos": { + "type": "int", + "doc": "The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position." + }, + "offset": { + "type": "int", + "doc": "The offset in the shader code (in UTF-16 code units) that the message refers to." + }, + "length": { + "type": "int", + "doc": "The length (in UTF-16 code units) of the span in the shader code that the message refers to." + } + }, + "methods": { }, + "doc": "A single diagnostic message produced when compiling a shader module.\n\nThe messages are available via the messages property of GPUCompilationInfo.\n" + }, + "GPUCompilationInfo": { + "bases": [ ], + "properties": { + "messages": { "type": "list[GPUCompilationMessage]", "doc": "A list of GPUCompilationMessage objects." } + }, + "methods": { }, + "doc": "The diagnostic messages produced when compiling a shader module.\n\nObtained from GPUShaderModule.get_compilation_info().\n" + }, + "GPUPipelineError": { + "bases": [ "DOMException" ], + "properties": { + "reason": { + "type": "enums.PipelineErrorReasonEnum", + "doc": "The reason for the failure, see enums.PipelineErrorReason." + } + }, + "methods": { + "constructor": { + "returns": { "type": "None", "doc": "A GPUPipelineError." }, + "args": { + "message": { "type": "str", "default": "\"\"", "required": false, "doc": "The human-readable error message." }, + "options": { + "type": "structs.PipelineErrorInitStruct", + "default": null, + "required": true, + "doc": "A structs.PipelineErrorInit with the reason of the error." + } + }, + "doc": "Create a GPUPipelineError.\n\nNormally these are created by the implementation rather than by user code.\n" + } + }, + "doc": "The error that is raised when asynchronous pipeline creation fails.\n\nRaised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async().\n" + }, + "GPUPipelineBase": { + "bases": [ ], + "properties": { }, + "methods": { + "get_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout", "doc": "A GPUBindGroupLayout." }, + "args": { + "index": { + "type": "int", + "default": null, + "required": true, + "doc": "The index of the bind group (the @group number in the shader)." + } + }, + "doc": "Get the GPUBindGroupLayout of the pipeline for the given bind group index.\n\nThis is especially useful for pipelines created with enums.AutoLayoutMode.auto, where the layouts are derived from the shader.\n" + } + }, + "doc": "The base class for GPUComputePipeline and GPURenderPipeline.\n\nIt provides access to the bind group layouts of the pipeline.\n" + }, + "GPUComputePipeline": { + "bases": [ "GPUObjectBase", "GPUPipelineBase" ], + "properties": { }, + "methods": { }, + "doc": "A pipeline that describes a compute shader and its resources.\n\nCreated with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline().\n" + }, + "GPURenderPipeline": { + "bases": [ "GPUObjectBase", "GPUPipelineBase" ], + "properties": { }, + "methods": { }, + "doc": "A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending.\n\nCreated with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline().\n" + }, + "GPUCommandBuffer": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "A recorded list of GPU commands, ready to be submitted.\n\nObtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once.\n" + }, + "GPUCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { }, + "doc": "A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt has no methods of its own in the current version of the API.\n" + }, + "GPUCommandEncoder": { + "bases": [ "GPUObjectBase", "GPUCommandsMixin", "GPUDebugCommandsMixin" ], + "properties": { }, + "methods": { + "begin_render_pass": { + "returns": { "type": "GPURenderPassEncoder", "doc": "A GPURenderPassEncoder." }, + "args": { + "descriptor": { + "type": "structs.RenderPassDescriptorStruct", + "default": null, + "required": true, + "doc": "A structs.RenderPassDescriptor describing the attachments of the pass." + } + }, + "doc": "Begin a render pass, returning a GPURenderPassEncoder to record draw commands with.\n\nThe pass must be ended with GPURenderPassEncoder.end() before the encoder can be used again.\n" + }, + "begin_compute_pass": { + "returns": { "type": "GPUComputePassEncoder", "doc": "A GPUComputePassEncoder." }, + "args": { + "descriptor": { + "type": "structs.ComputePassDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.ComputePassDescriptor. Optional." + } + }, + "doc": "Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with.\n\nThe pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again.\n" + }, + "copy_buffer_to_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "source": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to copy from." }, + "source_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the source buffer where the copy starts." + }, + "destination": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to copy to." }, + "destination_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the destination buffer where the data is written." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The number of bytes to copy. Defaults to the size of the source buffer minus the source_offset argument of this method." + } + }, + "doc": "Copy data from one GPUBuffer to another.\n\nThe source needs flags.BufferUsage.COPY_SRC and the destination flags.BufferUsage.COPY_DST.\nOffsets and size must be multiples of 4, and the ranges must not overlap if the buffers are the same.\n" + }, + "copy_buffer_to_texture": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "source": { + "type": "structs.TexelCopyBufferInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." + }, + "destination": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." + }, + "copy_size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": null, + "required": true, + "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." + } + }, + "doc": "Copy data from a GPUBuffer to a GPUTexture.\n\nThe source buffer needs flags.BufferUsage.COPY_SRC and the texture flags.TextureUsage.COPY_DST.\n" + }, + "copy_texture_to_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "source": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." + }, + "destination": { + "type": "structs.TexelCopyBufferInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." + }, + "copy_size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": null, + "required": true, + "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." + } + }, + "doc": "Copy data from a GPUTexture to a GPUBuffer.\n\nThe texture needs flags.TextureUsage.COPY_SRC and the destination buffer flags.BufferUsage.COPY_DST.\n" + }, + "copy_texture_to_texture": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "source": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." + }, + "destination": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." + }, + "copy_size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": null, + "required": true, + "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." + } + }, + "doc": "Copy data from one GPUTexture to another.\n\nThe source needs flags.TextureUsage.COPY_SRC and the destination flags.TextureUsage.COPY_DST.\nThe formats must be compatible, and the sample counts equal.\n" + }, + "clear_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to clear." }, + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "Fill (a part of) a GPUBuffer with zeros.\n\nThe buffer needs flags.BufferUsage.COPY_DST.\n" + }, + "resolve_query_set": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "query_set": { + "type": "GPUQuerySet", + "default": null, + "required": true, + "doc": "The GPUQuerySet to read results from." + }, + "first_query": { "type": "int", "default": null, "required": true, "doc": "The index of the first query to resolve." }, + "query_count": { "type": "int", "default": null, "required": true, "doc": "The number of queries to resolve." }, + "destination": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer to write the results to." + }, + "destination_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256." + } + }, + "doc": "Resolve the results of queries in a GPUQuerySet into a GPUBuffer.\n\nThe destination buffer needs flags.BufferUsage.QUERY_RESOLVE. Each result is written as a 64-bit unsigned integer.\n" + }, + "finish": { + "returns": { "type": "GPUCommandBuffer", "doc": "A GPUCommandBuffer." }, + "args": { + "descriptor": { + "type": "structs.CommandBufferDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.CommandBufferDescriptor. Optional." + } + }, + "doc": "Finish recording and return a GPUCommandBuffer.\n\nThe command buffer can be submitted with GPUQueue.submit(). The encoder cannot be used after this call.\n" + } + }, + "doc": "Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer.\n\nCreate one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit().\nOnly one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands.\n" + }, + "GPUBindingCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_bind_group": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "index": { + "type": "int", + "default": null, + "required": true, + "doc": "The index of the bind group (the @group number in the shader)." + }, + "bind_group": { + "type": "GPUBindGroup", + "default": null, + "required": true, + "doc": "The GPUBindGroup to set, or None to unset it." + }, + "dynamic_offsets_data": { + "type": "ArrayLike", + "default": null, + "required": true, + "doc": "A list or array of offsets in bytes, one for each dynamic buffer binding, in order of binding number." + }, + "dynamic_offsets_data_start": { + "type": "int", + "default": null, + "required": true, + "doc": "If dynamic_offsets_data is an array, the index of the first offset to use." + }, + "dynamic_offsets_data_length": { + "type": "int", + "default": null, + "required": true, + "doc": "If dynamic_offsets_data is an array, the number of offsets to use." + } + }, + "doc": "Set a GPUBindGroup for the given bind group index, to be used by subsequent draw or dispatch commands.\n\nThe bind group must be compatible with the layout of the pipeline. If the layout has entries with\ndynamic offsets (see the has_dynamic_offset field of structs.BufferBindingLayout), offsets must be provided.\nThe dynamic offsets can be given as a list, or as a range of an array (using the start and length arguments).\n" + }, + "set_immediates": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "range_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the immediate data range where the data is written. Must be a multiple of 4." + }, + "data": { + "type": "ArrayLike", + "default": null, + "required": true, + "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." + }, + "data_offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." + }, + "data_size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." + } + }, + "doc": "Set immediate data: a small amount of data (typically a few hundred bytes at most) that is passed to shaders directly without a buffer.\n\nThe size of the immediate data is determined by the immediate_size field of structs.PipelineLayoutDescriptor.\n" + } + }, + "doc": "A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt provides methods to set bind groups and immediate data.\n" + }, + "GPUDebugCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "push_debug_group": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "group_label": { "type": "str", "default": null, "required": true, "doc": "The label of the debug group." } + }, + "doc": "Begin a labeled debug group. Every call must be matched with a call to pop_debug_group().\n" + }, + "pop_debug_group": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "End the most recent debug group that was started with push_debug_group().\n" + }, + "insert_debug_marker": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "marker_label": { "type": "str", "default": null, "required": true, "doc": "The label of the marker." } + }, + "doc": "Insert a single labeled marker into the command stream.\n" + } + }, + "doc": "A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder.\n\nDebug groups and markers show up in debugging tools and in error messages.\n" + }, + "GPUComputePassEncoder": { + "bases": [ "GPUObjectBase", "GPUCommandsMixin", "GPUDebugCommandsMixin", "GPUBindingCommandsMixin" ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "pipeline": { + "type": "GPUComputePipeline", + "default": null, + "required": true, + "doc": "The GPUComputePipeline to use." + } + }, + "doc": "Set the GPUComputePipeline to use for subsequent dispatch commands.\n" + }, + "dispatch_workgroups": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "workgroup_count_x": { + "type": "int", + "default": null, + "required": true, + "doc": "The number of workgroups in the x dimension." + }, + "workgroup_count_y": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of workgroups in the y dimension. Defaults to 1." + }, + "workgroup_count_z": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of workgroups in the z dimension. Defaults to 1." + } + }, + "doc": "Run the compute shader of the current pipeline for a grid of workgroups.\n\nThe total number of invocations is the number of workgroups times the workgroup size defined in the shader.\n" + }, + "dispatch_workgroups_indirect": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "indirect_buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains the workgroup counts." + }, + "indirect_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the buffer where the counts start. Must be a multiple of 4." + } + }, + "doc": "Like dispatch_workgroups(), but the workgroup counts are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain three consecutive 32-bit unsigned integers (x, y, z) at the given offset.\n" + }, + "end": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "End the compute pass. The encoder can no longer be used afterwards.\n" + } + }, + "doc": "Records the commands of a compute pass.\n\nCreated with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work,\nand finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin.\n" + }, + "GPURenderPassEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "set_viewport": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "x": { + "type": "float", + "default": null, + "required": true, + "doc": "The x coordinate of the top-left corner of the viewport, in pixels." + }, + "y": { + "type": "float", + "default": null, + "required": true, + "doc": "The y coordinate of the top-left corner of the viewport, in pixels." + }, + "width": { "type": "float", "default": null, "required": true, "doc": "The width of the viewport, in pixels." }, + "height": { "type": "float", "default": null, "required": true, "doc": "The height of the viewport, in pixels." }, + "min_depth": { + "type": "float", + "default": null, + "required": true, + "doc": "The minimum depth value of the viewport (between 0 and 1)." + }, + "max_depth": { + "type": "float", + "default": null, + "required": true, + "doc": "The maximum depth value of the viewport (between 0 and 1)." + } + }, + "doc": "Set the viewport: the region of the attachments that the clip-space output is mapped to.\n\nDefaults to the full size of the attachments.\n" + }, + "set_scissor_rect": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "x": { + "type": "int", + "default": null, + "required": true, + "doc": "The x coordinate of the top-left corner of the rectangle, in pixels." + }, + "y": { + "type": "int", + "default": null, + "required": true, + "doc": "The y coordinate of the top-left corner of the rectangle, in pixels." + }, + "width": { "type": "int", "default": null, "required": true, "doc": "The width of the rectangle, in pixels." }, + "height": { "type": "int", "default": null, "required": true, "doc": "The height of the rectangle, in pixels." } + }, + "doc": "Set the scissor rectangle: fragments outside of this rectangle are discarded.\n\nDefaults to the full size of the attachments.\n" + }, + "set_blend_constant": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "color": { + "type": "tuple[float, float, float, float] | structs.ColorStruct", + "default": null, + "required": true, + "doc": "The color, as a structs.Color or a tuple (r, g, b, a)." + } + }, + "doc": "Set the blend constant color, used by blend factors enums.BlendFactor.constant and enums.BlendFactor.one_minus_constant.\n\nDefaults to transparent black (0, 0, 0, 0).\n" + }, + "set_stencil_reference": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "reference": { + "type": "int", + "default": null, + "required": true, + "doc": "The stencil reference value (an unsigned integer)." + } + }, + "doc": "Set the stencil reference value, used in stencil comparisons and by enums.StencilOperation.replace.\n\nDefaults to 0.\n" + }, + "begin_occlusion_query": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "query_index": { + "type": "int", + "default": null, + "required": true, + "doc": "The index in the query set where the result is stored." + } + }, + "doc": "Begin an occlusion query, which counts the samples that pass the depth and stencil tests.\n\nThe result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor).\nEnd the query with end_occlusion_query().\n" + }, + "end_occlusion_query": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "End the occlusion query that was started with begin_occlusion_query().\n" + }, + "execute_bundles": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "bundles": { + "type": "list[GPURenderBundle]", + "default": null, + "required": true, + "doc": "A list of GPURenderBundle objects to execute, in order." + } + }, + "doc": "Execute pre-recorded GPURenderBundle objects as part of this pass.\n\nBundles do not inherit the pipeline, bind groups or vertex/index buffers of the pass. After executing bundles (even zero of them),\nthat state is cleared, not restored, so it needs to be set again.\n" + }, + "end": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "End the render pass. The encoder can no longer be used afterwards.\n" + } + }, + "doc": "Records the commands of a render pass.\n\nCreated with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers,\ndraw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin.\n" + }, + "GPURenderCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "pipeline": { + "type": "GPURenderPipeline", + "default": null, + "required": true, + "doc": "The GPURenderPipeline to use." + } + }, + "doc": "Set the GPURenderPipeline to use for subsequent draw commands.\n" + }, + "set_index_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains the indices." + }, + "index_format": { + "type": "enums.IndexFormatEnum", + "default": null, + "required": true, + "doc": "The data type of the indices, see enums.IndexFormat." + }, + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes in the buffer where the indices start. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "Set the index buffer to use for subsequent indexed draw commands.\n\nThe buffer needs flags.BufferUsage.INDEX.\n" + }, + "set_vertex_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "slot": { + "type": "int", + "default": null, + "required": true, + "doc": "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." + }, + "buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains the vertex data, or None to unset the slot." + }, + "offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "Set a vertex buffer for the given slot, to be used by subsequent draw commands.\n\nThe buffer needs flags.BufferUsage.VERTEX. The layout is defined by the buffers field of structs.VertexState.\n" + }, + "draw": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "vertex_count": { "type": "int", "default": null, "required": true, "doc": "The number of vertices to draw." }, + "instance_count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of instances to draw. Defaults to 1." + }, + "first_vertex": { + "type": "int", + "default": "0", + "required": false, + "doc": "The index of the first vertex to draw (the offset into the vertex buffers, in vertices). Defaults to 0." + }, + "first_instance": { + "type": "int", + "default": "0", + "required": false, + "doc": "The instance index of the first instance to draw. Defaults to 0." + } + }, + "doc": "Draw primitives using the current pipeline and vertex buffers.\n" + }, + "draw_indexed": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "index_count": { "type": "int", "default": null, "required": true, "doc": "The number of indices to draw." }, + "instance_count": { + "type": "int", + "default": "1", + "required": false, + "doc": "The number of instances to draw. Defaults to 1." + }, + "first_index": { + "type": "int", + "default": "0", + "required": false, + "doc": "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." + }, + "base_vertex": { + "type": "int", + "default": "0", + "required": false, + "doc": "A value added to each index before looking up the vertex. Defaults to 0." + }, + "first_instance": { + "type": "int", + "default": "0", + "required": false, + "doc": "The instance index of the first instance to draw. Defaults to 0." + } + }, + "doc": "Draw primitives using the current pipeline, vertex buffers and index buffer (see set_index_buffer()).\n" + }, + "draw_indirect": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "indirect_buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains the draw parameters." + }, + "indirect_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." + } + }, + "doc": "Like draw(), but the parameters are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain a tightly packed block of four 32-bit unsigned integers (16 bytes)\nat the given offset: vertex_count, instance_count, first_vertex and first_instance.\nA non-zero first_instance requires enums.FeatureName.indirect_first_instance.\n" + }, + "draw_indexed_indirect": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "indirect_buffer": { + "type": "GPUBuffer", + "default": null, + "required": true, + "doc": "The GPUBuffer that contains the draw parameters." + }, + "indirect_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." + } + }, + "doc": "Like draw_indexed(), but the parameters are read from a GPUBuffer.\n\nThe buffer must have flags.BufferUsage.INDIRECT, and contain a tightly packed block of five 32-bit values (20 bytes) at the given offset:\nindex_count, instance_count, first_index, base_vertex and first_instance.\nA non-zero first_instance requires enums.FeatureName.indirect_first_instance.\n" + } + }, + "doc": "A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder.\n\nIt provides methods to set the pipeline, vertex and index buffers, and to draw.\n" + }, + "GPURenderBundle": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { }, + "doc": "A pre-recorded sequence of render commands that can be executed in render passes.\n\nObtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles().\n" + }, + "GPURenderBundleEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "finish": { + "returns": { "type": "GPURenderBundle", "doc": "A GPURenderBundle." }, + "args": { + "descriptor": { + "type": "structs.RenderBundleDescriptorStruct", + "default": "{}", + "required": false, + "doc": "A structs.RenderBundleDescriptor. Optional." + } + }, + "doc": "Finish recording and return a GPURenderBundle.\n\nThe encoder cannot be used after this call.\n" + } + }, + "doc": "Records render commands into a GPURenderBundle, which can be replayed in multiple render passes.\n\nCreated with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin,\nGPUDebugCommandsMixin and GPURenderCommandsMixin.\n" + }, + "GPUQueue": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { + "submit": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "command_buffers": { + "type": "list[GPUCommandBuffer]", + "default": null, + "required": true, + "doc": "A list of GPUCommandBuffer objects, executed in order." + } + }, + "doc": "Submit a list of command buffers for execution on the GPU.\n\nEach command buffer can only be submitted once.\n" + }, + "on_submitted_work_done": { + "returns": { "type": "None", "doc": "None (awaitable); resolves when the submitted work is done." }, + "args": { }, + "doc": "Wait until all work that was submitted so far has been completed by the GPU.\n\nResolving also implies completion of earlier GPUBuffer.map_async() calls on buffers last used exclusively on this queue.\n" + }, + "write_buffer": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to write to." }, + "buffer_offset": { + "type": "int", + "default": null, + "required": true, + "doc": "The offset in bytes in the buffer where the data is written." + }, + "data": { + "type": "ArrayLike", + "default": null, + "required": true, + "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." + }, + "data_offset": { + "type": "int", + "default": "0", + "required": false, + "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." + }, + "size": { + "type": "int", + "default": "None", + "required": false, + "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." + } + }, + "doc": "Write data to a GPUBuffer.\n\nThis is a convenient way to upload data. The buffer needs flags.BufferUsage.COPY_DST.\nThe size of the data to write and the offset must be multiples of 4.\n" + }, + "write_texture": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "destination": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to write to." + }, + "data": { + "type": "ArrayLike", + "default": null, + "required": true, + "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." + }, + "data_layout": { + "type": "structs.TexelCopyBufferLayoutStruct", + "default": null, + "required": true, + "doc": "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." + }, + "size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": null, + "required": true, + "doc": "A structs.Extent3D (or tuple) with the size of the region to write, in texels." + } + }, + "doc": "Write data to a GPUTexture.\n\nThis is a convenient way to upload texture data. The texture needs flags.TextureUsage.COPY_DST.\n" + } + }, + "doc": "The queue on which work is submitted to the GPU.\n\nEach GPUDevice has a default queue, available via the queue property of GPUDevice.\nIt is used to submit command buffers and to upload data to buffers and textures.\n" + }, + "GPUQuerySet": { + "bases": [ "GPUObjectBase" ], + "properties": { + "type": { "type": "enums.QueryTypeEnum", "doc": "The type of queries in the set, see enums.QueryType." }, + "count": { "type": "int", "doc": "The number of queries in the set." } + }, + "methods": { + "destroy": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Destroy the query set and free its resources.\n\nThe query set can no longer be used. Calling this multiple times is allowed.\n" + } + }, + "doc": "A set of queries that hold results such as occlusion counts or timestamps.\n\nCreated with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving\nthem into a buffer with GPUCommandEncoder.resolve_query_set().\n" + }, + "GPUCanvasContext": { + "bases": [ ], + "properties": { + "canvas": { "type": "CanvasLike", "doc": "The canvas (or window/surface object) that this context belongs to." } + }, + "methods": { + "configure": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "configuration": { + "type": "structs.CanvasConfigurationStruct", + "default": null, + "required": true, + "doc": "A structs.CanvasConfiguration with the device, format and other settings." + } + }, + "doc": "Configure the context for use with a device, so that textures can be obtained from it.\n\nCalling this again replaces the previous configuration. It also clears the drawing buffer to transparent black.\nUse get_configuration() to detect support for optional configuration members.\n" + }, + "unconfigure": { + "returns": { "type": "None", "doc": "None." }, + "args": { }, + "doc": "Remove the configuration and destroy any textures produced while configured.\n\nAfter this, get_current_texture() cannot be used until the context is configured again.\n" + }, + "get_configuration": { + "returns": { + "type": "structs.CanvasConfigurationStruct", + "doc": "The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured." + }, + "args": { }, + "doc": "Get the current configuration of the context, or None if it is not configured.\n\nThis is mainly useful for feature detection of optional members of structs.CanvasConfiguration; for supported members it returns the originally supplied values.\n" + }, + "get_current_texture": { + "returns": { "type": "GPUTexture", "doc": "A GPUTexture." }, + "args": { }, + "doc": "Get the GPUTexture to render to for the current frame.\n\nThe texture has the size of the canvas, and is the texture that will be composited to the canvas next. The same GPUTexture object is returned\nuntil the frame is presented (even if it was destroyed or failed validation); a new one is returned for the next frame.\n" + } + }, + "doc": "The connection between a canvas (or window) and the GPU, used to present rendered images.\n\nConfigure it with configure(), then each frame obtain a texture with get_current_texture(),\nrender to it, and submit the work. The result is presented when the frame ends.\n" + }, + "GPUDeviceLostInfo": { + "bases": [ ], + "properties": { + "reason": { + "type": "enums.DeviceLostReasonEnum", + "doc": "The reason the device was lost, see enums.DeviceLostReason." + }, + "message": { "type": "str", "doc": "A human-readable message with details about why the device was lost." } + }, + "methods": { }, + "doc": "Information about why a GPUDevice was lost.\n\nAvailable via the lost property of GPUDevice.\n" + }, + "GPUError": { + "bases": [ ], + "properties": { + "message": { + "type": "str", + "doc": "A human-readable description of the error, meant for developers (debugging, bug reports) and not for end users. Do not try to parse it." + } + }, + "methods": { }, + "doc": "The base class of errors that are generated by the GPU API.\n\nSubclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError.\nErrors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice.\n" + }, + "GPUValidationError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None", "doc": "A GPUValidationError." }, + "args": { + "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + }, + "doc": "Create a GPUValidationError.\n\nNormally these are created by the implementation rather than by user code.\n" + } + }, + "doc": "An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage.\n\nCaptured by error scopes with enums.ErrorFilter.validation.\n" + }, + "GPUOutOfMemoryError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None", "doc": "A GPUOutOfMemoryError." }, + "args": { + "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + }, + "doc": "Create a GPUOutOfMemoryError.\n\nNormally these are created by the implementation rather than by user code.\n" + } + }, + "doc": "An error that signals that there was not enough memory to complete an operation.\n\nCaptured by error scopes with enums.ErrorFilter.out_of_memory.\n" + }, + "GPUInternalError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None", "doc": "A GPUInternalError." }, + "args": { + "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + }, + "doc": "Create a GPUInternalError.\n\nNormally these are created by the implementation rather than by user code.\n" + } + }, + "doc": "An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit.\n\nCaptured by error scopes with enums.ErrorFilter.internal.\n" + } + } +} diff --git a/apigen/definitions/wgpu_api.toml b/apigen/definitions/wgpu_api.toml deleted file mode 100644 index f9bb56b9..00000000 --- a/apigen/definitions/wgpu_api.toml +++ /dev/null @@ -1,1190 +0,0 @@ -# wgpu_api.toml: the base wgpu-py API, generated from 'wgpu_api_web.toml' and 'diff_base.toml'. - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[flags] - -[flags.BufferUsage] -fields.MAP_READ = { value = 1 } -fields.MAP_WRITE = { value = 2 } -fields.COPY_SRC = { value = 4 } -fields.COPY_DST = { value = 8 } -fields.INDEX = { value = 16 } -fields.VERTEX = { value = 32 } -fields.UNIFORM = { value = 64 } -fields.STORAGE = { value = 128 } -fields.INDIRECT = { value = 256 } -fields.QUERY_RESOLVE = { value = 512 } - -[flags.MapMode] -fields.READ = { value = 1 } -fields.WRITE = { value = 2 } - -[flags.TextureUsage] -fields.COPY_SRC = { value = 1 } -fields.COPY_DST = { value = 2 } -fields.TEXTURE_BINDING = { value = 4 } -fields.STORAGE_BINDING = { value = 8 } -fields.RENDER_ATTACHMENT = { value = 16 } -fields.TRANSIENT_ATTACHMENT = { value = 32 } - -[flags.ShaderStage] -fields.VERTEX = { value = 1 } -fields.FRAGMENT = { value = 2 } -fields.COMPUTE = { value = 4 } - -[flags.ColorWrite] -fields.RED = { value = 1 } -fields.GREEN = { value = 2 } -fields.BLUE = { value = 4 } -fields.ALPHA = { value = 8 } -fields.ALL = { value = 15 } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[enums] - -[enums.PowerPreference] -fields.low_power = { value = 'low-power' } -fields.high_performance = { value = 'high-performance' } - -[enums.FeatureName] -fields.core_features_and_limits = { value = 'core-features-and-limits' } -fields.depth_clip_control = { value = 'depth-clip-control' } -fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } -fields.texture_compression_bc = { value = 'texture-compression-bc' } -fields.texture_compression_bc_sliced_d3 = { value = 'texture-compression-bc-sliced-3d' } -fields.texture_compression_etc2 = { value = 'texture-compression-etc2' } -fields.texture_compression_astc = { value = 'texture-compression-astc' } -fields.texture_compression_astc_sliced_d3 = { value = 'texture-compression-astc-sliced-3d' } -fields.timestamp_query = { value = 'timestamp-query' } -fields.indirect_first_instance = { value = 'indirect-first-instance' } -fields.shader_f16 = { value = 'shader-f16' } -fields.rg11b10ufloat_renderable = { value = 'rg11b10ufloat-renderable' } -fields.bgra8unorm_storage = { value = 'bgra8unorm-storage' } -fields.float32_filterable = { value = 'float32-filterable' } -fields.float32_blendable = { value = 'float32-blendable' } -fields.clip_distances = { value = 'clip-distances' } -fields.dual_source_blending = { value = 'dual-source-blending' } -fields.subgroups = { value = 'subgroups' } -fields.texture_formats_tier1 = { value = 'texture-formats-tier1' } -fields.texture_formats_tier2 = { value = 'texture-formats-tier2' } -fields.primitive_index = { value = 'primitive-index' } -fields.texture_component_swizzle = { value = 'texture-component-swizzle' } - -[enums.BufferMapState] -fields.unmapped = { value = 'unmapped' } -fields.pending = { value = 'pending' } -fields.mapped = { value = 'mapped' } - -[enums.TextureDimension] -fields.d1 = { value = '1d' } -fields.d2 = { value = '2d' } -fields.d3 = { value = '3d' } - -[enums.TextureViewDimension] -fields.d1 = { value = '1d' } -fields.d2 = { value = '2d' } -fields.d2_array = { value = '2d-array' } -fields.cube = { value = 'cube' } -fields.cube_array = { value = 'cube-array' } -fields.d3 = { value = '3d' } - -[enums.TextureAspect] -fields.all = { value = 'all' } -fields.stencil_only = { value = 'stencil-only' } -fields.depth_only = { value = 'depth-only' } - -[enums.TextureFormat] -fields.r8unorm = { value = 'r8unorm' } -fields.r8snorm = { value = 'r8snorm' } -fields.r8uint = { value = 'r8uint' } -fields.r8sint = { value = 'r8sint' } -fields.r16unorm = { value = 'r16unorm' } -fields.r16snorm = { value = 'r16snorm' } -fields.r16uint = { value = 'r16uint' } -fields.r16sint = { value = 'r16sint' } -fields.r16float = { value = 'r16float' } -fields.rg8unorm = { value = 'rg8unorm' } -fields.rg8snorm = { value = 'rg8snorm' } -fields.rg8uint = { value = 'rg8uint' } -fields.rg8sint = { value = 'rg8sint' } -fields.r32uint = { value = 'r32uint' } -fields.r32sint = { value = 'r32sint' } -fields.r32float = { value = 'r32float' } -fields.rg16unorm = { value = 'rg16unorm' } -fields.rg16snorm = { value = 'rg16snorm' } -fields.rg16uint = { value = 'rg16uint' } -fields.rg16sint = { value = 'rg16sint' } -fields.rg16float = { value = 'rg16float' } -fields.rgba8unorm = { value = 'rgba8unorm' } -fields.rgba8unorm_srgb = { value = 'rgba8unorm-srgb' } -fields.rgba8snorm = { value = 'rgba8snorm' } -fields.rgba8uint = { value = 'rgba8uint' } -fields.rgba8sint = { value = 'rgba8sint' } -fields.bgra8unorm = { value = 'bgra8unorm' } -fields.bgra8unorm_srgb = { value = 'bgra8unorm-srgb' } -fields.rgb9e5ufloat = { value = 'rgb9e5ufloat' } -fields.rgb10a2uint = { value = 'rgb10a2uint' } -fields.rgb10a2unorm = { value = 'rgb10a2unorm' } -fields.rg11b10ufloat = { value = 'rg11b10ufloat' } -fields.rg32uint = { value = 'rg32uint' } -fields.rg32sint = { value = 'rg32sint' } -fields.rg32float = { value = 'rg32float' } -fields.rgba16unorm = { value = 'rgba16unorm' } -fields.rgba16snorm = { value = 'rgba16snorm' } -fields.rgba16uint = { value = 'rgba16uint' } -fields.rgba16sint = { value = 'rgba16sint' } -fields.rgba16float = { value = 'rgba16float' } -fields.rgba32uint = { value = 'rgba32uint' } -fields.rgba32sint = { value = 'rgba32sint' } -fields.rgba32float = { value = 'rgba32float' } -fields.stencil8 = { value = 'stencil8' } -fields.depth16unorm = { value = 'depth16unorm' } -fields.depth24plus = { value = 'depth24plus' } -fields.depth24plus_stencil8 = { value = 'depth24plus-stencil8' } -fields.depth32float = { value = 'depth32float' } -fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } -fields.bc1_rgba_unorm = { value = 'bc1-rgba-unorm' } -fields.bc1_rgba_unorm_srgb = { value = 'bc1-rgba-unorm-srgb' } -fields.bc2_rgba_unorm = { value = 'bc2-rgba-unorm' } -fields.bc2_rgba_unorm_srgb = { value = 'bc2-rgba-unorm-srgb' } -fields.bc3_rgba_unorm = { value = 'bc3-rgba-unorm' } -fields.bc3_rgba_unorm_srgb = { value = 'bc3-rgba-unorm-srgb' } -fields.bc4_r_unorm = { value = 'bc4-r-unorm' } -fields.bc4_r_snorm = { value = 'bc4-r-snorm' } -fields.bc5_rg_unorm = { value = 'bc5-rg-unorm' } -fields.bc5_rg_snorm = { value = 'bc5-rg-snorm' } -fields.bc6h_rgb_ufloat = { value = 'bc6h-rgb-ufloat' } -fields.bc6h_rgb_float = { value = 'bc6h-rgb-float' } -fields.bc7_rgba_unorm = { value = 'bc7-rgba-unorm' } -fields.bc7_rgba_unorm_srgb = { value = 'bc7-rgba-unorm-srgb' } -fields.etc2_rgb8unorm = { value = 'etc2-rgb8unorm' } -fields.etc2_rgb8unorm_srgb = { value = 'etc2-rgb8unorm-srgb' } -fields.etc2_rgb8a1unorm = { value = 'etc2-rgb8a1unorm' } -fields.etc2_rgb8a1unorm_srgb = { value = 'etc2-rgb8a1unorm-srgb' } -fields.etc2_rgba8unorm = { value = 'etc2-rgba8unorm' } -fields.etc2_rgba8unorm_srgb = { value = 'etc2-rgba8unorm-srgb' } -fields.eac_r11unorm = { value = 'eac-r11unorm' } -fields.eac_r11snorm = { value = 'eac-r11snorm' } -fields.eac_rg11unorm = { value = 'eac-rg11unorm' } -fields.eac_rg11snorm = { value = 'eac-rg11snorm' } -fields.astc_4x4_unorm = { value = 'astc-4x4-unorm' } -fields.astc_4x4_unorm_srgb = { value = 'astc-4x4-unorm-srgb' } -fields.astc_5x4_unorm = { value = 'astc-5x4-unorm' } -fields.astc_5x4_unorm_srgb = { value = 'astc-5x4-unorm-srgb' } -fields.astc_5x5_unorm = { value = 'astc-5x5-unorm' } -fields.astc_5x5_unorm_srgb = { value = 'astc-5x5-unorm-srgb' } -fields.astc_6x5_unorm = { value = 'astc-6x5-unorm' } -fields.astc_6x5_unorm_srgb = { value = 'astc-6x5-unorm-srgb' } -fields.astc_6x6_unorm = { value = 'astc-6x6-unorm' } -fields.astc_6x6_unorm_srgb = { value = 'astc-6x6-unorm-srgb' } -fields.astc_8x5_unorm = { value = 'astc-8x5-unorm' } -fields.astc_8x5_unorm_srgb = { value = 'astc-8x5-unorm-srgb' } -fields.astc_8x6_unorm = { value = 'astc-8x6-unorm' } -fields.astc_8x6_unorm_srgb = { value = 'astc-8x6-unorm-srgb' } -fields.astc_8x8_unorm = { value = 'astc-8x8-unorm' } -fields.astc_8x8_unorm_srgb = { value = 'astc-8x8-unorm-srgb' } -fields.astc_10x5_unorm = { value = 'astc-10x5-unorm' } -fields.astc_10x5_unorm_srgb = { value = 'astc-10x5-unorm-srgb' } -fields.astc_10x6_unorm = { value = 'astc-10x6-unorm' } -fields.astc_10x6_unorm_srgb = { value = 'astc-10x6-unorm-srgb' } -fields.astc_10x8_unorm = { value = 'astc-10x8-unorm' } -fields.astc_10x8_unorm_srgb = { value = 'astc-10x8-unorm-srgb' } -fields.astc_10x10_unorm = { value = 'astc-10x10-unorm' } -fields.astc_10x10_unorm_srgb = { value = 'astc-10x10-unorm-srgb' } -fields.astc_12x10_unorm = { value = 'astc-12x10-unorm' } -fields.astc_12x10_unorm_srgb = { value = 'astc-12x10-unorm-srgb' } -fields.astc_12x12_unorm = { value = 'astc-12x12-unorm' } -fields.astc_12x12_unorm_srgb = { value = 'astc-12x12-unorm-srgb' } - -[enums.AddressMode] -fields.clamp_to_edge = { value = 'clamp-to-edge' } -fields.repeat = { value = 'repeat' } -fields.mirror_repeat = { value = 'mirror-repeat' } - -[enums.FilterMode] -fields.nearest = { value = 'nearest' } -fields.linear = { value = 'linear' } - -[enums.MipmapFilterMode] -fields.nearest = { value = 'nearest' } -fields.linear = { value = 'linear' } - -[enums.CompareFunction] -fields.never = { value = 'never' } -fields.less = { value = 'less' } -fields.equal = { value = 'equal' } -fields.less_equal = { value = 'less-equal' } -fields.greater = { value = 'greater' } -fields.not_equal = { value = 'not-equal' } -fields.greater_equal = { value = 'greater-equal' } -fields.always = { value = 'always' } - -[enums.BufferBindingType] -fields.uniform = { value = 'uniform' } -fields.storage = { value = 'storage' } -fields.read_only_storage = { value = 'read-only-storage' } - -[enums.SamplerBindingType] -fields.filtering = { value = 'filtering' } -fields.non_filtering = { value = 'non-filtering' } -fields.comparison = { value = 'comparison' } - -[enums.TextureSampleType] -fields.float = { value = 'float' } -fields.unfilterable_float = { value = 'unfilterable-float' } -fields.depth = { value = 'depth' } -fields.sint = { value = 'sint' } -fields.uint = { value = 'uint' } - -[enums.StorageTextureAccess] -fields.write_only = { value = 'write-only' } -fields.read_only = { value = 'read-only' } -fields.read_write = { value = 'read-write' } - -[enums.CompilationMessageType] -fields.error = { value = 'error' } -fields.warning = { value = 'warning' } -fields.info = { value = 'info' } - -[enums.PipelineErrorReason] -fields.validation = { value = 'validation' } -fields.internal = { value = 'internal' } - -[enums.AutoLayoutMode] -fields.auto = { value = 'auto' } - -[enums.PrimitiveTopology] -fields.point_list = { value = 'point-list' } -fields.line_list = { value = 'line-list' } -fields.line_strip = { value = 'line-strip' } -fields.triangle_list = { value = 'triangle-list' } -fields.triangle_strip = { value = 'triangle-strip' } - -[enums.FrontFace] -fields.ccw = { value = 'ccw' } -fields.cw = { value = 'cw' } - -[enums.CullMode] -fields.none = { value = 'none' } -fields.front = { value = 'front' } -fields.back = { value = 'back' } - -[enums.BlendFactor] -fields.zero = { value = 'zero' } -fields.one = { value = 'one' } -fields.src = { value = 'src' } -fields.one_minus_src = { value = 'one-minus-src' } -fields.src_alpha = { value = 'src-alpha' } -fields.one_minus_src_alpha = { value = 'one-minus-src-alpha' } -fields.dst = { value = 'dst' } -fields.one_minus_dst = { value = 'one-minus-dst' } -fields.dst_alpha = { value = 'dst-alpha' } -fields.one_minus_dst_alpha = { value = 'one-minus-dst-alpha' } -fields.src_alpha_saturated = { value = 'src-alpha-saturated' } -fields.constant = { value = 'constant' } -fields.one_minus_constant = { value = 'one-minus-constant' } -fields.src1 = { value = 'src1' } -fields.one_minus_src1 = { value = 'one-minus-src1' } -fields.src1_alpha = { value = 'src1-alpha' } -fields.one_minus_src1_alpha = { value = 'one-minus-src1-alpha' } - -[enums.BlendOperation] -fields.add = { value = 'add' } -fields.subtract = { value = 'subtract' } -fields.reverse_subtract = { value = 'reverse-subtract' } -fields.min = { value = 'min' } -fields.max = { value = 'max' } - -[enums.StencilOperation] -fields.keep = { value = 'keep' } -fields.zero = { value = 'zero' } -fields.replace = { value = 'replace' } -fields.invert = { value = 'invert' } -fields.increment_clamp = { value = 'increment-clamp' } -fields.decrement_clamp = { value = 'decrement-clamp' } -fields.increment_wrap = { value = 'increment-wrap' } -fields.decrement_wrap = { value = 'decrement-wrap' } - -[enums.IndexFormat] -fields.uint16 = { value = 'uint16' } -fields.uint32 = { value = 'uint32' } - -[enums.VertexFormat] -fields.uint8 = { value = 'uint8' } -fields.uint8x2 = { value = 'uint8x2' } -fields.uint8x4 = { value = 'uint8x4' } -fields.sint8 = { value = 'sint8' } -fields.sint8x2 = { value = 'sint8x2' } -fields.sint8x4 = { value = 'sint8x4' } -fields.unorm8 = { value = 'unorm8' } -fields.unorm8x2 = { value = 'unorm8x2' } -fields.unorm8x4 = { value = 'unorm8x4' } -fields.snorm8 = { value = 'snorm8' } -fields.snorm8x2 = { value = 'snorm8x2' } -fields.snorm8x4 = { value = 'snorm8x4' } -fields.uint16 = { value = 'uint16' } -fields.uint16x2 = { value = 'uint16x2' } -fields.uint16x4 = { value = 'uint16x4' } -fields.sint16 = { value = 'sint16' } -fields.sint16x2 = { value = 'sint16x2' } -fields.sint16x4 = { value = 'sint16x4' } -fields.unorm16 = { value = 'unorm16' } -fields.unorm16x2 = { value = 'unorm16x2' } -fields.unorm16x4 = { value = 'unorm16x4' } -fields.snorm16 = { value = 'snorm16' } -fields.snorm16x2 = { value = 'snorm16x2' } -fields.snorm16x4 = { value = 'snorm16x4' } -fields.float16 = { value = 'float16' } -fields.float16x2 = { value = 'float16x2' } -fields.float16x4 = { value = 'float16x4' } -fields.float32 = { value = 'float32' } -fields.float32x2 = { value = 'float32x2' } -fields.float32x3 = { value = 'float32x3' } -fields.float32x4 = { value = 'float32x4' } -fields.uint32 = { value = 'uint32' } -fields.uint32x2 = { value = 'uint32x2' } -fields.uint32x3 = { value = 'uint32x3' } -fields.uint32x4 = { value = 'uint32x4' } -fields.sint32 = { value = 'sint32' } -fields.sint32x2 = { value = 'sint32x2' } -fields.sint32x3 = { value = 'sint32x3' } -fields.sint32x4 = { value = 'sint32x4' } -fields.unorm10_10_10_2 = { value = 'unorm10-10-10-2' } -fields.unorm8x4_bgra = { value = 'unorm8x4-bgra' } - -[enums.VertexStepMode] -fields.vertex = { value = 'vertex' } -fields.instance = { value = 'instance' } - -[enums.LoadOp] -fields.load = { value = 'load' } -fields.clear = { value = 'clear' } - -[enums.StoreOp] -fields.store = { value = 'store' } -fields.discard = { value = 'discard' } - -[enums.QueryType] -fields.occlusion = { value = 'occlusion' } -fields.timestamp = { value = 'timestamp' } - -[enums.CanvasAlphaMode] -fields.opaque = { value = 'opaque' } -fields.premultiplied = { value = 'premultiplied' } - -[enums.CanvasToneMappingMode] -fields.standard = { value = 'standard' } -fields.extended = { value = 'extended' } - -[enums.DeviceLostReason] -fields.unknown = { value = 'unknown' } -fields.destroyed = { value = 'destroyed' } - -[enums.ErrorFilter] -fields.validation = { value = 'validation' } -fields.out_of_memory = { value = 'out-of-memory' } -fields.internal = { value = 'internal' } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[structs] - -[structs.RequestAdapterOptions] -fields.feature_level = { type = 'str', default = '"core"', required = false } -fields.power_preference = { type = 'enums.PowerPreferenceEnum', default = 'None', required = false } -fields.force_fallback_adapter = { type = 'bool', default = 'False', required = false } -fields.xr_compatible = { type = 'bool', default = 'False', required = false } - -[structs.DeviceDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.required_features = { type = 'list[enums.FeatureNameEnum]', default = '[]', required = false } -fields.required_limits = { type = 'dict[str, int | None]', default = '{}', required = false } -fields.default_queue = { type = 'structs.QueueDescriptorStruct', default = '{}', required = false } - -[structs.BufferDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.size = { type = 'int', default = 'None', required = true } -fields.usage = { type = 'flags.BufferUsageFlags', default = 'None', required = true } -fields.mapped_at_creation = { type = 'bool', default = 'False', required = false } - -[structs.TextureDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -fields.mip_level_count = { type = 'int', default = '1', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } -fields.dimension = { type = 'enums.TextureDimensionEnum', default = '"2d"', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.usage = { type = 'flags.TextureUsageFlags', default = 'None', required = true } -fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } -fields.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } - -[structs.TextureViewDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } -fields.usage = { type = 'flags.TextureUsageFlags', default = '0', required = false } -fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } -fields.base_mip_level = { type = 'int', default = '0', required = false } -fields.mip_level_count = { type = 'int', default = 'None', required = false } -fields.base_array_layer = { type = 'int', default = '0', required = false } -fields.array_layer_count = { type = 'int', default = 'None', required = false } -fields.swizzle = { type = 'str', default = '"rgba"', required = false } - -[structs.ExternalTextureDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.source = { type = 'ArrayLike | object', default = 'None', required = true } -fields.color_space = { type = 'str', default = '"srgb"', required = false } - -[structs.SamplerDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.address_mode_u = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.address_mode_v = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.address_mode_w = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.mag_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } -fields.min_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } -fields.mipmap_filter = { type = 'enums.MipmapFilterModeEnum', default = '"nearest"', required = false } -fields.lod_min_clamp = { type = 'float', default = '0', required = false } -fields.lod_max_clamp = { type = 'float', default = '32', required = false } -fields.compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } -fields.max_anisotropy = { type = 'int', default = '1', required = false } - -[structs.BindGroupLayoutDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.entries = { type = 'list[structs.BindGroupLayoutEntryStruct]', default = 'None', required = true } - -[structs.BindGroupLayoutEntry] -fields.binding = { type = 'int', default = 'None', required = true } -fields.visibility = { type = 'flags.ShaderStageFlags', default = 'None', required = true } -fields.buffer = { type = 'structs.BufferBindingLayoutStruct', default = 'None', required = false } -fields.sampler = { type = 'structs.SamplerBindingLayoutStruct', default = 'None', required = false } -fields.texture = { type = 'structs.TextureBindingLayoutStruct', default = 'None', required = false } -fields.storage_texture = { type = 'structs.StorageTextureBindingLayoutStruct', default = 'None', required = false } - -[structs.BufferBindingLayout] -fields.type = { type = 'enums.BufferBindingTypeEnum', default = '"uniform"', required = false } -fields.has_dynamic_offset = { type = 'bool', default = 'False', required = false } -fields.min_binding_size = { type = 'int', default = '0', required = false } - -[structs.SamplerBindingLayout] -fields.type = { type = 'enums.SamplerBindingTypeEnum', default = '"filtering"', required = false } - -[structs.TextureBindingLayout] -fields.sample_type = { type = 'enums.TextureSampleTypeEnum', default = '"float"', required = false } -fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } -fields.multisampled = { type = 'bool', default = 'False', required = false } - -[structs.StorageTextureBindingLayout] -fields.access = { type = 'enums.StorageTextureAccessEnum', default = '"write-only"', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } - -[structs.BindGroupDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUBindGroupLayout', default = 'None', required = true } -fields.entries = { type = 'list[structs.BindGroupEntryStruct]', default = 'None', required = true } - -[structs.BindGroupEntry] -fields.binding = { type = 'int', default = 'None', required = true } -fields.resource = { type = 'GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct', default = 'None', required = true } - -[structs.BufferBinding] -fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } -fields.offset = { type = 'int', default = '0', required = false } -fields.size = { type = 'int', default = 'None', required = false } - -[structs.PipelineLayoutDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.bind_group_layouts = { type = 'list[GPUBindGroupLayout]', default = 'None', required = true } -fields.immediate_size = { type = 'int', default = '0', required = false } - -[structs.ShaderModuleDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.code = { type = 'str', default = 'None', required = true } -fields.compilation_hints = { type = 'list[structs.ShaderModuleCompilationHintStruct]', default = '[]', required = false } - -[structs.ShaderModuleCompilationHint] -fields.entry_point = { type = 'str', default = 'None', required = true } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = false } - -[structs.PipelineErrorInit] -fields.reason = { type = 'enums.PipelineErrorReasonEnum', default = 'None', required = true } - -[structs.ProgrammableStage] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } - -[structs.ComputePipelineDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } -fields.compute = { type = 'structs.ProgrammableStageStruct', default = 'None', required = true } - -[structs.RenderPipelineDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } -fields.vertex = { type = 'structs.VertexStateStruct', default = 'None', required = true } -fields.primitive = { type = 'structs.PrimitiveStateStruct', default = '{}', required = false } -fields.depth_stencil = { type = 'structs.DepthStencilStateStruct', default = 'None', required = false } -fields.multisample = { type = 'structs.MultisampleStateStruct', default = '{}', required = false } -fields.fragment = { type = 'structs.FragmentStateStruct', default = 'None', required = false } - -[structs.PrimitiveState] -fields.topology = { type = 'enums.PrimitiveTopologyEnum', default = '"triangle-list"', required = false } -fields.strip_index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = false } -fields.front_face = { type = 'enums.FrontFaceEnum', default = '"ccw"', required = false } -fields.cull_mode = { type = 'enums.CullModeEnum', default = '"none"', required = false } -fields.unclipped_depth = { type = 'bool', default = 'False', required = false } - -[structs.MultisampleState] -fields.count = { type = 'int', default = '1', required = false } -fields.mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.alpha_to_coverage_enabled = { type = 'bool', default = 'False', required = false } - -[structs.FragmentState] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } -fields.targets = { type = 'list[structs.ColorTargetStateStruct]', default = 'None', required = true } - -[structs.ColorTargetState] -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.blend = { type = 'structs.BlendStateStruct', default = 'None', required = false } -fields.write_mask = { type = 'flags.ColorWriteFlags', default = '0xF', required = false } - -[structs.BlendState] -fields.color = { type = 'structs.BlendComponentStruct', default = 'None', required = true } -fields.alpha = { type = 'structs.BlendComponentStruct', default = 'None', required = true } - -[structs.BlendComponent] -fields.operation = { type = 'enums.BlendOperationEnum', default = '"add"', required = false } -fields.src_factor = { type = 'enums.BlendFactorEnum', default = '"one"', required = false } -fields.dst_factor = { type = 'enums.BlendFactorEnum', default = '"zero"', required = false } - -[structs.DepthStencilState] -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.depth_write_enabled = { type = 'bool', default = 'None', required = false } -fields.depth_compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } -fields.stencil_front = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } -fields.stencil_back = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } -fields.stencil_read_mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.stencil_write_mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.depth_bias = { type = 'int', default = '0', required = false } -fields.depth_bias_slope_scale = { type = 'float', default = '0', required = false } -fields.depth_bias_clamp = { type = 'float', default = '0', required = false } - -[structs.StencilFaceState] -fields.compare = { type = 'enums.CompareFunctionEnum', default = '"always"', required = false } -fields.fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } -fields.depth_fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } -fields.pass_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } - -[structs.VertexState] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } -fields.buffers = { type = 'list[structs.VertexBufferLayoutStruct]', default = '[]', required = false } - -[structs.VertexBufferLayout] -fields.array_stride = { type = 'int', default = 'None', required = true } -fields.step_mode = { type = 'enums.VertexStepModeEnum', default = '"vertex"', required = false } -fields.attributes = { type = 'list[structs.VertexAttributeStruct]', default = 'None', required = true } - -[structs.VertexAttribute] -fields.format = { type = 'enums.VertexFormatEnum', default = 'None', required = true } -fields.offset = { type = 'int', default = 'None', required = true } -fields.shader_location = { type = 'int', default = 'None', required = true } - -[structs.TexelCopyBufferLayout] -fields.offset = { type = 'int', default = '0', required = false } -fields.bytes_per_row = { type = 'int', default = 'None', required = false } -fields.rows_per_image = { type = 'int', default = 'None', required = false } - -[structs.TexelCopyBufferInfo] -fields.offset = { type = 'int', default = '0', required = false } -fields.bytes_per_row = { type = 'int', default = 'None', required = false } -fields.rows_per_image = { type = 'int', default = 'None', required = false } -fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } - -[structs.TexelCopyTextureInfo] -fields.texture = { type = 'GPUTexture', default = 'None', required = true } -fields.mip_level = { type = 'int', default = '0', required = false } -fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } -fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } - -[structs.CommandBufferDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.CommandEncoderDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.ComputePassTimestampWrites] -fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } -fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } - -[structs.ComputePassDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.timestamp_writes = { type = 'structs.ComputePassTimestampWritesStruct', default = 'None', required = false } - -[structs.RenderPassTimestampWrites] -fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } -fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } - -[structs.RenderPassDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.color_attachments = { type = 'list[structs.RenderPassColorAttachmentStruct]', default = 'None', required = true } -fields.depth_stencil_attachment = { type = 'structs.RenderPassDepthStencilAttachmentStruct', default = 'None', required = false } -fields.occlusion_query_set = { type = 'GPUQuerySet', default = 'None', required = false } -fields.timestamp_writes = { type = 'structs.RenderPassTimestampWritesStruct', default = 'None', required = false } -fields.max_draw_count = { type = 'int', default = '50000000', required = false } - -[structs.RenderPassColorAttachment] -fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } -fields.depth_slice = { type = 'int', default = 'None', required = false } -fields.resolve_target = { type = 'GPUTexture | GPUTextureView', default = 'None', required = false } -fields.clear_value = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = false } -fields.load_op = { type = 'enums.LoadOpEnum', default = 'None', required = true } -fields.store_op = { type = 'enums.StoreOpEnum', default = 'None', required = true } - -[structs.RenderPassDepthStencilAttachment] -fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } -fields.depth_clear_value = { type = 'float', default = 'None', required = false } -fields.depth_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } -fields.depth_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } -fields.depth_read_only = { type = 'bool', default = 'False', required = false } -fields.stencil_clear_value = { type = 'int', default = '0', required = false } -fields.stencil_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } -fields.stencil_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } -fields.stencil_read_only = { type = 'bool', default = 'False', required = false } - -[structs.RenderPassLayout] -fields.label = { type = 'str', default = '""', required = false } -fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } -fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } - -[structs.RenderBundleDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.RenderBundleEncoderDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } -fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } -fields.depth_read_only = { type = 'bool', default = 'False', required = false } -fields.stencil_read_only = { type = 'bool', default = 'False', required = false } - -[structs.QueueDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.QuerySetDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.type = { type = 'enums.QueryTypeEnum', default = 'None', required = true } -fields.count = { type = 'int', default = 'None', required = true } - -[structs.CanvasToneMapping] -fields.mode = { type = 'enums.CanvasToneMappingModeEnum', default = '"standard"', required = false } - -[structs.CanvasConfiguration] -fields.device = { type = 'GPUDevice', default = 'None', required = true } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.usage = { type = 'flags.TextureUsageFlags', default = '0x10', required = false } -fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } -fields.color_space = { type = 'str', default = '"srgb"', required = false } -fields.tone_mapping = { type = 'structs.CanvasToneMappingStruct', default = '{}', required = false } -fields.alpha_mode = { type = 'enums.CanvasAlphaModeEnum', default = '"opaque"', required = false } - -[structs.UncapturedErrorEventInit] -fields.error = { type = 'GPUError', default = 'None', required = true } - -[structs.Color] -fields.r = { type = 'float', default = 'None', required = true } -fields.g = { type = 'float', default = 'None', required = true } -fields.b = { type = 'float', default = 'None', required = true } -fields.a = { type = 'float', default = 'None', required = true } - -[structs.Origin2D] -fields.x = { type = 'int', default = '0', required = false } -fields.y = { type = 'int', default = '0', required = false } - -[structs.Origin3D] -fields.x = { type = 'int', default = '0', required = false } -fields.y = { type = 'int', default = '0', required = false } -fields.z = { type = 'int', default = '0', required = false } - -[structs.Extent3D] -fields.width = { type = 'int', default = 'None', required = true } -fields.height = { type = 'int', default = '1', required = false } -fields.depth_or_array_layers = { type = 'int', default = '1', required = false } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[classes] - -[classes.GPUObjectBase] -bases = [] -properties.label = { type = 'str' } -[classes.GPUObjectBase.methods] - -[classes.GPUAdapterInfo] -bases = [] -properties.vendor = { type = 'str' } -properties.architecture = { type = 'str' } -properties.device = { type = 'str' } -properties.description = { type = 'str' } -properties.subgroup_min_size = { type = 'int' } -properties.subgroup_max_size = { type = 'int' } -properties.is_fallback_adapter = { type = 'bool' } -[classes.GPUAdapterInfo.methods] - -[classes.GPU] -bases = [] -properties.wgsl_language_features = { type = 'set' } -[classes.GPU.methods] -[classes.GPU.methods.request_adapter] -returns = { type = 'GPUAdapter' } -args.options = { type = 'structs.RequestAdapterOptionsStruct', default = '{}', required = false } -[classes.GPU.methods.get_preferred_canvas_format] -returns = { type = 'enums.TextureFormatEnum' } - -[classes.GPUAdapter] -bases = [] -properties.features = { type = 'set' } -properties.limits = { type = 'dict' } -properties.info = { type = 'GPUAdapterInfo' } -[classes.GPUAdapter.methods] -[classes.GPUAdapter.methods.request_device] -returns = { type = 'GPUDevice' } -args.descriptor = { type = 'structs.DeviceDescriptorStruct', default = '{}', required = false } - -[classes.GPUDevice] -bases = ['EventTarget', 'GPUObjectBase'] -properties.features = { type = 'set' } -properties.limits = { type = 'dict' } -properties.adapter_info = { type = 'GPUAdapterInfo' } -properties.queue = { type = 'GPUQueue' } -properties.lost = { type = 'GPUDeviceLostInfo' } -properties.onuncapturederror = { type = 'None' } -[classes.GPUDevice.methods] -[classes.GPUDevice.methods.destroy] -returns = { type = 'None' } -[classes.GPUDevice.methods.create_buffer] -returns = { type = 'GPUBuffer' } -args.descriptor = { type = 'structs.BufferDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_texture] -returns = { type = 'GPUTexture' } -args.descriptor = { type = 'structs.TextureDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_sampler] -returns = { type = 'GPUSampler' } -args.descriptor = { type = 'structs.SamplerDescriptorStruct', default = '{}', required = false } -[classes.GPUDevice.methods.create_bind_group_layout] -returns = { type = 'GPUBindGroupLayout' } -args.descriptor = { type = 'structs.BindGroupLayoutDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_pipeline_layout] -returns = { type = 'GPUPipelineLayout' } -args.descriptor = { type = 'structs.PipelineLayoutDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_bind_group] -returns = { type = 'GPUBindGroup' } -args.descriptor = { type = 'structs.BindGroupDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_shader_module] -returns = { type = 'GPUShaderModule' } -args.descriptor = { type = 'structs.ShaderModuleDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_compute_pipeline] -returns = { type = 'GPUComputePipeline' } -args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_render_pipeline] -returns = { type = 'GPURenderPipeline' } -args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_compute_pipeline_async] -returns = { type = 'GPUPromise[GPUComputePipeline]' } -args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_render_pipeline_async] -returns = { type = 'GPUPromise[GPURenderPipeline]' } -args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_command_encoder] -returns = { type = 'GPUCommandEncoder' } -args.descriptor = { type = 'structs.CommandEncoderDescriptorStruct', default = '{}', required = false } -[classes.GPUDevice.methods.create_render_bundle_encoder] -returns = { type = 'GPURenderBundleEncoder' } -args.descriptor = { type = 'structs.RenderBundleEncoderDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_query_set] -returns = { type = 'GPUQuerySet' } -args.descriptor = { type = 'structs.QuerySetDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.push_error_scope] -returns = { type = 'None' } -args.filter = { type = 'enums.ErrorFilterEnum', default = 'None', required = true } -[classes.GPUDevice.methods.pop_error_scope] -returns = { type = 'GPUError' } - -[classes.GPUBuffer] -bases = ['GPUObjectBase'] -properties.size = { type = 'int' } -properties.usage = { type = 'int' } -properties.map_state = { type = 'enums.BufferMapStateEnum' } -[classes.GPUBuffer.methods] -[classes.GPUBuffer.methods.map_async] -returns = { type = 'GPUPromise[None]' } -args.mode = { type = 'flags.MapModeFlags', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUBuffer.methods.get_mapped_range] -returns = { type = 'ArrayLike' } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUBuffer.methods.unmap] -returns = { type = 'None' } -[classes.GPUBuffer.methods.destroy] -returns = { type = 'None' } - -[classes.GPUTexture] -bases = ['GPUObjectBase'] -properties.width = { type = 'int' } -properties.height = { type = 'int' } -properties.depth_or_array_layers = { type = 'int' } -properties.mip_level_count = { type = 'int' } -properties.sample_count = { type = 'int' } -properties.dimension = { type = 'enums.TextureDimensionEnum' } -properties.format = { type = 'enums.TextureFormatEnum' } -properties.usage = { type = 'int' } -properties.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum | None' } -[classes.GPUTexture.methods] -[classes.GPUTexture.methods.create_view] -returns = { type = 'GPUTextureView' } -args.descriptor = { type = 'structs.TextureViewDescriptorStruct', default = '{}', required = false } -[classes.GPUTexture.methods.destroy] -returns = { type = 'None' } - -[classes.GPUTextureView] -bases = ['GPUObjectBase'] -[classes.GPUTextureView.methods] - -[classes.GPUSampler] -bases = ['GPUObjectBase'] -[classes.GPUSampler.methods] - -[classes.GPUBindGroupLayout] -bases = ['GPUObjectBase'] -[classes.GPUBindGroupLayout.methods] - -[classes.GPUBindGroup] -bases = ['GPUObjectBase'] -[classes.GPUBindGroup.methods] - -[classes.GPUPipelineLayout] -bases = ['GPUObjectBase'] -[classes.GPUPipelineLayout.methods] - -[classes.GPUShaderModule] -bases = ['GPUObjectBase'] -[classes.GPUShaderModule.methods] -[classes.GPUShaderModule.methods.get_compilation_info] -returns = { type = 'GPUCompilationInfo' } - -[classes.GPUCompilationMessage] -bases = [] -properties.message = { type = 'str' } -properties.type = { type = 'enums.CompilationMessageTypeEnum' } -properties.line_num = { type = 'int' } -properties.line_pos = { type = 'int' } -properties.offset = { type = 'int' } -properties.length = { type = 'int' } -[classes.GPUCompilationMessage.methods] - -[classes.GPUCompilationInfo] -bases = [] -properties.messages = { type = 'list[GPUCompilationMessage]' } -[classes.GPUCompilationInfo.methods] - -[classes.GPUPipelineError] -bases = ['DOMException'] -properties.reason = { type = 'enums.PipelineErrorReasonEnum' } -[classes.GPUPipelineError.methods] -[classes.GPUPipelineError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = '""', required = false } -args.options = { type = 'structs.PipelineErrorInitStruct', default = 'None', required = true } - -[classes.GPUPipelineBase] -bases = [] -[classes.GPUPipelineBase.methods] -[classes.GPUPipelineBase.methods.get_bind_group_layout] -returns = { type = 'GPUBindGroupLayout' } -args.index = { type = 'int', default = 'None', required = true } - -[classes.GPUComputePipeline] -bases = ['GPUObjectBase', 'GPUPipelineBase'] -[classes.GPUComputePipeline.methods] - -[classes.GPURenderPipeline] -bases = ['GPUObjectBase', 'GPUPipelineBase'] -[classes.GPURenderPipeline.methods] - -[classes.GPUCommandBuffer] -bases = ['GPUObjectBase'] -[classes.GPUCommandBuffer.methods] - -[classes.GPUCommandsMixin] -bases = [] -[classes.GPUCommandsMixin.methods] - -[classes.GPUCommandEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin'] -[classes.GPUCommandEncoder.methods] -[classes.GPUCommandEncoder.methods.begin_render_pass] -returns = { type = 'GPURenderPassEncoder' } -args.descriptor = { type = 'structs.RenderPassDescriptorStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.begin_compute_pass] -returns = { type = 'GPUComputePassEncoder' } -args.descriptor = { type = 'structs.ComputePassDescriptorStruct', default = '{}', required = false } -[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] -returns = { type = 'None' } -args.source = { type = 'GPUBuffer', default = 'None', required = true } -args.source_offset = { type = 'int', default = 'None', required = true } -args.destination = { type = 'GPUBuffer', default = 'None', required = true } -args.destination_offset = { type = 'int', default = 'None', required = true } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.copy_texture_to_texture] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.clear_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUCommandEncoder.methods.resolve_query_set] -returns = { type = 'None' } -args.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -args.first_query = { type = 'int', default = 'None', required = true } -args.query_count = { type = 'int', default = 'None', required = true } -args.destination = { type = 'GPUBuffer', default = 'None', required = true } -args.destination_offset = { type = 'int', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.finish] -returns = { type = 'GPUCommandBuffer' } -args.descriptor = { type = 'structs.CommandBufferDescriptorStruct', default = '{}', required = false } - -[classes.GPUBindingCommandsMixin] -bases = [] -[classes.GPUBindingCommandsMixin.methods] -[classes.GPUBindingCommandsMixin.methods.set_bind_group] -returns = { type = 'None' } -args.index = { type = 'int', default = 'None', required = true } -args.bind_group = { type = 'GPUBindGroup', default = 'None', required = true } -args.dynamic_offsets_data = { type = 'ArrayLike', default = 'None', required = true } -args.dynamic_offsets_data_start = { type = 'int', default = 'None', required = true } -args.dynamic_offsets_data_length = { type = 'int', default = 'None', required = true } -[classes.GPUBindingCommandsMixin.methods.set_immediates] -returns = { type = 'None' } -args.range_offset = { type = 'int', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_offset = { type = 'int', default = '0', required = false } -args.data_size = { type = 'int', default = 'None', required = false } - -[classes.GPUDebugCommandsMixin] -bases = [] -[classes.GPUDebugCommandsMixin.methods] -[classes.GPUDebugCommandsMixin.methods.push_debug_group] -returns = { type = 'None' } -args.group_label = { type = 'str', default = 'None', required = true } -[classes.GPUDebugCommandsMixin.methods.pop_debug_group] -returns = { type = 'None' } -[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] -returns = { type = 'None' } -args.marker_label = { type = 'str', default = 'None', required = true } - -[classes.GPUComputePassEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin'] -[classes.GPUComputePassEncoder.methods] -[classes.GPUComputePassEncoder.methods.set_pipeline] -returns = { type = 'None' } -args.pipeline = { type = 'GPUComputePipeline', default = 'None', required = true } -[classes.GPUComputePassEncoder.methods.dispatch_workgroups] -returns = { type = 'None' } -args.workgroup_count_x = { type = 'int', default = 'None', required = true } -args.workgroup_count_y = { type = 'int', default = '1', required = false } -args.workgroup_count_z = { type = 'int', default = '1', required = false } -[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } -[classes.GPUComputePassEncoder.methods.end] -returns = { type = 'None' } - -[classes.GPURenderPassEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] -[classes.GPURenderPassEncoder.methods] -[classes.GPURenderPassEncoder.methods.set_viewport] -returns = { type = 'None' } -args.x = { type = 'float', default = 'None', required = true } -args.y = { type = 'float', default = 'None', required = true } -args.width = { type = 'float', default = 'None', required = true } -args.height = { type = 'float', default = 'None', required = true } -args.min_depth = { type = 'float', default = 'None', required = true } -args.max_depth = { type = 'float', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_scissor_rect] -returns = { type = 'None' } -args.x = { type = 'int', default = 'None', required = true } -args.y = { type = 'int', default = 'None', required = true } -args.width = { type = 'int', default = 'None', required = true } -args.height = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_blend_constant] -returns = { type = 'None' } -args.color = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_stencil_reference] -returns = { type = 'None' } -args.reference = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.begin_occlusion_query] -returns = { type = 'None' } -args.query_index = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.end_occlusion_query] -returns = { type = 'None' } -[classes.GPURenderPassEncoder.methods.execute_bundles] -returns = { type = 'None' } -args.bundles = { type = 'list[GPURenderBundle]', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.end] -returns = { type = 'None' } - -[classes.GPURenderCommandsMixin] -bases = [] -[classes.GPURenderCommandsMixin.methods] -[classes.GPURenderCommandsMixin.methods.set_pipeline] -returns = { type = 'None' } -args.pipeline = { type = 'GPURenderPipeline', default = 'None', required = true } -[classes.GPURenderCommandsMixin.methods.set_index_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] -returns = { type = 'None' } -args.slot = { type = 'int', default = 'None', required = true } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPURenderCommandsMixin.methods.draw] -returns = { type = 'None' } -args.vertex_count = { type = 'int', default = 'None', required = true } -args.instance_count = { type = 'int', default = '1', required = false } -args.first_vertex = { type = 'int', default = '0', required = false } -args.first_instance = { type = 'int', default = '0', required = false } -[classes.GPURenderCommandsMixin.methods.draw_indexed] -returns = { type = 'None' } -args.index_count = { type = 'int', default = 'None', required = true } -args.instance_count = { type = 'int', default = '1', required = false } -args.first_index = { type = 'int', default = '0', required = false } -args.base_vertex = { type = 'int', default = '0', required = false } -args.first_instance = { type = 'int', default = '0', required = false } -[classes.GPURenderCommandsMixin.methods.draw_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } -[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } - -[classes.GPURenderBundle] -bases = ['GPUObjectBase'] -[classes.GPURenderBundle.methods] - -[classes.GPURenderBundleEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] -[classes.GPURenderBundleEncoder.methods] -[classes.GPURenderBundleEncoder.methods.finish] -returns = { type = 'GPURenderBundle' } -args.descriptor = { type = 'structs.RenderBundleDescriptorStruct', default = '{}', required = false } - -[classes.GPUQueue] -bases = ['GPUObjectBase'] -[classes.GPUQueue.methods] -[classes.GPUQueue.methods.submit] -returns = { type = 'None' } -args.command_buffers = { type = 'list[GPUCommandBuffer]', default = 'None', required = true } -[classes.GPUQueue.methods.on_submitted_work_done] -returns = { type = 'None' } -[classes.GPUQueue.methods.write_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.buffer_offset = { type = 'int', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUQueue.methods.write_texture] -returns = { type = 'None' } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_layout = { type = 'structs.TexelCopyBufferLayoutStruct', default = 'None', required = true } -args.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } - -[classes.GPUQuerySet] -bases = ['GPUObjectBase'] -properties.type = { type = 'enums.QueryTypeEnum' } -properties.count = { type = 'int' } -[classes.GPUQuerySet.methods] -[classes.GPUQuerySet.methods.destroy] -returns = { type = 'None' } - -[classes.GPUCanvasContext] -bases = [] -properties.canvas = { type = 'CanvasLike' } -[classes.GPUCanvasContext.methods] -[classes.GPUCanvasContext.methods.configure] -returns = { type = 'None' } -args.configuration = { type = 'structs.CanvasConfigurationStruct', default = 'None', required = true } -[classes.GPUCanvasContext.methods.unconfigure] -returns = { type = 'None' } -[classes.GPUCanvasContext.methods.get_configuration] -returns = { type = 'structs.CanvasConfigurationStruct' } -[classes.GPUCanvasContext.methods.get_current_texture] -returns = { type = 'GPUTexture' } - -[classes.GPUDeviceLostInfo] -bases = [] -properties.reason = { type = 'enums.DeviceLostReasonEnum' } -properties.message = { type = 'str' } -[classes.GPUDeviceLostInfo.methods] - -[classes.GPUError] -bases = [] -properties.message = { type = 'str' } -[classes.GPUError.methods] - -[classes.GPUValidationError] -bases = ['GPUError'] -[classes.GPUValidationError.methods] -[classes.GPUValidationError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } - -[classes.GPUOutOfMemoryError] -bases = ['GPUError'] -[classes.GPUOutOfMemoryError.methods] -[classes.GPUOutOfMemoryError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } - -[classes.GPUInternalError] -bases = ['GPUError'] -[classes.GPUInternalError.methods] -[classes.GPUInternalError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } diff --git a/apigen/definitions/wgpu_api_web.json b/apigen/definitions/wgpu_api_web.json new file mode 100644 index 00000000..1dfb01bf --- /dev/null +++ b/apigen/definitions/wgpu_api_web.json @@ -0,0 +1,1716 @@ +{ + "meta": { + "filename": "wgpu_api_web.json", + "description": "Python-flavored WebGPU API, generated from 'webgpu.idl'.", + "notes": "All types are converted to the Python equivalents, all names are made Pythonic snake_case, methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly." + }, + "flags": { + "BufferUsage": { + "fields": { + "MAP_READ": { "value": 1 }, + "MAP_WRITE": { "value": 2 }, + "COPY_SRC": { "value": 4 }, + "COPY_DST": { "value": 8 }, + "INDEX": { "value": 16 }, + "VERTEX": { "value": 32 }, + "UNIFORM": { "value": 64 }, + "STORAGE": { "value": 128 }, + "INDIRECT": { "value": 256 }, + "QUERY_RESOLVE": { "value": 512 } + } + }, + "MapMode": { + "fields": { + "READ": { "value": 1 }, + "WRITE": { "value": 2 } + } + }, + "TextureUsage": { + "fields": { + "COPY_SRC": { "value": 1 }, + "COPY_DST": { "value": 2 }, + "TEXTURE_BINDING": { "value": 4 }, + "STORAGE_BINDING": { "value": 8 }, + "RENDER_ATTACHMENT": { "value": 16 }, + "TRANSIENT_ATTACHMENT": { "value": 32 } + } + }, + "ShaderStage": { + "fields": { + "VERTEX": { "value": 1 }, + "FRAGMENT": { "value": 2 }, + "COMPUTE": { "value": 4 } + } + }, + "ColorWrite": { + "fields": { + "RED": { "value": 1 }, + "GREEN": { "value": 2 }, + "BLUE": { "value": 4 }, + "ALPHA": { "value": 8 }, + "ALL": { "value": 15 } + } + } + }, + "enums": { + "PowerPreference": { + "fields": { + "low_power": { "value": "low-power" }, + "high_performance": { "value": "high-performance" } + } + }, + "FeatureName": { + "fields": { + "core_features_and_limits": { "value": "core-features-and-limits" }, + "depth_clip_control": { "value": "depth-clip-control" }, + "depth32float_stencil8": { "value": "depth32float-stencil8" }, + "texture_compression_bc": { "value": "texture-compression-bc" }, + "texture_compression_bc_sliced_d3": { "value": "texture-compression-bc-sliced-3d" }, + "texture_compression_etc2": { "value": "texture-compression-etc2" }, + "texture_compression_astc": { "value": "texture-compression-astc" }, + "texture_compression_astc_sliced_d3": { "value": "texture-compression-astc-sliced-3d" }, + "timestamp_query": { "value": "timestamp-query" }, + "indirect_first_instance": { "value": "indirect-first-instance" }, + "shader_f16": { "value": "shader-f16" }, + "rg11b10ufloat_renderable": { "value": "rg11b10ufloat-renderable" }, + "bgra8unorm_storage": { "value": "bgra8unorm-storage" }, + "float32_filterable": { "value": "float32-filterable" }, + "float32_blendable": { "value": "float32-blendable" }, + "clip_distances": { "value": "clip-distances" }, + "dual_source_blending": { "value": "dual-source-blending" }, + "subgroups": { "value": "subgroups" }, + "texture_formats_tier1": { "value": "texture-formats-tier1" }, + "texture_formats_tier2": { "value": "texture-formats-tier2" }, + "primitive_index": { "value": "primitive-index" }, + "texture_component_swizzle": { "value": "texture-component-swizzle" } + } + }, + "BufferMapState": { + "fields": { + "unmapped": { "value": "unmapped" }, + "pending": { "value": "pending" }, + "mapped": { "value": "mapped" } + } + }, + "TextureDimension": { + "fields": { + "d1": { "value": "1d" }, + "d2": { "value": "2d" }, + "d3": { "value": "3d" } + } + }, + "TextureViewDimension": { + "fields": { + "d1": { "value": "1d" }, + "d2": { "value": "2d" }, + "d2_array": { "value": "2d-array" }, + "cube": { "value": "cube" }, + "cube_array": { "value": "cube-array" }, + "d3": { "value": "3d" } + } + }, + "TextureAspect": { + "fields": { + "all": { "value": "all" }, + "stencil_only": { "value": "stencil-only" }, + "depth_only": { "value": "depth-only" } + } + }, + "TextureFormat": { + "fields": { + "r8unorm": { "value": "r8unorm" }, + "r8snorm": { "value": "r8snorm" }, + "r8uint": { "value": "r8uint" }, + "r8sint": { "value": "r8sint" }, + "r16unorm": { "value": "r16unorm" }, + "r16snorm": { "value": "r16snorm" }, + "r16uint": { "value": "r16uint" }, + "r16sint": { "value": "r16sint" }, + "r16float": { "value": "r16float" }, + "rg8unorm": { "value": "rg8unorm" }, + "rg8snorm": { "value": "rg8snorm" }, + "rg8uint": { "value": "rg8uint" }, + "rg8sint": { "value": "rg8sint" }, + "r32uint": { "value": "r32uint" }, + "r32sint": { "value": "r32sint" }, + "r32float": { "value": "r32float" }, + "rg16unorm": { "value": "rg16unorm" }, + "rg16snorm": { "value": "rg16snorm" }, + "rg16uint": { "value": "rg16uint" }, + "rg16sint": { "value": "rg16sint" }, + "rg16float": { "value": "rg16float" }, + "rgba8unorm": { "value": "rgba8unorm" }, + "rgba8unorm_srgb": { "value": "rgba8unorm-srgb" }, + "rgba8snorm": { "value": "rgba8snorm" }, + "rgba8uint": { "value": "rgba8uint" }, + "rgba8sint": { "value": "rgba8sint" }, + "bgra8unorm": { "value": "bgra8unorm" }, + "bgra8unorm_srgb": { "value": "bgra8unorm-srgb" }, + "rgb9e5ufloat": { "value": "rgb9e5ufloat" }, + "rgb10a2uint": { "value": "rgb10a2uint" }, + "rgb10a2unorm": { "value": "rgb10a2unorm" }, + "rg11b10ufloat": { "value": "rg11b10ufloat" }, + "rg32uint": { "value": "rg32uint" }, + "rg32sint": { "value": "rg32sint" }, + "rg32float": { "value": "rg32float" }, + "rgba16unorm": { "value": "rgba16unorm" }, + "rgba16snorm": { "value": "rgba16snorm" }, + "rgba16uint": { "value": "rgba16uint" }, + "rgba16sint": { "value": "rgba16sint" }, + "rgba16float": { "value": "rgba16float" }, + "rgba32uint": { "value": "rgba32uint" }, + "rgba32sint": { "value": "rgba32sint" }, + "rgba32float": { "value": "rgba32float" }, + "stencil8": { "value": "stencil8" }, + "depth16unorm": { "value": "depth16unorm" }, + "depth24plus": { "value": "depth24plus" }, + "depth24plus_stencil8": { "value": "depth24plus-stencil8" }, + "depth32float": { "value": "depth32float" }, + "depth32float_stencil8": { "value": "depth32float-stencil8" }, + "bc1_rgba_unorm": { "value": "bc1-rgba-unorm" }, + "bc1_rgba_unorm_srgb": { "value": "bc1-rgba-unorm-srgb" }, + "bc2_rgba_unorm": { "value": "bc2-rgba-unorm" }, + "bc2_rgba_unorm_srgb": { "value": "bc2-rgba-unorm-srgb" }, + "bc3_rgba_unorm": { "value": "bc3-rgba-unorm" }, + "bc3_rgba_unorm_srgb": { "value": "bc3-rgba-unorm-srgb" }, + "bc4_r_unorm": { "value": "bc4-r-unorm" }, + "bc4_r_snorm": { "value": "bc4-r-snorm" }, + "bc5_rg_unorm": { "value": "bc5-rg-unorm" }, + "bc5_rg_snorm": { "value": "bc5-rg-snorm" }, + "bc6h_rgb_ufloat": { "value": "bc6h-rgb-ufloat" }, + "bc6h_rgb_float": { "value": "bc6h-rgb-float" }, + "bc7_rgba_unorm": { "value": "bc7-rgba-unorm" }, + "bc7_rgba_unorm_srgb": { "value": "bc7-rgba-unorm-srgb" }, + "etc2_rgb8unorm": { "value": "etc2-rgb8unorm" }, + "etc2_rgb8unorm_srgb": { "value": "etc2-rgb8unorm-srgb" }, + "etc2_rgb8a1unorm": { "value": "etc2-rgb8a1unorm" }, + "etc2_rgb8a1unorm_srgb": { "value": "etc2-rgb8a1unorm-srgb" }, + "etc2_rgba8unorm": { "value": "etc2-rgba8unorm" }, + "etc2_rgba8unorm_srgb": { "value": "etc2-rgba8unorm-srgb" }, + "eac_r11unorm": { "value": "eac-r11unorm" }, + "eac_r11snorm": { "value": "eac-r11snorm" }, + "eac_rg11unorm": { "value": "eac-rg11unorm" }, + "eac_rg11snorm": { "value": "eac-rg11snorm" }, + "astc_4x4_unorm": { "value": "astc-4x4-unorm" }, + "astc_4x4_unorm_srgb": { "value": "astc-4x4-unorm-srgb" }, + "astc_5x4_unorm": { "value": "astc-5x4-unorm" }, + "astc_5x4_unorm_srgb": { "value": "astc-5x4-unorm-srgb" }, + "astc_5x5_unorm": { "value": "astc-5x5-unorm" }, + "astc_5x5_unorm_srgb": { "value": "astc-5x5-unorm-srgb" }, + "astc_6x5_unorm": { "value": "astc-6x5-unorm" }, + "astc_6x5_unorm_srgb": { "value": "astc-6x5-unorm-srgb" }, + "astc_6x6_unorm": { "value": "astc-6x6-unorm" }, + "astc_6x6_unorm_srgb": { "value": "astc-6x6-unorm-srgb" }, + "astc_8x5_unorm": { "value": "astc-8x5-unorm" }, + "astc_8x5_unorm_srgb": { "value": "astc-8x5-unorm-srgb" }, + "astc_8x6_unorm": { "value": "astc-8x6-unorm" }, + "astc_8x6_unorm_srgb": { "value": "astc-8x6-unorm-srgb" }, + "astc_8x8_unorm": { "value": "astc-8x8-unorm" }, + "astc_8x8_unorm_srgb": { "value": "astc-8x8-unorm-srgb" }, + "astc_10x5_unorm": { "value": "astc-10x5-unorm" }, + "astc_10x5_unorm_srgb": { "value": "astc-10x5-unorm-srgb" }, + "astc_10x6_unorm": { "value": "astc-10x6-unorm" }, + "astc_10x6_unorm_srgb": { "value": "astc-10x6-unorm-srgb" }, + "astc_10x8_unorm": { "value": "astc-10x8-unorm" }, + "astc_10x8_unorm_srgb": { "value": "astc-10x8-unorm-srgb" }, + "astc_10x10_unorm": { "value": "astc-10x10-unorm" }, + "astc_10x10_unorm_srgb": { "value": "astc-10x10-unorm-srgb" }, + "astc_12x10_unorm": { "value": "astc-12x10-unorm" }, + "astc_12x10_unorm_srgb": { "value": "astc-12x10-unorm-srgb" }, + "astc_12x12_unorm": { "value": "astc-12x12-unorm" }, + "astc_12x12_unorm_srgb": { "value": "astc-12x12-unorm-srgb" } + } + }, + "AddressMode": { + "fields": { + "clamp_to_edge": { "value": "clamp-to-edge" }, + "repeat": { "value": "repeat" }, + "mirror_repeat": { "value": "mirror-repeat" } + } + }, + "FilterMode": { + "fields": { + "nearest": { "value": "nearest" }, + "linear": { "value": "linear" } + } + }, + "MipmapFilterMode": { + "fields": { + "nearest": { "value": "nearest" }, + "linear": { "value": "linear" } + } + }, + "CompareFunction": { + "fields": { + "never": { "value": "never" }, + "less": { "value": "less" }, + "equal": { "value": "equal" }, + "less_equal": { "value": "less-equal" }, + "greater": { "value": "greater" }, + "not_equal": { "value": "not-equal" }, + "greater_equal": { "value": "greater-equal" }, + "always": { "value": "always" } + } + }, + "BufferBindingType": { + "fields": { + "uniform": { "value": "uniform" }, + "storage": { "value": "storage" }, + "read_only_storage": { "value": "read-only-storage" } + } + }, + "SamplerBindingType": { + "fields": { + "filtering": { "value": "filtering" }, + "non_filtering": { "value": "non-filtering" }, + "comparison": { "value": "comparison" } + } + }, + "TextureSampleType": { + "fields": { + "float": { "value": "float" }, + "unfilterable_float": { "value": "unfilterable-float" }, + "depth": { "value": "depth" }, + "sint": { "value": "sint" }, + "uint": { "value": "uint" } + } + }, + "StorageTextureAccess": { + "fields": { + "write_only": { "value": "write-only" }, + "read_only": { "value": "read-only" }, + "read_write": { "value": "read-write" } + } + }, + "CompilationMessageType": { + "fields": { + "error": { "value": "error" }, + "warning": { "value": "warning" }, + "info": { "value": "info" } + } + }, + "PipelineErrorReason": { + "fields": { + "validation": { "value": "validation" }, + "internal": { "value": "internal" } + } + }, + "AutoLayoutMode": { + "fields": { + "auto": { "value": "auto" } + } + }, + "PrimitiveTopology": { + "fields": { + "point_list": { "value": "point-list" }, + "line_list": { "value": "line-list" }, + "line_strip": { "value": "line-strip" }, + "triangle_list": { "value": "triangle-list" }, + "triangle_strip": { "value": "triangle-strip" } + } + }, + "FrontFace": { + "fields": { + "ccw": { "value": "ccw" }, + "cw": { "value": "cw" } + } + }, + "CullMode": { + "fields": { + "none": { "value": "none" }, + "front": { "value": "front" }, + "back": { "value": "back" } + } + }, + "BlendFactor": { + "fields": { + "zero": { "value": "zero" }, + "one": { "value": "one" }, + "src": { "value": "src" }, + "one_minus_src": { "value": "one-minus-src" }, + "src_alpha": { "value": "src-alpha" }, + "one_minus_src_alpha": { "value": "one-minus-src-alpha" }, + "dst": { "value": "dst" }, + "one_minus_dst": { "value": "one-minus-dst" }, + "dst_alpha": { "value": "dst-alpha" }, + "one_minus_dst_alpha": { "value": "one-minus-dst-alpha" }, + "src_alpha_saturated": { "value": "src-alpha-saturated" }, + "constant": { "value": "constant" }, + "one_minus_constant": { "value": "one-minus-constant" }, + "src1": { "value": "src1" }, + "one_minus_src1": { "value": "one-minus-src1" }, + "src1_alpha": { "value": "src1-alpha" }, + "one_minus_src1_alpha": { "value": "one-minus-src1-alpha" } + } + }, + "BlendOperation": { + "fields": { + "add": { "value": "add" }, + "subtract": { "value": "subtract" }, + "reverse_subtract": { "value": "reverse-subtract" }, + "min": { "value": "min" }, + "max": { "value": "max" } + } + }, + "StencilOperation": { + "fields": { + "keep": { "value": "keep" }, + "zero": { "value": "zero" }, + "replace": { "value": "replace" }, + "invert": { "value": "invert" }, + "increment_clamp": { "value": "increment-clamp" }, + "decrement_clamp": { "value": "decrement-clamp" }, + "increment_wrap": { "value": "increment-wrap" }, + "decrement_wrap": { "value": "decrement-wrap" } + } + }, + "IndexFormat": { + "fields": { + "uint16": { "value": "uint16" }, + "uint32": { "value": "uint32" } + } + }, + "VertexFormat": { + "fields": { + "uint8": { "value": "uint8" }, + "uint8x2": { "value": "uint8x2" }, + "uint8x4": { "value": "uint8x4" }, + "sint8": { "value": "sint8" }, + "sint8x2": { "value": "sint8x2" }, + "sint8x4": { "value": "sint8x4" }, + "unorm8": { "value": "unorm8" }, + "unorm8x2": { "value": "unorm8x2" }, + "unorm8x4": { "value": "unorm8x4" }, + "snorm8": { "value": "snorm8" }, + "snorm8x2": { "value": "snorm8x2" }, + "snorm8x4": { "value": "snorm8x4" }, + "uint16": { "value": "uint16" }, + "uint16x2": { "value": "uint16x2" }, + "uint16x4": { "value": "uint16x4" }, + "sint16": { "value": "sint16" }, + "sint16x2": { "value": "sint16x2" }, + "sint16x4": { "value": "sint16x4" }, + "unorm16": { "value": "unorm16" }, + "unorm16x2": { "value": "unorm16x2" }, + "unorm16x4": { "value": "unorm16x4" }, + "snorm16": { "value": "snorm16" }, + "snorm16x2": { "value": "snorm16x2" }, + "snorm16x4": { "value": "snorm16x4" }, + "float16": { "value": "float16" }, + "float16x2": { "value": "float16x2" }, + "float16x4": { "value": "float16x4" }, + "float32": { "value": "float32" }, + "float32x2": { "value": "float32x2" }, + "float32x3": { "value": "float32x3" }, + "float32x4": { "value": "float32x4" }, + "uint32": { "value": "uint32" }, + "uint32x2": { "value": "uint32x2" }, + "uint32x3": { "value": "uint32x3" }, + "uint32x4": { "value": "uint32x4" }, + "sint32": { "value": "sint32" }, + "sint32x2": { "value": "sint32x2" }, + "sint32x3": { "value": "sint32x3" }, + "sint32x4": { "value": "sint32x4" }, + "unorm10_10_10_2": { "value": "unorm10-10-10-2" }, + "unorm8x4_bgra": { "value": "unorm8x4-bgra" } + } + }, + "VertexStepMode": { + "fields": { + "vertex": { "value": "vertex" }, + "instance": { "value": "instance" } + } + }, + "LoadOp": { + "fields": { + "load": { "value": "load" }, + "clear": { "value": "clear" } + } + }, + "StoreOp": { + "fields": { + "store": { "value": "store" }, + "discard": { "value": "discard" } + } + }, + "QueryType": { + "fields": { + "occlusion": { "value": "occlusion" }, + "timestamp": { "value": "timestamp" } + } + }, + "CanvasAlphaMode": { + "fields": { + "opaque": { "value": "opaque" }, + "premultiplied": { "value": "premultiplied" } + } + }, + "CanvasToneMappingMode": { + "fields": { + "standard": { "value": "standard" }, + "extended": { "value": "extended" } + } + }, + "DeviceLostReason": { + "fields": { + "unknown": { "value": "unknown" }, + "destroyed": { "value": "destroyed" } + } + }, + "ErrorFilter": { + "fields": { + "validation": { "value": "validation" }, + "out_of_memory": { "value": "out-of-memory" }, + "internal": { "value": "internal" } + } + } + }, + "structs": { + "RequestAdapterOptions": { + "fields": { + "feature_level": { "type": "str", "default": "\"core\"", "required": false }, + "power_preference": { "type": "enums.PowerPreferenceEnum", "default": null, "required": false }, + "force_fallback_adapter": { "type": "bool", "default": "False", "required": false }, + "xr_compatible": { "type": "bool", "default": "False", "required": false } + } + }, + "DeviceDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "required_features": { "type": "list[enums.FeatureNameEnum]", "default": "[]", "required": false }, + "required_limits": { "type": "dict[str, int | None]", "default": "{}", "required": false }, + "default_queue": { "type": "structs.QueueDescriptorStruct", "default": "{}", "required": false } + } + }, + "BufferDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "size": { "type": "int", "default": null, "required": true }, + "usage": { "type": "flags.BufferUsageFlags", "default": null, "required": true }, + "mapped_at_creation": { "type": "bool", "default": "False", "required": false } + } + }, + "TextureDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true }, + "mip_level_count": { "type": "int", "default": "1", "required": false }, + "sample_count": { "type": "int", "default": "1", "required": false }, + "dimension": { "type": "enums.TextureDimensionEnum", "default": "\"2d\"", "required": false }, + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, + "usage": { "type": "flags.TextureUsageFlags", "default": null, "required": true }, + "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", "required": false }, + "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": null, "required": false } + } + }, + "TextureViewDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, + "dimension": { "type": "enums.TextureViewDimensionEnum", "default": null, "required": false }, + "usage": { "type": "flags.TextureUsageFlags", "default": "0", "required": false }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false }, + "base_mip_level": { "type": "int", "default": "0", "required": false }, + "mip_level_count": { "type": "int", "default": null, "required": false }, + "base_array_layer": { "type": "int", "default": "0", "required": false }, + "array_layer_count": { "type": "int", "default": null, "required": false }, + "swizzle": { "type": "str", "default": "\"rgba\"", "required": false } + } + }, + "ExternalTextureDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "source": { "type": "ArrayLike | object", "default": null, "required": true }, + "color_space": { "type": "str", "default": "\"srgb\"", "required": false } + } + }, + "SamplerDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "address_mode_u": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, + "address_mode_v": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, + "address_mode_w": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, + "mag_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", "required": false }, + "min_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", "required": false }, + "mipmap_filter": { "type": "enums.MipmapFilterModeEnum", "default": "\"nearest\"", "required": false }, + "lod_min_clamp": { "type": "float", "default": "0", "required": false }, + "lod_max_clamp": { "type": "float", "default": "32", "required": false }, + "compare": { "type": "enums.CompareFunctionEnum", "default": null, "required": false }, + "max_anisotropy": { "type": "int", "default": "1", "required": false } + } + }, + "BindGroupLayoutDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "entries": { "type": "list[structs.BindGroupLayoutEntryStruct]", "default": null, "required": true } + } + }, + "BindGroupLayoutEntry": { + "fields": { + "binding": { "type": "int", "default": null, "required": true }, + "visibility": { "type": "flags.ShaderStageFlags", "default": null, "required": true }, + "buffer": { "type": "structs.BufferBindingLayoutStruct", "default": null, "required": false }, + "sampler": { "type": "structs.SamplerBindingLayoutStruct", "default": null, "required": false }, + "texture": { "type": "structs.TextureBindingLayoutStruct", "default": null, "required": false }, + "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct", "default": null, "required": false }, + "external_texture": { "type": "structs.ExternalTextureBindingLayoutStruct", "default": null, "required": false } + } + }, + "BufferBindingLayout": { + "fields": { + "type": { "type": "enums.BufferBindingTypeEnum", "default": "\"uniform\"", "required": false }, + "has_dynamic_offset": { "type": "bool", "default": "False", "required": false }, + "min_binding_size": { "type": "int", "default": "0", "required": false } + } + }, + "SamplerBindingLayout": { + "fields": { + "type": { "type": "enums.SamplerBindingTypeEnum", "default": "\"filtering\"", "required": false } + } + }, + "TextureBindingLayout": { + "fields": { + "sample_type": { "type": "enums.TextureSampleTypeEnum", "default": "\"float\"", "required": false }, + "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", "required": false }, + "multisampled": { "type": "bool", "default": "False", "required": false } + } + }, + "StorageTextureBindingLayout": { + "fields": { + "access": { "type": "enums.StorageTextureAccessEnum", "default": "\"write-only\"", "required": false }, + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, + "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", "required": false } + } + }, + "ExternalTextureBindingLayout": { + "fields": { } + }, + "BindGroupDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "layout": { "type": "GPUBindGroupLayout", "default": null, "required": true }, + "entries": { "type": "list[structs.BindGroupEntryStruct]", "default": null, "required": true } + } + }, + "BindGroupEntry": { + "fields": { + "binding": { "type": "int", "default": null, "required": true }, + "resource": { + "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", + "default": null, + "required": true + } + } + }, + "BufferBinding": { + "fields": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": null, "required": false } + } + }, + "PipelineLayoutDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "bind_group_layouts": { "type": "list[GPUBindGroupLayout]", "default": null, "required": true }, + "immediate_size": { "type": "int", "default": "0", "required": false } + } + }, + "ShaderModuleDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "code": { "type": "str", "default": null, "required": true }, + "compilation_hints": { "type": "list[structs.ShaderModuleCompilationHintStruct]", "default": "[]", "required": false } + } + }, + "ShaderModuleCompilationHint": { + "fields": { + "entry_point": { "type": "str", "default": null, "required": true }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": false } + } + }, + "PipelineErrorInit": { + "fields": { + "reason": { "type": "enums.PipelineErrorReasonEnum", "default": null, "required": true } + } + }, + "ProgrammableStage": { + "fields": { + "module": { "type": "GPUShaderModule", "default": null, "required": true }, + "entry_point": { "type": "str", "default": null, "required": false }, + "constants": { "type": "dict[str, float]", "default": "{}", "required": false } + } + }, + "ComputePipelineDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": true }, + "compute": { "type": "structs.ProgrammableStageStruct", "default": null, "required": true } + } + }, + "RenderPipelineDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": true }, + "vertex": { "type": "structs.VertexStateStruct", "default": null, "required": true }, + "primitive": { "type": "structs.PrimitiveStateStruct", "default": "{}", "required": false }, + "depth_stencil": { "type": "structs.DepthStencilStateStruct", "default": null, "required": false }, + "multisample": { "type": "structs.MultisampleStateStruct", "default": "{}", "required": false }, + "fragment": { "type": "structs.FragmentStateStruct", "default": null, "required": false } + } + }, + "PrimitiveState": { + "fields": { + "topology": { "type": "enums.PrimitiveTopologyEnum", "default": "\"triangle-list\"", "required": false }, + "strip_index_format": { "type": "enums.IndexFormatEnum", "default": null, "required": false }, + "front_face": { "type": "enums.FrontFaceEnum", "default": "\"ccw\"", "required": false }, + "cull_mode": { "type": "enums.CullModeEnum", "default": "\"none\"", "required": false }, + "unclipped_depth": { "type": "bool", "default": "False", "required": false } + } + }, + "MultisampleState": { + "fields": { + "count": { "type": "int", "default": "1", "required": false }, + "mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, + "alpha_to_coverage_enabled": { "type": "bool", "default": "False", "required": false } + } + }, + "FragmentState": { + "fields": { + "module": { "type": "GPUShaderModule", "default": null, "required": true }, + "entry_point": { "type": "str", "default": null, "required": false }, + "constants": { "type": "dict[str, float]", "default": "{}", "required": false }, + "targets": { "type": "list[structs.ColorTargetStateStruct]", "default": null, "required": true } + } + }, + "ColorTargetState": { + "fields": { + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, + "blend": { "type": "structs.BlendStateStruct", "default": null, "required": false }, + "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF", "required": false } + } + }, + "BlendState": { + "fields": { + "color": { "type": "structs.BlendComponentStruct", "default": null, "required": true }, + "alpha": { "type": "structs.BlendComponentStruct", "default": null, "required": true } + } + }, + "BlendComponent": { + "fields": { + "operation": { "type": "enums.BlendOperationEnum", "default": "\"add\"", "required": false }, + "src_factor": { "type": "enums.BlendFactorEnum", "default": "\"one\"", "required": false }, + "dst_factor": { "type": "enums.BlendFactorEnum", "default": "\"zero\"", "required": false } + } + }, + "DepthStencilState": { + "fields": { + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, + "depth_write_enabled": { "type": "bool", "default": null, "required": false }, + "depth_compare": { "type": "enums.CompareFunctionEnum", "default": null, "required": false }, + "stencil_front": { "type": "structs.StencilFaceStateStruct", "default": "{}", "required": false }, + "stencil_back": { "type": "structs.StencilFaceStateStruct", "default": "{}", "required": false }, + "stencil_read_mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, + "stencil_write_mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, + "depth_bias": { "type": "int", "default": "0", "required": false }, + "depth_bias_slope_scale": { "type": "float", "default": "0", "required": false }, + "depth_bias_clamp": { "type": "float", "default": "0", "required": false } + } + }, + "StencilFaceState": { + "fields": { + "compare": { "type": "enums.CompareFunctionEnum", "default": "\"always\"", "required": false }, + "fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false }, + "depth_fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false }, + "pass_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false } + } + }, + "VertexState": { + "fields": { + "module": { "type": "GPUShaderModule", "default": null, "required": true }, + "entry_point": { "type": "str", "default": null, "required": false }, + "constants": { "type": "dict[str, float]", "default": "{}", "required": false }, + "buffers": { "type": "list[structs.VertexBufferLayoutStruct]", "default": "[]", "required": false } + } + }, + "VertexBufferLayout": { + "fields": { + "array_stride": { "type": "int", "default": null, "required": true }, + "step_mode": { "type": "enums.VertexStepModeEnum", "default": "\"vertex\"", "required": false }, + "attributes": { "type": "list[structs.VertexAttributeStruct]", "default": null, "required": true } + } + }, + "VertexAttribute": { + "fields": { + "format": { "type": "enums.VertexFormatEnum", "default": null, "required": true }, + "offset": { "type": "int", "default": null, "required": true }, + "shader_location": { "type": "int", "default": null, "required": true } + } + }, + "TexelCopyBufferLayout": { + "fields": { + "offset": { "type": "int", "default": "0", "required": false }, + "bytes_per_row": { "type": "int", "default": null, "required": false }, + "rows_per_image": { "type": "int", "default": null, "required": false } + } + }, + "TexelCopyBufferInfo": { + "fields": { + "offset": { "type": "int", "default": "0", "required": false }, + "bytes_per_row": { "type": "int", "default": null, "required": false }, + "rows_per_image": { "type": "int", "default": null, "required": false }, + "buffer": { "type": "GPUBuffer", "default": null, "required": true } + } + }, + "TexelCopyTextureInfo": { + "fields": { + "texture": { "type": "GPUTexture", "default": null, "required": true }, + "mip_level": { "type": "int", "default": "0", "required": false }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}", "required": false }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false } + } + }, + "CopyExternalImageDestInfo": { + "fields": { + "texture": { "type": "GPUTexture", "default": null, "required": true }, + "mip_level": { "type": "int", "default": "0", "required": false }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}", "required": false }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false }, + "color_space": { "type": "str", "default": "\"srgb\"", "required": false }, + "premultiplied_alpha": { "type": "bool", "default": "False", "required": false } + } + }, + "CopyExternalImageSourceInfo": { + "fields": { + "source": { "type": "ArrayLike | CanvasLike | object", "default": null, "required": true }, + "origin": { "type": "tuple[int, int] | structs.Origin2DStruct", "default": "{}", "required": false }, + "flip_y": { "type": "bool", "default": "False", "required": false } + } + }, + "CommandBufferDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false } + } + }, + "CommandEncoderDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false } + } + }, + "ComputePassTimestampWrites": { + "fields": { + "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, + "beginning_of_pass_write_index": { "type": "int", "default": null, "required": false }, + "end_of_pass_write_index": { "type": "int", "default": null, "required": false } + } + }, + "ComputePassDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct", "default": null, "required": false } + } + }, + "RenderPassTimestampWrites": { + "fields": { + "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, + "beginning_of_pass_write_index": { "type": "int", "default": null, "required": false }, + "end_of_pass_write_index": { "type": "int", "default": null, "required": false } + } + }, + "RenderPassDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "color_attachments": { "type": "list[structs.RenderPassColorAttachmentStruct]", "default": null, "required": true }, + "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct", "default": null, "required": false }, + "occlusion_query_set": { "type": "GPUQuerySet", "default": null, "required": false }, + "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct", "default": null, "required": false }, + "max_draw_count": { "type": "int", "default": "50000000", "required": false } + } + }, + "RenderPassColorAttachment": { + "fields": { + "view": { "type": "GPUTexture | GPUTextureView", "default": null, "required": true }, + "depth_slice": { "type": "int", "default": null, "required": false }, + "resolve_target": { "type": "GPUTexture | GPUTextureView", "default": null, "required": false }, + "clear_value": { + "type": "tuple[float, float, float, float] | structs.ColorStruct", + "default": null, + "required": false + }, + "load_op": { "type": "enums.LoadOpEnum", "default": null, "required": true }, + "store_op": { "type": "enums.StoreOpEnum", "default": null, "required": true } + } + }, + "RenderPassDepthStencilAttachment": { + "fields": { + "view": { "type": "GPUTexture | GPUTextureView", "default": null, "required": true }, + "depth_clear_value": { "type": "float", "default": null, "required": false }, + "depth_load_op": { "type": "enums.LoadOpEnum", "default": null, "required": false }, + "depth_store_op": { "type": "enums.StoreOpEnum", "default": null, "required": false }, + "depth_read_only": { "type": "bool", "default": "False", "required": false }, + "stencil_clear_value": { "type": "int", "default": "0", "required": false }, + "stencil_load_op": { "type": "enums.LoadOpEnum", "default": null, "required": false }, + "stencil_store_op": { "type": "enums.StoreOpEnum", "default": null, "required": false }, + "stencil_read_only": { "type": "bool", "default": "False", "required": false } + } + }, + "RenderPassLayout": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": null, "required": true }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, + "sample_count": { "type": "int", "default": "1", "required": false } + } + }, + "RenderBundleDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false } + } + }, + "RenderBundleEncoderDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": null, "required": true }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, + "sample_count": { "type": "int", "default": "1", "required": false }, + "depth_read_only": { "type": "bool", "default": "False", "required": false }, + "stencil_read_only": { "type": "bool", "default": "False", "required": false } + } + }, + "QueueDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false } + } + }, + "QuerySetDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"", "required": false }, + "type": { "type": "enums.QueryTypeEnum", "default": null, "required": true }, + "count": { "type": "int", "default": null, "required": true } + } + }, + "CanvasToneMapping": { + "fields": { + "mode": { "type": "enums.CanvasToneMappingModeEnum", "default": "\"standard\"", "required": false } + } + }, + "CanvasConfiguration": { + "fields": { + "device": { "type": "GPUDevice", "default": null, "required": true }, + "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, + "usage": { "type": "flags.TextureUsageFlags", "default": "0x10", "required": false }, + "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", "required": false }, + "color_space": { "type": "str", "default": "\"srgb\"", "required": false }, + "tone_mapping": { "type": "structs.CanvasToneMappingStruct", "default": "{}", "required": false }, + "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"", "required": false } + } + }, + "UncapturedErrorEventInit": { + "fields": { + "error": { "type": "GPUError", "default": null, "required": true } + } + }, + "Color": { + "fields": { + "r": { "type": "float", "default": null, "required": true }, + "g": { "type": "float", "default": null, "required": true }, + "b": { "type": "float", "default": null, "required": true }, + "a": { "type": "float", "default": null, "required": true } + } + }, + "Origin2D": { + "fields": { + "x": { "type": "int", "default": "0", "required": false }, + "y": { "type": "int", "default": "0", "required": false } + } + }, + "Origin3D": { + "fields": { + "x": { "type": "int", "default": "0", "required": false }, + "y": { "type": "int", "default": "0", "required": false }, + "z": { "type": "int", "default": "0", "required": false } + } + }, + "Extent3D": { + "fields": { + "width": { "type": "int", "default": null, "required": true }, + "height": { "type": "int", "default": "1", "required": false }, + "depth_or_array_layers": { "type": "int", "default": "1", "required": false } + } + } + }, + "classes": { + "GPUObjectBase": { + "bases": [ ], + "properties": { + "label": { "type": "str" } + }, + "methods": { } + }, + "GPUAdapterInfo": { + "bases": [ ], + "properties": { + "vendor": { "type": "str" }, + "architecture": { "type": "str" }, + "device": { "type": "str" }, + "description": { "type": "str" }, + "subgroup_min_size": { "type": "int" }, + "subgroup_max_size": { "type": "int" }, + "is_fallback_adapter": { "type": "bool" } + }, + "methods": { } + }, + "GPU": { + "bases": [ ], + "properties": { + "wgsl_language_features": { "type": "set" } + }, + "methods": { + "request_adapter": { + "returns": { "type": "GPUAdapter" }, + "args": { + "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}", "required": false } + } + }, + "get_preferred_canvas_format": { + "returns": { "type": "enums.TextureFormatEnum" }, + "args": { } + } + } + }, + "GPUAdapter": { + "bases": [ ], + "properties": { + "features": { "type": "set" }, + "limits": { "type": "dict" }, + "info": { "type": "GPUAdapterInfo" } + }, + "methods": { + "request_device": { + "returns": { "type": "GPUDevice" }, + "args": { + "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}", "required": false } + } + } + } + }, + "GPUDevice": { + "bases": [ "EventTarget", "GPUObjectBase" ], + "properties": { + "features": { "type": "set" }, + "limits": { "type": "dict" }, + "adapter_info": { "type": "GPUAdapterInfo" }, + "queue": { "type": "GPUQueue" }, + "lost": { "type": "GPUDeviceLostInfo" }, + "onuncapturederror": { "type": "None" } + }, + "methods": { + "destroy": { + "returns": { "type": "None" }, + "args": { } + }, + "create_buffer": { + "returns": { "type": "GPUBuffer" }, + "args": { + "descriptor": { "type": "structs.BufferDescriptorStruct", "default": null, "required": true } + } + }, + "create_texture": { + "returns": { "type": "GPUTexture" }, + "args": { + "descriptor": { "type": "structs.TextureDescriptorStruct", "default": null, "required": true } + } + }, + "create_sampler": { + "returns": { "type": "GPUSampler" }, + "args": { + "descriptor": { "type": "structs.SamplerDescriptorStruct", "default": "{}", "required": false } + } + }, + "import_external_texture": { + "returns": { "type": "object" }, + "args": { + "descriptor": { "type": "structs.ExternalTextureDescriptorStruct", "default": null, "required": true } + } + }, + "create_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout" }, + "args": { + "descriptor": { "type": "structs.BindGroupLayoutDescriptorStruct", "default": null, "required": true } + } + }, + "create_pipeline_layout": { + "returns": { "type": "GPUPipelineLayout" }, + "args": { + "descriptor": { "type": "structs.PipelineLayoutDescriptorStruct", "default": null, "required": true } + } + }, + "create_bind_group": { + "returns": { "type": "GPUBindGroup" }, + "args": { + "descriptor": { "type": "structs.BindGroupDescriptorStruct", "default": null, "required": true } + } + }, + "create_shader_module": { + "returns": { "type": "GPUShaderModule" }, + "args": { + "descriptor": { "type": "structs.ShaderModuleDescriptorStruct", "default": null, "required": true } + } + }, + "create_compute_pipeline": { + "returns": { "type": "GPUComputePipeline" }, + "args": { + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": null, "required": true } + } + }, + "create_render_pipeline": { + "returns": { "type": "GPURenderPipeline" }, + "args": { + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": null, "required": true } + } + }, + "create_compute_pipeline_async": { + "returns": { "type": "GPUPromise[GPUComputePipeline]" }, + "args": { + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": null, "required": true } + } + }, + "create_render_pipeline_async": { + "returns": { "type": "GPUPromise[GPURenderPipeline]" }, + "args": { + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": null, "required": true } + } + }, + "create_command_encoder": { + "returns": { "type": "GPUCommandEncoder" }, + "args": { + "descriptor": { "type": "structs.CommandEncoderDescriptorStruct", "default": "{}", "required": false } + } + }, + "create_render_bundle_encoder": { + "returns": { "type": "GPURenderBundleEncoder" }, + "args": { + "descriptor": { "type": "structs.RenderBundleEncoderDescriptorStruct", "default": null, "required": true } + } + }, + "create_query_set": { + "returns": { "type": "GPUQuerySet" }, + "args": { + "descriptor": { "type": "structs.QuerySetDescriptorStruct", "default": null, "required": true } + } + }, + "push_error_scope": { + "returns": { "type": "None" }, + "args": { + "filter": { "type": "enums.ErrorFilterEnum", "default": null, "required": true } + } + }, + "pop_error_scope": { + "returns": { "type": "GPUError" }, + "args": { } + } + } + }, + "GPUBuffer": { + "bases": [ "GPUObjectBase" ], + "properties": { + "size": { "type": "int" }, + "usage": { "type": "int" }, + "map_state": { "type": "enums.BufferMapStateEnum" } + }, + "methods": { + "map_async": { + "returns": { "type": "GPUPromise[None]" }, + "args": { + "mode": { "type": "flags.MapModeFlags", "default": null, "required": true }, + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "get_mapped_range": { + "returns": { "type": "ArrayLike" }, + "args": { + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "unmap": { + "returns": { "type": "None" }, + "args": { } + }, + "destroy": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPUTexture": { + "bases": [ "GPUObjectBase" ], + "properties": { + "width": { "type": "int" }, + "height": { "type": "int" }, + "depth_or_array_layers": { "type": "int" }, + "mip_level_count": { "type": "int" }, + "sample_count": { "type": "int" }, + "dimension": { "type": "enums.TextureDimensionEnum" }, + "format": { "type": "enums.TextureFormatEnum" }, + "usage": { "type": "int" }, + "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum | None" } + }, + "methods": { + "create_view": { + "returns": { "type": "GPUTextureView" }, + "args": { + "descriptor": { "type": "structs.TextureViewDescriptorStruct", "default": "{}", "required": false } + } + }, + "destroy": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPUTextureView": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUSampler": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUBindGroupLayout": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUBindGroup": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUPipelineLayout": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUShaderModule": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { + "get_compilation_info": { + "returns": { "type": "GPUCompilationInfo" }, + "args": { } + } + } + }, + "GPUCompilationMessage": { + "bases": [ ], + "properties": { + "message": { "type": "str" }, + "type": { "type": "enums.CompilationMessageTypeEnum" }, + "line_num": { "type": "int" }, + "line_pos": { "type": "int" }, + "offset": { "type": "int" }, + "length": { "type": "int" } + }, + "methods": { } + }, + "GPUCompilationInfo": { + "bases": [ ], + "properties": { + "messages": { "type": "list[GPUCompilationMessage]" } + }, + "methods": { } + }, + "GPUPipelineError": { + "bases": [ "DOMException" ], + "properties": { + "reason": { "type": "enums.PipelineErrorReasonEnum" } + }, + "methods": { + "constructor": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": "\"\"", "required": false }, + "options": { "type": "structs.PipelineErrorInitStruct", "default": null, "required": true } + } + } + } + }, + "GPUPipelineBase": { + "bases": [ ], + "properties": { }, + "methods": { + "get_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout" }, + "args": { + "index": { "type": "int", "default": null, "required": true } + } + } + } + }, + "GPUComputePipeline": { + "bases": [ "GPUObjectBase", "GPUPipelineBase" ], + "properties": { }, + "methods": { } + }, + "GPURenderPipeline": { + "bases": [ "GPUObjectBase", "GPUPipelineBase" ], + "properties": { }, + "methods": { } + }, + "GPUCommandBuffer": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { } + }, + "GPUCommandEncoder": { + "bases": [ "GPUObjectBase", "GPUCommandsMixin", "GPUDebugCommandsMixin" ], + "properties": { }, + "methods": { + "begin_render_pass": { + "returns": { "type": "GPURenderPassEncoder" }, + "args": { + "descriptor": { "type": "structs.RenderPassDescriptorStruct", "default": null, "required": true } + } + }, + "begin_compute_pass": { + "returns": { "type": "GPUComputePassEncoder" }, + "args": { + "descriptor": { "type": "structs.ComputePassDescriptorStruct", "default": "{}", "required": false } + } + }, + "copy_buffer_to_buffer": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "GPUBuffer", "default": null, "required": true }, + "source_offset": { "type": "int", "default": null, "required": true }, + "destination": { "type": "GPUBuffer", "default": null, "required": true }, + "destination_offset": { "type": "int", "default": null, "required": true }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "copy_buffer_to_texture": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "structs.TexelCopyBufferInfoStruct", "default": null, "required": true }, + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + } + }, + "copy_texture_to_buffer": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, + "destination": { "type": "structs.TexelCopyBufferInfoStruct", "default": null, "required": true }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + } + }, + "copy_texture_to_texture": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + } + }, + "clear_buffer": { + "returns": { "type": "None" }, + "args": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "resolve_query_set": { + "returns": { "type": "None" }, + "args": { + "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, + "first_query": { "type": "int", "default": null, "required": true }, + "query_count": { "type": "int", "default": null, "required": true }, + "destination": { "type": "GPUBuffer", "default": null, "required": true }, + "destination_offset": { "type": "int", "default": null, "required": true } + } + }, + "finish": { + "returns": { "type": "GPUCommandBuffer" }, + "args": { + "descriptor": { "type": "structs.CommandBufferDescriptorStruct", "default": "{}", "required": false } + } + } + } + }, + "GPUBindingCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_bind_group": { + "returns": { "type": "None" }, + "args": { + "index": { "type": "int", "default": null, "required": true }, + "bind_group": { "type": "GPUBindGroup", "default": null, "required": true }, + "dynamic_offsets_data": { "type": "ArrayLike", "default": null, "required": true }, + "dynamic_offsets_data_start": { "type": "int", "default": null, "required": true }, + "dynamic_offsets_data_length": { "type": "int", "default": null, "required": true } + } + }, + "set_immediates": { + "returns": { "type": "None" }, + "args": { + "range_offset": { "type": "int", "default": null, "required": true }, + "data": { "type": "ArrayLike", "default": null, "required": true }, + "data_offset": { "type": "int", "default": "0", "required": false }, + "data_size": { "type": "int", "default": "None", "required": false } + } + } + } + }, + "GPUDebugCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "push_debug_group": { + "returns": { "type": "None" }, + "args": { + "group_label": { "type": "str", "default": null, "required": true } + } + }, + "pop_debug_group": { + "returns": { "type": "None" }, + "args": { } + }, + "insert_debug_marker": { + "returns": { "type": "None" }, + "args": { + "marker_label": { "type": "str", "default": null, "required": true } + } + } + } + }, + "GPUComputePassEncoder": { + "bases": [ "GPUObjectBase", "GPUCommandsMixin", "GPUDebugCommandsMixin", "GPUBindingCommandsMixin" ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None" }, + "args": { + "pipeline": { "type": "GPUComputePipeline", "default": null, "required": true } + } + }, + "dispatch_workgroups": { + "returns": { "type": "None" }, + "args": { + "workgroup_count_x": { "type": "int", "default": null, "required": true }, + "workgroup_count_y": { "type": "int", "default": "1", "required": false }, + "workgroup_count_z": { "type": "int", "default": "1", "required": false } + } + }, + "dispatch_workgroups_indirect": { + "returns": { "type": "None" }, + "args": { + "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "indirect_offset": { "type": "int", "default": null, "required": true } + } + }, + "end": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPURenderPassEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "set_viewport": { + "returns": { "type": "None" }, + "args": { + "x": { "type": "float", "default": null, "required": true }, + "y": { "type": "float", "default": null, "required": true }, + "width": { "type": "float", "default": null, "required": true }, + "height": { "type": "float", "default": null, "required": true }, + "min_depth": { "type": "float", "default": null, "required": true }, + "max_depth": { "type": "float", "default": null, "required": true } + } + }, + "set_scissor_rect": { + "returns": { "type": "None" }, + "args": { + "x": { "type": "int", "default": null, "required": true }, + "y": { "type": "int", "default": null, "required": true }, + "width": { "type": "int", "default": null, "required": true }, + "height": { "type": "int", "default": null, "required": true } + } + }, + "set_blend_constant": { + "returns": { "type": "None" }, + "args": { + "color": { + "type": "tuple[float, float, float, float] | structs.ColorStruct", + "default": null, + "required": true + } + } + }, + "set_stencil_reference": { + "returns": { "type": "None" }, + "args": { + "reference": { "type": "int", "default": null, "required": true } + } + }, + "begin_occlusion_query": { + "returns": { "type": "None" }, + "args": { + "query_index": { "type": "int", "default": null, "required": true } + } + }, + "end_occlusion_query": { + "returns": { "type": "None" }, + "args": { } + }, + "execute_bundles": { + "returns": { "type": "None" }, + "args": { + "bundles": { "type": "list[GPURenderBundle]", "default": null, "required": true } + } + }, + "end": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPURenderCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None" }, + "args": { + "pipeline": { "type": "GPURenderPipeline", "default": null, "required": true } + } + }, + "set_index_buffer": { + "returns": { "type": "None" }, + "args": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "index_format": { "type": "enums.IndexFormatEnum", "default": null, "required": true }, + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "set_vertex_buffer": { + "returns": { "type": "None" }, + "args": { + "slot": { "type": "int", "default": null, "required": true }, + "buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "draw": { + "returns": { "type": "None" }, + "args": { + "vertex_count": { "type": "int", "default": null, "required": true }, + "instance_count": { "type": "int", "default": "1", "required": false }, + "first_vertex": { "type": "int", "default": "0", "required": false }, + "first_instance": { "type": "int", "default": "0", "required": false } + } + }, + "draw_indexed": { + "returns": { "type": "None" }, + "args": { + "index_count": { "type": "int", "default": null, "required": true }, + "instance_count": { "type": "int", "default": "1", "required": false }, + "first_index": { "type": "int", "default": "0", "required": false }, + "base_vertex": { "type": "int", "default": "0", "required": false }, + "first_instance": { "type": "int", "default": "0", "required": false } + } + }, + "draw_indirect": { + "returns": { "type": "None" }, + "args": { + "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "indirect_offset": { "type": "int", "default": null, "required": true } + } + }, + "draw_indexed_indirect": { + "returns": { "type": "None" }, + "args": { + "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "indirect_offset": { "type": "int", "default": null, "required": true } + } + } + } + }, + "GPURenderBundle": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPURenderBundleEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "finish": { + "returns": { "type": "GPURenderBundle" }, + "args": { + "descriptor": { "type": "structs.RenderBundleDescriptorStruct", "default": "{}", "required": false } + } + } + } + }, + "GPUQueue": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { + "submit": { + "returns": { "type": "None" }, + "args": { + "command_buffers": { "type": "list[GPUCommandBuffer]", "default": null, "required": true } + } + }, + "on_submitted_work_done": { + "returns": { "type": "None" }, + "args": { } + }, + "write_buffer": { + "returns": { "type": "None" }, + "args": { + "buffer": { "type": "GPUBuffer", "default": null, "required": true }, + "buffer_offset": { "type": "int", "default": null, "required": true }, + "data": { "type": "ArrayLike", "default": null, "required": true }, + "data_offset": { "type": "int", "default": "0", "required": false }, + "size": { "type": "int", "default": "None", "required": false } + } + }, + "write_texture": { + "returns": { "type": "None" }, + "args": { + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, + "data": { "type": "ArrayLike", "default": null, "required": true }, + "data_layout": { "type": "structs.TexelCopyBufferLayoutStruct", "default": null, "required": true }, + "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + } + }, + "copy_external_image_to_texture": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "structs.CopyExternalImageSourceInfoStruct", "default": null, "required": true }, + "destination": { "type": "structs.CopyExternalImageDestInfoStruct", "default": null, "required": true }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + } + } + } + }, + "GPUQuerySet": { + "bases": [ "GPUObjectBase" ], + "properties": { + "type": { "type": "enums.QueryTypeEnum" }, + "count": { "type": "int" } + }, + "methods": { + "destroy": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPUCanvasContext": { + "bases": [ ], + "properties": { + "canvas": { "type": "CanvasLike" } + }, + "methods": { + "configure": { + "returns": { "type": "None" }, + "args": { + "configuration": { "type": "structs.CanvasConfigurationStruct", "default": null, "required": true } + } + }, + "unconfigure": { + "returns": { "type": "None" }, + "args": { } + }, + "get_configuration": { + "returns": { "type": "structs.CanvasConfigurationStruct" }, + "args": { } + }, + "get_current_texture": { + "returns": { "type": "GPUTexture" }, + "args": { } + } + } + }, + "GPUDeviceLostInfo": { + "bases": [ ], + "properties": { + "reason": { "type": "enums.DeviceLostReasonEnum" }, + "message": { "type": "str" } + }, + "methods": { } + }, + "GPUError": { + "bases": [ ], + "properties": { + "message": { "type": "str" } + }, + "methods": { } + }, + "GPUValidationError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": null, "required": true } + } + } + } + }, + "GPUOutOfMemoryError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": null, "required": true } + } + } + } + }, + "GPUInternalError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "constructor": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": null, "required": true } + } + } + } + } + } +} diff --git a/apigen/definitions/wgpu_api_web.toml b/apigen/definitions/wgpu_api_web.toml deleted file mode 100644 index 4a33c954..00000000 --- a/apigen/definitions/wgpu_api_web.toml +++ /dev/null @@ -1,1217 +0,0 @@ -# wgpu_api_web.toml: Python-flavoured WebGPU API, generated from 'webgpu.idl'. -# All types are converted to the Python equivalents. -# All names are made Pythonic snake_case. -# Methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly. - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[flags] - -[flags.BufferUsage] -fields.MAP_READ = { value = 1 } -fields.MAP_WRITE = { value = 2 } -fields.COPY_SRC = { value = 4 } -fields.COPY_DST = { value = 8 } -fields.INDEX = { value = 16 } -fields.VERTEX = { value = 32 } -fields.UNIFORM = { value = 64 } -fields.STORAGE = { value = 128 } -fields.INDIRECT = { value = 256 } -fields.QUERY_RESOLVE = { value = 512 } - -[flags.MapMode] -fields.READ = { value = 1 } -fields.WRITE = { value = 2 } - -[flags.TextureUsage] -fields.COPY_SRC = { value = 1 } -fields.COPY_DST = { value = 2 } -fields.TEXTURE_BINDING = { value = 4 } -fields.STORAGE_BINDING = { value = 8 } -fields.RENDER_ATTACHMENT = { value = 16 } -fields.TRANSIENT_ATTACHMENT = { value = 32 } - -[flags.ShaderStage] -fields.VERTEX = { value = 1 } -fields.FRAGMENT = { value = 2 } -fields.COMPUTE = { value = 4 } - -[flags.ColorWrite] -fields.RED = { value = 1 } -fields.GREEN = { value = 2 } -fields.BLUE = { value = 4 } -fields.ALPHA = { value = 8 } -fields.ALL = { value = 15 } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[enums] - -[enums.PowerPreference] -fields.low_power = { value = 'low-power' } -fields.high_performance = { value = 'high-performance' } - -[enums.FeatureName] -fields.core_features_and_limits = { value = 'core-features-and-limits' } -fields.depth_clip_control = { value = 'depth-clip-control' } -fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } -fields.texture_compression_bc = { value = 'texture-compression-bc' } -fields.texture_compression_bc_sliced_d3 = { value = 'texture-compression-bc-sliced-3d' } -fields.texture_compression_etc2 = { value = 'texture-compression-etc2' } -fields.texture_compression_astc = { value = 'texture-compression-astc' } -fields.texture_compression_astc_sliced_d3 = { value = 'texture-compression-astc-sliced-3d' } -fields.timestamp_query = { value = 'timestamp-query' } -fields.indirect_first_instance = { value = 'indirect-first-instance' } -fields.shader_f16 = { value = 'shader-f16' } -fields.rg11b10ufloat_renderable = { value = 'rg11b10ufloat-renderable' } -fields.bgra8unorm_storage = { value = 'bgra8unorm-storage' } -fields.float32_filterable = { value = 'float32-filterable' } -fields.float32_blendable = { value = 'float32-blendable' } -fields.clip_distances = { value = 'clip-distances' } -fields.dual_source_blending = { value = 'dual-source-blending' } -fields.subgroups = { value = 'subgroups' } -fields.texture_formats_tier1 = { value = 'texture-formats-tier1' } -fields.texture_formats_tier2 = { value = 'texture-formats-tier2' } -fields.primitive_index = { value = 'primitive-index' } -fields.texture_component_swizzle = { value = 'texture-component-swizzle' } - -[enums.BufferMapState] -fields.unmapped = { value = 'unmapped' } -fields.pending = { value = 'pending' } -fields.mapped = { value = 'mapped' } - -[enums.TextureDimension] -fields.d1 = { value = '1d' } -fields.d2 = { value = '2d' } -fields.d3 = { value = '3d' } - -[enums.TextureViewDimension] -fields.d1 = { value = '1d' } -fields.d2 = { value = '2d' } -fields.d2_array = { value = '2d-array' } -fields.cube = { value = 'cube' } -fields.cube_array = { value = 'cube-array' } -fields.d3 = { value = '3d' } - -[enums.TextureAspect] -fields.all = { value = 'all' } -fields.stencil_only = { value = 'stencil-only' } -fields.depth_only = { value = 'depth-only' } - -[enums.TextureFormat] -fields.r8unorm = { value = 'r8unorm' } -fields.r8snorm = { value = 'r8snorm' } -fields.r8uint = { value = 'r8uint' } -fields.r8sint = { value = 'r8sint' } -fields.r16unorm = { value = 'r16unorm' } -fields.r16snorm = { value = 'r16snorm' } -fields.r16uint = { value = 'r16uint' } -fields.r16sint = { value = 'r16sint' } -fields.r16float = { value = 'r16float' } -fields.rg8unorm = { value = 'rg8unorm' } -fields.rg8snorm = { value = 'rg8snorm' } -fields.rg8uint = { value = 'rg8uint' } -fields.rg8sint = { value = 'rg8sint' } -fields.r32uint = { value = 'r32uint' } -fields.r32sint = { value = 'r32sint' } -fields.r32float = { value = 'r32float' } -fields.rg16unorm = { value = 'rg16unorm' } -fields.rg16snorm = { value = 'rg16snorm' } -fields.rg16uint = { value = 'rg16uint' } -fields.rg16sint = { value = 'rg16sint' } -fields.rg16float = { value = 'rg16float' } -fields.rgba8unorm = { value = 'rgba8unorm' } -fields.rgba8unorm_srgb = { value = 'rgba8unorm-srgb' } -fields.rgba8snorm = { value = 'rgba8snorm' } -fields.rgba8uint = { value = 'rgba8uint' } -fields.rgba8sint = { value = 'rgba8sint' } -fields.bgra8unorm = { value = 'bgra8unorm' } -fields.bgra8unorm_srgb = { value = 'bgra8unorm-srgb' } -fields.rgb9e5ufloat = { value = 'rgb9e5ufloat' } -fields.rgb10a2uint = { value = 'rgb10a2uint' } -fields.rgb10a2unorm = { value = 'rgb10a2unorm' } -fields.rg11b10ufloat = { value = 'rg11b10ufloat' } -fields.rg32uint = { value = 'rg32uint' } -fields.rg32sint = { value = 'rg32sint' } -fields.rg32float = { value = 'rg32float' } -fields.rgba16unorm = { value = 'rgba16unorm' } -fields.rgba16snorm = { value = 'rgba16snorm' } -fields.rgba16uint = { value = 'rgba16uint' } -fields.rgba16sint = { value = 'rgba16sint' } -fields.rgba16float = { value = 'rgba16float' } -fields.rgba32uint = { value = 'rgba32uint' } -fields.rgba32sint = { value = 'rgba32sint' } -fields.rgba32float = { value = 'rgba32float' } -fields.stencil8 = { value = 'stencil8' } -fields.depth16unorm = { value = 'depth16unorm' } -fields.depth24plus = { value = 'depth24plus' } -fields.depth24plus_stencil8 = { value = 'depth24plus-stencil8' } -fields.depth32float = { value = 'depth32float' } -fields.depth32float_stencil8 = { value = 'depth32float-stencil8' } -fields.bc1_rgba_unorm = { value = 'bc1-rgba-unorm' } -fields.bc1_rgba_unorm_srgb = { value = 'bc1-rgba-unorm-srgb' } -fields.bc2_rgba_unorm = { value = 'bc2-rgba-unorm' } -fields.bc2_rgba_unorm_srgb = { value = 'bc2-rgba-unorm-srgb' } -fields.bc3_rgba_unorm = { value = 'bc3-rgba-unorm' } -fields.bc3_rgba_unorm_srgb = { value = 'bc3-rgba-unorm-srgb' } -fields.bc4_r_unorm = { value = 'bc4-r-unorm' } -fields.bc4_r_snorm = { value = 'bc4-r-snorm' } -fields.bc5_rg_unorm = { value = 'bc5-rg-unorm' } -fields.bc5_rg_snorm = { value = 'bc5-rg-snorm' } -fields.bc6h_rgb_ufloat = { value = 'bc6h-rgb-ufloat' } -fields.bc6h_rgb_float = { value = 'bc6h-rgb-float' } -fields.bc7_rgba_unorm = { value = 'bc7-rgba-unorm' } -fields.bc7_rgba_unorm_srgb = { value = 'bc7-rgba-unorm-srgb' } -fields.etc2_rgb8unorm = { value = 'etc2-rgb8unorm' } -fields.etc2_rgb8unorm_srgb = { value = 'etc2-rgb8unorm-srgb' } -fields.etc2_rgb8a1unorm = { value = 'etc2-rgb8a1unorm' } -fields.etc2_rgb8a1unorm_srgb = { value = 'etc2-rgb8a1unorm-srgb' } -fields.etc2_rgba8unorm = { value = 'etc2-rgba8unorm' } -fields.etc2_rgba8unorm_srgb = { value = 'etc2-rgba8unorm-srgb' } -fields.eac_r11unorm = { value = 'eac-r11unorm' } -fields.eac_r11snorm = { value = 'eac-r11snorm' } -fields.eac_rg11unorm = { value = 'eac-rg11unorm' } -fields.eac_rg11snorm = { value = 'eac-rg11snorm' } -fields.astc_4x4_unorm = { value = 'astc-4x4-unorm' } -fields.astc_4x4_unorm_srgb = { value = 'astc-4x4-unorm-srgb' } -fields.astc_5x4_unorm = { value = 'astc-5x4-unorm' } -fields.astc_5x4_unorm_srgb = { value = 'astc-5x4-unorm-srgb' } -fields.astc_5x5_unorm = { value = 'astc-5x5-unorm' } -fields.astc_5x5_unorm_srgb = { value = 'astc-5x5-unorm-srgb' } -fields.astc_6x5_unorm = { value = 'astc-6x5-unorm' } -fields.astc_6x5_unorm_srgb = { value = 'astc-6x5-unorm-srgb' } -fields.astc_6x6_unorm = { value = 'astc-6x6-unorm' } -fields.astc_6x6_unorm_srgb = { value = 'astc-6x6-unorm-srgb' } -fields.astc_8x5_unorm = { value = 'astc-8x5-unorm' } -fields.astc_8x5_unorm_srgb = { value = 'astc-8x5-unorm-srgb' } -fields.astc_8x6_unorm = { value = 'astc-8x6-unorm' } -fields.astc_8x6_unorm_srgb = { value = 'astc-8x6-unorm-srgb' } -fields.astc_8x8_unorm = { value = 'astc-8x8-unorm' } -fields.astc_8x8_unorm_srgb = { value = 'astc-8x8-unorm-srgb' } -fields.astc_10x5_unorm = { value = 'astc-10x5-unorm' } -fields.astc_10x5_unorm_srgb = { value = 'astc-10x5-unorm-srgb' } -fields.astc_10x6_unorm = { value = 'astc-10x6-unorm' } -fields.astc_10x6_unorm_srgb = { value = 'astc-10x6-unorm-srgb' } -fields.astc_10x8_unorm = { value = 'astc-10x8-unorm' } -fields.astc_10x8_unorm_srgb = { value = 'astc-10x8-unorm-srgb' } -fields.astc_10x10_unorm = { value = 'astc-10x10-unorm' } -fields.astc_10x10_unorm_srgb = { value = 'astc-10x10-unorm-srgb' } -fields.astc_12x10_unorm = { value = 'astc-12x10-unorm' } -fields.astc_12x10_unorm_srgb = { value = 'astc-12x10-unorm-srgb' } -fields.astc_12x12_unorm = { value = 'astc-12x12-unorm' } -fields.astc_12x12_unorm_srgb = { value = 'astc-12x12-unorm-srgb' } - -[enums.AddressMode] -fields.clamp_to_edge = { value = 'clamp-to-edge' } -fields.repeat = { value = 'repeat' } -fields.mirror_repeat = { value = 'mirror-repeat' } - -[enums.FilterMode] -fields.nearest = { value = 'nearest' } -fields.linear = { value = 'linear' } - -[enums.MipmapFilterMode] -fields.nearest = { value = 'nearest' } -fields.linear = { value = 'linear' } - -[enums.CompareFunction] -fields.never = { value = 'never' } -fields.less = { value = 'less' } -fields.equal = { value = 'equal' } -fields.less_equal = { value = 'less-equal' } -fields.greater = { value = 'greater' } -fields.not_equal = { value = 'not-equal' } -fields.greater_equal = { value = 'greater-equal' } -fields.always = { value = 'always' } - -[enums.BufferBindingType] -fields.uniform = { value = 'uniform' } -fields.storage = { value = 'storage' } -fields.read_only_storage = { value = 'read-only-storage' } - -[enums.SamplerBindingType] -fields.filtering = { value = 'filtering' } -fields.non_filtering = { value = 'non-filtering' } -fields.comparison = { value = 'comparison' } - -[enums.TextureSampleType] -fields.float = { value = 'float' } -fields.unfilterable_float = { value = 'unfilterable-float' } -fields.depth = { value = 'depth' } -fields.sint = { value = 'sint' } -fields.uint = { value = 'uint' } - -[enums.StorageTextureAccess] -fields.write_only = { value = 'write-only' } -fields.read_only = { value = 'read-only' } -fields.read_write = { value = 'read-write' } - -[enums.CompilationMessageType] -fields.error = { value = 'error' } -fields.warning = { value = 'warning' } -fields.info = { value = 'info' } - -[enums.PipelineErrorReason] -fields.validation = { value = 'validation' } -fields.internal = { value = 'internal' } - -[enums.AutoLayoutMode] -fields.auto = { value = 'auto' } - -[enums.PrimitiveTopology] -fields.point_list = { value = 'point-list' } -fields.line_list = { value = 'line-list' } -fields.line_strip = { value = 'line-strip' } -fields.triangle_list = { value = 'triangle-list' } -fields.triangle_strip = { value = 'triangle-strip' } - -[enums.FrontFace] -fields.ccw = { value = 'ccw' } -fields.cw = { value = 'cw' } - -[enums.CullMode] -fields.none = { value = 'none' } -fields.front = { value = 'front' } -fields.back = { value = 'back' } - -[enums.BlendFactor] -fields.zero = { value = 'zero' } -fields.one = { value = 'one' } -fields.src = { value = 'src' } -fields.one_minus_src = { value = 'one-minus-src' } -fields.src_alpha = { value = 'src-alpha' } -fields.one_minus_src_alpha = { value = 'one-minus-src-alpha' } -fields.dst = { value = 'dst' } -fields.one_minus_dst = { value = 'one-minus-dst' } -fields.dst_alpha = { value = 'dst-alpha' } -fields.one_minus_dst_alpha = { value = 'one-minus-dst-alpha' } -fields.src_alpha_saturated = { value = 'src-alpha-saturated' } -fields.constant = { value = 'constant' } -fields.one_minus_constant = { value = 'one-minus-constant' } -fields.src1 = { value = 'src1' } -fields.one_minus_src1 = { value = 'one-minus-src1' } -fields.src1_alpha = { value = 'src1-alpha' } -fields.one_minus_src1_alpha = { value = 'one-minus-src1-alpha' } - -[enums.BlendOperation] -fields.add = { value = 'add' } -fields.subtract = { value = 'subtract' } -fields.reverse_subtract = { value = 'reverse-subtract' } -fields.min = { value = 'min' } -fields.max = { value = 'max' } - -[enums.StencilOperation] -fields.keep = { value = 'keep' } -fields.zero = { value = 'zero' } -fields.replace = { value = 'replace' } -fields.invert = { value = 'invert' } -fields.increment_clamp = { value = 'increment-clamp' } -fields.decrement_clamp = { value = 'decrement-clamp' } -fields.increment_wrap = { value = 'increment-wrap' } -fields.decrement_wrap = { value = 'decrement-wrap' } - -[enums.IndexFormat] -fields.uint16 = { value = 'uint16' } -fields.uint32 = { value = 'uint32' } - -[enums.VertexFormat] -fields.uint8 = { value = 'uint8' } -fields.uint8x2 = { value = 'uint8x2' } -fields.uint8x4 = { value = 'uint8x4' } -fields.sint8 = { value = 'sint8' } -fields.sint8x2 = { value = 'sint8x2' } -fields.sint8x4 = { value = 'sint8x4' } -fields.unorm8 = { value = 'unorm8' } -fields.unorm8x2 = { value = 'unorm8x2' } -fields.unorm8x4 = { value = 'unorm8x4' } -fields.snorm8 = { value = 'snorm8' } -fields.snorm8x2 = { value = 'snorm8x2' } -fields.snorm8x4 = { value = 'snorm8x4' } -fields.uint16 = { value = 'uint16' } -fields.uint16x2 = { value = 'uint16x2' } -fields.uint16x4 = { value = 'uint16x4' } -fields.sint16 = { value = 'sint16' } -fields.sint16x2 = { value = 'sint16x2' } -fields.sint16x4 = { value = 'sint16x4' } -fields.unorm16 = { value = 'unorm16' } -fields.unorm16x2 = { value = 'unorm16x2' } -fields.unorm16x4 = { value = 'unorm16x4' } -fields.snorm16 = { value = 'snorm16' } -fields.snorm16x2 = { value = 'snorm16x2' } -fields.snorm16x4 = { value = 'snorm16x4' } -fields.float16 = { value = 'float16' } -fields.float16x2 = { value = 'float16x2' } -fields.float16x4 = { value = 'float16x4' } -fields.float32 = { value = 'float32' } -fields.float32x2 = { value = 'float32x2' } -fields.float32x3 = { value = 'float32x3' } -fields.float32x4 = { value = 'float32x4' } -fields.uint32 = { value = 'uint32' } -fields.uint32x2 = { value = 'uint32x2' } -fields.uint32x3 = { value = 'uint32x3' } -fields.uint32x4 = { value = 'uint32x4' } -fields.sint32 = { value = 'sint32' } -fields.sint32x2 = { value = 'sint32x2' } -fields.sint32x3 = { value = 'sint32x3' } -fields.sint32x4 = { value = 'sint32x4' } -fields.unorm10_10_10_2 = { value = 'unorm10-10-10-2' } -fields.unorm8x4_bgra = { value = 'unorm8x4-bgra' } - -[enums.VertexStepMode] -fields.vertex = { value = 'vertex' } -fields.instance = { value = 'instance' } - -[enums.LoadOp] -fields.load = { value = 'load' } -fields.clear = { value = 'clear' } - -[enums.StoreOp] -fields.store = { value = 'store' } -fields.discard = { value = 'discard' } - -[enums.QueryType] -fields.occlusion = { value = 'occlusion' } -fields.timestamp = { value = 'timestamp' } - -[enums.CanvasAlphaMode] -fields.opaque = { value = 'opaque' } -fields.premultiplied = { value = 'premultiplied' } - -[enums.CanvasToneMappingMode] -fields.standard = { value = 'standard' } -fields.extended = { value = 'extended' } - -[enums.DeviceLostReason] -fields.unknown = { value = 'unknown' } -fields.destroyed = { value = 'destroyed' } - -[enums.ErrorFilter] -fields.validation = { value = 'validation' } -fields.out_of_memory = { value = 'out-of-memory' } -fields.internal = { value = 'internal' } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[structs] - -[structs.RequestAdapterOptions] -fields.feature_level = { type = 'str', default = '"core"', required = false } -fields.power_preference = { type = 'enums.PowerPreferenceEnum', default = 'None', required = false } -fields.force_fallback_adapter = { type = 'bool', default = 'False', required = false } -fields.xr_compatible = { type = 'bool', default = 'False', required = false } - -[structs.DeviceDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.required_features = { type = 'list[enums.FeatureNameEnum]', default = '[]', required = false } -fields.required_limits = { type = 'dict[str, int | None]', default = '{}', required = false } -fields.default_queue = { type = 'structs.QueueDescriptorStruct', default = '{}', required = false } - -[structs.BufferDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.size = { type = 'int', default = 'None', required = true } -fields.usage = { type = 'flags.BufferUsageFlags', default = 'None', required = true } -fields.mapped_at_creation = { type = 'bool', default = 'False', required = false } - -[structs.TextureDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -fields.mip_level_count = { type = 'int', default = '1', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } -fields.dimension = { type = 'enums.TextureDimensionEnum', default = '"2d"', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.usage = { type = 'flags.TextureUsageFlags', default = 'None', required = true } -fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } -fields.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } - -[structs.TextureViewDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.dimension = { type = 'enums.TextureViewDimensionEnum', default = 'None', required = false } -fields.usage = { type = 'flags.TextureUsageFlags', default = '0', required = false } -fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } -fields.base_mip_level = { type = 'int', default = '0', required = false } -fields.mip_level_count = { type = 'int', default = 'None', required = false } -fields.base_array_layer = { type = 'int', default = '0', required = false } -fields.array_layer_count = { type = 'int', default = 'None', required = false } -fields.swizzle = { type = 'str', default = '"rgba"', required = false } - -[structs.ExternalTextureDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.source = { type = 'ArrayLike | object', default = 'None', required = true } -fields.color_space = { type = 'str', default = '"srgb"', required = false } - -[structs.SamplerDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.address_mode_u = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.address_mode_v = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.address_mode_w = { type = 'enums.AddressModeEnum', default = '"clamp-to-edge"', required = false } -fields.mag_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } -fields.min_filter = { type = 'enums.FilterModeEnum', default = '"nearest"', required = false } -fields.mipmap_filter = { type = 'enums.MipmapFilterModeEnum', default = '"nearest"', required = false } -fields.lod_min_clamp = { type = 'float', default = '0', required = false } -fields.lod_max_clamp = { type = 'float', default = '32', required = false } -fields.compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } -fields.max_anisotropy = { type = 'int', default = '1', required = false } - -[structs.BindGroupLayoutDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.entries = { type = 'list[structs.BindGroupLayoutEntryStruct]', default = 'None', required = true } - -[structs.BindGroupLayoutEntry] -fields.binding = { type = 'int', default = 'None', required = true } -fields.visibility = { type = 'flags.ShaderStageFlags', default = 'None', required = true } -fields.buffer = { type = 'structs.BufferBindingLayoutStruct', default = 'None', required = false } -fields.sampler = { type = 'structs.SamplerBindingLayoutStruct', default = 'None', required = false } -fields.texture = { type = 'structs.TextureBindingLayoutStruct', default = 'None', required = false } -fields.storage_texture = { type = 'structs.StorageTextureBindingLayoutStruct', default = 'None', required = false } -fields.external_texture = { type = 'structs.ExternalTextureBindingLayoutStruct', default = 'None', required = false } - -[structs.BufferBindingLayout] -fields.type = { type = 'enums.BufferBindingTypeEnum', default = '"uniform"', required = false } -fields.has_dynamic_offset = { type = 'bool', default = 'False', required = false } -fields.min_binding_size = { type = 'int', default = '0', required = false } - -[structs.SamplerBindingLayout] -fields.type = { type = 'enums.SamplerBindingTypeEnum', default = '"filtering"', required = false } - -[structs.TextureBindingLayout] -fields.sample_type = { type = 'enums.TextureSampleTypeEnum', default = '"float"', required = false } -fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } -fields.multisampled = { type = 'bool', default = 'False', required = false } - -[structs.StorageTextureBindingLayout] -fields.access = { type = 'enums.StorageTextureAccessEnum', default = '"write-only"', required = false } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.view_dimension = { type = 'enums.TextureViewDimensionEnum', default = '"2d"', required = false } - -[structs.ExternalTextureBindingLayout] - -[structs.BindGroupDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUBindGroupLayout', default = 'None', required = true } -fields.entries = { type = 'list[structs.BindGroupEntryStruct]', default = 'None', required = true } - -[structs.BindGroupEntry] -fields.binding = { type = 'int', default = 'None', required = true } -fields.resource = { type = 'GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct', default = 'None', required = true } - -[structs.BufferBinding] -fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } -fields.offset = { type = 'int', default = '0', required = false } -fields.size = { type = 'int', default = 'None', required = false } - -[structs.PipelineLayoutDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.bind_group_layouts = { type = 'list[GPUBindGroupLayout]', default = 'None', required = true } -fields.immediate_size = { type = 'int', default = '0', required = false } - -[structs.ShaderModuleDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.code = { type = 'str', default = 'None', required = true } -fields.compilation_hints = { type = 'list[structs.ShaderModuleCompilationHintStruct]', default = '[]', required = false } - -[structs.ShaderModuleCompilationHint] -fields.entry_point = { type = 'str', default = 'None', required = true } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = false } - -[structs.PipelineErrorInit] -fields.reason = { type = 'enums.PipelineErrorReasonEnum', default = 'None', required = true } - -[structs.ProgrammableStage] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } - -[structs.ComputePipelineDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } -fields.compute = { type = 'structs.ProgrammableStageStruct', default = 'None', required = true } - -[structs.RenderPipelineDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.layout = { type = 'GPUPipelineLayout | enums.AutoLayoutModeEnum', default = 'None', required = true } -fields.vertex = { type = 'structs.VertexStateStruct', default = 'None', required = true } -fields.primitive = { type = 'structs.PrimitiveStateStruct', default = '{}', required = false } -fields.depth_stencil = { type = 'structs.DepthStencilStateStruct', default = 'None', required = false } -fields.multisample = { type = 'structs.MultisampleStateStruct', default = '{}', required = false } -fields.fragment = { type = 'structs.FragmentStateStruct', default = 'None', required = false } - -[structs.PrimitiveState] -fields.topology = { type = 'enums.PrimitiveTopologyEnum', default = '"triangle-list"', required = false } -fields.strip_index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = false } -fields.front_face = { type = 'enums.FrontFaceEnum', default = '"ccw"', required = false } -fields.cull_mode = { type = 'enums.CullModeEnum', default = '"none"', required = false } -fields.unclipped_depth = { type = 'bool', default = 'False', required = false } - -[structs.MultisampleState] -fields.count = { type = 'int', default = '1', required = false } -fields.mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.alpha_to_coverage_enabled = { type = 'bool', default = 'False', required = false } - -[structs.FragmentState] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } -fields.targets = { type = 'list[structs.ColorTargetStateStruct]', default = 'None', required = true } - -[structs.ColorTargetState] -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.blend = { type = 'structs.BlendStateStruct', default = 'None', required = false } -fields.write_mask = { type = 'flags.ColorWriteFlags', default = '0xF', required = false } - -[structs.BlendState] -fields.color = { type = 'structs.BlendComponentStruct', default = 'None', required = true } -fields.alpha = { type = 'structs.BlendComponentStruct', default = 'None', required = true } - -[structs.BlendComponent] -fields.operation = { type = 'enums.BlendOperationEnum', default = '"add"', required = false } -fields.src_factor = { type = 'enums.BlendFactorEnum', default = '"one"', required = false } -fields.dst_factor = { type = 'enums.BlendFactorEnum', default = '"zero"', required = false } - -[structs.DepthStencilState] -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.depth_write_enabled = { type = 'bool', default = 'None', required = false } -fields.depth_compare = { type = 'enums.CompareFunctionEnum', default = 'None', required = false } -fields.stencil_front = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } -fields.stencil_back = { type = 'structs.StencilFaceStateStruct', default = '{}', required = false } -fields.stencil_read_mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.stencil_write_mask = { type = 'int', default = '0xFFFFFFFF', required = false } -fields.depth_bias = { type = 'int', default = '0', required = false } -fields.depth_bias_slope_scale = { type = 'float', default = '0', required = false } -fields.depth_bias_clamp = { type = 'float', default = '0', required = false } - -[structs.StencilFaceState] -fields.compare = { type = 'enums.CompareFunctionEnum', default = '"always"', required = false } -fields.fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } -fields.depth_fail_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } -fields.pass_op = { type = 'enums.StencilOperationEnum', default = '"keep"', required = false } - -[structs.VertexState] -fields.module = { type = 'GPUShaderModule', default = 'None', required = true } -fields.entry_point = { type = 'str', default = 'None', required = false } -fields.constants = { type = 'dict[str, float]', default = '{}', required = false } -fields.buffers = { type = 'list[structs.VertexBufferLayoutStruct]', default = '[]', required = false } - -[structs.VertexBufferLayout] -fields.array_stride = { type = 'int', default = 'None', required = true } -fields.step_mode = { type = 'enums.VertexStepModeEnum', default = '"vertex"', required = false } -fields.attributes = { type = 'list[structs.VertexAttributeStruct]', default = 'None', required = true } - -[structs.VertexAttribute] -fields.format = { type = 'enums.VertexFormatEnum', default = 'None', required = true } -fields.offset = { type = 'int', default = 'None', required = true } -fields.shader_location = { type = 'int', default = 'None', required = true } - -[structs.TexelCopyBufferLayout] -fields.offset = { type = 'int', default = '0', required = false } -fields.bytes_per_row = { type = 'int', default = 'None', required = false } -fields.rows_per_image = { type = 'int', default = 'None', required = false } - -[structs.TexelCopyBufferInfo] -fields.offset = { type = 'int', default = '0', required = false } -fields.bytes_per_row = { type = 'int', default = 'None', required = false } -fields.rows_per_image = { type = 'int', default = 'None', required = false } -fields.buffer = { type = 'GPUBuffer', default = 'None', required = true } - -[structs.TexelCopyTextureInfo] -fields.texture = { type = 'GPUTexture', default = 'None', required = true } -fields.mip_level = { type = 'int', default = '0', required = false } -fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } -fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } - -[structs.CopyExternalImageDestInfo] -fields.texture = { type = 'GPUTexture', default = 'None', required = true } -fields.mip_level = { type = 'int', default = '0', required = false } -fields.origin = { type = 'tuple[int, int, int] | structs.Origin3DStruct', default = '{}', required = false } -fields.aspect = { type = 'enums.TextureAspectEnum', default = '"all"', required = false } -fields.color_space = { type = 'str', default = '"srgb"', required = false } -fields.premultiplied_alpha = { type = 'bool', default = 'False', required = false } - -[structs.CopyExternalImageSourceInfo] -fields.source = { type = 'ArrayLike | CanvasLike | object', default = 'None', required = true } -fields.origin = { type = 'tuple[int, int] | structs.Origin2DStruct', default = '{}', required = false } -fields.flip_y = { type = 'bool', default = 'False', required = false } - -[structs.CommandBufferDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.CommandEncoderDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.ComputePassTimestampWrites] -fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } -fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } - -[structs.ComputePassDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.timestamp_writes = { type = 'structs.ComputePassTimestampWritesStruct', default = 'None', required = false } - -[structs.RenderPassTimestampWrites] -fields.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -fields.beginning_of_pass_write_index = { type = 'int', default = 'None', required = false } -fields.end_of_pass_write_index = { type = 'int', default = 'None', required = false } - -[structs.RenderPassDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.color_attachments = { type = 'list[structs.RenderPassColorAttachmentStruct]', default = 'None', required = true } -fields.depth_stencil_attachment = { type = 'structs.RenderPassDepthStencilAttachmentStruct', default = 'None', required = false } -fields.occlusion_query_set = { type = 'GPUQuerySet', default = 'None', required = false } -fields.timestamp_writes = { type = 'structs.RenderPassTimestampWritesStruct', default = 'None', required = false } -fields.max_draw_count = { type = 'int', default = '50000000', required = false } - -[structs.RenderPassColorAttachment] -fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } -fields.depth_slice = { type = 'int', default = 'None', required = false } -fields.resolve_target = { type = 'GPUTexture | GPUTextureView', default = 'None', required = false } -fields.clear_value = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = false } -fields.load_op = { type = 'enums.LoadOpEnum', default = 'None', required = true } -fields.store_op = { type = 'enums.StoreOpEnum', default = 'None', required = true } - -[structs.RenderPassDepthStencilAttachment] -fields.view = { type = 'GPUTexture | GPUTextureView', default = 'None', required = true } -fields.depth_clear_value = { type = 'float', default = 'None', required = false } -fields.depth_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } -fields.depth_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } -fields.depth_read_only = { type = 'bool', default = 'False', required = false } -fields.stencil_clear_value = { type = 'int', default = '0', required = false } -fields.stencil_load_op = { type = 'enums.LoadOpEnum', default = 'None', required = false } -fields.stencil_store_op = { type = 'enums.StoreOpEnum', default = 'None', required = false } -fields.stencil_read_only = { type = 'bool', default = 'False', required = false } - -[structs.RenderPassLayout] -fields.label = { type = 'str', default = '""', required = false } -fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } -fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } - -[structs.RenderBundleDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.RenderBundleEncoderDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.color_formats = { type = 'list[enums.TextureFormatEnum]', default = 'None', required = true } -fields.depth_stencil_format = { type = 'enums.TextureFormatEnum', default = 'None', required = false } -fields.sample_count = { type = 'int', default = '1', required = false } -fields.depth_read_only = { type = 'bool', default = 'False', required = false } -fields.stencil_read_only = { type = 'bool', default = 'False', required = false } - -[structs.QueueDescriptor] -fields.label = { type = 'str', default = '""', required = false } - -[structs.QuerySetDescriptor] -fields.label = { type = 'str', default = '""', required = false } -fields.type = { type = 'enums.QueryTypeEnum', default = 'None', required = true } -fields.count = { type = 'int', default = 'None', required = true } - -[structs.CanvasToneMapping] -fields.mode = { type = 'enums.CanvasToneMappingModeEnum', default = '"standard"', required = false } - -[structs.CanvasConfiguration] -fields.device = { type = 'GPUDevice', default = 'None', required = true } -fields.format = { type = 'enums.TextureFormatEnum', default = 'None', required = true } -fields.usage = { type = 'flags.TextureUsageFlags', default = '0x10', required = false } -fields.view_formats = { type = 'list[enums.TextureFormatEnum]', default = '[]', required = false } -fields.color_space = { type = 'str', default = '"srgb"', required = false } -fields.tone_mapping = { type = 'structs.CanvasToneMappingStruct', default = '{}', required = false } -fields.alpha_mode = { type = 'enums.CanvasAlphaModeEnum', default = '"opaque"', required = false } - -[structs.UncapturedErrorEventInit] -fields.error = { type = 'GPUError', default = 'None', required = true } - -[structs.Color] -fields.r = { type = 'float', default = 'None', required = true } -fields.g = { type = 'float', default = 'None', required = true } -fields.b = { type = 'float', default = 'None', required = true } -fields.a = { type = 'float', default = 'None', required = true } - -[structs.Origin2D] -fields.x = { type = 'int', default = '0', required = false } -fields.y = { type = 'int', default = '0', required = false } - -[structs.Origin3D] -fields.x = { type = 'int', default = '0', required = false } -fields.y = { type = 'int', default = '0', required = false } -fields.z = { type = 'int', default = '0', required = false } - -[structs.Extent3D] -fields.width = { type = 'int', default = 'None', required = true } -fields.height = { type = 'int', default = '1', required = false } -fields.depth_or_array_layers = { type = 'int', default = '1', required = false } - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[classes] - -[classes.GPUObjectBase] -bases = [] -properties.label = { type = 'str' } -[classes.GPUObjectBase.methods] - -[classes.GPUAdapterInfo] -bases = [] -properties.vendor = { type = 'str' } -properties.architecture = { type = 'str' } -properties.device = { type = 'str' } -properties.description = { type = 'str' } -properties.subgroup_min_size = { type = 'int' } -properties.subgroup_max_size = { type = 'int' } -properties.is_fallback_adapter = { type = 'bool' } -[classes.GPUAdapterInfo.methods] - -[classes.GPU] -bases = [] -properties.wgsl_language_features = { type = 'set' } -[classes.GPU.methods] -[classes.GPU.methods.request_adapter] -returns = { type = 'GPUAdapter' } -args.options = { type = 'structs.RequestAdapterOptionsStruct', default = '{}', required = false } -[classes.GPU.methods.get_preferred_canvas_format] -returns = { type = 'enums.TextureFormatEnum' } - -[classes.GPUAdapter] -bases = [] -properties.features = { type = 'set' } -properties.limits = { type = 'dict' } -properties.info = { type = 'GPUAdapterInfo' } -[classes.GPUAdapter.methods] -[classes.GPUAdapter.methods.request_device] -returns = { type = 'GPUDevice' } -args.descriptor = { type = 'structs.DeviceDescriptorStruct', default = '{}', required = false } - -[classes.GPUDevice] -bases = ['EventTarget', 'GPUObjectBase'] -properties.features = { type = 'set' } -properties.limits = { type = 'dict' } -properties.adapter_info = { type = 'GPUAdapterInfo' } -properties.queue = { type = 'GPUQueue' } -properties.lost = { type = 'GPUDeviceLostInfo' } -properties.onuncapturederror = { type = 'None' } -[classes.GPUDevice.methods] -[classes.GPUDevice.methods.destroy] -returns = { type = 'None' } -[classes.GPUDevice.methods.create_buffer] -returns = { type = 'GPUBuffer' } -args.descriptor = { type = 'structs.BufferDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_texture] -returns = { type = 'GPUTexture' } -args.descriptor = { type = 'structs.TextureDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_sampler] -returns = { type = 'GPUSampler' } -args.descriptor = { type = 'structs.SamplerDescriptorStruct', default = '{}', required = false } -[classes.GPUDevice.methods.import_external_texture] -returns = { type = 'object' } -args.descriptor = { type = 'structs.ExternalTextureDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_bind_group_layout] -returns = { type = 'GPUBindGroupLayout' } -args.descriptor = { type = 'structs.BindGroupLayoutDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_pipeline_layout] -returns = { type = 'GPUPipelineLayout' } -args.descriptor = { type = 'structs.PipelineLayoutDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_bind_group] -returns = { type = 'GPUBindGroup' } -args.descriptor = { type = 'structs.BindGroupDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_shader_module] -returns = { type = 'GPUShaderModule' } -args.descriptor = { type = 'structs.ShaderModuleDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_compute_pipeline] -returns = { type = 'GPUComputePipeline' } -args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_render_pipeline] -returns = { type = 'GPURenderPipeline' } -args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_compute_pipeline_async] -returns = { type = 'GPUPromise[GPUComputePipeline]' } -args.descriptor = { type = 'structs.ComputePipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_render_pipeline_async] -returns = { type = 'GPUPromise[GPURenderPipeline]' } -args.descriptor = { type = 'structs.RenderPipelineDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_command_encoder] -returns = { type = 'GPUCommandEncoder' } -args.descriptor = { type = 'structs.CommandEncoderDescriptorStruct', default = '{}', required = false } -[classes.GPUDevice.methods.create_render_bundle_encoder] -returns = { type = 'GPURenderBundleEncoder' } -args.descriptor = { type = 'structs.RenderBundleEncoderDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.create_query_set] -returns = { type = 'GPUQuerySet' } -args.descriptor = { type = 'structs.QuerySetDescriptorStruct', default = 'None', required = true } -[classes.GPUDevice.methods.push_error_scope] -returns = { type = 'None' } -args.filter = { type = 'enums.ErrorFilterEnum', default = 'None', required = true } -[classes.GPUDevice.methods.pop_error_scope] -returns = { type = 'GPUError' } - -[classes.GPUBuffer] -bases = ['GPUObjectBase'] -properties.size = { type = 'int' } -properties.usage = { type = 'int' } -properties.map_state = { type = 'enums.BufferMapStateEnum' } -[classes.GPUBuffer.methods] -[classes.GPUBuffer.methods.map_async] -returns = { type = 'GPUPromise[None]' } -args.mode = { type = 'flags.MapModeFlags', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUBuffer.methods.get_mapped_range] -returns = { type = 'ArrayLike' } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUBuffer.methods.unmap] -returns = { type = 'None' } -[classes.GPUBuffer.methods.destroy] -returns = { type = 'None' } - -[classes.GPUTexture] -bases = ['GPUObjectBase'] -properties.width = { type = 'int' } -properties.height = { type = 'int' } -properties.depth_or_array_layers = { type = 'int' } -properties.mip_level_count = { type = 'int' } -properties.sample_count = { type = 'int' } -properties.dimension = { type = 'enums.TextureDimensionEnum' } -properties.format = { type = 'enums.TextureFormatEnum' } -properties.usage = { type = 'int' } -properties.texture_binding_view_dimension = { type = 'enums.TextureViewDimensionEnum | None' } -[classes.GPUTexture.methods] -[classes.GPUTexture.methods.create_view] -returns = { type = 'GPUTextureView' } -args.descriptor = { type = 'structs.TextureViewDescriptorStruct', default = '{}', required = false } -[classes.GPUTexture.methods.destroy] -returns = { type = 'None' } - -[classes.GPUTextureView] -bases = ['GPUObjectBase'] -[classes.GPUTextureView.methods] - -[classes.GPUSampler] -bases = ['GPUObjectBase'] -[classes.GPUSampler.methods] - -[classes.GPUBindGroupLayout] -bases = ['GPUObjectBase'] -[classes.GPUBindGroupLayout.methods] - -[classes.GPUBindGroup] -bases = ['GPUObjectBase'] -[classes.GPUBindGroup.methods] - -[classes.GPUPipelineLayout] -bases = ['GPUObjectBase'] -[classes.GPUPipelineLayout.methods] - -[classes.GPUShaderModule] -bases = ['GPUObjectBase'] -[classes.GPUShaderModule.methods] -[classes.GPUShaderModule.methods.get_compilation_info] -returns = { type = 'GPUCompilationInfo' } - -[classes.GPUCompilationMessage] -bases = [] -properties.message = { type = 'str' } -properties.type = { type = 'enums.CompilationMessageTypeEnum' } -properties.line_num = { type = 'int' } -properties.line_pos = { type = 'int' } -properties.offset = { type = 'int' } -properties.length = { type = 'int' } -[classes.GPUCompilationMessage.methods] - -[classes.GPUCompilationInfo] -bases = [] -properties.messages = { type = 'list[GPUCompilationMessage]' } -[classes.GPUCompilationInfo.methods] - -[classes.GPUPipelineError] -bases = ['DOMException'] -properties.reason = { type = 'enums.PipelineErrorReasonEnum' } -[classes.GPUPipelineError.methods] -[classes.GPUPipelineError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = '""', required = false } -args.options = { type = 'structs.PipelineErrorInitStruct', default = 'None', required = true } - -[classes.GPUPipelineBase] -bases = [] -[classes.GPUPipelineBase.methods] -[classes.GPUPipelineBase.methods.get_bind_group_layout] -returns = { type = 'GPUBindGroupLayout' } -args.index = { type = 'int', default = 'None', required = true } - -[classes.GPUComputePipeline] -bases = ['GPUObjectBase', 'GPUPipelineBase'] -[classes.GPUComputePipeline.methods] - -[classes.GPURenderPipeline] -bases = ['GPUObjectBase', 'GPUPipelineBase'] -[classes.GPURenderPipeline.methods] - -[classes.GPUCommandBuffer] -bases = ['GPUObjectBase'] -[classes.GPUCommandBuffer.methods] - -[classes.GPUCommandsMixin] -bases = [] -[classes.GPUCommandsMixin.methods] - -[classes.GPUCommandEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin'] -[classes.GPUCommandEncoder.methods] -[classes.GPUCommandEncoder.methods.begin_render_pass] -returns = { type = 'GPURenderPassEncoder' } -args.descriptor = { type = 'structs.RenderPassDescriptorStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.begin_compute_pass] -returns = { type = 'GPUComputePassEncoder' } -args.descriptor = { type = 'structs.ComputePassDescriptorStruct', default = '{}', required = false } -[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] -returns = { type = 'None' } -args.source = { type = 'GPUBuffer', default = 'None', required = true } -args.source_offset = { type = 'int', default = 'None', required = true } -args.destination = { type = 'GPUBuffer', default = 'None', required = true } -args.destination_offset = { type = 'int', default = 'None', required = true } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyBufferInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.copy_texture_to_texture] -returns = { type = 'None' } -args.source = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.clear_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUCommandEncoder.methods.resolve_query_set] -returns = { type = 'None' } -args.query_set = { type = 'GPUQuerySet', default = 'None', required = true } -args.first_query = { type = 'int', default = 'None', required = true } -args.query_count = { type = 'int', default = 'None', required = true } -args.destination = { type = 'GPUBuffer', default = 'None', required = true } -args.destination_offset = { type = 'int', default = 'None', required = true } -[classes.GPUCommandEncoder.methods.finish] -returns = { type = 'GPUCommandBuffer' } -args.descriptor = { type = 'structs.CommandBufferDescriptorStruct', default = '{}', required = false } - -[classes.GPUBindingCommandsMixin] -bases = [] -[classes.GPUBindingCommandsMixin.methods] -[classes.GPUBindingCommandsMixin.methods.set_bind_group] -returns = { type = 'None' } -args.index = { type = 'int', default = 'None', required = true } -args.bind_group = { type = 'GPUBindGroup', default = 'None', required = true } -args.dynamic_offsets_data = { type = 'ArrayLike', default = 'None', required = true } -args.dynamic_offsets_data_start = { type = 'int', default = 'None', required = true } -args.dynamic_offsets_data_length = { type = 'int', default = 'None', required = true } -[classes.GPUBindingCommandsMixin.methods.set_immediates] -returns = { type = 'None' } -args.range_offset = { type = 'int', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_offset = { type = 'int', default = '0', required = false } -args.data_size = { type = 'int', default = 'None', required = false } - -[classes.GPUDebugCommandsMixin] -bases = [] -[classes.GPUDebugCommandsMixin.methods] -[classes.GPUDebugCommandsMixin.methods.push_debug_group] -returns = { type = 'None' } -args.group_label = { type = 'str', default = 'None', required = true } -[classes.GPUDebugCommandsMixin.methods.pop_debug_group] -returns = { type = 'None' } -[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] -returns = { type = 'None' } -args.marker_label = { type = 'str', default = 'None', required = true } - -[classes.GPUComputePassEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin'] -[classes.GPUComputePassEncoder.methods] -[classes.GPUComputePassEncoder.methods.set_pipeline] -returns = { type = 'None' } -args.pipeline = { type = 'GPUComputePipeline', default = 'None', required = true } -[classes.GPUComputePassEncoder.methods.dispatch_workgroups] -returns = { type = 'None' } -args.workgroup_count_x = { type = 'int', default = 'None', required = true } -args.workgroup_count_y = { type = 'int', default = '1', required = false } -args.workgroup_count_z = { type = 'int', default = '1', required = false } -[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } -[classes.GPUComputePassEncoder.methods.end] -returns = { type = 'None' } - -[classes.GPURenderPassEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] -[classes.GPURenderPassEncoder.methods] -[classes.GPURenderPassEncoder.methods.set_viewport] -returns = { type = 'None' } -args.x = { type = 'float', default = 'None', required = true } -args.y = { type = 'float', default = 'None', required = true } -args.width = { type = 'float', default = 'None', required = true } -args.height = { type = 'float', default = 'None', required = true } -args.min_depth = { type = 'float', default = 'None', required = true } -args.max_depth = { type = 'float', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_scissor_rect] -returns = { type = 'None' } -args.x = { type = 'int', default = 'None', required = true } -args.y = { type = 'int', default = 'None', required = true } -args.width = { type = 'int', default = 'None', required = true } -args.height = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_blend_constant] -returns = { type = 'None' } -args.color = { type = 'tuple[float, float, float, float] | structs.ColorStruct', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.set_stencil_reference] -returns = { type = 'None' } -args.reference = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.begin_occlusion_query] -returns = { type = 'None' } -args.query_index = { type = 'int', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.end_occlusion_query] -returns = { type = 'None' } -[classes.GPURenderPassEncoder.methods.execute_bundles] -returns = { type = 'None' } -args.bundles = { type = 'list[GPURenderBundle]', default = 'None', required = true } -[classes.GPURenderPassEncoder.methods.end] -returns = { type = 'None' } - -[classes.GPURenderCommandsMixin] -bases = [] -[classes.GPURenderCommandsMixin.methods] -[classes.GPURenderCommandsMixin.methods.set_pipeline] -returns = { type = 'None' } -args.pipeline = { type = 'GPURenderPipeline', default = 'None', required = true } -[classes.GPURenderCommandsMixin.methods.set_index_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.index_format = { type = 'enums.IndexFormatEnum', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] -returns = { type = 'None' } -args.slot = { type = 'int', default = 'None', required = true } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPURenderCommandsMixin.methods.draw] -returns = { type = 'None' } -args.vertex_count = { type = 'int', default = 'None', required = true } -args.instance_count = { type = 'int', default = '1', required = false } -args.first_vertex = { type = 'int', default = '0', required = false } -args.first_instance = { type = 'int', default = '0', required = false } -[classes.GPURenderCommandsMixin.methods.draw_indexed] -returns = { type = 'None' } -args.index_count = { type = 'int', default = 'None', required = true } -args.instance_count = { type = 'int', default = '1', required = false } -args.first_index = { type = 'int', default = '0', required = false } -args.base_vertex = { type = 'int', default = '0', required = false } -args.first_instance = { type = 'int', default = '0', required = false } -[classes.GPURenderCommandsMixin.methods.draw_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } -[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] -returns = { type = 'None' } -args.indirect_buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.indirect_offset = { type = 'int', default = 'None', required = true } - -[classes.GPURenderBundle] -bases = ['GPUObjectBase'] -[classes.GPURenderBundle.methods] - -[classes.GPURenderBundleEncoder] -bases = ['GPUObjectBase', 'GPUCommandsMixin', 'GPUDebugCommandsMixin', 'GPUBindingCommandsMixin', 'GPURenderCommandsMixin'] -[classes.GPURenderBundleEncoder.methods] -[classes.GPURenderBundleEncoder.methods.finish] -returns = { type = 'GPURenderBundle' } -args.descriptor = { type = 'structs.RenderBundleDescriptorStruct', default = '{}', required = false } - -[classes.GPUQueue] -bases = ['GPUObjectBase'] -[classes.GPUQueue.methods] -[classes.GPUQueue.methods.submit] -returns = { type = 'None' } -args.command_buffers = { type = 'list[GPUCommandBuffer]', default = 'None', required = true } -[classes.GPUQueue.methods.on_submitted_work_done] -returns = { type = 'None' } -[classes.GPUQueue.methods.write_buffer] -returns = { type = 'None' } -args.buffer = { type = 'GPUBuffer', default = 'None', required = true } -args.buffer_offset = { type = 'int', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_offset = { type = 'int', default = '0', required = false } -args.size = { type = 'int', default = 'None', required = false } -[classes.GPUQueue.methods.write_texture] -returns = { type = 'None' } -args.destination = { type = 'structs.TexelCopyTextureInfoStruct', default = 'None', required = true } -args.data = { type = 'ArrayLike', default = 'None', required = true } -args.data_layout = { type = 'structs.TexelCopyBufferLayoutStruct', default = 'None', required = true } -args.size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } -[classes.GPUQueue.methods.copy_external_image_to_texture] -returns = { type = 'None' } -args.source = { type = 'structs.CopyExternalImageSourceInfoStruct', default = 'None', required = true } -args.destination = { type = 'structs.CopyExternalImageDestInfoStruct', default = 'None', required = true } -args.copy_size = { type = 'tuple[int, int, int] | structs.Extent3DStruct', default = 'None', required = true } - -[classes.GPUQuerySet] -bases = ['GPUObjectBase'] -properties.type = { type = 'enums.QueryTypeEnum' } -properties.count = { type = 'int' } -[classes.GPUQuerySet.methods] -[classes.GPUQuerySet.methods.destroy] -returns = { type = 'None' } - -[classes.GPUCanvasContext] -bases = [] -properties.canvas = { type = 'CanvasLike' } -[classes.GPUCanvasContext.methods] -[classes.GPUCanvasContext.methods.configure] -returns = { type = 'None' } -args.configuration = { type = 'structs.CanvasConfigurationStruct', default = 'None', required = true } -[classes.GPUCanvasContext.methods.unconfigure] -returns = { type = 'None' } -[classes.GPUCanvasContext.methods.get_configuration] -returns = { type = 'structs.CanvasConfigurationStruct' } -[classes.GPUCanvasContext.methods.get_current_texture] -returns = { type = 'GPUTexture' } - -[classes.GPUDeviceLostInfo] -bases = [] -properties.reason = { type = 'enums.DeviceLostReasonEnum' } -properties.message = { type = 'str' } -[classes.GPUDeviceLostInfo.methods] - -[classes.GPUError] -bases = [] -properties.message = { type = 'str' } -[classes.GPUError.methods] - -[classes.GPUValidationError] -bases = ['GPUError'] -[classes.GPUValidationError.methods] -[classes.GPUValidationError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } - -[classes.GPUOutOfMemoryError] -bases = ['GPUError'] -[classes.GPUOutOfMemoryError.methods] -[classes.GPUOutOfMemoryError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } - -[classes.GPUInternalError] -bases = ['GPUError'] -[classes.GPUInternalError.methods] -[classes.GPUInternalError.methods.constructor] -returns = { type = 'None' } -args.message = { type = 'str', default = 'None', required = true } diff --git a/apigen/definitions/wgpu_docs.toml b/apigen/definitions/wgpu_docs.toml deleted file mode 100644 index e78b1ba4..00000000 --- a/apigen/definitions/wgpu_docs.toml +++ /dev/null @@ -1,2413 +0,0 @@ -# wgpu_docs.toml -# Documentation for the wgpu-py API, composed from 'docs_ai.toml', 'docs_ts.toml', and 'docs_dev.toml' - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[flags] - -[flags.BufferUsage] -doc = """Bit flags describing how a GPUBuffer can be used. Combine them with the bitwise OR operator. - -The usage is set when creating the buffer (see the usage field of structs.BufferDescriptor) and cannot be changed afterwards. -Using a buffer in a way that was not declared here results in a validation error. -""" -fields.MAP_READ.doc = """The buffer can be mapped for reading by the CPU (see flags.MapMode.READ). Can only be combined with COPY_DST.""" -fields.MAP_WRITE.doc = """The buffer can be mapped for writing by the CPU (see flags.MapMode.WRITE). Can only be combined with COPY_SRC.""" -fields.COPY_SRC.doc = """The buffer can be the source of a copy operation, e.g. the source of GPUCommandEncoder.copy_buffer_to_buffer().""" -fields.COPY_DST.doc = """The buffer can be the destination of a copy or write operation, e.g. GPUQueue.write_buffer() or GPUCommandEncoder.clear_buffer().""" -fields.INDEX.doc = """The buffer can be used as an index buffer, see GPURenderCommandsMixin.set_index_buffer().""" -fields.VERTEX.doc = """The buffer can be used as a vertex buffer, see GPURenderCommandsMixin.set_vertex_buffer().""" -fields.UNIFORM.doc = """The buffer can be bound as a uniform buffer, see enums.BufferBindingType.uniform.""" -fields.STORAGE.doc = """The buffer can be bound as a storage buffer, see enums.BufferBindingType.storage.""" -fields.INDIRECT.doc = """The buffer can be used to source indirect draw or dispatch parameters, e.g. GPURenderCommandsMixin.draw_indirect().""" -fields.QUERY_RESOLVE.doc = """The buffer can be the destination of GPUCommandEncoder.resolve_query_set().""" - -[flags.MapMode] -doc = """Bit flags that specify whether a buffer is mapped for reading or writing. - -Used in the mode argument of the GPUBuffer.map_async() method. The mode must match the -flags.BufferUsage of the buffer: READ requires flags.BufferUsage.MAP_READ, WRITE requires flags.BufferUsage.MAP_WRITE. -""" -fields.READ.doc = """Map the buffer for reading. Requires the buffer to have flags.BufferUsage.MAP_READ.""" -fields.WRITE.doc = """Map the buffer for writing. Requires the buffer to have flags.BufferUsage.MAP_WRITE.""" - -[flags.TextureUsage] -doc = """Bit flags describing how a GPUTexture can be used. Combine them with the bitwise OR operator. - -The usage is set when creating the texture (see the usage field of structs.TextureDescriptor). -Texture views can restrict the usage further (see the usage field of structs.TextureViewDescriptor). -""" -fields.COPY_SRC.doc = """The texture can be the source of a copy operation, e.g. GPUCommandEncoder.copy_texture_to_buffer().""" -fields.COPY_DST.doc = """The texture can be the destination of a copy or write operation, e.g. GPUQueue.write_texture().""" -fields.TEXTURE_BINDING.doc = """The texture can be bound for sampling in a shader, see structs.TextureBindingLayout.""" -fields.STORAGE_BINDING.doc = """The texture can be bound as a storage texture in a shader, see structs.StorageTextureBindingLayout.""" -fields.RENDER_ATTACHMENT.doc = """The texture can be used as a color or depth/stencil attachment in a render pass, see structs.RenderPassDescriptor.""" -fields.TRANSIENT_ATTACHMENT.doc = """The texture is a transient attachment: its contents only live for the duration of a render pass and may never be written to memory. Must be combined with RENDER_ATTACHMENT only, and used with enums.StoreOp.discard.""" - -[flags.ShaderStage] -doc = """Bit flags that specify in which shader stages a resource is visible. - -Used in the visibility field of structs.BindGroupLayoutEntry. -""" -fields.VERTEX.doc = """The vertex shader stage.""" -fields.FRAGMENT.doc = """The fragment shader stage.""" -fields.COMPUTE.doc = """The compute shader stage.""" - -[flags.ColorWrite] -doc = """Bit flags that specify which color channels of a render target are written to. - -Used in the write_mask field of structs.ColorTargetState. -""" -fields.RED.doc = """Write the red channel.""" -fields.GREEN.doc = """Write the green channel.""" -fields.BLUE.doc = """Write the blue channel.""" -fields.ALPHA.doc = """Write the alpha channel.""" -fields.ALL.doc = """Write all channels (RED, GREEN, BLUE and ALPHA).""" - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[enums] - -[enums.PowerPreference] -doc = """Hint for which kind of adapter to select. - -Used in the power_preference field of structs.RequestAdapterOptions. This is only a hint; -the implementation may ignore it. -""" -fields.low_power.doc = """Prefer an adapter that uses little power, e.g. an integrated GPU.""" -fields.high_performance.doc = """Prefer an adapter with the highest performance, e.g. a discrete GPU.""" - -[enums.FeatureName] -doc = """Names of optional features that an adapter may support and a device may request. - -Available features can be inspected via the features property of GPUAdapter. Features -are enabled by listing them in the required_features field of structs.DeviceDescriptor. -The features of the device are available via the features property of GPUDevice. -""" -fields.core_features_and_limits.doc = """Indicates that the adapter supports the core WebGPU features and limits (as opposed to compatibility mode).""" -fields.depth_clip_control.doc = """Allows disabling depth clipping, see the unclipped_depth field of structs.PrimitiveState.""" -fields.depth32float_stencil8.doc = """Enables enums.TextureFormat.depth32float_stencil8.""" -fields.texture_compression_bc.doc = """Enables the BC (S3TC, RGTC, BPTC) compressed texture formats, e.g. enums.TextureFormat.bc1_rgba_unorm.""" -fields.texture_compression_bc_sliced_d3.doc = """Allows the BC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_bc.""" -fields.texture_compression_etc2.doc = """Enables the ETC2 and EAC compressed texture formats, e.g. enums.TextureFormat.etc2_rgb8unorm.""" -fields.texture_compression_astc.doc = """Enables the ASTC compressed texture formats, e.g. enums.TextureFormat.astc_4x4_unorm.""" -fields.texture_compression_astc_sliced_d3.doc = """Allows the ASTC compressed formats to be used with enums.TextureDimension.d3 textures. Requires texture_compression_astc.""" -fields.timestamp_query.doc = """Enables timestamp queries, see enums.QueryType.timestamp and structs.RenderPassTimestampWrites.""" -fields.indirect_first_instance.doc = """Allows a non-zero first_instance in indirect draw commands, e.g. GPURenderCommandsMixin.draw_indirect().""" -fields.shader_f16.doc = """Allows the use of the f16 type in WGSL shaders (the enable f16 directive).""" -fields.rg11b10ufloat_renderable.doc = """Allows enums.TextureFormat.rg11b10ufloat to be used as a render attachment, with blending and multisampling.""" -fields.bgra8unorm_storage.doc = """Allows enums.TextureFormat.bgra8unorm to be used as a storage texture.""" -fields.float32_filterable.doc = """Allows 32-bit float textures to be filtered, i.e. used with a filtering sampler.""" -fields.float32_blendable.doc = """Allows 32-bit float color attachments to be used with blending.""" -fields.clip_distances.doc = """Allows the clip_distances built-in in WGSL vertex shaders, for user-defined clip planes.""" -fields.dual_source_blending.doc = """Allows blending with a second fragment shader output, see enums.BlendFactor.src1.""" -fields.subgroups.doc = """Allows the use of subgroup operations in WGSL shaders.""" -fields.texture_formats_tier1.doc = """Enables additional texture format capabilities, including the 16-bit normalized formats (e.g. enums.TextureFormat.r16unorm), and more storage and render support for existing formats.""" -fields.texture_formats_tier2.doc = """Enables further texture format capabilities, such as read-write storage access for more formats. Requires texture_formats_tier1.""" -fields.primitive_index.doc = """Allows the primitive_index built-in in WGSL fragment shaders.""" -fields.texture_component_swizzle.doc = """Allows swizzling the components of a texture view, see the swizzle field of structs.TextureViewDescriptor.""" - -[enums.BufferMapState] -doc = """The mapping state of a GPUBuffer, available via the map_state property of GPUBuffer. -""" -fields.unmapped.doc = """The buffer is not mapped; it can be used by the GPU.""" -fields.pending.doc = """A GPUBuffer.map_async() call is in progress but has not yet completed.""" -fields.mapped.doc = """The buffer is mapped and its memory can be accessed using GPUBuffer.get_mapped_range().""" - -[enums.TextureDimension] -doc = """The dimensionality of a GPUTexture. - -Used in the dimension field of structs.TextureDescriptor. -""" -fields.d1.doc = """A one-dimensional texture, with only a width.""" -fields.d2.doc = """A two-dimensional texture, with width and height. Also used for 2D array textures and cube maps (via layers).""" -fields.d3.doc = """A three-dimensional (volume) texture, with width, height and depth.""" - -[enums.TextureViewDimension] -doc = """The dimensionality of a GPUTextureView, i.e. how a texture is interpreted when bound to a shader. - -Used in the dimension field of structs.TextureViewDescriptor and the view_dimension field of -structs.TextureBindingLayout and structs.StorageTextureBindingLayout. -""" -fields.d1.doc = """A one-dimensional view; corresponds to texture_1d in WGSL.""" -fields.d2.doc = """A two-dimensional view of a single layer; corresponds to texture_2d in WGSL.""" -fields.d2_array.doc = """A view of an array of 2D layers; corresponds to texture_2d_array in WGSL.""" -fields.cube.doc = """A cube map view consisting of six 2D layers; corresponds to texture_cube in WGSL.""" -fields.cube_array.doc = """A view of an array of cube maps (a multiple of six layers); corresponds to texture_cube_array in WGSL.""" -fields.d3.doc = """A three-dimensional view; corresponds to texture_3d in WGSL.""" - -[enums.TextureAspect] -doc = """Which aspect (part) of a texture a view or copy operation refers to. - -This is mostly relevant for depth-stencil formats, which have separate depth and stencil aspects. -""" -fields.all.doc = """All available aspects of the texture format.""" -fields.stencil_only.doc = """Only the stencil aspect of a depth-stencil format.""" -fields.depth_only.doc = """Only the depth aspect of a depth-stencil format.""" - -[enums.TextureFormat] -doc = """The pixel format of a GPUTexture. - -Names are of the form: channels, bit size per channel, and a type suffix. -The suffixes mean: unorm = unsigned normalized (0..1), snorm = signed normalized (-1..1), -uint/sint = unsigned/signed integer, float = floating point, and srgb = the color -is stored in sRGB and automatically converted to linear when sampled (and back when written). -Some formats require a feature (see enums.FeatureName), and not all formats can be used with all usages (see flags.TextureUsage). -""" -fields.r8unorm.doc = """One channel (red), 8-bit unsigned normalized.""" -fields.r8snorm.doc = """One channel (red), 8-bit signed normalized.""" -fields.r8uint.doc = """One channel (red), 8-bit unsigned integer.""" -fields.r8sint.doc = """One channel (red), 8-bit signed integer.""" -fields.r16unorm.doc = """One channel (red), 16-bit unsigned normalized. Requires feature texture_formats_tier1.""" -fields.r16snorm.doc = """One channel (red), 16-bit signed normalized. Requires feature texture_formats_tier1.""" -fields.r16uint.doc = """One channel (red), 16-bit unsigned integer.""" -fields.r16sint.doc = """One channel (red), 16-bit signed integer.""" -fields.r16float.doc = """One channel (red), 16-bit floating point.""" -fields.rg8unorm.doc = """Two channels (red, green), 8-bit unsigned normalized each.""" -fields.rg8snorm.doc = """Two channels (red, green), 8-bit signed normalized each.""" -fields.rg8uint.doc = """Two channels (red, green), 8-bit unsigned integer each.""" -fields.rg8sint.doc = """Two channels (red, green), 8-bit signed integer each.""" -fields.r32uint.doc = """One channel (red), 32-bit unsigned integer.""" -fields.r32sint.doc = """One channel (red), 32-bit signed integer.""" -fields.r32float.doc = """One channel (red), 32-bit floating point.""" -fields.rg16unorm.doc = """Two channels (red, green), 16-bit unsigned normalized each. Requires feature texture_formats_tier1.""" -fields.rg16snorm.doc = """Two channels (red, green), 16-bit signed normalized each. Requires feature texture_formats_tier1.""" -fields.rg16uint.doc = """Two channels (red, green), 16-bit unsigned integer each.""" -fields.rg16sint.doc = """Two channels (red, green), 16-bit signed integer each.""" -fields.rg16float.doc = """Two channels (red, green), 16-bit floating point each.""" -fields.rgba8unorm.doc = """Four channels (red, green, blue, alpha), 8-bit unsigned normalized each.""" -fields.rgba8unorm_srgb.doc = """Four channels (RGBA), 8-bit unsigned normalized each, with sRGB encoding of the color channels.""" -fields.rgba8snorm.doc = """Four channels (RGBA), 8-bit signed normalized each.""" -fields.rgba8uint.doc = """Four channels (RGBA), 8-bit unsigned integer each.""" -fields.rgba8sint.doc = """Four channels (RGBA), 8-bit signed integer each.""" -fields.bgra8unorm.doc = """Four channels in blue, green, red, alpha order, 8-bit unsigned normalized each. Often the preferred canvas format, see GPU.get_preferred_canvas_format().""" -fields.bgra8unorm_srgb.doc = """Four channels in BGRA order, 8-bit unsigned normalized each, with sRGB encoding of the color channels.""" -fields.rgb9e5ufloat.doc = """Packed 32-bit format with three 9-bit unsigned float mantissas (RGB) and a shared 5-bit exponent. Not renderable.""" -fields.rgb10a2uint.doc = """Packed 32-bit format with 10-bit unsigned integer RGB channels and a 2-bit unsigned integer alpha.""" -fields.rgb10a2unorm.doc = """Packed 32-bit format with 10-bit unsigned normalized RGB channels and a 2-bit unsigned normalized alpha.""" -fields.rg11b10ufloat.doc = """Packed 32-bit format with unsigned floating point R and G (11 bits each) and B (10 bits). Renderable only with feature rg11b10ufloat_renderable.""" -fields.rg32uint.doc = """Two channels (red, green), 32-bit unsigned integer each.""" -fields.rg32sint.doc = """Two channels (red, green), 32-bit signed integer each.""" -fields.rg32float.doc = """Two channels (red, green), 32-bit floating point each.""" -fields.rgba16unorm.doc = """Four channels (RGBA), 16-bit unsigned normalized each. Requires feature texture_formats_tier1.""" -fields.rgba16snorm.doc = """Four channels (RGBA), 16-bit signed normalized each. Requires feature texture_formats_tier1.""" -fields.rgba16uint.doc = """Four channels (RGBA), 16-bit unsigned integer each.""" -fields.rgba16sint.doc = """Four channels (RGBA), 16-bit signed integer each.""" -fields.rgba16float.doc = """Four channels (RGBA), 16-bit floating point each.""" -fields.rgba32uint.doc = """Four channels (RGBA), 32-bit unsigned integer each.""" -fields.rgba32sint.doc = """Four channels (RGBA), 32-bit signed integer each.""" -fields.rgba32float.doc = """Four channels (RGBA), 32-bit floating point each.""" -fields.stencil8.doc = """A stencil-only format with 8 bits per pixel.""" -fields.depth16unorm.doc = """A depth-only format with 16-bit unsigned normalized depth.""" -fields.depth24plus.doc = """A depth-only format with at least 24 bits of depth. The exact representation is implementation-defined and cannot be copied to a buffer.""" -fields.depth24plus_stencil8.doc = """A depth-stencil format with at least 24 bits of depth and 8 bits of stencil. The depth aspect cannot be copied to a buffer.""" -fields.depth32float.doc = """A depth-only format with 32-bit floating point depth.""" -fields.depth32float_stencil8.doc = """A depth-stencil format with 32-bit floating point depth and 8 bits of stencil. Requires feature depth32float_stencil8.""" -fields.bc1_rgba_unorm.doc = """BC1 (DXT1) compressed RGBA, unsigned normalized. 4x4 blocks of 8 bytes. Requires feature texture_compression_bc.""" -fields.bc1_rgba_unorm_srgb.doc = """BC1 (DXT1) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" -fields.bc2_rgba_unorm.doc = """BC2 (DXT3) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc.""" -fields.bc2_rgba_unorm_srgb.doc = """BC2 (DXT3) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" -fields.bc3_rgba_unorm.doc = """BC3 (DXT5) compressed RGBA, unsigned normalized. 4x4 blocks of 16 bytes. Requires feature texture_compression_bc.""" -fields.bc3_rgba_unorm_srgb.doc = """BC3 (DXT5) compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" -fields.bc4_r_unorm.doc = """BC4 compressed single channel, unsigned normalized. Requires feature texture_compression_bc.""" -fields.bc4_r_snorm.doc = """BC4 compressed single channel, signed normalized. Requires feature texture_compression_bc.""" -fields.bc5_rg_unorm.doc = """BC5 compressed two channels, unsigned normalized. Requires feature texture_compression_bc.""" -fields.bc5_rg_snorm.doc = """BC5 compressed two channels, signed normalized. Requires feature texture_compression_bc.""" -fields.bc6h_rgb_ufloat.doc = """BC6H compressed HDR RGB, unsigned float. Requires feature texture_compression_bc.""" -fields.bc6h_rgb_float.doc = """BC6H compressed HDR RGB, signed float. Requires feature texture_compression_bc.""" -fields.bc7_rgba_unorm.doc = """BC7 compressed RGBA, unsigned normalized. Requires feature texture_compression_bc.""" -fields.bc7_rgba_unorm_srgb.doc = """BC7 compressed RGBA with sRGB encoding. Requires feature texture_compression_bc.""" -fields.etc2_rgb8unorm.doc = """ETC2 compressed RGB, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2.""" -fields.etc2_rgb8unorm_srgb.doc = """ETC2 compressed RGB with sRGB encoding. Requires feature texture_compression_etc2.""" -fields.etc2_rgb8a1unorm.doc = """ETC2 compressed RGB with 1-bit punch-through alpha, unsigned normalized. Requires feature texture_compression_etc2.""" -fields.etc2_rgb8a1unorm_srgb.doc = """ETC2 compressed RGB with 1-bit alpha and sRGB encoding. Requires feature texture_compression_etc2.""" -fields.etc2_rgba8unorm.doc = """ETC2 compressed RGBA, 8 bits per channel, unsigned normalized. Requires feature texture_compression_etc2.""" -fields.etc2_rgba8unorm_srgb.doc = """ETC2 compressed RGBA with sRGB encoding. Requires feature texture_compression_etc2.""" -fields.eac_r11unorm.doc = """EAC compressed single channel, 11-bit unsigned normalized. Requires feature texture_compression_etc2.""" -fields.eac_r11snorm.doc = """EAC compressed single channel, 11-bit signed normalized. Requires feature texture_compression_etc2.""" -fields.eac_rg11unorm.doc = """EAC compressed two channels, 11-bit unsigned normalized each. Requires feature texture_compression_etc2.""" -fields.eac_rg11snorm.doc = """EAC compressed two channels, 11-bit signed normalized each. Requires feature texture_compression_etc2.""" -fields.astc_4x4_unorm.doc = """ASTC compressed RGBA with 4x4 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_4x4_unorm_srgb.doc = """ASTC compressed RGBA with 4x4 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_5x4_unorm.doc = """ASTC compressed RGBA with 5x4 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_5x4_unorm_srgb.doc = """ASTC compressed RGBA with 5x4 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_5x5_unorm.doc = """ASTC compressed RGBA with 5x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_5x5_unorm_srgb.doc = """ASTC compressed RGBA with 5x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_6x5_unorm.doc = """ASTC compressed RGBA with 6x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_6x5_unorm_srgb.doc = """ASTC compressed RGBA with 6x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_6x6_unorm.doc = """ASTC compressed RGBA with 6x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_6x6_unorm_srgb.doc = """ASTC compressed RGBA with 6x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_8x5_unorm.doc = """ASTC compressed RGBA with 8x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_8x5_unorm_srgb.doc = """ASTC compressed RGBA with 8x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_8x6_unorm.doc = """ASTC compressed RGBA with 8x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_8x6_unorm_srgb.doc = """ASTC compressed RGBA with 8x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_8x8_unorm.doc = """ASTC compressed RGBA with 8x8 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_8x8_unorm_srgb.doc = """ASTC compressed RGBA with 8x8 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_10x5_unorm.doc = """ASTC compressed RGBA with 10x5 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_10x5_unorm_srgb.doc = """ASTC compressed RGBA with 10x5 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_10x6_unorm.doc = """ASTC compressed RGBA with 10x6 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_10x6_unorm_srgb.doc = """ASTC compressed RGBA with 10x6 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_10x8_unorm.doc = """ASTC compressed RGBA with 10x8 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_10x8_unorm_srgb.doc = """ASTC compressed RGBA with 10x8 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_10x10_unorm.doc = """ASTC compressed RGBA with 10x10 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_10x10_unorm_srgb.doc = """ASTC compressed RGBA with 10x10 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_12x10_unorm.doc = """ASTC compressed RGBA with 12x10 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_12x10_unorm_srgb.doc = """ASTC compressed RGBA with 12x10 blocks and sRGB encoding. Requires feature texture_compression_astc.""" -fields.astc_12x12_unorm.doc = """ASTC compressed RGBA with 12x12 blocks, unsigned normalized. Requires feature texture_compression_astc.""" -fields.astc_12x12_unorm_srgb.doc = """ASTC compressed RGBA with 12x12 blocks and sRGB encoding. Requires feature texture_compression_astc.""" - -[enums.AddressMode] -doc = """How a sampler handles texture coordinates outside the 0..1 range, per axis. - -Used in the address_mode_u, address_mode_v and address_mode_w fields of structs.SamplerDescriptor. -""" -fields.clamp_to_edge.doc = """Coordinates are clamped to the range 0..1, so the edge texels are repeated.""" -fields.repeat.doc = """The texture tiles: only the fractional part of the coordinate is used.""" -fields.mirror_repeat.doc = """The texture tiles, but is mirrored every other repetition.""" - -[enums.FilterMode] -doc = """How a sampler filters texels when a texture is magnified or minified. - -Used in the mag_filter and min_filter fields of structs.SamplerDescriptor. -""" -fields.nearest.doc = """Use the value of the nearest texel.""" -fields.linear.doc = """Linearly interpolate between the nearest texels.""" - -[enums.MipmapFilterMode] -doc = """How a sampler filters between mip levels. - -Used in the mipmap_filter field of structs.SamplerDescriptor. -""" -fields.nearest.doc = """Use the nearest mip level.""" -fields.linear.doc = """Linearly interpolate between the two nearest mip levels.""" - -[enums.CompareFunction] -doc = """A comparison function, used for depth testing, stencil testing and comparison samplers. - -The comparison is made as: new_value (the incoming fragment, or the sampled reference) compared to -the existing value. If the comparison is true, the test passes. -""" -fields.never.doc = """The comparison never passes.""" -fields.less.doc = """Passes if the new value is less than the existing value.""" -fields.equal.doc = """Passes if the new value is equal to the existing value.""" -fields.less_equal.doc = """Passes if the new value is less than or equal to the existing value.""" -fields.greater.doc = """Passes if the new value is greater than the existing value.""" -fields.not_equal.doc = """Passes if the new value is not equal to the existing value.""" -fields.greater_equal.doc = """Passes if the new value is greater than or equal to the existing value.""" -fields.always.doc = """The comparison always passes.""" - -[enums.BufferBindingType] -doc = """The type of a buffer binding in a bind group layout. - -Used in the type field of structs.BufferBindingLayout. -""" -fields.uniform.doc = """A uniform buffer: read-only, limited in size, and fast. Requires flags.BufferUsage.UNIFORM.""" -fields.storage.doc = """A read-write storage buffer. Requires flags.BufferUsage.STORAGE.""" -fields.read_only_storage.doc = """A read-only storage buffer. Requires flags.BufferUsage.STORAGE.""" - -[enums.SamplerBindingType] -doc = """The type of a sampler binding in a bind group layout. - -Used in the type field of structs.SamplerBindingLayout. -""" -fields.filtering.doc = """A sampler that may filter (linear) texels. Can be used with textures of sample type float, but not unfilterable_float.""" -fields.non_filtering.doc = """A sampler that only uses nearest filtering. Can be used with any float texture.""" -fields.comparison.doc = """A comparison sampler, used for depth textures (see the compare field of structs.SamplerDescriptor).""" - -[enums.TextureSampleType] -doc = """The type of values that is returned when sampling a texture in a shader. - -Used in the sample_type field of structs.TextureBindingLayout. -""" -fields.float.doc = """Floating point values; the texture can be sampled with a filtering sampler.""" -fields.unfilterable_float.doc = """Floating point values, but the texture cannot be filtered (e.g. 32-bit float without the float32_filterable feature).""" -fields.depth.doc = """Depth values, as returned from depth textures. Can be sampled as float, or with a comparison sampler.""" -fields.sint.doc = """Signed integer values.""" -fields.uint.doc = """Unsigned integer values.""" - -[enums.StorageTextureAccess] -doc = """How a storage texture can be accessed by a shader. - -Used in the access field of structs.StorageTextureBindingLayout. -""" -fields.write_only.doc = """The shader can only write to the texture.""" -fields.read_only.doc = """The shader can only read from the texture.""" -fields.read_write.doc = """The shader can both read from and write to the texture.""" - -[enums.CompilationMessageType] -doc = """The severity of a GPUCompilationMessage. -""" -fields.error.doc = """An error; the shader module is invalid.""" -fields.warning.doc = """A warning; the shader module is valid but something may be wrong.""" -fields.info.doc = """An informational message.""" - -[enums.PipelineErrorReason] -doc = """The reason for a GPUPipelineError. - -Available via the reason property of GPUPipelineError. -""" -fields.validation.doc = """The pipeline failed validation, e.g. because of an invalid descriptor or shader.""" -fields.internal.doc = """An internal error occurred when creating the pipeline, e.g. the shader could not be compiled by the backend.""" - -[enums.AutoLayoutMode] -doc = """Indicates that a pipeline layout should be derived automatically from the shader code. - -Used as the layout field of structs.ComputePipelineDescriptor and structs.RenderPipelineDescriptor. -The resulting bind group layouts can be retrieved with GPUPipelineBase.get_bind_group_layout(). -""" -fields.auto.doc = """Derive the pipeline layout from the shader.""" - -[enums.PrimitiveTopology] -doc = """How vertices are assembled into primitives. - -Used in the topology field of structs.PrimitiveState. -""" -fields.point_list.doc = """Each vertex defines a point.""" -fields.line_list.doc = """Each pair of vertices defines a separate line.""" -fields.line_strip.doc = """Each vertex after the first defines a line to the previous vertex.""" -fields.triangle_list.doc = """Each triple of vertices defines a separate triangle.""" -fields.triangle_strip.doc = """Each vertex after the first two defines a triangle with the previous two vertices.""" - -[enums.FrontFace] -doc = """Defines which winding order of a triangle is considered front-facing. - -Used in the front_face field of structs.PrimitiveState. -""" -fields.ccw.doc = """Triangles with counter-clockwise vertices (in framebuffer space) are front-facing.""" -fields.cw.doc = """Triangles with clockwise vertices (in framebuffer space) are front-facing.""" - -[enums.CullMode] -doc = """Defines which faces of triangles are culled (not drawn). - -Used in the cull_mode field of structs.PrimitiveState. -""" -fields.none.doc = """No faces are culled.""" -fields.front.doc = """Front-facing triangles are culled.""" -fields.back.doc = """Back-facing triangles are culled.""" - -[enums.BlendFactor] -doc = """A factor that is multiplied with the source or destination color or alpha in blending. - -Used in the src_factor and dst_factor fields of structs.BlendComponent. In the descriptions, -src is the output of the fragment shader and dst is the existing value in the render target. -""" -fields.zero.doc = """Factor 0.""" -fields.one.doc = """Factor 1.""" -fields.src.doc = """The source color, per component.""" -fields.one_minus_src.doc = """One minus the source color, per component.""" -fields.src_alpha.doc = """The source alpha.""" -fields.one_minus_src_alpha.doc = """One minus the source alpha.""" -fields.dst.doc = """The destination color, per component.""" -fields.one_minus_dst.doc = """One minus the destination color, per component.""" -fields.dst_alpha.doc = """The destination alpha.""" -fields.one_minus_dst_alpha.doc = """One minus the destination alpha.""" -fields.src_alpha_saturated.doc = """The minimum of the source alpha and one minus the destination alpha (for color), and 1 for alpha.""" -fields.constant.doc = """The blend constant color, see GPURenderPassEncoder.set_blend_constant().""" -fields.one_minus_constant.doc = """One minus the blend constant color.""" -fields.src1.doc = """The second source color output of the fragment shader. Requires feature dual_source_blending.""" -fields.one_minus_src1.doc = """One minus the second source color. Requires feature dual_source_blending.""" -fields.src1_alpha.doc = """The second source alpha. Requires feature dual_source_blending.""" -fields.one_minus_src1_alpha.doc = """One minus the second source alpha. Requires feature dual_source_blending.""" - -[enums.BlendOperation] -doc = """The operation used to combine the scaled source and destination values in blending. - -Used in the operation field of structs.BlendComponent. -""" -fields.add.doc = """Result is source plus destination.""" -fields.subtract.doc = """Result is source minus destination.""" -fields.reverse_subtract.doc = """Result is destination minus source.""" -fields.min.doc = """Result is the minimum of source and destination (blend factors are ignored).""" -fields.max.doc = """Result is the maximum of source and destination (blend factors are ignored).""" - -[enums.StencilOperation] -doc = """The operation performed on the stencil buffer value after a stencil or depth test. - -Used in the fail_op, depth_fail_op and pass_op fields of structs.StencilFaceState. -""" -fields.keep.doc = """Keep the current stencil value.""" -fields.zero.doc = """Set the stencil value to zero.""" -fields.replace.doc = """Replace the stencil value with the stencil reference value, see GPURenderPassEncoder.set_stencil_reference().""" -fields.invert.doc = """Bitwise invert the current stencil value.""" -fields.increment_clamp.doc = """Increment the stencil value, clamping to the maximum.""" -fields.decrement_clamp.doc = """Decrement the stencil value, clamping to zero.""" -fields.increment_wrap.doc = """Increment the stencil value, wrapping to zero on overflow.""" -fields.decrement_wrap.doc = """Decrement the stencil value, wrapping to the maximum on underflow.""" - -[enums.IndexFormat] -doc = """The data type of the indices in an index buffer. - -Used in the index_format argument of the GPURenderCommandsMixin.set_index_buffer() method -and the strip_index_format field of structs.PrimitiveState. -""" -fields.uint16.doc = """Indices are 16-bit unsigned integers.""" -fields.uint32.doc = """Indices are 32-bit unsigned integers.""" - -[enums.VertexFormat] -doc = """The format of a vertex attribute in a vertex buffer. - -Used in the format field of structs.VertexAttribute. The name consists of the component type and -bit size, optionally followed by xN for the number of components. The shader sees the data as -float (for unorm, snorm and float formats), i32 (for sint) or u32 (for uint), with the same number of components. -""" -fields.uint8.doc = """One 8-bit unsigned integer.""" -fields.uint8x2.doc = """Two 8-bit unsigned integers.""" -fields.uint8x4.doc = """Four 8-bit unsigned integers.""" -fields.sint8.doc = """One 8-bit signed integer.""" -fields.sint8x2.doc = """Two 8-bit signed integers.""" -fields.sint8x4.doc = """Four 8-bit signed integers.""" -fields.unorm8.doc = """One 8-bit unsigned normalized value (0..1).""" -fields.unorm8x2.doc = """Two 8-bit unsigned normalized values (0..1).""" -fields.unorm8x4.doc = """Four 8-bit unsigned normalized values (0..1).""" -fields.snorm8.doc = """One 8-bit signed normalized value (-1..1).""" -fields.snorm8x2.doc = """Two 8-bit signed normalized values (-1..1).""" -fields.snorm8x4.doc = """Four 8-bit signed normalized values (-1..1).""" -fields.uint16.doc = """One 16-bit unsigned integer.""" -fields.uint16x2.doc = """Two 16-bit unsigned integers.""" -fields.uint16x4.doc = """Four 16-bit unsigned integers.""" -fields.sint16.doc = """One 16-bit signed integer.""" -fields.sint16x2.doc = """Two 16-bit signed integers.""" -fields.sint16x4.doc = """Four 16-bit signed integers.""" -fields.unorm16.doc = """One 16-bit unsigned normalized value (0..1).""" -fields.unorm16x2.doc = """Two 16-bit unsigned normalized values (0..1).""" -fields.unorm16x4.doc = """Four 16-bit unsigned normalized values (0..1).""" -fields.snorm16.doc = """One 16-bit signed normalized value (-1..1).""" -fields.snorm16x2.doc = """Two 16-bit signed normalized values (-1..1).""" -fields.snorm16x4.doc = """Four 16-bit signed normalized values (-1..1).""" -fields.float16.doc = """One 16-bit float.""" -fields.float16x2.doc = """Two 16-bit floats.""" -fields.float16x4.doc = """Four 16-bit floats.""" -fields.float32.doc = """One 32-bit float.""" -fields.float32x2.doc = """Two 32-bit floats.""" -fields.float32x3.doc = """Three 32-bit floats.""" -fields.float32x4.doc = """Four 32-bit floats.""" -fields.uint32.doc = """One 32-bit unsigned integer.""" -fields.uint32x2.doc = """Two 32-bit unsigned integers.""" -fields.uint32x3.doc = """Three 32-bit unsigned integers.""" -fields.uint32x4.doc = """Four 32-bit unsigned integers.""" -fields.sint32.doc = """One 32-bit signed integer.""" -fields.sint32x2.doc = """Two 32-bit signed integers.""" -fields.sint32x3.doc = """Three 32-bit signed integers.""" -fields.sint32x4.doc = """Four 32-bit signed integers.""" -fields.unorm10_10_10_2.doc = """A packed 32-bit value with three 10-bit and one 2-bit unsigned normalized components, presented as a vec4 of float.""" -fields.unorm8x4_bgra.doc = """Four 8-bit unsigned normalized values stored in BGRA order, presented to the shader in RGBA order.""" - -[enums.VertexStepMode] -doc = """How often a vertex buffer is advanced. - -Used in the step_mode field of structs.VertexBufferLayout. -""" -fields.vertex.doc = """The buffer is advanced for each vertex.""" -fields.instance.doc = """The buffer is advanced for each instance.""" - -[enums.LoadOp] -doc = """What happens to the contents of an attachment at the start of a render pass. - -Used in the load_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. -""" -fields.load.doc = """Keep the existing contents of the attachment.""" -fields.clear.doc = """Clear the attachment to the clear value (e.g. the clear_value field of structs.RenderPassColorAttachment).""" - -[enums.StoreOp] -doc = """What happens to the contents of an attachment at the end of a render pass. - -Used in the store_op fields of structs.RenderPassColorAttachment and structs.RenderPassDepthStencilAttachment. -""" -fields.store.doc = """Store the results of the render pass in the attachment.""" -fields.discard.doc = """Discard the results; the contents of the attachment become undefined (zero-initialized when next used).""" - -[enums.QueryType] -doc = """The type of queries in a GPUQuerySet. - -Used in the type field of structs.QuerySetDescriptor. -""" -fields.occlusion.doc = """Occlusion queries count the number of samples that pass the depth and stencil tests, see GPURenderPassEncoder.begin_occlusion_query().""" -fields.timestamp.doc = """Timestamp queries record GPU timestamps. Requires feature timestamp_query.""" - -[enums.CanvasAlphaMode] -doc = """How the alpha channel of a canvas texture is interpreted when compositing with the page or window. - -Used in the alpha_mode field of structs.CanvasConfiguration. -""" -fields.opaque.doc = """The alpha channel is ignored and the canvas is treated as fully opaque.""" -fields.premultiplied.doc = """The color channels are expected to be premultiplied by the alpha channel.""" - -[enums.CanvasToneMappingMode] -doc = """How the content of a canvas is tone mapped when displayed. - -Used in the mode field of structs.CanvasToneMapping. -""" -fields.standard.doc = """Color values are clamped to the standard dynamic range (SDR) of the display.""" -fields.extended.doc = """Color values may exceed the SDR range, up to the dynamic range of the display (HDR).""" - -[enums.DeviceLostReason] -doc = """The reason a GPUDevice was lost. - -Available via the reason property of GPUDeviceLostInfo. -""" -fields.unknown.doc = """The device was lost for a reason other than being destroyed, e.g. a driver crash or hardware removal.""" -fields.destroyed.doc = """The device was lost because GPUDevice.destroy() was called.""" - -[enums.ErrorFilter] -doc = """The type of error that is captured by an error scope. - -Used in the filter argument of the GPUDevice.push_error_scope() method. -""" -fields.validation.doc = """Captures GPUValidationError errors, which signal incorrect API usage.""" -fields.out_of_memory.doc = """Captures GPUOutOfMemoryError errors, which signal that there was not enough memory for an operation.""" -fields.internal.doc = """Captures GPUInternalError errors, which signal failures not caused by incorrect usage (e.g. implementation limits).""" - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[structs] - -[structs.RequestAdapterOptions] -doc = """Options for requesting an adapter. - -Used as the options argument of the GPU.request_adapter() method. -""" -fields.feature_level.doc = """Requests an adapter that supports at least a particular set of capabilities. -This influences the {@link adapter#[[default feature level]]} of devices created -from this adapter. The capabilities for each level are defined below, and the exact -steps are defined in {@link GPU#requestAdapter} and "a new device". -If the implementation or system does not support all of the capabilities in the -requested feature level, {@link GPU#requestAdapter} will return `null`. -Note: -Applications should typically make a single {@link GPU#requestAdapter} call with the lowest -feature level they support, then inspect the adapter for additional capabilities they can -use optionally, and request those in {@link GPUAdapter#requestDevice}. -The allowed feature level string values are: -
-: "core" -The following set of capabilities: -- The limit/Default limits. -- {@link GPUFeatureName} `"core-features-and-limits"`. -Note: -Adapters with this {@link adapter#[[default feature level]]} may -conventionally be referred to as "Core-defaulting". -: "compatibility" -The following set of capabilities: -- The limit/Compatibility Mode Default limits. -- No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.) -If the implementation cannot enforce the stricter "Compatibility Mode" -validation rules, {@link GPU#requestAdapter} will ignore this request and -treat it as a request for feature level string/"core". -Note: -Adapters with this {@link adapter#[[default feature level]]} may -conventionally be referred to as "Compatibility-defaulting". -""" -fields.power_preference.doc = """Optionally provides a hint indicating what class of adapter should be selected from -the system's available adapters. -The value of this hint may influence which adapter is chosen, but it must not -influence whether an adapter is returned or not. -Note: -The primary utility of this hint is to influence which GPU is used in a multi-GPU system. -For instance, some laptops have a low-power integrated GPU and a high-performance -discrete GPU. This hint may also affect the power configuration of the selected GPU to -match the requested power preference. -Note: -Depending on the exact hardware configuration, such as battery status and attached displays -or removable GPUs, the user agent may select different adapters given the same power -preference. -Typically, given the same hardware configuration and state and -`powerPreference`, the user agent is likely to select the same adapter. -""" -fields.force_fallback_adapter.doc = """When set to `true` indicates that only a fallback adapter may be returned. If the user -agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to -resolve to `null`. -Note: -{@link GPU#requestAdapter} may still return a fallback adapter if -{@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no -other appropriate adapter is available or the user agent chooses to return a -fallback adapter. Developers that wish to prevent their applications from running on -fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter} -attribute prior to requesting a {@link GPUDevice}. -""" -fields.xr_compatible.doc = """If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers.""" - -[structs.DeviceDescriptor] -doc = """Descriptor for requesting a device. - -Used as the descriptor argument of the GPUAdapter.request_device() method. -""" -fields.label.doc = """A human-readable label for the device, used in debugging and error messages.""" -fields.required_features.doc = """Specifies the features that are required by the device request. -The request will fail if the adapter cannot provide these features. -Exactly the specified set of features, and no more or less, will be allowed in validation -of API calls on the resulting device. -""" -fields.required_limits.doc = """Specifies the limits that are required by the device request. -The request will fail if the adapter cannot provide these limits. -Each key with a non-`undefined` value must be the name of a member of supported limits. -API calls on the resulting device perform validation according to the exact limits of the -device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}). - -""" -fields.default_queue.doc = """The descriptor for the default {@link GPUQueue}.""" - -[structs.BufferDescriptor] -doc = """Descriptor for creating a GPUBuffer. - -Used as the descriptor argument of the GPUDevice.create_buffer() method. -""" -fields.label.doc = """A human-readable label for the buffer, used in debugging and error messages.""" -fields.size.doc = """The size of the buffer in bytes.""" -fields.usage.doc = """The allowed usages for the buffer.""" -fields.mapped_at_creation.doc = """If `true` creates the buffer in an already mapped state, allowing -{@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set -{@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage} -does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be -used to set the buffer's initial data. -Guarantees that even if the buffer creation eventually fails, it will still appear as if the -mapped range can be written/read to until it is unmapped. -""" - -[structs.TextureDescriptor] -doc = """Descriptor for creating a GPUTexture. - -Used as the descriptor argument of the GPUDevice.create_texture() method. -""" -fields.label.doc = """A human-readable label for the texture, used in debugging and error messages.""" -fields.size.doc = """The width, height, and depth or layer count of the texture.""" -fields.mip_level_count.doc = """The number of mip levels the texture will contain.""" -fields.sample_count.doc = """The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates -a multisampled texture. -""" -fields.dimension.doc = """Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.""" -fields.format.doc = """The format of the texture.""" -fields.usage.doc = """The allowed usages for the texture.""" -fields.view_formats.doc = """Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling -{@link GPUTexture#createView} on this texture (in addition to the texture's actual -{@link GPUTextureDescriptor#format}). -
-Adding a format to this list may have a significant performance impact, so it is best -to avoid adding formats unnecessarily. -The actual performance impact is highly dependent on the target system; developers must -test various systems to find out the impact on their particular application. -For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or -{@link GPUTextureDescriptor#viewFormats} entry including -{@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a -{@link GPUTextureFormat} `"rgba8unorm"` texture which does not. -Similar caveats exist for other formats and pairs of formats on other systems. -
-Formats in this list must be texture view format compatible with the texture format. -
-Two {@link GPUTextureFormat}s `format` and `viewFormat` are texture view format compatible on a given `device` if: -- `format` equals `viewFormat`, or -- `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`. -
-""" -fields.texture_binding_view_dimension.doc = """
-On devices without {@link GPUFeatureName} `"core-features-and-limits"`, -views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}. -If not specified, a default is chosen. -
-On devices with {@link GPUFeatureName} `"core-features-and-limits"`, -this is ignored, and there is no such restriction. -""" - -[structs.TextureViewDescriptor] -doc = """Descriptor for creating a GPUTextureView. - -Used as the descriptor argument of the GPUTexture.create_view() method. Unspecified fields -get a default derived from the texture, so by default the view covers the whole texture. -""" -fields.label.doc = """A human-readable label for the texture view, used in debugging and error messages.""" -fields.format.doc = """The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the -texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation. -""" -fields.dimension.doc = """The dimension to view the texture as.""" -fields.usage.doc = """The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the -{@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of -{@link GPUTexture#usage} flags of the texture. -Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the -texture's {@link GPUTextureDescriptor#usage}s, the default will fail, -and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly. -""" -fields.aspect.doc = """Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.""" -fields.base_mip_level.doc = """The first (most detailed) mipmap level accessible to the texture view.""" -fields.mip_level_count.doc = """How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to -the texture view. -""" -fields.base_array_layer.doc = """The index of the first array layer accessible to the texture view.""" -fields.array_layer_count.doc = """How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible -to the texture view. -""" -fields.swizzle.doc = """A string of length four, with each character mapping to the texture view's red/green/blue/alpha -channels, respectively. -When accessed by a shader, the red/green/blue/alpha channels are replaced by the value -corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and -`swizzle[3]`, respectively: -- `"r"`: Take its value from the red channel of the texture. -- `"g"`: Take its value from the green channel of the texture. -- `"b"`: Take its value from the blue channel of the texture. -- `"a"`: Take its value from the alpha channel of the texture. -- `"0"`: Force its value to 0. -- `"1"`: Force its value to 1. -Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled. -""" - -[structs.ExternalTextureDescriptor] -doc = """Descriptor for importing an external texture, such as a video frame. - -Used as the descriptor argument of the GPUDevice.import_external_texture() method. -""" -fields.label.doc = """A human-readable label for the external texture, used in debugging and error messages.""" -fields.source.doc = """The video source to import the external texture from. Source size is determined as described -by the external source dimensions table. -""" -fields.color_space.doc = """The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be -converted into when reading. -""" - -[structs.SamplerDescriptor] -doc = """Descriptor for creating a GPUSampler. - -Used as the descriptor argument of the GPUDevice.create_sampler() method. -""" -fields.label.doc = """A human-readable label for the sampler, used in debugging and error messages.""" -fields.address_mode_u.doc = """How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge.""" -fields.address_mode_v.doc = """How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge.""" -fields.address_mode_w.doc = """Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth -coordinates, respectively. -""" -fields.mag_filter.doc = """Specifies the sampling behavior when the sampled area is smaller than or equal to one -texel. -""" -fields.min_filter.doc = """Specifies the sampling behavior when the sampled area is larger than one texel.""" -fields.mipmap_filter.doc = """Specifies behavior for sampling between mipmap levels.""" -fields.lod_min_clamp.doc = """The minimum level of detail used when sampling. Defaults to 0.""" -fields.lod_max_clamp.doc = """Specifies the minimum and maximum levels of detail, respectively, used internally when -sampling a texture. -""" -fields.compare.doc = """When provided the sampler will be a comparison sampler with the specified -{@link GPUCompareFunction}. -Note: Comparison samplers may use filtering, but the sampling results will be -implementation-dependent and may differ from the normal filtering rules. -""" -fields.max_anisotropy.doc = """Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is -enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it. -Anisotropic filtering improves the image quality of textures sampled at oblique viewing -angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of -anisotropy supported when filtering. -
-Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range -between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy} -will be clamped to the maximum value that the platform supports. -The precise filtering behavior is implementation-dependent. -
-""" - -[structs.BindGroupLayoutDescriptor] -doc = """Descriptor for creating a GPUBindGroupLayout. - -Used as the descriptor argument of the GPUDevice.create_bind_group_layout() method. -""" -fields.label.doc = """A human-readable label for the bind group layout, used in debugging and error messages.""" -fields.entries.doc = """A list of entries describing the shader resource bindings for a bind group.""" - -[structs.BindGroupLayoutEntry] -doc = """Describes a single binding in a bind group layout. - -Exactly one of buffer, sampler, texture, storage_texture and external_texture must be set, -which determines the type of resource that is bound. -""" -fields.binding.doc = """A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding -to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding -attribute in the {@link GPUShaderModule}. -""" -fields.visibility.doc = """A bitset of the members of {@link GPUShaderStage}. -Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource -will be accessible from the associated shader stage. -""" -fields.buffer.doc = """If set, a structs.BufferBindingLayout: the entry is a buffer binding.""" -fields.sampler.doc = """If set, a structs.SamplerBindingLayout: the entry is a sampler binding.""" -fields.texture.doc = """If set, a structs.TextureBindingLayout: the entry is a sampled texture binding.""" -fields.storage_texture.doc = """If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding.""" - -[structs.BufferBindingLayout] -doc = """Describes the layout of a buffer binding. - -Used in the buffer field of structs.BindGroupLayoutEntry. -""" -fields.type.doc = """Indicates the type required for buffers bound to this binding.""" -fields.has_dynamic_offset.doc = """Indicates whether this binding requires a dynamic offset.""" -fields.min_binding_size.doc = """Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point. -Bindings are always validated against this size in {@link GPUDevice#createBindGroup}. -If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$] -that this value ≥ the minimum buffer binding size of the variable. -If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands -[$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup} -satisfies the minimum buffer binding size of the variable. -Note: -Similar execution-time validation is theoretically possible for other -binding-related fields specified for early validation, like -{@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format}, -which currently can only be validated in pipeline creation. -However, such execution-time validation could be costly or unnecessarily complex, so it is -available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the -most ergonomic impact. -""" - -[structs.SamplerBindingLayout] -doc = """Describes the layout of a sampler binding. - -Used in the sampler field of structs.BindGroupLayoutEntry. -""" -fields.type.doc = """Indicates the required type of a sampler bound to this bindings.""" - -[structs.TextureBindingLayout] -doc = """Describes the layout of a sampled texture binding. - -Used in the texture field of structs.BindGroupLayoutEntry. -""" -fields.sample_type.doc = """Indicates the type required for texture views bound to this binding.""" -fields.view_dimension.doc = """Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to -this binding. -""" -fields.multisampled.doc = """Indicates whether or not texture views bound to this binding must be multisampled.""" - -[structs.StorageTextureBindingLayout] -doc = """Describes the layout of a storage texture binding. - -Used in the storage_texture field of structs.BindGroupLayoutEntry. -""" -fields.access.doc = """The access mode for this binding, indicating readability and writability.""" -fields.format.doc = """The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.""" -fields.view_dimension.doc = """Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to -this binding. -""" - -[structs.BindGroupDescriptor] -doc = """Descriptor for creating a GPUBindGroup. - -Used as the descriptor argument of the GPUDevice.create_bind_group() method. -""" -fields.label.doc = """A human-readable label for the bind group, used in debugging and error messages.""" -fields.layout.doc = """The {@link GPUBindGroupLayout} the entries of this bind group will conform to.""" -fields.entries.doc = """A list of entries describing the resources to expose to the shader for each binding -described by the {@link GPUBindGroupDescriptor#layout}. -""" - -[structs.BindGroupEntry] -doc = """A single resource binding in a bind group. - -Used in the entries field of structs.BindGroupDescriptor. -""" -fields.binding.doc = """A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a -{@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding -attribute in the {@link GPUShaderModule}. -""" -fields.resource.doc = """The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView}, -{@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}. -""" - -[structs.BufferBinding] -doc = """Describes a range of a GPUBuffer to bind. - -Can be used as the resource field of structs.BindGroupEntry. -""" -fields.buffer.doc = """The {@link GPUBuffer} to bind.""" -fields.offset.doc = """The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the -beginning of the range exposed to the shader by the buffer binding. -""" -fields.size.doc = """The size, in bytes, of the buffer binding. -If not map/exist|provided, specifies the range starting at -{@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}. -""" - -[structs.PipelineLayoutDescriptor] -doc = """Descriptor for creating a GPUPipelineLayout. - -Used as the descriptor argument of the GPUDevice.create_pipeline_layout() method. -""" -fields.label.doc = """A human-readable label for the pipeline layout, used in debugging and error messages.""" -fields.bind_group_layouts.doc = """A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds -to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding -with `@group(N)`. -""" -fields.immediate_size.doc = """The size, in bytes, of the immediate data range used by the pipeline.""" - -[structs.ShaderModuleDescriptor] -doc = """Descriptor for creating a GPUShaderModule. - -Used as the descriptor argument of the GPUDevice.create_shader_module() method. -""" -fields.label.doc = """A human-readable label for the shader module, used in debugging and error messages.""" -fields.code.doc = """The WGSL source code for the shader -module. -""" -fields.compilation_hints.doc = """A list of {@link GPUShaderModuleCompilationHint}s. -Any hint provided by an application **should** contain information about one entry point of -a pipeline that will eventually be created from the entry point. -Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint} -to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}. -Aside from type-checking, these hints are not validated in any way. -
-Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any -observable effect, other than performance. It may be detrimental to performance to -provide hints for pipelines that never end up being created. -Because a single shader module can hold multiple entry points, and multiple pipelines -can be created from a single shader module, it can be more performant for an -implementation to do as much compilation as possible once in -{@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to -{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}. -Hints are only applied to the entry points they explicitly name. -Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint}, -there is no default, even if only one entry point is present in the module. -
-Note: -Hints are not validated in an observable way, but user agents **may** surface identifiable -errors (like unknown entry point names or incompatible pipeline layouts) to developers, -for example in the browser developer console. -""" - -[structs.ShaderModuleCompilationHint] -doc = """A hint for the compilation of a shader module. - -Used in the compilation_hints field of structs.ShaderModuleDescriptor. These are optional and only -affect performance, not behavior. -""" -fields.entry_point.doc = """The name of the shader entry point that the hint applies to.""" -fields.layout.doc = """A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future -{@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call. -If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$] -for the entry point associated with this hint will be used. -""" - -[structs.PipelineErrorInit] -doc = """Initialization options for a GPUPipelineError. - -Used as the options argument of the GPUPipelineError constructor. -""" -fields.reason.doc = """The reason for the error, see enums.PipelineErrorReason.""" - -[structs.ProgrammableStage] -doc = """Describes a programmable (shader) stage of a pipeline. - -This is the base for structs.VertexState, structs.FragmentState and the compute field of -structs.ComputePipelineDescriptor. -""" -fields.module.doc = """The {@link GPUShaderModule} containing the code that this programmable stage will execute.""" -fields.entry_point.doc = """The name of the function in {@link GPUProgrammableStage#module} that this stage will use to -perform its work. -NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is -not required, methods which consume a {@link GPUProgrammableStage} must use the -"[$get the entry point$]" algorithm to determine which entry point -it refers to. -""" -fields.constants.doc = """Specifies the values of pipeline-overridable constants in the shader module -{@link GPUProgrammableStage#module}. -Each such pipeline-overridable constant is uniquely identified by a single -pipeline-overridable constant identifier string, representing the pipeline -constant ID of the constant if its declaration specifies one, and otherwise the -constant's identifier name. -The key of each key-value pair must equal the -pipeline-overridable constant identifier string|identifier string -of one such constant, with the comparison performed -according to the rules for WGSL identifier comparison. -When the pipeline is executed, that constant will have the specified value. -Values are specified as GPUPipelineConstantValue, which is a `double`. -They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`). -If conversion fails, a validation error is generated. -
-Pipeline-overridable constants defined in WGSL: -```wgsl -override width: f32 = 0.0; // Specifed at the API level -// using the name "width". -override depth: f32; // Specifed at the API level -// using the name "depth". -// Must be overridden. -override height = 2 * depth; // The default value -// (if not set at the API level), -// depends on another -// overridable constant. -``` -Corresponding JavaScript code, providing only the overrides which are required -(have no defaults): -```js -{ -// ... -constants: { -1300: 2.0, // "gain" -depth: -1, // "depth" -} -} -``` -Corresponding JavaScript code, overriding all constants: -```js -{ -// ... -constants: { -0: false, // "has_point_light" -1200: 3.0, // "specular_param" -1300: 2.0, // "gain" -width: 20, // "width" -depth: -1, // "depth" -height: 15, // "height" -} -} -``` -
-""" - -[structs.ComputePipelineDescriptor] -doc = """Descriptor for creating a GPUComputePipeline. - -Used as the descriptor argument of the GPUDevice.create_compute_pipeline() method. -""" -fields.label.doc = """A human-readable label for the pipeline, used in debugging and error messages.""" -fields.layout.doc = """The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader.""" -fields.compute.doc = """Describes the compute shader entry point of the pipeline.""" - -[structs.RenderPipelineDescriptor] -doc = """Descriptor for creating a GPURenderPipeline. - -Used as the descriptor argument of the GPUDevice.create_render_pipeline() method. -""" -fields.label.doc = """A human-readable label for the pipeline, used in debugging and error messages.""" -fields.layout.doc = """The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shaders.""" -fields.vertex.doc = """Describes the vertex shader entry point of the pipeline and its input buffer layouts.""" -fields.primitive.doc = """Describes the primitive-related properties of the pipeline.""" -fields.depth_stencil.doc = """Describes the optional depth-stencil properties, including the testing, operations, and bias.""" -fields.multisample.doc = """Describes the multi-sampling properties of the pipeline.""" -fields.fragment.doc = """Describes the fragment shader entry point of the pipeline and its output colors. If -not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled. -""" - -[structs.PrimitiveState] -doc = """Describes how a render pipeline assembles and rasterizes primitives. - -Used in the primitive field of structs.RenderPipelineDescriptor. -""" -fields.topology.doc = """The type of primitive to be constructed from the vertex inputs.""" -fields.strip_index_format.doc = """For pipelines with strip topologies -({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`), -this determines the index buffer format and primitive restart value -({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`). -It is not allowed on pipelines with non-strip topologies. -Note: Some implementations require knowledge of the primitive restart value to compile -pipeline state objects. -To use a strip-topology pipeline with an indexed draw call -({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}), -this must be set, and it must match the index buffer format used with the draw call -(set in {@link GPURenderCommandsMixin#setIndexBuffer}). -See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details. -""" -fields.front_face.doc = """Defines which polygons are considered front-facing.""" -fields.cull_mode.doc = """Defines which polygon orientation will be culled, if any.""" -fields.unclipped_depth.doc = """If true, indicates that depth clipping is disabled. -Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled. -""" - -[structs.MultisampleState] -doc = """Describes the multisampling of a render pipeline. - -Used in the multisample field of structs.RenderPipelineDescriptor. -""" -fields.count.doc = """Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only -with attachment textures ({@link GPURenderPassDescriptor#colorAttachments} -and {@link GPURenderPassDescriptor#depthStencilAttachment}) -with matching {@link GPUTextureDescriptor#sampleCount}s. -""" -fields.mask.doc = """Mask determining which samples are written to.""" -fields.alpha_to_coverage_enabled.doc = """When `true` indicates that a fragment's alpha channel should be used to generate a sample -coverage mask. -""" - -[structs.FragmentState] -doc = """Describes the fragment shader stage and render targets of a render pipeline. - -Used in the fragment field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. -""" -fields.module.doc = """The GPUShaderModule containing the fragment shader code.""" -fields.entry_point.doc = """The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point.""" -fields.constants.doc = """A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use.""" -fields.targets.doc = """A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets -this pipeline writes to. -""" - -[structs.ColorTargetState] -doc = """Describes a color render target of a render pipeline. - -Used in the targets field of structs.FragmentState. -""" -fields.format.doc = """The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with -{@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the -corresponding color attachment. -""" -fields.blend.doc = """The blending behavior for this color target. If left undefined, disables blending for this -color target. -""" -fields.write_mask.doc = """Bitmask controlling which channels are are written to when drawing to this color target.""" - -[structs.BlendState] -doc = """Describes how blending is performed for a color target. - -Used in the blend field of structs.ColorTargetState. -""" -fields.color.doc = """Defines the blending behavior of the corresponding render target for color channels.""" -fields.alpha.doc = """Defines the blending behavior of the corresponding render target for the alpha channel.""" - -[structs.BlendComponent] -doc = """Describes how the blending of a single component (color or alpha) is performed. - -The result is: operation(src * src_factor, dst * dst_factor). -""" -fields.operation.doc = """Defines the {@link GPUBlendOperation} used to calculate the values written to the target -attachment components. -""" -fields.src_factor.doc = """Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.""" -fields.dst_factor.doc = """Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.""" - -[structs.DepthStencilState] -doc = """Describes the depth and stencil state of a render pipeline. - -Used in the depth_stencil field of structs.RenderPipelineDescriptor. -""" -fields.format.doc = """The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment} -this {@link GPURenderPipeline} will be compatible with. -""" -fields.depth_write_enabled.doc = """Indicates if this {@link GPURenderPipeline} can modify -{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. -""" -fields.depth_compare.doc = """The comparison operation used to test fragment depths against -{@link GPURenderPassDescriptor#depthStencilAttachment} depth values. -""" -fields.stencil_front.doc = """Defines how stencil comparisons and operations are performed for front-facing primitives.""" -fields.stencil_back.doc = """Defines how stencil comparisons and operations are performed for back-facing primitives.""" -fields.stencil_read_mask.doc = """Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value -bits are read when performing stencil comparison tests. -""" -fields.stencil_write_mask.doc = """Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value -bits are written to when performing stencil operations. -""" -fields.depth_bias.doc = """Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.""" -fields.depth_bias_slope_scale.doc = """Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.""" -fields.depth_bias_clamp.doc = """The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.""" - -[structs.StencilFaceState] -doc = """Describes the stencil operations for one face (front or back) of primitives. - -Used in the stencil_front and stencil_back fields of structs.DepthStencilState. -""" -fields.compare.doc = """The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value -against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values. -""" -fields.fail_op.doc = """The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by -{@link GPUStencilFaceState#compare} fails. -""" -fields.depth_fail_op.doc = """The {@link GPUStencilOperation} performed if the fragment depth comparison described by -{@link GPUDepthStencilState#depthCompare} fails. -""" -fields.pass_op.doc = """The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by -{@link GPUStencilFaceState#compare} passes. -""" - -[structs.VertexState] -doc = """Describes the vertex shader stage and vertex buffers of a render pipeline. - -Used in the vertex field of structs.RenderPipelineDescriptor. Extends structs.ProgrammableStage. -""" -fields.module.doc = """The GPUShaderModule containing the vertex shader code.""" -fields.entry_point.doc = """The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point.""" -fields.constants.doc = """A mapping of the names (or ids) of pipeline-overridable constants in the shader to the values to use.""" -fields.buffers.doc = """A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a -vertex buffer used by this pipeline. -""" - -[structs.VertexBufferLayout] -doc = """Describes the layout of a vertex buffer. - -Used in the buffers field of structs.VertexState. -""" -fields.array_stride.doc = """The stride, in bytes, between elements of this array.""" -fields.step_mode.doc = """Whether each element of this array represents per-vertex data or per-instance data""" -fields.attributes.doc = """An array defining the layout of the vertex attributes within each element.""" - -[structs.VertexAttribute] -doc = """Describes a single vertex attribute within a vertex buffer. - -Used in the attributes field of structs.VertexBufferLayout. -""" -fields.format.doc = """The {@link GPUVertexFormat} of the attribute.""" -fields.offset.doc = """The offset, in bytes, from the beginning of the element to the data for the attribute.""" -fields.shader_location.doc = """The numeric location associated with this attribute, which will correspond with a -"@location" attribute -declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}. -""" - -[structs.TexelCopyBufferLayout] -doc = """Describes the layout of texel data in a buffer or in a block of memory. - -Used as the data_layout argument of the GPUQueue.write_texture() method. Also see structs.TexelCopyBufferInfo. -""" -fields.offset.doc = """The offset, in bytes, from the beginning of the texel data source (such as a -{@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data -within that source. -""" -fields.bytes_per_row.doc = """The stride, in bytes, between the beginning of each texel block row and the subsequent -texel block row. -Required if there are multiple texel block rows (i.e. the copy height or depth is more -than one block). -""" -fields.rows_per_image.doc = """Number of texel block rows per single texel image of the texture. -{@link GPUTexelCopyBufferLayout#rowsPerImage} × -{@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each -texel image of data and the subsequent texel image. -Required if there are multiple texel images (i.e. the copy depth is more than one). -""" - -[structs.TexelCopyBufferInfo] -doc = """Describes a buffer and the layout of texel data in it. - -Used as source or destination in GPUCommandEncoder.copy_buffer_to_texture() and GPUCommandEncoder.copy_texture_to_buffer(). -Extends structs.TexelCopyBufferLayout. -""" -fields.offset.doc = """The offset in bytes into the buffer where the texel data starts. Defaults to 0.""" -fields.bytes_per_row.doc = """The stride in bytes between rows of texels. Required if there is more than one row. Must be a multiple of 256.""" -fields.rows_per_image.doc = """The number of rows per image (layer or slice). Required if there is more than one image.""" -fields.buffer.doc = """A buffer which either contains texel data to be copied or will store the texel data being -copied, depending on the method it is being passed to. -""" - -[structs.TexelCopyTextureInfo] -doc = """Describes a texture and the part of it that is the source or destination of a copy. - -Used in GPUCommandEncoder.copy_buffer_to_texture(), GPUCommandEncoder.copy_texture_to_buffer(), -GPUCommandEncoder.copy_texture_to_texture() and GPUQueue.write_texture(). -""" -fields.texture.doc = """Texture to copy to/from.""" -fields.mip_level.doc = """Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.""" -fields.origin.doc = """Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. -Together with `copySize`, defines the full copy sub-region. -""" -fields.aspect.doc = """Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.""" - -[structs.CommandBufferDescriptor] -doc = """Descriptor for a GPUCommandBuffer. - -Used as the descriptor argument of the GPUCommandEncoder.finish() method. -""" -fields.label.doc = """A human-readable label for the command buffer, used in debugging and error messages.""" - -[structs.CommandEncoderDescriptor] -doc = """Descriptor for creating a GPUCommandEncoder. - -Used as the descriptor argument of the GPUDevice.create_command_encoder() method. -""" -fields.label.doc = """A human-readable label for the command encoder, used in debugging and error messages.""" - -[structs.ComputePassTimestampWrites] -doc = """Describes where to write timestamps for a compute pass. - -Used in the timestamp_writes field of structs.ComputePassDescriptor. Requires feature timestamp_query. -""" -fields.query_set.doc = """The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be -written to. -""" -fields.beginning_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the beginning of the compute pass will be written. -""" -fields.end_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the end of the compute pass will be written. -""" - -[structs.ComputePassDescriptor] -doc = """Descriptor for beginning a compute pass. - -Used as the descriptor argument of the GPUCommandEncoder.begin_compute_pass() method. -""" -fields.label.doc = """A human-readable label for the compute pass, used in debugging and error messages.""" -fields.timestamp_writes.doc = """Defines which timestamp values will be written for this pass, and where to write them to.""" - -[structs.RenderPassTimestampWrites] -doc = """Describes where to write timestamps for a render pass. - -Used in the timestamp_writes field of structs.RenderPassDescriptor. Requires feature timestamp_query. -""" -fields.query_set.doc = """The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be -written to. -""" -fields.beginning_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the beginning of the render pass will be written. -""" -fields.end_of_pass_write_index.doc = """If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into -which the timestamp at the end of the render pass will be written. -""" - -[structs.RenderPassDescriptor] -doc = """Descriptor for beginning a render pass. - -Used as the descriptor argument of the GPUCommandEncoder.begin_render_pass() method. -""" -fields.label.doc = """A human-readable label for the render pass, used in debugging and error messages.""" -fields.color_attachments.doc = """The set of {@link GPURenderPassColorAttachment} values in this sequence defines which -color attachments will be output to when executing this render pass. -Due to compatible usage list|usage compatibility, no color attachment -may alias another attachment or any resource used inside the render pass. -""" -fields.depth_stencil_attachment.doc = """The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil -attachment that will be output to and tested against when executing this render pass. -Due to compatible usage list|usage compatibility, no writable depth/stencil attachment -may alias another attachment or any resource used inside the render pass. -""" -fields.occlusion_query_set.doc = """The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.""" -fields.timestamp_writes.doc = """Defines which timestamp values will be written for this pass, and where to write them to.""" -fields.max_draw_count.doc = """The maximum number of draw calls that will be done in the render pass. Used by some -implementations to size work injected before the render pass. Keeping the default value -is a good default, unless it is known that more draw calls will be done. -""" - -[structs.RenderPassColorAttachment] -doc = """Describes a color attachment of a render pass. - -Used in the color_attachments field of structs.RenderPassDescriptor. -""" -fields.view.doc = """Describes the texture subresource that will be output to for this color attachment. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}). -""" -fields.depth_slice.doc = """Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view} -that will be output to for this color attachment. -""" -fields.resolve_target.doc = """Describes the texture subresource that will receive the resolved output for this color -attachment if {@link GPURenderPassColorAttachment#view} is multisampled. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}). -""" -fields.clear_value.doc = """Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the -render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored -if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`. -The components of {@link GPURenderPassColorAttachment#clearValue} are all double values. -They are converted [$to a texel value of texture format$] matching the render attachment. -If conversion fails, a validation error is generated. -""" -fields.load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to -executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -""" -fields.store_op.doc = """The store operation to perform on {@link GPURenderPassColorAttachment#view} -after executing the render pass. -""" - -[structs.RenderPassDepthStencilAttachment] -doc = """Describes the depth-stencil attachment of a render pass. - -Used in the depth_stencil_attachment field of structs.RenderPassDescriptor. -""" -fields.view.doc = """Describes the texture subresource that will be output to and read from for this -depth/stencil attachment. -The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}). -""" -fields.depth_clear_value.doc = """Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component -to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp} -is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive. - -""" -fields.depth_load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -depth component prior to executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -""" -fields.depth_store_op.doc = """The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -depth component after executing the render pass. -""" -fields.depth_read_only.doc = """Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view} -is read only. -""" -fields.stencil_clear_value.doc = """Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component -to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp} -is not {@link GPULoadOp} `"clear"`. -The value will be converted to the type of the stencil aspect of `view` by taking the same -number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`. -""" -fields.stencil_load_op.doc = """Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -stencil component prior to executing the render pass. -Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details. -""" -fields.stencil_store_op.doc = """The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s -stencil component after executing the render pass. -""" -fields.stencil_read_only.doc = """Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view} -is read only. -""" - -[structs.RenderPassLayout] -doc = """Describes the attachment formats of a render pass or render bundle. - -This is the base of structs.RenderBundleEncoderDescriptor. A render pipeline can only be used with -passes (or bundles) whose layout is compatible with the pipeline. -""" -fields.label.doc = """A human-readable label, used in debugging and error messages.""" -fields.color_formats.doc = """A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.""" -fields.depth_stencil_format.doc = """The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.""" -fields.sample_count.doc = """Number of samples per pixel in the attachments for this pass or bundle.""" - -[structs.RenderBundleDescriptor] -doc = """Descriptor for a GPURenderBundle. - -Used as the descriptor argument of the GPURenderBundleEncoder.finish() method. -""" -fields.label.doc = """A human-readable label for the render bundle, used in debugging and error messages.""" - -[structs.RenderBundleEncoderDescriptor] -doc = """Descriptor for creating a GPURenderBundleEncoder. - -Used as the descriptor argument of the GPUDevice.create_render_bundle_encoder() method. -Extends structs.RenderPassLayout. -""" -fields.label.doc = """A human-readable label for the render bundle encoder, used in debugging and error messages.""" -fields.color_formats.doc = """A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with.""" -fields.depth_stencil_format.doc = """The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any.""" -fields.sample_count.doc = """The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1.""" -fields.depth_read_only.doc = """If `true`, indicates that the render bundle does not modify the depth component of the -{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed -in. -See read-only depth-stencil. -""" -fields.stencil_read_only.doc = """If `true`, indicates that the render bundle does not modify the stencil component of the -{@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed -in. -See read-only depth-stencil. -""" - -[structs.QueueDescriptor] -doc = """Descriptor for a GPUQueue. - -Used in the default_queue field of structs.DeviceDescriptor. -""" -fields.label.doc = """A human-readable label for the queue, used in debugging and error messages.""" - -[structs.QuerySetDescriptor] -doc = """Descriptor for creating a GPUQuerySet. - -Used as the descriptor argument of the GPUDevice.create_query_set() method. -""" -fields.label.doc = """A human-readable label for the query set, used in debugging and error messages.""" -fields.type.doc = """The type of queries managed by {@link GPUQuerySet}.""" -fields.count.doc = """The number of queries managed by {@link GPUQuerySet}.""" - -[structs.CanvasToneMapping] -doc = """Describes the tone mapping of a canvas. - -Used in the tone_mapping field of structs.CanvasConfiguration. -""" -fields.mode.doc = """The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard.""" - -[structs.CanvasConfiguration] -doc = """Configuration for a GPUCanvasContext. - -Used as the configuration argument of the GPUCanvasContext.configure() method. -""" -fields.device.doc = """The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be -compatible with. -""" -fields.format.doc = """The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. -Must be one of the Supported context formats. -""" -fields.usage.doc = """The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have. -{@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included -if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT} -when setting a custom usage if you wish to use textures returned by -{@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass. -""" -fields.view_formats.doc = """The formats that views created from textures returned by -{@link GPUCanvasContext#getCurrentTexture} may use. -""" -fields.color_space.doc = """The color space that values written into textures returned by -{@link GPUCanvasContext#getCurrentTexture} should be displayed with. -""" -fields.tone_mapping.doc = """The tone mapping determines how the content of textures returned by -{@link GPUCanvasContext#getCurrentTexture} are to be displayed. -
-This is a required feature, but user agents might not yet implement it, -effectively supporting only the default {@link GPUCanvasToneMapping}. -In such implementations, this member **should not** exist in its implementation of -{@link GPUCanvasConfiguration}, to make feature detection possible using -{@link GPUCanvasContext#getConfiguration}. -This is especially important in implementations which otherwise have HDR capabilities -(where a '@media/dynamic-range' of ''@media/dynamic-range/high'' would be -exposed). -If an implementation exposes this member and a `high` dynamic range, it **should** render the -canvas as an HDR element, not clamp values to the SDR range of the HDR display. -
-""" -fields.alpha_mode.doc = """Determines the effect that alpha values will have on the content of textures returned by -{@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source. -""" - -[structs.UncapturedErrorEventInit] -doc = """Initialization data for an uncaptured error event. - -The event is passed to the callback set via the onuncapturederror property of GPUDevice. -""" -fields.error.doc = """The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope.""" - -[structs.Color] -doc = """An RGBA color with floating point components. - -Can also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment. -""" -fields.r.doc = """The red component.""" -fields.g.doc = """The green component.""" -fields.b.doc = """The blue component.""" -fields.a.doc = """The alpha component.""" - -[structs.Origin2D] -doc = """A 2D origin (offset) in a texture or image, in texels. - -Can also be given as a tuple (x, y). -""" -fields.x.doc = """The x coordinate (horizontal). Defaults to 0.""" -fields.y.doc = """The y coordinate (vertical). Defaults to 0.""" - -[structs.Origin3D] -doc = """A 3D origin (offset) in a texture, in texels. - -Can also be given as a tuple (x, y, z). -""" -fields.x.doc = """The x coordinate (horizontal). Defaults to 0.""" -fields.y.doc = """The y coordinate (vertical). Defaults to 0.""" -fields.z.doc = """The z coordinate (depth, or array layer). Defaults to 0.""" - -[structs.Extent3D] -doc = """A 3D size (extent) of a texture, in texels. - -Can also be given as a tuple (width, height, depth_or_array_layers). -""" -fields.width.doc = """The width of the extent.""" -fields.height.doc = """The height of the extent. Defaults to 1.""" -fields.depth_or_array_layers.doc = """The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1.""" - -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------- -[classes] - -[classes.GPUObjectBase] -doc = """The base class of all GPU objects. - -It provides the label property that is shared by all objects in the API. -""" -properties.label.doc = """A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it.""" -[classes.GPUObjectBase.methods] - -[classes.GPUAdapterInfo] -doc = """Information about a physical adapter (GPU). - -An instance is available via the info property of GPUAdapter and the adapter_info property of GPUDevice. -The values are strings that are possibly empty if the information is not available. -""" -properties.vendor.doc = """The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'.""" -properties.architecture.doc = """The name of the family or class of GPUs the adapter belongs to.""" -properties.device.doc = """A vendor-specific identifier of the adapter.""" -properties.description.doc = """A human-readable description of the adapter, e.g. the name of the GPU.""" -properties.subgroup_min_size.doc = """The minimum supported subgroup size of the adapter.""" -properties.subgroup_max_size.doc = """The maximum supported subgroup size of the adapter.""" -properties.is_fallback_adapter.doc = """Whether this is a fallback adapter, e.g. a software renderer.""" -[classes.GPUAdapterInfo.methods] - -[classes.GPU] -doc = """The entry point of the API. - -It is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu. -""" -properties.wgsl_language_features.doc = """The set of WGSL language features that are supported by the implementation.""" -[classes.GPU.methods] -[classes.GPU.methods.request_adapter] -doc = """Requests an adapter from the user agent. -The user agent chooses whether to return an adapter, and, if so, -chooses according to the provided options. -""" -returns.doc = """A GPUAdapter, or None if no suitable adapter was found.""" -args.options.doc = """Criteria used to select the adapter.""" -[classes.GPU.methods.get_preferred_canvas_format] -doc = """Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range -content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or -{@link GPUTextureFormat} `"bgra8unorm"`. -The returned value can be passed as the {@link GPUCanvasConfiguration#format} to -{@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated -canvas is able to display its contents efficiently. -Note: Canvases which are not displayed to the screen may or may not benefit from using this -format. -""" -returns.doc = """An enums.TextureFormat, either rgba8unorm or bgra8unorm.""" - -[classes.GPUAdapter] -doc = """Represents a physical GPU (or a software implementation of one). - -An adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice, -which is used to do actual work. Adapters are obtained via GPU.request_adapter(). -""" -properties.features.doc = """The set of enums.FeatureName that the adapter supports.""" -properties.limits.doc = """A mapping of limit names to the maximum values supported by the adapter.""" -properties.info.doc = """A GPUAdapterInfo with information about the adapter.""" -[classes.GPUAdapter.methods] -[classes.GPUAdapter.methods.request_device] -doc = """Requests a device from the adapter. -This is a one-time action: if a device is returned successfully, -the adapter becomes {@link adapter#[[state]]#"consumed"}. -""" -returns.doc = """A GPUDevice.""" -args.descriptor.doc = """Description of the {@link GPUDevice} to request.""" - -[classes.GPUDevice] -doc = """The main object that is used to create GPU resources and to submit work. - -A device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue -(the queue property) which is used to submit work to the GPU. Most resources -(buffers, textures, pipelines, etc.) are created using the create_* methods of the device. -""" -properties.features.doc = """The set of enums.FeatureName that are enabled on the device.""" -properties.limits.doc = """A mapping of limit names to the values that are in effect for the device.""" -properties.adapter_info.doc = """A GPUAdapterInfo with information about the adapter that this device was created from.""" -properties.queue.doc = """The default GPUQueue of the device.""" -properties.lost.doc = """A promise or future that resolves to a GPUDeviceLostInfo when the device is lost.""" -properties.onuncapturederror.doc = """A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope.""" -[classes.GPUDevice.methods] -[classes.GPUDevice.methods.destroy] -doc = """Destroys the device, preventing further operations on it. -Outstanding asynchronous operations will fail. -Note: It is valid to destroy a device multiple times. -Note: Since no further operations can be enqueued on this device, implementations can abort -outstanding asynchronous operations immediately and free resource allocations, including -mapped memory that was just unmapped. -""" -returns.doc = """None.""" -[classes.GPUDevice.methods.create_buffer] -doc = """Creates a {@link GPUBuffer}.""" -returns.doc = """A GPUBuffer.""" -args.descriptor.doc = """Description of the {@link GPUBuffer} to create.""" -[classes.GPUDevice.methods.create_texture] -doc = """Creates a {@link GPUTexture}.""" -returns.doc = """A GPUTexture.""" -args.descriptor.doc = """Description of the {@link GPUTexture} to create.""" -[classes.GPUDevice.methods.create_sampler] -doc = """Creates a {@link GPUSampler}.""" -returns.doc = """A GPUSampler.""" -args.descriptor.doc = """Description of the {@link GPUSampler} to create.""" -[classes.GPUDevice.methods.create_bind_group_layout] -doc = """Creates a {@link GPUBindGroupLayout}.""" -returns.doc = """A GPUBindGroupLayout.""" -args.descriptor.doc = """Description of the {@link GPUBindGroupLayout} to create.""" -[classes.GPUDevice.methods.create_pipeline_layout] -doc = """Creates a {@link GPUPipelineLayout}.""" -returns.doc = """A GPUPipelineLayout.""" -args.descriptor.doc = """Description of the {@link GPUPipelineLayout} to create.""" -[classes.GPUDevice.methods.create_bind_group] -doc = """Creates a {@link GPUBindGroup}.""" -returns.doc = """A GPUBindGroup.""" -args.descriptor.doc = """Description of the {@link GPUBindGroup} to create.""" -[classes.GPUDevice.methods.create_shader_module] -doc = """Creates a {@link GPUShaderModule}.""" -returns.doc = """A GPUShaderModule.""" -args.descriptor.doc = """Description of the {@link GPUShaderModule} to create.""" -[classes.GPUDevice.methods.create_compute_pipeline] -doc = """Creates a {@link GPUComputePipeline} using immediate pipeline creation.""" -returns.doc = """A GPUComputePipeline.""" -args.descriptor.doc = """Description of the {@link GPUComputePipeline} to create.""" -[classes.GPUDevice.methods.create_render_pipeline] -doc = """Creates a {@link GPURenderPipeline} using immediate pipeline creation.""" -returns.doc = """A GPURenderPipeline.""" -args.descriptor.doc = """Description of the {@link GPURenderPipeline} to create.""" -[classes.GPUDevice.methods.create_compute_pipeline_async] -doc = """Creates a {@link GPUComputePipeline} using async pipeline creation. -The returned Promise resolves when the created pipeline -is ready to be used without additional delay. -If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. -(A {@link GPUError} is not dispatched to the device.) -Note: Use of this method is preferred whenever possible, as it prevents blocking the -queue timeline work on pipeline compilation. -""" -returns.doc = """A GPUComputePipeline (awaitable).""" -args.descriptor.doc = """Description of the {@link GPUComputePipeline} to create.""" -[classes.GPUDevice.methods.create_render_pipeline_async] -doc = """Creates a {@link GPURenderPipeline} using async pipeline creation. -The returned Promise resolves when the created pipeline -is ready to be used without additional delay. -If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}. -(A {@link GPUError} is not dispatched to the device.) -Note: Use of this method is preferred whenever possible, as it prevents blocking the -queue timeline work on pipeline compilation. -""" -returns.doc = """A GPURenderPipeline (awaitable).""" -args.descriptor.doc = """Description of the {@link GPURenderPipeline} to create.""" -[classes.GPUDevice.methods.create_command_encoder] -doc = """Creates a {@link GPUCommandEncoder}.""" -returns.doc = """A GPUCommandEncoder.""" -args.descriptor.doc = """Description of the {@link GPUCommandEncoder} to create.""" -[classes.GPUDevice.methods.create_render_bundle_encoder] -doc = """Creates a {@link GPURenderBundleEncoder}.""" -returns.doc = """A GPURenderBundleEncoder.""" -args.descriptor.doc = """Description of the {@link GPURenderBundleEncoder} to create.""" -[classes.GPUDevice.methods.create_query_set] -doc = """Creates a {@link GPUQuerySet}.""" -returns.doc = """A GPUQuerySet.""" -args.descriptor.doc = """Description of the {@link GPUQuerySet} to create.""" -[classes.GPUDevice.methods.push_error_scope] -doc = """Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.""" -returns.doc = """None.""" -args.filter.doc = """Which class of errors this error scope observes.""" -[classes.GPUDevice.methods.pop_error_scope] -doc = """Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this` -and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none. -There is no guarantee of the ordering of promise resolution. -""" -returns.doc = """A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured.""" - -[classes.GPUBuffer] -doc = """A block of memory that can be used by the GPU for e.g. vertex data, uniform data or general storage. - -Buffers are created with GPUDevice.create_buffer(). Data can be uploaded with GPUQueue.write_buffer() or -copy commands, or by mapping the buffer. Mapping makes the memory accessible to the CPU, but the -buffer cannot be used by the GPU while it is mapped. -""" -properties.size.doc = """The size of the buffer in bytes.""" -properties.usage.doc = """The usage of the buffer, a combination of flags.BufferUsage.""" -properties.map_state.doc = """The current mapping state of the buffer, see enums.BufferMapState.""" -[classes.GPUBuffer.methods] -[classes.GPUBuffer.methods.map_async] -doc = """Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the -{@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}. -The resolution of the returned Promise **only** indicates that the buffer has been mapped. -It does not guarantee the completion of any other operations visible to the content timeline, -and in particular does not imply that any other Promise returned from -{@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s -have resolved. -The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone} -**does** imply the completion of -{@link GPUBuffer#mapAsync} calls made prior to that call, -on {@link GPUBuffer}s last used exclusively on that queue. -""" -returns.doc = """None (awaitable); resolves when the buffer is mapped.""" -args.mode.doc = """Whether the buffer should be mapped for reading or writing.""" -args.offset.doc = """Offset in bytes into the buffer to the start of the range to map.""" -args.size.doc = """Size in bytes of the range to map.""" -[classes.GPUBuffer.methods.get_mapped_range] -doc = """Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.""" -returns.doc = """A writable memory view (e.g. a memoryview) on the mapped range.""" -args.offset.doc = """Offset in bytes into the buffer to return buffer contents from.""" -args.size.doc = """Size in bytes of the ArrayBuffer to return.""" -[classes.GPUBuffer.methods.unmap] -doc = """Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the -GPU again. -""" -returns.doc = """None.""" -[classes.GPUBuffer.methods.destroy] -doc = """Destroys the {@link GPUBuffer}. -Note: It is valid to destroy a buffer multiple times. -Note: Since no further operations can be enqueued using this buffer, implementations can -free resource allocations, including mapped memory that was just unmapped. -""" -returns.doc = """None.""" - -[classes.GPUTexture] -doc = """An image resource of one, two or three dimensions, optionally with mip levels and array layers. - -Textures are created with GPUDevice.create_texture(). To use a texture in a shader or as a render -attachment, create a GPUTextureView with create_view(). -""" -properties.width.doc = """The width of the texture in texels.""" -properties.height.doc = """The height of the texture in texels.""" -properties.depth_or_array_layers.doc = """The depth (for 3D textures) or the number of array layers of the texture.""" -properties.mip_level_count.doc = """The number of mip levels of the texture.""" -properties.sample_count.doc = """The number of samples per pixel of the texture (1 unless multisampled).""" -properties.dimension.doc = """The dimensionality of the texture, see enums.TextureDimension.""" -properties.format.doc = """The pixel format of the texture, see enums.TextureFormat.""" -properties.usage.doc = """The allowed usages of the texture, a combination of flags.TextureUsage.""" -properties.texture_binding_view_dimension.doc = """Compatibility mode only: the enums.TextureViewDimension that views of this texture can use for texture binding.""" -[classes.GPUTexture.methods] -[classes.GPUTexture.methods.create_view] -doc = """Creates a {@link GPUTextureView}.""" -returns.doc = """A GPUTextureView.""" -args.descriptor.doc = """Description of the {@link GPUTextureView} to create.""" -[classes.GPUTexture.methods.destroy] -doc = """Destroys the {@link GPUTexture}.""" -returns.doc = """None.""" - -[classes.GPUTextureView] -doc = """A view on (a part of) a GPUTexture. - -Texture views are created with GPUTexture.create_view(), and are used in bind groups (see structs.BindGroupEntry) -and as render pass attachments (see structs.RenderPassColorAttachment). -""" -[classes.GPUTextureView.methods] - -[classes.GPUSampler] -doc = """Defines how a texture is sampled in a shader: the filtering and the handling of coordinates outside of the texture. - -Samplers are created with GPUDevice.create_sampler(). -""" -[classes.GPUSampler.methods] - -[classes.GPUBindGroupLayout] -doc = """Describes the types of resources and their shader visibility for the bindings in a GPUBindGroup. - -Bind group layouts are created with GPUDevice.create_bind_group_layout() or obtained from a pipeline -via GPUPipelineBase.get_bind_group_layout(). -""" -[classes.GPUBindGroupLayout.methods] - -[classes.GPUBindGroup] -doc = """A set of resources (buffers, samplers, texture views) bound together, following a GPUBindGroupLayout. - -Bind groups are created with GPUDevice.create_bind_group() and activated with GPUBindingCommandsMixin.set_bind_group(). -""" -[classes.GPUBindGroup.methods] - -[classes.GPUPipelineLayout] -doc = """Describes the bind group layouts (and immediate data size) that a pipeline uses. - -Pipeline layouts are created with GPUDevice.create_pipeline_layout(), or derived automatically using enums.AutoLayoutMode.auto. -""" -[classes.GPUPipelineLayout.methods] - -[classes.GPUShaderModule] -doc = """A compiled piece of shader code (WGSL), containing one or more entry points. - -Shader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage). -""" -[classes.GPUShaderModule.methods] -[classes.GPUShaderModule.methods.get_compilation_info] -doc = """Returns any messages generated during the {@link GPUShaderModule}'s compilation. -The locations, order, and contents of messages are implementation-defined. -In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}. -""" -returns.doc = """A GPUCompilationInfo (awaitable) with the list of messages.""" - -[classes.GPUCompilationMessage] -doc = """A single diagnostic message produced when compiling a shader module. - -The messages are available via the messages property of GPUCompilationInfo. -""" -properties.message.doc = """The human-readable text of the message.""" -properties.type.doc = """The severity of the message, see enums.CompilationMessageType.""" -properties.line_num.doc = """The 1-based line number in the shader code that the message refers to, or 0 if it does not apply to a line.""" -properties.line_pos.doc = """The 1-based position in the line (in UTF-16 code units) that the message refers to, or 0 if it does not apply to a position.""" -properties.offset.doc = """The offset in the shader code (in UTF-16 code units) that the message refers to.""" -properties.length.doc = """The length (in UTF-16 code units) of the span in the shader code that the message refers to.""" -[classes.GPUCompilationMessage.methods] - -[classes.GPUCompilationInfo] -doc = """The diagnostic messages produced when compiling a shader module. - -Obtained from GPUShaderModule.get_compilation_info(). -""" -properties.messages.doc = """A list of GPUCompilationMessage objects.""" -[classes.GPUCompilationInfo.methods] - -[classes.GPUPipelineError] -doc = """The error that is raised when asynchronous pipeline creation fails. - -Raised by GPUDevice.create_compute_pipeline_async() and GPUDevice.create_render_pipeline_async(). -""" -properties.reason.doc = """The reason for the failure, see enums.PipelineErrorReason.""" -[classes.GPUPipelineError.methods] -[classes.GPUPipelineError.methods.constructor] -doc = """Create a GPUPipelineError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = """A GPUPipelineError.""" -args.message.doc = """The human-readable error message.""" -args.options.doc = """A structs.PipelineErrorInit with the reason of the error.""" - -[classes.GPUPipelineBase] -doc = """The base class for GPUComputePipeline and GPURenderPipeline. - -It provides access to the bind group layouts of the pipeline. -""" -[classes.GPUPipelineBase.methods] -[classes.GPUPipelineBase.methods.get_bind_group_layout] -doc = """Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s -{@link GPUBindGroupLayout} at `index`. -""" -returns.doc = """A GPUBindGroupLayout.""" -args.index.doc = """Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]` sequence.""" - -[classes.GPUComputePipeline] -doc = """A pipeline that describes a compute shader and its resources. - -Created with GPUDevice.create_compute_pipeline(). It is used in a compute pass with GPUComputePassEncoder.set_pipeline(). -""" -[classes.GPUComputePipeline.methods] - -[classes.GPURenderPipeline] -doc = """A pipeline that describes the complete graphics pipeline state: shaders, vertex layout, rasterization, depth/stencil and blending. - -Created with GPUDevice.create_render_pipeline(). It is used in a render pass with GPURenderCommandsMixin.set_pipeline(). -""" -[classes.GPURenderPipeline.methods] - -[classes.GPUCommandBuffer] -doc = """A recorded list of GPU commands, ready to be submitted. - -Obtained from GPUCommandEncoder.finish() and submitted with GPUQueue.submit(). A command buffer can only be submitted once. -""" -[classes.GPUCommandBuffer.methods] - -[classes.GPUCommandsMixin] -doc = """A mixin class for objects that record commands: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -It has no methods of its own in the current version of the API. -""" -[classes.GPUCommandsMixin.methods] - -[classes.GPUCommandEncoder] -doc = """Records GPU commands (render passes, compute passes and copy operations) into a GPUCommandBuffer. - -Create one with GPUDevice.create_command_encoder(). Call finish() to obtain the command buffer, and submit it with GPUQueue.submit(). -Only one pass can be active at a time; end the pass (using the end() method of the pass encoder) before recording other commands. -""" -[classes.GPUCommandEncoder.methods] -[classes.GPUCommandEncoder.methods.begin_render_pass] -doc = """Begins encoding a render pass described by `descriptor`.""" -returns.doc = """A GPURenderPassEncoder.""" -args.descriptor.doc = """Description of the {@link GPURenderPassEncoder} to create.""" -[classes.GPUCommandEncoder.methods.begin_compute_pass] -doc = """Begin a compute pass, returning a GPUComputePassEncoder to record dispatch commands with. - -The pass must be ended with GPUComputePassEncoder.end() before the encoder can be used again. -""" -returns.doc = """A GPUComputePassEncoder.""" -args.descriptor.doc = """A structs.ComputePassDescriptor. Optional.""" -[classes.GPUCommandEncoder.methods.copy_buffer_to_buffer] -doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a -{@link GPUBuffer} to a sub-region of another {@link GPUBuffer}. -""" -returns.doc = """None.""" -args.source.doc = """The {@link GPUBuffer} to copy from.""" -args.source_offset.doc = """Offset in bytes into `source` to begin copying from.""" -args.destination.doc = """The {@link GPUBuffer} to copy to.""" -args.destination_offset.doc = """Offset in bytes into `destination` to place the copied data.""" -args.size.doc = """Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.""" -[classes.GPUCommandEncoder.methods.copy_buffer_to_texture] -doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a -{@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources. -""" -returns.doc = """None.""" -args.source.doc = """Combined with `copySize`, defines the region of the source buffer.""" -args.destination.doc = """Combined with `copySize`, defines the region of the destination texture subresource. `copySize`:""" -args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" -[classes.GPUCommandEncoder.methods.copy_texture_to_buffer] -doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or -multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}. -""" -returns.doc = """None.""" -args.source.doc = """Combined with `copySize`, defines the region of the source texture subresources.""" -args.destination.doc = """Combined with `copySize`, defines the region of the destination buffer. `copySize`:""" -args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" -[classes.GPUCommandEncoder.methods.copy_texture_to_texture] -doc = """Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one -or multiple contiguous texture subresources to another sub-region of one or -multiple continuous texture subresources. -""" -returns.doc = """None.""" -args.source.doc = """Combined with `copySize`, defines the region of the source texture subresources.""" -args.destination.doc = """Combined with `copySize`, defines the region of the destination texture subresources. `copySize`:""" -args.copy_size.doc = """A structs.Extent3D (or tuple) with the size of the region to copy, in texels.""" -[classes.GPUCommandEncoder.methods.clear_buffer] -doc = """Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a -{@link GPUBuffer} with zeros. -""" -returns.doc = """None.""" -args.buffer.doc = """The {@link GPUBuffer} to clear.""" -args.offset.doc = """Offset in bytes into `buffer` where the sub-region to clear begins.""" -args.size.doc = """Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.""" -[classes.GPUCommandEncoder.methods.resolve_query_set] -doc = """Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}. - querySet: - firstQuery: - queryCount: - destination: - destinationOffset: -""" -returns.doc = """None.""" -args.query_set.doc = """The GPUQuerySet to read results from.""" -args.first_query.doc = """The index of the first query to resolve.""" -args.query_count.doc = """The number of queries to resolve.""" -args.destination.doc = """The GPUBuffer to write the results to.""" -args.destination_offset.doc = """The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256.""" -[classes.GPUCommandEncoder.methods.finish] -doc = """Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}. - descriptor: -""" -returns.doc = """A GPUCommandBuffer.""" -args.descriptor.doc = """A structs.CommandBufferDescriptor. Optional.""" - -[classes.GPUBindingCommandsMixin] -doc = """A mixin class for pass encoders that can bind resources: GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -It provides methods to set bind groups and immediate data. -""" -[classes.GPUBindingCommandsMixin.methods] -[classes.GPUBindingCommandsMixin.methods.set_bind_group] -doc = """Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset -of a Uint32Array. -""" -returns.doc = """None.""" -args.index.doc = """The index to set the bind group at.""" -args.bind_group.doc = """Bind group to use for subsequent render or compute commands.""" -args.dynamic_offsets_data.doc = """Array containing buffer offsets in bytes for each entry in `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.""" -args.dynamic_offsets_data_start.doc = """Offset in elements into `dynamicOffsetsData` where the buffer offset data begins.""" -args.dynamic_offsets_data_length.doc = """Number of buffer offsets to read from `dynamicOffsetsData`.""" -[classes.GPUBindingCommandsMixin.methods.set_immediates] -doc = """Sets immediate data for subsequent render or compute commands.""" -returns.doc = """None.""" -args.range_offset.doc = """Offset in bytes into the immediate data range to begin writing at.""" -args.data.doc = """Data to write into the immediate data range.""" -args.data_offset.doc = """Offset into `data` to begin writing from. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.""" -args.data_size.doc = """Size of content to write from `data`. Given in elements if `data` is a {@link TypedArray} and bytes otherwise.""" - -[classes.GPUDebugCommandsMixin] -doc = """A mixin class for objects that record commands and support debug labeling: GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder and GPURenderBundleEncoder. - -Debug groups and markers show up in debugging tools and in error messages. -""" -[classes.GPUDebugCommandsMixin.methods] -[classes.GPUDebugCommandsMixin.methods.push_debug_group] -doc = """Begins a labeled debug group containing subsequent commands.""" -returns.doc = """None.""" -args.group_label.doc = """The label for the command group.""" -[classes.GPUDebugCommandsMixin.methods.pop_debug_group] -doc = """Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.""" -returns.doc = """None.""" -[classes.GPUDebugCommandsMixin.methods.insert_debug_marker] -doc = """Marks a point in a stream of commands with a label.""" -returns.doc = """None.""" -args.marker_label.doc = """The label to insert.""" - -[classes.GPUComputePassEncoder] -doc = """Records the commands of a compute pass. - -Created with GPUCommandEncoder.begin_compute_pass(). Set a pipeline and bind groups, dispatch work, -and finally call end(). Also has the methods of GPUBindingCommandsMixin and GPUDebugCommandsMixin. -""" -[classes.GPUComputePassEncoder.methods] -[classes.GPUComputePassEncoder.methods.set_pipeline] -doc = """Sets the current {@link GPUComputePipeline}.""" -returns.doc = """None.""" -args.pipeline.doc = """The compute pipeline to use for subsequent dispatch commands.""" -[classes.GPUComputePassEncoder.methods.dispatch_workgroups] -doc = """Dispatch work to be performed with the current {@link GPUComputePipeline}. -See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. -""" -returns.doc = """None.""" -args.workgroup_count_x.doc = """X dimension of the grid of workgroups to dispatch.""" -args.workgroup_count_y.doc = """Y dimension of the grid of workgroups to dispatch.""" -args.workgroup_count_z.doc = """Z dimension of the grid of workgroups to dispatch.""" -[classes.GPUComputePassEncoder.methods.dispatch_workgroups_indirect] -doc = """Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read -from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification. -packed block of **three 32-bit unsigned integer values (12 bytes total)**, -given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}. -For example: -""" -returns.doc = """None.""" -args.indirect_buffer.doc = """Buffer containing the indirect dispatch parameters.""" -args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the dispatch data begins.""" -[classes.GPUComputePassEncoder.methods.end] -doc = """Completes recording of the compute pass commands sequence.""" -returns.doc = """None.""" - -[classes.GPURenderPassEncoder] -doc = """Records the commands of a render pass. - -Created with GPUCommandEncoder.begin_render_pass(). Set a pipeline, bind groups and vertex/index buffers, -draw, and finally call end(). Also has the methods of GPUBindingCommandsMixin, GPUDebugCommandsMixin and GPURenderCommandsMixin. -""" -[classes.GPURenderPassEncoder.methods] -[classes.GPURenderPassEncoder.methods.set_viewport] -doc = """Sets the viewport used during the rasterization stage to linearly map from -NDC|normalized device coordinates to viewport coordinates. -""" -returns.doc = """None.""" -args.x.doc = """Minimum X value of the viewport in pixels.""" -args.y.doc = """Minimum Y value of the viewport in pixels.""" -args.width.doc = """Width of the viewport in pixels.""" -args.height.doc = """Height of the viewport in pixels.""" -args.min_depth.doc = """Minimum depth value of the viewport.""" -args.max_depth.doc = """Maximum depth value of the viewport.""" -[classes.GPURenderPassEncoder.methods.set_scissor_rect] -doc = """Sets the scissor rectangle used during the rasterization stage. -After transformation into viewport coordinates any fragments which fall outside the scissor -rectangle will be discarded. -""" -returns.doc = """None.""" -args.x.doc = """Minimum X value of the scissor rectangle in pixels.""" -args.y.doc = """Minimum Y value of the scissor rectangle in pixels.""" -args.width.doc = """Width of the scissor rectangle in pixels.""" -args.height.doc = """Height of the scissor rectangle in pixels.""" -[classes.GPURenderPassEncoder.methods.set_blend_constant] -doc = """Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"` -and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s. -""" -returns.doc = """None.""" -args.color.doc = """The color to use when blending.""" -[classes.GPURenderPassEncoder.methods.set_stencil_reference] -doc = """Sets the RenderState.`[[stencilReference]]` value used during stencil tests with -the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}. -""" -returns.doc = """None.""" -args.reference.doc = """The new stencil reference value.""" -[classes.GPURenderPassEncoder.methods.begin_occlusion_query] -doc = """Begin an occlusion query, which counts the samples that pass the depth and stencil tests. - -The result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor). -End the query with end_occlusion_query(). -""" -returns.doc = """None.""" -args.query_index.doc = """The index of the query in the query set.""" -[classes.GPURenderPassEncoder.methods.end_occlusion_query] -doc = """End the occlusion query that was started with begin_occlusion_query(). -""" -returns.doc = """None.""" -[classes.GPURenderPassEncoder.methods.execute_bundles] -doc = """Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of -this render pass. -When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind -groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render -pass's pipeline, bind group, and vertex/index buffer state is cleared -(to the initial, empty values). -Note: The state is cleared, not restored to the previous state. -This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed. -""" -returns.doc = """None.""" -args.bundles.doc = """List of render bundles to execute.""" -[classes.GPURenderPassEncoder.methods.end] -doc = """Completes recording of the render pass commands sequence.""" -returns.doc = """None.""" - -[classes.GPURenderCommandsMixin] -doc = """A mixin class for objects that record render commands: GPURenderPassEncoder and GPURenderBundleEncoder. - -It provides methods to set the pipeline, vertex and index buffers, and to draw. -""" -[classes.GPURenderCommandsMixin.methods] -[classes.GPURenderCommandsMixin.methods.set_pipeline] -doc = """Sets the current {@link GPURenderPipeline}.""" -returns.doc = """None.""" -args.pipeline.doc = """The render pipeline to use for subsequent drawing commands.""" -[classes.GPURenderCommandsMixin.methods.set_index_buffer] -doc = """Sets the current index buffer.""" -returns.doc = """None.""" -args.buffer.doc = """Buffer containing index data to use for subsequent drawing commands.""" -args.index_format.doc = """Format of the index data contained in `buffer`.""" -args.offset.doc = """Offset in bytes into `buffer` where the index data begins. Defaults to `0`.""" -args.size.doc = """Size in bytes of the index data in `buffer`. Defaults to the size of the buffer minus the offset.""" -[classes.GPURenderCommandsMixin.methods.set_vertex_buffer] -doc = """Sets the current vertex buffer for the given slot.""" -returns.doc = """None.""" -args.slot.doc = """The vertex buffer slot to set the vertex buffer for.""" -args.buffer.doc = """Buffer containing vertex data to use for subsequent drawing commands.""" -args.offset.doc = """Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.""" -args.size.doc = """Size in bytes of the vertex data in `buffer`. Defaults to the size of the buffer minus the offset.""" -[classes.GPURenderCommandsMixin.methods.draw] -doc = """Draws primitives. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -""" -returns.doc = """None.""" -args.vertex_count.doc = """The number of vertices to draw.""" -args.instance_count.doc = """The number of instances to draw.""" -args.first_vertex.doc = """Offset into the vertex buffers, in vertices, to begin drawing from.""" -args.first_instance.doc = """First instance to draw.""" -[classes.GPURenderCommandsMixin.methods.draw_indexed] -doc = """Draws indexed primitives. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -""" -returns.doc = """None.""" -args.index_count.doc = """The number of indices to draw.""" -args.instance_count.doc = """The number of instances to draw.""" -args.first_index.doc = """Offset into the index buffer, in indices, begin drawing from.""" -args.base_vertex.doc = """Added to each index value before indexing into the vertex buffers.""" -args.first_instance.doc = """First instance to draw.""" -[classes.GPURenderCommandsMixin.methods.draw_indirect] -doc = """Draws primitives using parameters read from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same -order as the arguments for {@link GPURenderCommandsMixin#draw}. For example: -""" -returns.doc = """None.""" -args.indirect_buffer.doc = """Buffer containing the indirect draw parameters.""" -args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the drawing data begins.""" -[classes.GPURenderCommandsMixin.methods.draw_indexed_indirect] -doc = """Draws indexed primitives using parameters read from a {@link GPUBuffer}. -See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification. -tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in -the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example: -""" -returns.doc = """None.""" -args.indirect_buffer.doc = """Buffer containing the indirect drawIndexed parameters.""" -args.indirect_offset.doc = """Offset in bytes into `indirectBuffer` where the drawing data begins.""" - -[classes.GPURenderBundle] -doc = """A pre-recorded sequence of render commands that can be executed in render passes. - -Obtained from GPURenderBundleEncoder.finish() and executed with GPURenderPassEncoder.execute_bundles(). -""" -[classes.GPURenderBundle.methods] - -[classes.GPURenderBundleEncoder] -doc = """Records render commands into a GPURenderBundle, which can be replayed in multiple render passes. - -Created with GPUDevice.create_render_bundle_encoder(). Also has the methods of GPUBindingCommandsMixin, -GPUDebugCommandsMixin and GPURenderCommandsMixin. -""" -[classes.GPURenderBundleEncoder.methods] -[classes.GPURenderBundleEncoder.methods.finish] -doc = """Completes recording of the render bundle commands sequence. - descriptor: -""" -returns.doc = """A GPURenderBundle.""" -args.descriptor.doc = """A structs.RenderBundleDescriptor. Optional.""" - -[classes.GPUQueue] -doc = """The queue on which work is submitted to the GPU. - -Each GPUDevice has a default queue, available via the queue property of GPUDevice. -It is used to submit command buffers and to upload data to buffers and textures. -""" -[classes.GPUQueue.methods] -[classes.GPUQueue.methods.submit] -doc = """Schedules the execution of the command buffers by the GPU on this queue. -Submitted command buffers cannot be used again. - `commandBuffers`: -""" -returns.doc = """None.""" -args.command_buffers.doc = """A list of GPUCommandBuffer objects, executed in order.""" -[classes.GPUQueue.methods.on_submitted_work_done] -doc = """Returns a Promise that resolves once this queue finishes processing all the work submitted -up to this moment. -Resolution of this Promise implies the completion of -{@link GPUBuffer#mapAsync} calls made prior to that call, -on {@link GPUBuffer}s last used exclusively on that queue. -""" -returns.doc = """None (awaitable); resolves when the submitted work is done.""" -[classes.GPUQueue.methods.write_buffer] -doc = """Issues a write operation of the provided data into a {@link GPUBuffer}.""" -returns.doc = """None.""" -args.buffer.doc = """The buffer to write to.""" -args.buffer_offset.doc = """Offset in bytes into `buffer` to begin writing at.""" -args.data.doc = """Data to write into `buffer`.""" -args.data_offset.doc = """Offset in into `data` to begin writing from. Given in elements if `data` is a `TypedArray` and bytes otherwise.""" -args.size.doc = """Size of content to write from `data` to `buffer`. Given in elements if `data` is a `TypedArray` and bytes otherwise.""" -[classes.GPUQueue.methods.write_texture] -doc = """Issues a write operation of the provided data into a {@link GPUTexture}.""" -returns.doc = """None.""" -args.destination.doc = """The texture subresource and origin to write to.""" -args.data.doc = """Data to write into `destination`.""" -args.data_layout.doc = """Layout of the content in `data`.""" -args.size.doc = """Extents of the content to write from `data` to `destination`.""" - -[classes.GPUQuerySet] -doc = """A set of queries that hold results such as occlusion counts or timestamps. - -Created with GPUDevice.create_query_set(). Results are written during passes and can be read by resolving -them into a buffer with GPUCommandEncoder.resolve_query_set(). -""" -properties.type.doc = """The type of queries in the set, see enums.QueryType.""" -properties.count.doc = """The number of queries in the set.""" -[classes.GPUQuerySet.methods] -[classes.GPUQuerySet.methods.destroy] -doc = """Destroys the {@link GPUQuerySet}.""" -returns.doc = """None.""" - -[classes.GPUCanvasContext] -doc = """The connection between a canvas (or window) and the GPU, used to present rendered images. - -Configure it with configure(), then each frame obtain a texture with get_current_texture(), -render to it, and submit the work. The result is presented when the frame ends. -""" -properties.canvas.doc = """The canvas (or window/surface object) that this context belongs to.""" -[classes.GPUCanvasContext.methods] -[classes.GPUCanvasContext.methods.configure] -doc = """Configures the context for this canvas. -This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]). -See {@link GPUCanvasContext#getConfiguration} for information on feature detection. -""" -returns.doc = """None.""" -args.configuration.doc = """Desired configuration for the context.""" -[classes.GPUCanvasContext.methods.unconfigure] -doc = """Removes the context configuration. Destroys any textures produced while configured.""" -returns.doc = """None.""" -[classes.GPUCanvasContext.methods.get_configuration] -doc = """Returns the context configuration, or `null` if the context is not configured. -Note: -This method exists primarily for feature detection of members (and sub-members) of -{@link GPUCanvasConfiguration}; see those members for details. -For supported members, it returns the originally-supplied values. -""" -returns.doc = """The structs.CanvasConfiguration that was last passed to configure(), or None if the context is not configured.""" -[classes.GPUCanvasContext.methods.get_current_texture] -doc = """Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext} -next. -Note: The same {@link GPUTexture} object will be returned by every -call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]" -runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate. -""" -returns.doc = """A GPUTexture.""" - -[classes.GPUDeviceLostInfo] -doc = """Information about why a GPUDevice was lost. - -Available via the lost property of GPUDevice. -""" -properties.reason.doc = """The reason the device was lost, see enums.DeviceLostReason.""" -properties.message.doc = """A human-readable message with details about why the device was lost.""" -[classes.GPUDeviceLostInfo.methods] - -[classes.GPUError] -doc = """The base class of errors that are generated by the GPU API. - -Subclasses are GPUValidationError, GPUOutOfMemoryError and GPUInternalError. -Errors are obtained via error scopes (see GPUDevice.push_error_scope()) or the onuncapturederror property of GPUDevice. -""" -properties.message.doc = """A human-readable description of the error.""" -[classes.GPUError.methods] - -[classes.GPUValidationError] -doc = """An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage. - -Captured by error scopes with enums.ErrorFilter.validation. -""" -[classes.GPUValidationError.methods] -[classes.GPUValidationError.methods.constructor] -doc = """Create a GPUValidationError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = """A GPUValidationError.""" -args.message.doc = """The human-readable error message.""" - -[classes.GPUOutOfMemoryError] -doc = """An error that signals that there was not enough memory to complete an operation. - -Captured by error scopes with enums.ErrorFilter.out_of_memory. -""" -[classes.GPUOutOfMemoryError.methods] -[classes.GPUOutOfMemoryError.methods.constructor] -doc = """Create a GPUOutOfMemoryError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = """A GPUOutOfMemoryError.""" -args.message.doc = """The human-readable error message.""" - -[classes.GPUInternalError] -doc = """An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit. - -Captured by error scopes with enums.ErrorFilter.internal. -""" -[classes.GPUInternalError.methods] -[classes.GPUInternalError.methods.constructor] -doc = """Create a GPUInternalError. - -Normally these are created by the implementation rather than by user code. -""" -returns.doc = """A GPUInternalError.""" -args.message.doc = """The human-readable error message.""" diff --git a/apigen/download.py b/apigen/download_idl.py similarity index 50% rename from apigen/download.py rename to apigen/download_idl.py index 21daf913..3c766ac2 100644 --- a/apigen/download.py +++ b/apigen/download_idl.py @@ -1,8 +1,11 @@ import urllib.request + from apigen_utils import DEFINITIONS_DIR def download_idl(): + """Download the latest webgpu.idl from the gpuweb repo.""" + url = ( "https://raw.githubusercontent.com/gpuweb/gpuweb/refs/heads/gh-pages/webgpu.idl" ) @@ -18,23 +21,5 @@ def download_idl(): print(f"Wrote to {filename}") -def download_ts(): - # Typescript type definition with docs - url = ( - "https://raw.githubusercontent.com/gpuweb/types/refs/heads/main/dist/index.d.ts" - ) - - with urllib.request.urlopen(url, timeout=10) as response: - data = response.read() - - filename = DEFINITIONS_DIR / "index.d.ts" - - with open(filename, "wb") as f: - f.write(data) - - print(f"Wrote to {filename}") - - if __name__ == "__main__": - # download_idl() - download_ts() + download_idl() diff --git a/apigen/parse_idl.py b/apigen/extract_idl.py similarity index 88% rename from apigen/parse_idl.py rename to apigen/extract_idl.py index a3d0a4ab..5489eb3c 100644 --- a/apigen/parse_idl.py +++ b/apigen/extract_idl.py @@ -1,12 +1,19 @@ -""" Parse the webgpu.idl to create wgpu_api_web.toml""" - from typing import Literal -from apigen_utils import read_file, read_definition_file, DEFINITIONS_DIR, to_snake_case +from apigen_utils import ( + read_definition_file, + read_file, + to_snake_case, + write_definition_file, +) + +builtins = __builtins__ +if not isinstance(builtins, dict): + builtins = builtins.__dict__ -def parse_idl_to_toml(): - """Parse the IDL specification to a structured form in toml.""" +def extract_idl(): + """Parse the IDL specification to a structured form in json.""" # TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure @@ -15,63 +22,53 @@ def parse_idl_to_toml(): parser = IdlParser(source) parser.parse() - # Generate TOML + # Generate structure - fname = "wgpu_api_web.toml" - hline = "# " + '-' * 80 - hline3 = "\n" + hline + "\n" + hline + "\n" + hline - - toml_lines = [ - f"# {fname}: Python-flavored WebGPU API, generated from 'webgpu.idl'.", - "# All types are converted to the Python equivalents.", - "# All names are made Pythonic snake_case.", - "# Methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly.", - ] - toml_lines.append(hline3) - toml_lines.append("[flags]") + fname = "wgpu_api_web.json" + s = {} + s["meta"] = { + "filename": fname, + "description": "Python-flavored WebGPU API, generated from 'webgpu.idl'.", + "notes": "All types are converted to the Python equivalents, all names are made Pythonic snake_case, methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly.", + } + flags_dict = s["flags"] = {} for flag_name, d in parser.flags.items(): - toml_lines.append(f"\n[flags.{flag_name}]") + flag_dict = flags_dict[flag_name] = {} + flag_dict["fields"] = {} for k, v in d.items(): - toml_lines.append(f"fields.{k} = {{ value = {v!r} }}") + flag_dict["fields"][k] = {"value": v} - toml_lines.append(hline3) - toml_lines.append("[enums]") + enums_dict = s["enums"] = {} for enum_name, d in parser.enums.items(): - toml_lines.append(f"\n[enums.{enum_name}]") + enum_dict = enums_dict[enum_name] = {} + enum_dict["fields"] = {} for k, v in d.items(): - toml_lines.append(f"fields.{k} = {{ value = {v!r} }}") + enum_dict["fields"][k] = {"value": v} - toml_lines.append(hline3) - toml_lines.append("[structs]") + structs_dict = s["structs"] = {} for struct_name, d in parser.structs.items(): - toml_lines.append(f"\n[structs.{struct_name}]") + struct_dict = structs_dict[struct_name] = {} + struct_dict["fields"] = {} for att in d.values(): - toml_lines.append(f"fields.{att.py_name} = {att.to_toml()}") + struct_dict["fields"][att.py_name] = att.to_dict() - toml_lines.append(hline3) - toml_lines.append("[classes]") + classes_dict = s["classes"] = {} for class_name, interface in parser.classes.items(): - toml_lines.append(f"\n[classes.{class_name}]") - toml_lines.append(f"bases = {interface.bases!r}") + class_dict = classes_dict[class_name] = {} + class_dict["bases"] = interface.bases + class_dict["properties"] = {} for prop_name, attr_type in interface.properties.items(): - toml_lines.append(f"properties.{prop_name} = {{ type = {attr_type!r} }}") - toml_lines.append(f"[classes.{class_name}.methods]") + class_dict["properties"][prop_name] = {"type": attr_type} # str + class_dict["methods"] = {} for func in interface.methods.values(): - toml_lines.append(f"[classes.{class_name}.methods.{func.py_name}]") - toml_lines.append(f"returns = {{ type = '{func.return_type}' }}") + method_dict = class_dict["methods"][func.py_name] = {} + method_dict["returns"] = {"type": func.return_type} + method_dict["args"] = {} for attribute in func.args: - toml_lines.append(f"args.{attribute.py_name} = {attribute.to_toml()}") - - # Write - - toml_lines.append("") - toml = "\n".join(toml_lines) - - - with open(DEFINITIONS_DIR / fname, "wb") as f: - f.write(toml.encode()) + method_dict["args"][attribute.py_name] = attribute.to_dict() - # Check that file is correct toml and structure + # Write (and read back as a validation step) + write_definition_file(s, fname) read_definition_file(fname) @@ -126,11 +123,12 @@ def __init__(self, line: str, source: Literal["struct", "param"]): def __repr__(self): return f"" - def to_str(self) -> str: - return self.line - - def to_toml(self) -> str: - return f"{{ type = '{self.py_type}', default = '{self.default}', required = {repr(self.required).lower()} }}" + def to_dict(self) -> dict: + return { + "type": self.py_type, + "default": self.default, + "required": self.required, + } class Interface: @@ -145,6 +143,7 @@ def __init__(self, name, bases): class Function: """A function definition.""" + def __init__(self, name, line): self.name = name self.line = line @@ -200,8 +199,7 @@ def _peek_line(self): return "" def parse(self, verbose=True): - """Parse the IDL file and build up an internal structure. - """ + """Parse the IDL file and build up an internal structure.""" self._interfaces = {} self.classes = {} self.structs = {} @@ -451,20 +449,26 @@ def _post_process(self): for classname, interface in self.classes.items(): for idl_prop_name in list(interface.properties.keys()): py_prop_name = to_snake_case(idl_prop_name) - interface.properties[py_prop_name] = self.resolve_type(interface.properties.pop(idl_prop_name)) + interface.properties[py_prop_name] = self.resolve_type( + interface.properties.pop(idl_prop_name) + ) for funcname in list(interface.methods.keys()): func = interface.methods[funcname] - args, return_type = self._resolve_signature(classname, funcname, func.line) + args, return_type = self._resolve_signature( + classname, funcname, func.line + ) if return_type: return_type = self.resolve_type(return_type) - if funcname.lower().endswith("async"): # TODO: doesn't the type handle this already? + if funcname.lower().endswith( + "async" + ): # TODO: doesn't the type handle this already? return_type = f"GPUPromise[{return_type}]" for arg in args: arg.py_name = to_snake_case(arg.name) arg.py_type = self.resolve_type(arg.idl_type) func.py_name = to_snake_case(func.name) - func.return_type = return_type + func.return_type = return_type or "None" func.args = args def resolve_type(self, typename) -> str: @@ -566,7 +570,7 @@ def resolve_type(self, typename) -> str: return self.resolve_type(name) # Triage - if name in __builtins__.__dict__: + if name in builtins: return name # ok elif name in ["ArrayLike", "CanvasLike"]: return name # virtual types @@ -606,4 +610,4 @@ def _resolve_signature(self, classname, methodname, idl_line): if __name__ == "__main__": - parse_idl_to_toml() + extract_idl() diff --git a/apigen/format_json.py b/apigen/format_json.py new file mode 100644 index 00000000..bdfd6145 --- /dev/null +++ b/apigen/format_json.py @@ -0,0 +1,19 @@ +import os + +from apigen_utils import DEFINITIONS_DIR, read_definition_file, write_definition_file + + +def format_json(): + """Format the static json files for consistency.""" + files = [ + fname + for fname in os.listdir(DEFINITIONS_DIR) + if fname.endswith(".json") and fname.startswith(("diff_", "docs_")) + ] + for fname in files: + s = read_definition_file(fname) + write_definition_file(s, fname) + + +if __name__ == "__main__": + format_json() diff --git a/apigen/merge_json.py b/apigen/merge_json.py new file mode 100644 index 00000000..60f0548a --- /dev/null +++ b/apigen/merge_json.py @@ -0,0 +1,30 @@ +from apigen_utils import dict_deep_merge, read_definition_file, write_definition_file + + +def merge_json(): + """Merge the structure definitions into a single definition for the base API.""" + + # Read + api_web = read_definition_file("wgpu_api_web.json") + diff_base = read_definition_file("diff_base.json") + docs_ai = read_definition_file("docs_ai.json") + docs_dev = read_definition_file("docs_dev.json") + + # Combine + api = dict_deep_merge(api_web, diff_base) + + # Insert docs + api = dict_deep_merge(api, docs_ai, allow_add=False) + api = dict_deep_merge(api, docs_dev, allow_add=False) + + api["meta"] = { + "filename": "wgpu_api.json", + "description": "Definition of the base wgpu API, derived from 'wgpu_api_web.json', 'diff_base.json', 'docs_ai.json', 'docs_dev.json'.", + "notes": "The full API, including docs, in one file. This does *not* include enums/flags/structs from any of the backends.", + } + + write_definition_file(api, "wgpu_api.json") + + +if __name__ == "__main__": + merge_json() diff --git a/apigen/parse_ts.py b/apigen/parse_ts.py deleted file mode 100644 index 3afc8b49..00000000 --- a/apigen/parse_ts.py +++ /dev/null @@ -1,332 +0,0 @@ -"""Parse the WebGPU Typescript type definitions (index.d.ts) to extract docs for most objects.""" - -import re - -from apigen_utils import read_file, read_definition_file, DEFINITIONS_DIR, to_snake_case - -KINDS = [ - "flag", - "flagfield", - "enum", - "enumfield", - "struct", - "structfield", - "class", - "property", - "method", - "arg", - "returns", -] -OPEN, CLOSE = "([{<", ")]}>" - - -def parse_ts_to_toml(): - """Parse the typescript file to a TOML structure.""" - source = read_file("apigen", "definitions", "index.d.ts") - docs = parse(source) - - flat = {"flags": {}, "enums": {}, "structs": {}, "classes": {}} - - category_map = { - "flag": "flags", - "flagfield": "flags", - "enum": "enums", - "enumfield": "enums", - "struct": "structs", - "structfield": "structs", - "class": "classes", - "property": "classes", - "method": "classes", - "arg": "classes", - "returns": "classes", - } - - # First we flatten the docs - for category, d in docs.items(): - for k, v in d.items(): - section = category_map[category] - target_dict = flat[section] - name_parts = k.split(".") - if category in ("structfield", "property", "method", "arg", "returns"): - name_parts[1] = to_snake_case(name_parts[1]) - if category in ("arg", ): - name_parts[-1] = to_snake_case(name_parts[-1]) - if category.endswith("field"): - name_parts.insert(1, "fields") - if category == "returns": - name_parts.append("returns") - if category == "arg": - name_parts.insert(-1, "args") - if category in ("property", "method", "arg", "returns"): - name_parts.insert(1, "methods") - if section != "classes" and name_parts[0].startswith("GPU"): - name_parts[0] = name_parts[0][3:] - name_parts.append("doc") - key = ".".join(name_parts) - target_dict[key] = v - - # Generate TOML - - fname = "docs_ts.toml" - hline = "# " + "-" * 80 - hline3 = "\n" + hline + "\n" + hline + "\n" + hline - - toml_lines = [ - f"# {fname}: Docs generated from 'index.d.ts'.", - ] - for section_name, d in flat.items(): - toml_lines.append(hline3) - toml_lines.append(f"[{section_name}]") - keys = sorted(d.keys()) - prev_prefix = "" - for key in keys: - doc = d[key] - if doc: - prefix = key.split(".")[0] - if prefix != prev_prefix: - toml_lines.append("") - prev_prefix = prefix - if "\n" not in doc: - toml_lines.append(f"{key} = {doc!r}") - else: - toml_lines.append(f"{key} = '''\n{doc}\n'''") - - # Write - - toml_lines.append("") - toml = "\n".join(toml_lines) - - with open(DEFINITIONS_DIR / fname, "wb") as f: - f.write(toml.encode()) - - # Check that file is correct toml and structure - read_definition_file(fname) - - -def clean_doc(raw): - """'/** ... */' -> plain text lines.""" - body = re.sub(r"^\s*/\*\*", "", raw) - body = re.sub(r"\*/\s*$", "", body) - lines = [re.sub(r"^\s*\*? ?", "", l).rstrip() for l in body.split("\n")] - return "\n".join(lines).strip() - - -def split_doc(doc): - """-> (description, {param: text}, returns_text)""" - desc, params, ret = [], {}, "" - cur = None - for line in doc.split("\n"): - m = re.match(r"@param\s+(?:\{[^}]*\}\s*)?(\w+)\s*-?\s*(.*)", line) - if m: - cur = m.group(1) - params[cur] = m.group(2) - continue - if line.startswith("@") and not line.startswith("@deprecated"): - cur = None - continue - if cur and line and not line.startswith("@"): - params[cur] += " " + line.strip() - else: - cur = None - desc.append(line) - d = "\n".join(desc).strip() - m = re.search(r"\*\*Returns:\*\*\s*(.*)", d) - if m: - ret = re.sub(r"]*>", "", m.group(1)).strip() - return d, params, ret - - -def scan_balanced(s, i): - """s[i] is an opener; return index just past its matching closer. - '=>' and '>' inside arrows are not treated as closers of '<'.""" - depth = 0 - while i < len(s): - c = s[i] - if c in "([{<": - depth += 1 - elif c in ")]}": - depth -= 1 - elif c == ">" and s[i - 1] != "=": - depth -= 1 - if depth == 0: - return i + 1 - i += 1 - return i - - -def block_end(s, i): - """s[i] == '{'; return index past the matching '}', skipping comments/strings.""" - depth, n = 0, len(s) - while i < n: - if s.startswith("/*", i): - i = s.index("*/", i) + 2 - continue - if s.startswith("//", i): - nl = s.find("\n", i) - i = n if nl < 0 else nl - continue - c = s[i] - if c in "\"'`": - j = i + 1 - while j < n and s[j] != c: - j += 2 if s[j] == "\\" else 1 - i = j + 1 - continue - if c == "{": - depth += 1 - elif c == "}": - depth -= 1 - if depth == 0: - return i + 1 - i += 1 - return n - - -def split_top(s, sep=","): - out, depth, cur = [], 0, [] - for i, c in enumerate(s): - if c in "([{<": - depth += 1 - elif c in ")]}" or (c == ">" and s[i - 1] != "="): - depth -= 1 - if c == sep and depth == 0: - out.append("".join(cur)) - cur = [] - else: - cur.append(c) - if "".join(cur).strip(): - out.append("".join(cur)) - return out - - -def tokenize_members(body): - """Yield (doc_or_None, member_text) from an interface body.""" - i, n = 0, len(body) - doc = None - while i < n: - if body[i].isspace(): - i += 1 - continue - if body.startswith("/**", i): - j = body.index("*/", i) + 2 - doc = clean_doc(body[i:j]) - i = j - continue - if body.startswith("/*", i): - i = body.index("*/", i) + 2 - continue - if body.startswith("//", i): - nl = body.find("\n", i) - i = n if nl < 0 else nl - continue - # member: runs to ';' at depth 0 - j, depth = i, 0 - while j < n: - c = body[j] - if c in "([{<": - depth += 1 - elif c in ")]}" or (c == ">" and body[j - 1] != "="): - depth -= 1 - elif c == ";" and depth == 0: - break - j += 1 - yield doc, re.sub(r"\s+", " ", body[i:j]).strip() - doc = None - i = j + 1 - - -def parse_member(text): - """-> dict(name, is_method, params[list of names], ret) or None""" - m = re.match(r"(?:readonly\s+)?(?:\[(\w+)[^\]]*\]|(\w+))\s*(\?)?\s*", text) - if not m: - return None - name = m.group(2) or m.group(1) - rest = text[m.end() :] - if rest.startswith("<"): # generics on a method - rest = rest[scan_balanced(rest, 0) :].lstrip() - if rest.startswith("("): - end = scan_balanced(rest, 0) - plist = rest[1 : end - 1] - params = [] - for p in split_top(plist): - pm = re.match(r"\s*(?:\.\.\.)?(\w+)", p) - if pm: - params.append(pm.group(1)) - ret = rest[end:].lstrip(": ").strip() - return dict(name=name, method=True, params=params, ret=ret) - ty = rest.lstrip(": ").strip() - return dict(name=name, method=False, ty=ty) - - -def parse(src): - out = {k: {} for k in KINDS} - - def put(kind, key, val): - if val or key not in out[kind]: - out[kind][key] = val if val else out[kind].get(key, "") - - # statements at top level - pos, n = 0, len(src) - pending_doc = None - stmt_re = re.compile(r"^(?:declare\s+)?(interface|type)\s+(\w+)", re.M) - while True: - m = stmt_re.search(src, pos) - if not m: - break - # doc comment immediately before? - before = src[: m.start()].rstrip() - pending_doc = None - if before.endswith("*/"): - st = before.rfind("/**") - if st >= 0 and "*/" not in before[st:-2]: - pending_doc = clean_doc(before[st:]) - kind, name = m.group(1), m.group(2) - if kind == "type": - end = src.index(";", m.end()) - while src[end - 1] == "\\": - end = src.index(";", end + 1) - body = src[m.end() : end] - lits = re.findall(r'^\s*\|\s*"([^"]*)"', body, re.M) - if lits and re.fullmatch(r'\s*=\s*(\|\s*"[^"]*"\s*)+', body): - put("enum", name, split_doc(pending_doc)[0] if pending_doc else "") - for v in lits: - put("enumfield", f"{name}.{v}", "") - pos = end + 1 - continue - # interface - ob = src.index("{", m.end()) - cb = block_end(src, ob) - body = src[ob + 1 : cb - 1] - pos = cb - members = [(d, parse_member(t)) for d, t in tokenize_members(body)] - members = [(d, p) for d, p in members if p] - idoc = split_doc(pending_doc)[0] if pending_doc else "" - if not members: - continue - if all((not p["method"]) and p["ty"] == "GPUFlagsConstant" for _, p in members): - put("flag", name, idoc) - for d, p in members: - put("flagfield", f"{name}.{p['name']}", split_doc(d)[0] if d else "") - elif any(p["name"] == "__brand" or p["method"] for _, p in members): - put("class", name, idoc) - for d, p in members: - if p["name"] == "__brand": - continue - if p["method"]: - desc, pdocs, ret = split_doc(d) if d else ("", {}, "") - key = f"{name}.{p['name']}" - put("method", key, desc) - for a in p["params"]: - put("arg", f"{key}.{a}", pdocs.get(a, "")) - put("returns", key, ret) - else: - put("property", f"{name}.{p['name']}", split_doc(d)[0] if d else "") - else: - put("struct", name, idoc) - for d, p in members: - put("structfield", f"{name}.{p['name']}", split_doc(d)[0] if d else "") - return out - - -if __name__ == "__main__": - parse_ts_to_toml() diff --git a/apigen/tests/test_structures.py b/apigen/tests/test_structures.py index 66ac7169..a20eefad 100644 --- a/apigen/tests/test_structures.py +++ b/apigen/tests/test_structures.py @@ -1,10 +1,9 @@ import os -import tomllib from apigen_utils import DEFINITIONS_DIR, read_file -FILES = [fname for fname in os.listdir(DEFINITIONS_DIR) if fname.endswith(".toml")] -BACKEND_FILES = ["diff_backend_pyodide.toml", "diff_backend_wgpu.toml"] +FILES = [fname for fname in os.listdir(DEFINITIONS_DIR) if fname.endswith(".json")] +BACKEND_FILES = ["diff_backend_pyodide.json", "diff_backend_wgpu.json"] def check_all_definition_files(): diff --git a/apigen/unite.py b/apigen/unite.py deleted file mode 100644 index b0da06e4..00000000 --- a/apigen/unite.py +++ /dev/null @@ -1,158 +0,0 @@ -"""Unite/merge the structure definitions into more final definitions. """ - -from apigen_utils import read_definition_file, dict_deep_merge, DEFINITIONS_DIR - - -def unite_toml_files(): - unite_base_api() - unite_docs() - - -def unite_base_api(): - - # Read - api_web = read_definition_file("wgpu_api_web.toml") - diff_base = read_definition_file("diff_base.toml") - - # Combine - api = dict_deep_merge(api_web, diff_base) - - # Generate toml - # We generate the whole structure, but ignore "do"" fields, assuming they are handled separately. - - fname = "wgpu_api.toml" - hline = "# " + '-' * 80 - hline3 = "\n" + hline + "\n" + hline + "\n" + hline - - toml_lines = [ - f"# {fname}: the base wgpu-py API, generated from 'wgpu_api_web.toml' and 'diff_base.toml'." - ] - - toml_lines.append(hline3) - toml_lines.append("[flags]") - for flag_name, flag_dict in api["flags"].items(): - toml_lines.append(f"\n[flags.{flag_name}]") - for k, d in flag_dict['fields'].items(): - toml_lines.append(f"fields.{k} = {{ value = {d['value']!r} }}") - - toml_lines.append(hline3) - toml_lines.append("[enums]") - for enum_name, enum_dict in api["enums"].items(): - toml_lines.append(f"\n[enums.{enum_name}]") - for k, d in enum_dict['fields'].items(): - toml_lines.append(f"fields.{k} = {{ value = '{d['value']}' }}") - - toml_lines.append(hline3) - toml_lines.append("[structs]") - for struct_name, struct_dict in api["structs"].items(): - toml_lines.append(f"\n[structs.{struct_name}]") - for k, d in struct_dict.get('fields', {}).items(): - toml_lines.append(f"fields.{k} = {{ type = {d['type']!r}, default = '{d['default']}', required = {repr(d['required']).lower()} }}") - - toml_lines.append(hline3) - toml_lines.append("[classes]") - for class_name, class_dict in api["classes"].items(): - toml_lines.append(f"\n[classes.{class_name}]") - toml_lines.append(f"bases = {class_dict['bases']!r}") - for prop_name, d in class_dict.get('properties', {}).items(): - toml_lines.append(f"properties.{prop_name} = {{ type = {d['type']!r} }}") - toml_lines.append(f"[classes.{class_name}.methods]") - for method_name, method_dict in class_dict['methods'].items(): - toml_lines.append(f"[classes.{class_name}.methods.{method_name}]") - toml_lines.append(f"returns = {{ type = '{method_dict['returns']['type']}' }}") - for arg_name, d in method_dict.get('args', {}).items(): - toml_lines.append(f"args.{arg_name} = {{ type = {d['type']!r}, default = '{d['default']}', required = {repr(d['required']).lower()} }}") - - # Write - - toml_lines.append("") - toml = "\n".join(toml_lines) - - with open(DEFINITIONS_DIR / fname, "wb") as f: - f.write(toml.encode()) - - # Check that file is correct toml and structure - read_definition_file(fname) - - -def unite_docs(): - - # Read definitions - api = read_definition_file("wgpu_api.toml") - docs_ai = read_definition_file("docs_ai.toml") - docs_ts = read_definition_file("docs_ts.toml") - docs_dev = read_definition_file("docs_dev.toml") - - # Combine into api. Only add docs for stuff that's actually in the API - docs = api - docs = dict_deep_merge(docs, docs_ai, allow_add=False) - docs = dict_deep_merge(docs, docs_ts, allow_add=False) - docs = dict_deep_merge(docs, docs_dev, allow_add=False) - - # Generate toml, only the doc fields. We assume that there is a doc - # field for every leaf node. If not, add it to docs_dev.toml! - - fname = "wgpu_docs.toml" - hline = "# " + '-' * 80 - hline3 = "\n" + hline + "\n" + hline + "\n" + hline - - toml_lines = [ - f"# {fname}", - "# Documentation for the wgpu-py API, composed from 'docs_ai.toml', 'docs_ts.toml', and 'docs_dev.toml'", - ] - - toml_lines.append(hline3) - toml_lines.append("[flags]") - for flag_name, flag_dict in docs["flags"].items(): - toml_lines.append(f"\n[flags.{flag_name}]") - toml_lines.append(f'doc = """{flag_dict["doc"]}"""') - for k, d in flag_dict['fields'].items(): - toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') - - toml_lines.append(hline3) - toml_lines.append("[enums]") - for enum_name, enum_dict in docs["enums"].items(): - toml_lines.append(f"\n[enums.{enum_name}]") - toml_lines.append(f'doc = """{enum_dict["doc"]}"""') - for k, d in enum_dict['fields'].items(): - toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') - - toml_lines.append(hline3) - toml_lines.append("[structs]") - for struct_name, struct_dict in docs["structs"].items(): - toml_lines.append(f"\n[structs.{struct_name}]") - toml_lines.append(f'doc = """{struct_dict["doc"]}"""') - for k, d in struct_dict.get('fields', {}).items(): - toml_lines.append(f'fields.{k}.doc = """{d["doc"]}"""') - - toml_lines.append(hline3) - toml_lines.append("[classes]") - for class_name, class_dict in docs["classes"].items(): - toml_lines.append(f"\n[classes.{class_name}]") - toml_lines.append(f'doc = """{class_dict["doc"]}"""') - for prop_name, d in class_dict.get('properties', {}).items(): - toml_lines.append(f'properties.{prop_name}.doc = """{d["doc"]}"""') - toml_lines.append(f"[classes.{class_name}.methods]") - for method_name, method_dict in class_dict['methods'].items(): - toml_lines.append(f'[classes.{class_name}.methods.{method_name}]') - toml_lines.append(f'doc = """{method_dict["doc"]}"""') - toml_lines.append(f'returns.doc = """{method_dict["returns"]["doc"]}"""') - for arg_name, d in method_dict.get('args', {}).items(): - toml_lines.append(f'args.{arg_name}.doc = """{d["doc"]}"""') - - - # Write - - toml_lines.append("") - toml = "\n".join(toml_lines) - - with open(DEFINITIONS_DIR / fname, "wb") as f: - f.write(toml.encode()) - - # Check that file is correct toml and structure - read_definition_file(fname) - - - -if __name__ == "__main__": - unite_toml_files() diff --git a/apigen/write_api.py b/apigen/write_api.py new file mode 100644 index 00000000..862f4b0b --- /dev/null +++ b/apigen/write_api.py @@ -0,0 +1,193 @@ +"""Generate the simple API from the definitions.""" + +import re + +from apigen_utils import ( + dict_deep_merge, + format_code, + # indent, + read_definition_file, + read_file, + write_file, +) + + +def write_api(): + """Write the Python code for the flags, enums, and structs.""" + + api = read_definition_file("wgpu_api.json") + + # Flags, enums, and structs (and their fields) defined in specific backends are added to the global set of flags/enums/structs, + # but they'll each have a '_ext' suffix + for fname in ["diff_backend_pyodide.json", "diff_backend_wgpu.json"]: + extra_api = read_definition_file(fname) + api = dict_deep_merge(api, extra_api) + + write_flags(api["flags"]) + write_enums(api["enums"]) + write_structs(api["structs"]) + + +ref_pattern = re.compile( + r"\W((GPU|classes\.|flags\.|enums\.|structs\.)\w+?)\W", re.MULTILINE +) + + +def resolve_crossrefs(text): + text += " " + i2 = 0 + while True: + m = ref_pattern.search(text, i2) + if not m: + break + i1, i2 = m.start(1), m.end(1) + ref = m.group(1) + ref = "." + ref.strip("`").lstrip(".") # Leading dot means fuzzy search + text = text[:i1] + "`" + ref + "`" + text[i2:] + i2 += len(ref) + return text.rstrip() + + +def write_flags(flags_dict): + # Get preamble + pylines = [] + for line in read_file("wgpu", "flags.py").splitlines(): + pylines.append(line) + if "AUTOGENERATED" in line: + pylines += ["", ""] + break + + # List'm + n = len(flags_dict) + pylines.append(f"# There are {n} flags\n") + pylines.append("__all__ = [") + for name in sorted(flags_dict.keys()): + pylines.append(f' "{name}",') + pylines.append("]\n\n") + + # The flags definitions + for name, flag_dict in flags_dict.items(): + pylines.append(f"{name}Flags = int | str\n\n") + pylines.append(f"class {name}(Flags):\n") + # pylines.append(f' """{indent(flag_dict["doc"])}"""') + for field_name, field_dict in flag_dict["fields"].items(): + pylines.append( + f" {field_name} = {field_dict['value']!r}" + ) # " #: {field_dict['doc']}") + pylines.append("\n") + + # Write + code = format_code("\n".join(pylines)) + write_file(code, "wgpu", "flags.py") + print(f"Wrote {n} flags to flags.py") + + +def write_enums(enums_dict): + # Get preamble + pylines = [] + for line in read_file("wgpu", "enums.py").splitlines(): + pylines.append(line) + if "AUTOGENERATED" in line: + pylines += ["", ""] + break + + # List'm + n = len(enums_dict) + pylines.append(f"# There are {n} enums\n") + pylines.append("__all__ = [") + for name in sorted(enums_dict.keys()): + pylines.append(f' "{name}",') + pylines.append("]\n\n") + + # The enum definitions + for name, enum_dict in enums_dict.items(): + quoted_values = [f'"{f["value"]}"' for f in enum_dict["fields"].values()] + pylines.append(f"{name}Enum = Literal[{', '.join(quoted_values)}] | str\n\n") + pylines.append(f"class {name}(Enum):\n") + # pylines.append(f' """{indent(enum_dict["doc"])}"""') + for field_name, field_dict in enum_dict["fields"].items(): + pylines.append( + f' {field_name} = "{field_dict["value"]}"' + ) # " #: {field_dict["doc"]}'') + pylines.append("\n") + + # Write + code = format_code("\n".join(pylines)) + write_file(code, "wgpu", "enums.py") + print(f"Wrote {n} enums to enums.py") + + +def write_structs(structs_dict): + # Get preamble + pylines = [] + for line in read_file("wgpu", "structs.py").splitlines(): + pylines.append(line) + if "AUTOGENERATED" in line: + pylines += ["", ""] + break + + # List'm + n = len(structs_dict) + pylines.append(f"# There are {n} structs\n") + pylines.append("__all__ = [") + for name in sorted(structs_dict.keys()): + pylines.append(f' "{name}",') + pylines.append("]\n\n") + + # The struct definitions + for name, struct_dict in structs_dict.items(): + pylines.append(f"@dataclass(kw_only=True, repr=False)\nclass {name}(Struct):") + # pylines.append(f' """{indent(struct_dict["doc"])}"""') + for field_name, field_dict in struct_dict["fields"].items(): + # Get type to include in code + raw_type = field_dict["type"] + # TODO: do these conversions earlier! + code_type = raw_type.replace("GPU", "classes.GPU").replace("structs.", "") + code_type = code_type.replace("list[", "Sequence[") + # Get type to include in docs + docs_type = "" + if ( + "flags." in raw_type + or "enums." in raw_type + or "structs." in raw_type + or "classes." in raw_type + ): + docs_type = raw_type.replace("Flags", "").replace("Enum", "") + docs_type = resolve_crossrefs(f" {docs_type} ") + # Get default + # TODO: move this logic earlier; the json files should be leading! + # if field_name == "power_preference": + # breakpoint() + default = field_dict["default"] + if default == "[]": + default = "()" + elif default == "{}": + default = "None" # no mutable defaults + code_type += " | None" + if not default and not field_dict["required"]: + default = "None" + if "None" not in code_type: + code_type += " | None" + # Build docs + doc = "" + if docs_type: + doc += f"{docs_type.strip()} " + if default: + pylines.append( + f" #: {doc}\n {field_name}: {code_type} = {default}" + ) + else: + pylines.append(f" #: {doc}\n {field_name}: {code_type}") + if len(struct_dict) == 0: + pylines.append(" pass") + pylines.append("\n") + pylines.append(f"{name}Struct = {name} | dict") + + # Write + code = format_code("\n".join(pylines)) + write_file(code, "wgpu", "structs.py") + print(f"Wrote {n} structs to structs.py") + + +if __name__ == "__main__": + write_api() diff --git a/apigen/write_flags_enums_structs.py b/apigen/write_flags_enums_structs.py deleted file mode 100644 index ab9d0926..00000000 --- a/apigen/write_flags_enums_structs.py +++ /dev/null @@ -1,83 +0,0 @@ -""" Generate the simple API from the definitions. """ - -from apigen_utils import read_definition_file, read_file, write_file, dict_deep_merge, format_code, indent - - -def write_api(): - api_without_docs = read_definition_file("wgpu_api.toml") - docs = read_definition_file("wgpu_docs.toml") - - api = dict_deep_merge(api_without_docs, docs, allow_add=False) - - print(t1-t0) - write_flags(api['flags']) - write_enums(api['enums']) - - -def write_flags(flags_dict): - # Get preamble - pylines = [] - for line in read_file("wgpu", "flags.py").splitlines(): - pylines.append(line) - if "AUTOGENERATED" in line: - pylines += ["", ""] - break - - # List'm - n = len(flags_dict) - pylines.append(f"# There are {n} flags\n") - pylines.append("__all__ = [") - for name in sorted(flags_dict.keys()): - pylines.append(f' "{name}",') - pylines.append("]\n\n") - - # The flags definitions - for name, flag_dict in flags_dict.items(): - # Generate Code - pylines.append(f"{name}Flags = int | str\n\n") - pylines.append(f"class {name}(Flags):\n") - pylines.append(f' """{indent(flag_dict["doc"])}"""') - for field_name, field_dict in flag_dict['fields'].items(): - pylines.append(f" {field_name} = {field_dict['value']!r} #: {field_dict['doc']}") # note: can add docs using "#: " - pylines.append("\n") - - # Write - code = format_code("\n".join(pylines)) - write_file(code, "wgpu", "flags.py") - print(f"Wrote {n} flags to flags.py") - - -def write_enums(enums_dict): - # Get preamble - pylines = [] - for line in read_file("wgpu", "flags.py").splitlines(): - pylines.append(line) - if "AUTOGENERATED" in line: - pylines += ["", ""] - break - - # List'm - n = len(flags_dict) - pylines.append(f"# There are {n} flags\n") - pylines.append("__all__ = [") - for name in sorted(flags_dict.keys()): - pylines.append(f' "{name}",') - pylines.append("]\n\n") - - # The flags definitions - for name, flag_dict in flags_dict.items(): - # Generate Code - pylines.append(f"{name}Flags = int | str\n\n") - pylines.append(f"class {name}(Flags):\n") - pylines.append(f' """{indent(flag_dict["doc"])}"""') - for field_name, field_dict in flag_dict['fields'].items(): - pylines.append(f" {field_name} = {field_dict['value']!r} #: {field_dict['doc']}") # note: can add docs using "#: " - pylines.append("\n") - - # Write - code = format_code("\n".join(pylines)) - write_file(code, "wgpu", "flags.py") - print(f"Wrote {n} flags to flags.py") - -if __name__ == "__main__": - write_api() diff --git a/docs/conf.py b/docs/conf.py index 64bbadeb..b1560b9b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,11 +10,10 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -import re import os -import sys +import re import shutil - +import sys ROOT_DIR = os.path.abspath(os.path.join(__file__, "..", "..")) sys.path.insert(0, ROOT_DIR) @@ -27,7 +26,6 @@ import wgpu.utils.compute # noqa: E402 import wgpu.utils.glfw_present_info # noqa: E402 - # -- Tests ------------------------------------------------------------------- # Ensure that all classes are referenced in the alphabetic list, @@ -59,6 +57,10 @@ ) +# Set the default role, so that any crossref in a docstring that looks like "`.enums.SomeEnum`" becomes a link. +default_role = "py:obj" + + def resolve_crossrefs(text): text = (text or "").lstrip() From 4e408563662badaa49f19a4d1c110d65ee7ece1f Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 15 Oct 2026 16:13:38 +0200 Subject: [PATCH 03/10] cleaning up --- apigen/__init__.py | 3 +- apigen/apigen_utils.py | 68 ++++++++++++++++-------- apigen/definitions/diff_base.json | 8 ++- apigen/definitions/wgpu_api_web.json | 79 ++++++++++++++++++++++++++++ apigen/extract_idl.py | 14 +---- 5 files changed, 133 insertions(+), 39 deletions(-) diff --git a/apigen/__init__.py b/apigen/__init__.py index c5119cc0..ad297a4b 100644 --- a/apigen/__init__.py +++ b/apigen/__init__.py @@ -1,5 +1,4 @@ -""" Code to generate the wgpu-py API. -""" +"""Code to generate the wgpu-py API.""" from download_idl import download_idl from extract_idl import extract_idl diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py index 218e2ef9..239bfc5f 100644 --- a/apigen/apigen_utils.py +++ b/apigen/apigen_utils.py @@ -20,7 +20,7 @@ def read_file(*fname): ) -def write_file(text:str, *fname): +def write_file(text: str, *fname): """Write the given text to disk, using the relative filename. Line endings are matched to what's used for __init__.py.""" filename = ROOT_DIR.joinpath(*fname) if not text.endswith("\n"): @@ -44,7 +44,8 @@ def _get_line_endings(text): else: return "\r\n" -LE = _get_line_endings((ROOT_DIR / 'apigen' / "__init__.py").read_bytes().decode()) + +LE = _get_line_endings((ROOT_DIR / "apigen" / "__init__.py").read_bytes().decode()) def to_snake_case(name, separator="_"): @@ -64,14 +65,14 @@ def to_snake_case(name, separator="_"): return name2 -def dict_deep_merge(a:dict, b:dict, allow_add: bool=True) -> dict: +def dict_deep_merge(a: dict, b: dict, allow_add: bool = True) -> dict: """Return a new dict: b merged into a, recursing into nested dicts.""" result = dict(a) for key, val in b.items(): if isinstance(val, dict): if key in result and isinstance(result[key], dict): if "diff" in val: - assert val['diff'] == "REMOVE" + assert val["diff"] == "REMOVE" result.pop(key, None) else: result[key] = dict_deep_merge(result[key], val, allow_add) @@ -183,7 +184,7 @@ def read_definition_file(fname: str) -> dict: structure = json.loads(source) possible_default_types = (None.__class__, int, float, str, list, dict) - diff_actions = ("REMOVE", ) + diff_actions = ("REMOVE",) assert ( "meta" in structure @@ -221,9 +222,11 @@ def read_definition_file(fname: str) -> dict: elif field_dict_key == "diff": assert field_dict_val in diff_actions elif field_dict_key == "value": - assert isinstance(field_dict_val, int) + assert isinstance(field_dict_val, int) else: - raise RuntimeError(f"Invalid flag field dict key {field_dict_key!r}") + raise RuntimeError( + f"Invalid flag field dict key {field_dict_key!r}" + ) else: raise RuntimeError(f"Invalid flag attr {flag_attr_key!r}") @@ -246,10 +249,14 @@ def read_definition_file(fname: str) -> dict: elif field_dict_key == "diff": assert field_dict_val in diff_actions elif field_dict_key == "value": - assert isinstance(field_dict_val, str) - assert field_dict_val == enum_name_to_value(field_name) + assert isinstance(field_dict_val, str) + assert field_dict_val == enum_name_to_value( + field_name + ) else: - raise RuntimeError(f"Invalid enum field dict key {field_dict_key!r}") + raise RuntimeError( + f"Invalid enum field dict key {field_dict_key!r}" + ) else: raise RuntimeError(f"Invalid enum attr {enum_attr_key!r}") @@ -272,19 +279,20 @@ def read_definition_file(fname: str) -> dict: elif field_dict_key == "diff": assert field_dict_val in diff_actions elif field_dict_key == "type": - assert isinstance(field_dict_val, str) + assert isinstance(field_dict_val, str) elif field_dict_key == "default": assert isinstance( field_dict_val, possible_default_types ) elif field_dict_key == "required": - assert isinstance(field_dict_val, bool) + assert isinstance(field_dict_val, bool) else: - raise RuntimeError(f"Invalid struct field dict key {field_dict_key!r}") + raise RuntimeError( + f"Invalid struct field dict key {field_dict_key!r}" + ) else: raise RuntimeError(f"Invalid struct attr {struct_attr_key!r}") - if section == "classes": for class_name, class_dict in structure[section].items(): assert "_" not in class_name @@ -294,8 +302,8 @@ def read_definition_file(fname: str) -> dict: elif class_attr_key == "diff": assert class_attr_value in diff_actions elif class_attr_key == "bases": - assert isinstance(class_attr_value, list) - assert all(isinstance(x, str) for x in class_attr_value) + assert isinstance(class_attr_value, list) + assert all(isinstance(x, str) for x in class_attr_value) elif class_attr_key == "properties": assert isinstance(class_attr_value, dict) for prop_name, prop_dict in class_attr_value.items(): @@ -307,9 +315,11 @@ def read_definition_file(fname: str) -> dict: elif prop_dict_key == "diff": assert prop_dict_val in diff_actions elif prop_dict_key == "type": - assert isinstance(prop_dict_val, str) + assert isinstance(prop_dict_val, str) else: - raise RuntimeError(f"Invalid property dict key {prop_dict_key!r}") + raise RuntimeError( + f"Invalid property dict key {prop_dict_key!r}" + ) elif class_attr_key == "methods": assert isinstance(class_attr_value, dict) for method_name, method_dict in class_attr_value.items(): @@ -322,19 +332,27 @@ def read_definition_file(fname: str) -> dict: assert method_dict_val in diff_actions elif method_dict_key == "returns": assert isinstance(method_dict_val, dict) - for return_dict_key, return_dict_val in method_dict_val.items(): + for ( + return_dict_key, + return_dict_val, + ) in method_dict_val.items(): if return_dict_key == "doc": assert isinstance(return_dict_val, str) elif return_dict_key == "type": assert isinstance(return_dict_val, str) else: - raise RuntimeError(f"Invalid method returns dict key {return_dict_key!r}") + raise RuntimeError( + f"Invalid method returns dict key {return_dict_key!r}" + ) elif method_dict_key == "args": assert isinstance(method_dict_val, dict) for arg_name, arg_dict in method_dict_val.items(): assert arg_name.lower() == arg_name assert isinstance(arg_dict, dict) - for arg_dict_key, arg_dict_val in arg_dict.items(): + for ( + arg_dict_key, + arg_dict_val, + ) in arg_dict.items(): if arg_dict_key == "doc": assert isinstance(arg_dict_val, str) elif arg_dict_key == "diff": @@ -348,9 +366,13 @@ def read_definition_file(fname: str) -> dict: elif arg_dict_key == "required": assert isinstance(arg_dict_val, bool) else: - raise RuntimeError(f"Invalid method arg dict key {arg_dict_key!r}") + raise RuntimeError( + f"Invalid method arg dict key {arg_dict_key!r}" + ) else: - raise RuntimeError(f"Invalid method dict key {method_dict_key!r}") + raise RuntimeError( + f"Invalid method dict key {method_dict_key!r}" + ) else: raise RuntimeError(f"Invalid class attr {class_attr_key!r}") diff --git a/apigen/definitions/diff_base.json b/apigen/definitions/diff_base.json index c8f71191..1e14230e 100644 --- a/apigen/definitions/diff_base.json +++ b/apigen/definitions/diff_base.json @@ -14,7 +14,13 @@ "methods": { "import_external_texture": { "diff": "REMOVE" } } - } + }, + "NavigatorGPU": { "diff": "REMOVE" }, + "GPUExternalTexture": { "diff": "REMOVE" }, + "GPUUncapturedErrorEvent": { "diff": "REMOVE" }, + "GPUSupportedLimits": { "diff": "REMOVE" }, + "GPUSupportedFeatures": { "diff": "REMOVE" }, + "WGSLLanguageFeatures": { "diff": "REMOVE" } }, "structs": { "ExternalTextureBindingLayout": { "diff": "REMOVE" }, diff --git a/apigen/definitions/wgpu_api_web.json b/apigen/definitions/wgpu_api_web.json index 1dfb01bf..7b38373d 100644 --- a/apigen/definitions/wgpu_api_web.json +++ b/apigen/definitions/wgpu_api_web.json @@ -947,6 +947,58 @@ }, "methods": { } }, + "GPUSupportedLimits": { + "bases": [ ], + "properties": { + "max_texture_dimension_1d": { "type": "int" }, + "max_texture_dimension_2d": { "type": "int" }, + "max_texture_dimension_3d": { "type": "int" }, + "max_texture_array_layers": { "type": "int" }, + "max_bind_groups": { "type": "int" }, + "max_bind_groups_plus_vertex_buffers": { "type": "int" }, + "max_immediate_size": { "type": "int" }, + "max_bindings_per_bind_group": { "type": "int" }, + "max_dynamic_uniform_buffers_per_pipeline_layout": { "type": "int" }, + "max_dynamic_storage_buffers_per_pipeline_layout": { "type": "int" }, + "max_sampled_textures_per_shader_stage": { "type": "int" }, + "max_samplers_per_shader_stage": { "type": "int" }, + "max_storage_buffers_per_shader_stage": { "type": "int" }, + "max_storage_buffers_in_vertex_stage": { "type": "int" }, + "max_storage_buffers_in_fragment_stage": { "type": "int" }, + "max_storage_textures_per_shader_stage": { "type": "int" }, + "max_storage_textures_in_vertex_stage": { "type": "int" }, + "max_storage_textures_in_fragment_stage": { "type": "int" }, + "max_uniform_buffers_per_shader_stage": { "type": "int" }, + "max_uniform_buffer_binding_size": { "type": "int" }, + "max_storage_buffer_binding_size": { "type": "int" }, + "min_uniform_buffer_offset_alignment": { "type": "int" }, + "min_storage_buffer_offset_alignment": { "type": "int" }, + "max_vertex_buffers": { "type": "int" }, + "max_buffer_size": { "type": "int" }, + "max_vertex_attributes": { "type": "int" }, + "max_vertex_buffer_array_stride": { "type": "int" }, + "max_inter_stage_shader_variables": { "type": "int" }, + "max_color_attachments": { "type": "int" }, + "max_color_attachment_bytes_per_sample": { "type": "int" }, + "max_compute_workgroup_storage_size": { "type": "int" }, + "max_compute_invocations_per_workgroup": { "type": "int" }, + "max_compute_workgroup_size_x": { "type": "int" }, + "max_compute_workgroup_size_y": { "type": "int" }, + "max_compute_workgroup_size_z": { "type": "int" }, + "max_compute_workgroups_per_dimension": { "type": "int" } + }, + "methods": { } + }, + "GPUSupportedFeatures": { + "bases": [ ], + "properties": { }, + "methods": { } + }, + "WGSLLanguageFeatures": { + "bases": [ ], + "properties": { }, + "methods": { } + }, "GPUAdapterInfo": { "bases": [ ], "properties": { @@ -960,6 +1012,13 @@ }, "methods": { } }, + "NavigatorGPU": { + "bases": [ ], + "properties": { + "gpu": { "type": "GPU" } + }, + "methods": { } + }, "GPU": { "bases": [ ], "properties": { @@ -1175,6 +1234,11 @@ "properties": { }, "methods": { } }, + "GPUExternalTexture": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, "GPUSampler": { "bases": [ "GPUObjectBase" ], "properties": { }, @@ -1711,6 +1775,21 @@ } } } + }, + "GPUUncapturedErrorEvent": { + "bases": [ "Event" ], + "properties": { + "error": { "type": "GPUError" } + }, + "methods": { + "constructor": { + "returns": { "type": "None" }, + "args": { + "type": { "type": "str", "default": null, "required": true }, + "gpu_uncaptured_error_event_init_dict": { "type": "structs.UncapturedErrorEventInitStruct", "default": null, "required": true } + } + } + } } } } diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 5489eb3c..5de2a42c 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -403,18 +403,6 @@ def _post_process(self): we do that here. """ - # Drop some toplevel names - # TODO: drop in apidiff - for name in [ - "NavigatorGPU", - "GPUSupportedLimits", - "GPUSupportedFeatures", - "WGSLLanguageFeatures", - "GPUUncapturedErrorEvent", - "GPUExternalTexture", - ]: - self._interfaces.pop(name, None) - # Divide flags and class definitions for name, interface in self._interfaces.items(): if interface.constants: @@ -462,7 +450,7 @@ def _post_process(self): return_type = self.resolve_type(return_type) if funcname.lower().endswith( "async" - ): # TODO: doesn't the type handle this already? + ): # TODO: doesn't the type-resolving handle this already? return_type = f"GPUPromise[{return_type}]" for arg in args: arg.py_name = to_snake_case(arg.name) From 9197997b3e95797c0bdfa0ae14dd2ced2c31e74e Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 15 Oct 2026 22:35:58 +0200 Subject: [PATCH 04/10] tweak how defaults/required is handled --- apigen/README.md | 6 +- apigen/apigen_utils.py | 13 +- apigen/definitions/test.json | 69 --- apigen/definitions/wgpu_api.json | 827 +++++++-------------------- apigen/definitions/wgpu_api_web.json | 709 ++++++++++++----------- apigen/extract_idl.py | 29 +- apigen/write_api.py | 13 +- 7 files changed, 574 insertions(+), 1092 deletions(-) delete mode 100644 apigen/definitions/test.json diff --git a/apigen/README.md b/apigen/README.md index 20eb1f2d..c5b5e0a8 100644 --- a/apigen/README.md +++ b/apigen/README.md @@ -73,8 +73,7 @@ The structure has some two dozen leaf nodes and looks a bit like this: "some_field": { "doc": "", "type": "int", - "default": 0, - "required": false + "default": "0" } } } @@ -101,8 +100,7 @@ The structure has some two dozen leaf nodes and looks a bit like this: "some_arg": { "doc": "", "type": "", - "default": "", - "required": true + "default": "" } } } diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py index 239bfc5f..17c82ab2 100644 --- a/apigen/apigen_utils.py +++ b/apigen/apigen_utils.py @@ -183,7 +183,6 @@ def read_definition_file(fname: str) -> dict: source = read_file("apigen", "definitions", fname) structure = json.loads(source) - possible_default_types = (None.__class__, int, float, str, list, dict) diff_actions = ("REMOVE",) assert ( @@ -281,11 +280,7 @@ def read_definition_file(fname: str) -> dict: elif field_dict_key == "type": assert isinstance(field_dict_val, str) elif field_dict_key == "default": - assert isinstance( - field_dict_val, possible_default_types - ) - elif field_dict_key == "required": - assert isinstance(field_dict_val, bool) + assert isinstance(field_dict_val, str) else: raise RuntimeError( f"Invalid struct field dict key {field_dict_key!r}" @@ -360,11 +355,7 @@ def read_definition_file(fname: str) -> dict: elif arg_dict_key == "type": assert isinstance(arg_dict_val, str) elif arg_dict_key == "default": - assert isinstance( - arg_dict_val, possible_default_types - ) - elif arg_dict_key == "required": - assert isinstance(arg_dict_val, bool) + assert isinstance(arg_dict_val, str) else: raise RuntimeError( f"Invalid method arg dict key {arg_dict_key!r}" diff --git a/apigen/definitions/test.json b/apigen/definitions/test.json deleted file mode 100644 index 18272efd..00000000 --- a/apigen/definitions/test.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "flags": { - "SomeFlag": { - "doc": "", - "fields": { - "SOME_FIELD": { - "doc": "", - "value": 1 - } - } - } - }, - - "enums": { - "SomeEnum": { - "doc": "", - "fields": { - "some_field": { - "doc": "", - "value": "some-field" - } - } - } - }, - - "structs": { - "SomeStruct": { - "doc": "", - "fields": { - "some_field": { - "doc": "", - "type": "int", - "default": 0, - "required": false - } - } - } - }, - - "classes": { - "GPUSomeClass": { - "doc": "", - "bases": ["GPUObject"], - "properties": { - "some_prop": { - "doc": "", - "type": "int" - } - }, - "methods": { - "some_method": { - "doc": "", - "returns": { - "doc": "", - "type": "None" - }, - "args": { - "some_arg": { - "doc": "", - "type": "", - "default": "", - "required": true - } - } - } - } - } - } -} diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json index 4c189876..a032c457 100644 --- a/apigen/definitions/wgpu_api.json +++ b/apigen/definitions/wgpu_api.json @@ -960,25 +960,21 @@ "feature_level": { "type": "str", "default": "\"core\"", - "required": false, "doc": "The feature level to request: 'core' (default) or 'compatibility'. Core implies the default limits and enums.FeatureName.core_features_and_limits; compatibility has stricter, more widely supported defaults and no features. If the implementation cannot enforce the compatibility rules it treats the request as core. If the level is not supported, no adapter is returned." }, "power_preference": { "type": "enums.PowerPreferenceEnum", - "default": null, - "required": false, + "default": "None", "doc": "Hint for the kind of adapter to select, see enums.PowerPreference. It may influence which adapter is chosen (mainly in multi-GPU systems), but never whether an adapter is returned." }, "force_fallback_adapter": { "type": "bool", "default": "False", - "required": false, "doc": "If true, only a fallback adapter may be returned (no adapter if unsupported). If false, a fallback adapter may still be returned; check the is_fallback_adapter property of GPUAdapterInfo to avoid it." }, "xr_compatible": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." } }, @@ -989,25 +985,21 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the device, used in debugging and error messages." }, "required_features": { "type": "list[enums.FeatureNameEnum]", "default": "[]", - "required": false, "doc": "A list of enums.FeatureName that the device must support. The request fails if the adapter cannot provide them. Exactly this set of features, no more and no less, is allowed on the resulting device." }, "required_limits": { "type": "dict[str, int | None]", "default": "{}", - "required": false, "doc": "A mapping of limit names to the values the device requires; the request fails if the adapter cannot provide them. Unspecified limits get their default value. Validation on the device uses these exact limits, not the (possibly higher) limits of the adapter." }, "default_queue": { "type": "structs.QueueDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.QueueDescriptor with options for the default queue of the device." } }, @@ -1018,20 +1010,17 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the buffer, used in debugging and error messages." }, - "size": { "type": "int", "default": null, "required": true, "doc": "The size of the buffer in bytes." }, + "size": { "type": "int", "default": "", "doc": "The size of the buffer in bytes." }, "usage": { "type": "flags.BufferUsageFlags", - "default": null, - "required": true, + "default": "", "doc": "The allowed usages of the buffer, a combination of flags.BufferUsage." }, "mapped_at_creation": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the buffer is created in a mapped state so GPUBuffer.get_mapped_range() can be called immediately, which is useful to set initial data. This is allowed even without flags.BufferUsage.MAP_READ or flags.BufferUsage.MAP_WRITE. The size must then be a multiple of 4." } }, @@ -1042,50 +1031,42 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the texture, used in debugging and error messages." }, "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", - "default": null, - "required": true, + "default": "", "doc": "The size of the texture as a structs.Extent3D, or a tuple of (width, height, depth_or_array_layers). Height and depth default to 1." }, - "mip_level_count": { "type": "int", "default": "1", "required": false, "doc": "The number of mip levels. Defaults to 1." }, + "mip_level_count": { "type": "int", "default": "1", "doc": "The number of mip levels. Defaults to 1." }, "sample_count": { "type": "int", "default": "1", - "required": false, "doc": "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." }, "dimension": { "type": "enums.TextureDimensionEnum", "default": "\"2d\"", - "required": false, "doc": "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." }, "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The pixel format of the texture, see enums.TextureFormat." }, "usage": { "type": "flags.TextureUsageFlags", - "default": null, - "required": true, + "default": "", "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." }, "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", - "required": false, "doc": "Additional enums.TextureFormat values that views of this texture may use in GPUTexture.create_view(). They must be view-compatible with the texture format: equal, or (on devices with enums.FeatureName.core_features_and_limits) differing only in sRGB-ness. Adding formats can hurt performance on some systems, so only add what is needed." }, "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum", - "default": null, - "required": false, + "default": "None", "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. A default is chosen if omitted. Ignored on core devices." } }, @@ -1096,61 +1077,47 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the texture view, used in debugging and error messages." }, "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": false, + "default": "None", "doc": "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." }, "dimension": { "type": "enums.TextureViewDimensionEnum", - "default": null, - "required": false, + "default": "None", "doc": "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." }, "usage": { "type": "flags.TextureUsageFlags", "default": "0", - "required": false, "doc": "The usages the view will be used for, a subset of the usage of the texture (see flags.TextureUsage). If 0 or omitted, defaults to all usages of the texture; this fails if the view format does not support all of them, in which case set it explicitly." }, "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", - "required": false, "doc": "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." }, - "base_mip_level": { - "type": "int", - "default": "0", - "required": false, - "doc": "The first mip level accessible via the view. Defaults to 0." - }, + "base_mip_level": { "type": "int", "default": "0", "doc": "The first mip level accessible via the view. Defaults to 0." }, "mip_level_count": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." }, "base_array_layer": { "type": "int", "default": "0", - "required": false, "doc": "The first array layer accessible via the view. Defaults to 0." }, "array_layer_count": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." }, "swizzle": { "type": "str", "default": "\"rgba\"", - "required": false, "doc": "A string of four characters (default 'rgba') that defines how the components of the view are mapped, e.g. 'bgra'. Allowed characters are r, g, b, a, 0 and 1. Requires enums.FeatureName.texture_component_swizzle." } }, @@ -1161,19 +1128,16 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the external texture, used in debugging and error messages." }, "source": { "type": "ArrayLike | object", - "default": null, - "required": true, + "default": "", "doc": "The source of the image data, e.g. a video element or video frame. Only meaningful in browser environments." }, "color_space": { "type": "str", "default": "\"srgb\"", - "required": false, "doc": "The color space of the source image, e.g. 'srgb'. Defaults to 'srgb'." } }, @@ -1184,67 +1148,56 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the sampler, used in debugging and error messages." }, "address_mode_u": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", - "required": false, "doc": "How to handle texture coordinates outside 0..1 along the u (x) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, "address_mode_v": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", - "required": false, "doc": "How to handle texture coordinates outside 0..1 along the v (y) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, "address_mode_w": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", - "required": false, "doc": "How to handle texture coordinates outside 0..1 along the w (z) axis, see enums.AddressMode. Defaults to clamp_to_edge." }, "mag_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", - "required": false, "doc": "The filter used when the sampled area is smaller than or equal to one texel (magnification), see enums.FilterMode. Defaults to nearest." }, "min_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", - "required": false, "doc": "The filter used when the sampled area is larger than one texel (minification), see enums.FilterMode. Defaults to nearest." }, "mipmap_filter": { "type": "enums.MipmapFilterModeEnum", "default": "\"nearest\"", - "required": false, "doc": "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." }, "lod_min_clamp": { "type": "float", "default": "0", - "required": false, "doc": "The minimum level of detail used when sampling. Defaults to 0." }, "lod_max_clamp": { "type": "float", "default": "32", - "required": false, "doc": "The maximum level of detail used when sampling. Defaults to 32." }, "compare": { "type": "enums.CompareFunctionEnum", - "default": null, - "required": false, + "default": "None", "doc": "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures. Filtering results of comparison samplers are implementation-dependent." }, "max_anisotropy": { "type": "int", "default": "1", - "required": false, "doc": "The maximum anisotropy for anisotropic filtering: 1 (default) disables it. Values above 1 require all filters to be linear. The value is clamped to the platform maximum (typically 16)." } }, @@ -1255,13 +1208,11 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the bind group layout, used in debugging and error messages." }, "entries": { "type": "list[structs.BindGroupLayoutEntryStruct]", - "default": null, - "required": true, + "default": "", "doc": "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." } }, @@ -1271,38 +1222,32 @@ "fields": { "binding": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The binding number, matching the @binding attribute in the shader." }, "visibility": { "type": "flags.ShaderStageFlags", - "default": null, - "required": true, + "default": "", "doc": "The shader stages in which the resource is visible, a combination of flags.ShaderStage." }, "buffer": { "type": "structs.BufferBindingLayoutStruct", - "default": null, - "required": false, + "default": "None", "doc": "If set, a structs.BufferBindingLayout: the entry is a buffer binding." }, "sampler": { "type": "structs.SamplerBindingLayoutStruct", - "default": null, - "required": false, + "default": "None", "doc": "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." }, "texture": { "type": "structs.TextureBindingLayoutStruct", - "default": null, - "required": false, + "default": "None", "doc": "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." }, "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct", - "default": null, - "required": false, + "default": "None", "doc": "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." } }, @@ -1313,19 +1258,16 @@ "type": { "type": "enums.BufferBindingTypeEnum", "default": "\"uniform\"", - "required": false, "doc": "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." }, "has_dynamic_offset": { "type": "bool", "default": "False", - "required": false, "doc": "If true, an offset can be given in GPUBindingCommandsMixin.set_bind_group() when binding. Defaults to false." }, "min_binding_size": { "type": "int", "default": "0", - "required": false, "doc": "The minimum size in bytes of a buffer bound to this entry; bindings are always validated against it in GPUDevice.create_bind_group(). If non-zero, pipeline creation also checks it against the minimum binding size of the shader variable. If 0 (default), that check is skipped at pipeline creation and done at draw/dispatch time instead." } }, @@ -1336,7 +1278,6 @@ "type": { "type": "enums.SamplerBindingTypeEnum", "default": "\"filtering\"", - "required": false, "doc": "The type of sampler binding, see enums.SamplerBindingType. Defaults to filtering." } }, @@ -1347,19 +1288,16 @@ "sample_type": { "type": "enums.TextureSampleTypeEnum", "default": "\"float\"", - "required": false, "doc": "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." }, "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", - "required": false, "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." }, "multisampled": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the bound texture must be multisampled. Defaults to false." } }, @@ -1370,19 +1308,16 @@ "access": { "type": "enums.StorageTextureAccessEnum", "default": "\"write-only\"", - "required": false, "doc": "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." }, "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The enums.TextureFormat that the bound texture view must have." }, "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", - "required": false, "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." } }, @@ -1393,19 +1328,16 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the bind group, used in debugging and error messages." }, "layout": { "type": "GPUBindGroupLayout", - "default": null, - "required": true, + "default": "", "doc": "The GPUBindGroupLayout that this bind group conforms to." }, "entries": { "type": "list[structs.BindGroupEntryStruct]", - "default": null, - "required": true, + "default": "", "doc": "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." } }, @@ -1415,14 +1347,12 @@ "fields": { "binding": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." }, "resource": { "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", - "default": null, - "required": true, + "default": "", "doc": "The resource to bind: a GPUSampler, GPUTexture (as its default view), GPUTextureView, GPUBuffer (the whole buffer), structs.BufferBinding, or GPUExternalTexture. Must match the type in the corresponding layout entry." } }, @@ -1430,17 +1360,15 @@ }, "BufferBinding": { "fields": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to bind." }, + "buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to bind." }, "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes into the buffer where the binding starts. Defaults to 0." }, "size": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." } }, @@ -1451,19 +1379,16 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the pipeline layout, used in debugging and error messages." }, "bind_group_layouts": { "type": "list[GPUBindGroupLayout]", - "default": null, - "required": true, + "default": "", "doc": "A list of GPUBindGroupLayout (or None for unused groups) used by the pipeline. The Nth element corresponds to @group(N) in the shader." }, "immediate_size": { "type": "int", "default": "0", - "required": false, "doc": "The size in bytes of the immediate data (small data set with GPUBindingCommandsMixin.set_immediates()). Defaults to 0." } }, @@ -1474,14 +1399,12 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the shader module, used in debugging and error messages." }, - "code": { "type": "str", "default": null, "required": true, "doc": "The shader source code, in WGSL." }, + "code": { "type": "str", "default": "", "doc": "The shader source code, in WGSL." }, "compilation_hints": { "type": "list[structs.ShaderModuleCompilationHintStruct]", "default": "[]", - "required": false, "doc": "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile early. Hints only affect performance, are not validated, and only apply to the entry points they name (there is no default entry point)." } }, @@ -1489,16 +1412,10 @@ }, "ShaderModuleCompilationHint": { "fields": { - "entry_point": { - "type": "str", - "default": null, - "required": true, - "doc": "The name of the shader entry point that the hint applies to." - }, + "entry_point": { "type": "str", "default": "", "doc": "The name of the shader entry point that the hint applies to." }, "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", - "default": null, - "required": false, + "default": "None", "doc": "The GPUPipelineLayout that the entry point will be used with, or enums.AutoLayoutMode.auto (the default pipeline layout for that entry point)." } }, @@ -1508,8 +1425,7 @@ "fields": { "reason": { "type": "enums.PipelineErrorReasonEnum", - "default": null, - "required": true, + "default": "", "doc": "The reason for the error, see enums.PipelineErrorReason." } }, @@ -1517,22 +1433,15 @@ }, "ProgrammableStage": { "fields": { - "module": { - "type": "GPUShaderModule", - "default": null, - "required": true, - "doc": "The GPUShaderModule containing the shader code." - }, + "module": { "type": "GPUShaderModule", "default": "", "doc": "The GPUShaderModule containing the shader code." }, "entry_point": { "type": "str", - "default": null, - "required": false, + "default": "None", "doc": "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." }, "constants": { "type": "dict[str, float]", "default": "{}", - "required": false, "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." } }, @@ -1543,19 +1452,16 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the pipeline, used in debugging and error messages." }, "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", - "default": null, - "required": true, + "default": "", "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." }, "compute": { "type": "structs.ProgrammableStageStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.ProgrammableStage describing the compute shader." } }, @@ -1566,43 +1472,36 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the pipeline, used in debugging and error messages." }, "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", - "default": null, - "required": true, + "default": "", "doc": "The GPUPipelineLayout for the pipeline, or enums.AutoLayoutMode.auto to derive it from the shader(s). With auto, the pipeline cannot share bind groups with other pipelines." }, "vertex": { "type": "structs.VertexStateStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.VertexState describing the vertex shader and vertex buffers." }, "primitive": { "type": "structs.PrimitiveStateStruct", "default": "{}", - "required": false, "doc": "A structs.PrimitiveState describing how primitives are assembled and rasterized." }, "depth_stencil": { "type": "structs.DepthStencilStateStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." }, "multisample": { "type": "structs.MultisampleStateStruct", "default": "{}", - "required": false, "doc": "A structs.MultisampleState describing multisampling." }, "fragment": { "type": "structs.FragmentStateStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.FragmentState describing the fragment shader and render targets. If omitted, the pipeline has no color output (e.g. for depth-only passes)." } }, @@ -1613,31 +1512,26 @@ "topology": { "type": "enums.PrimitiveTopologyEnum", "default": "\"triangle-list\"", - "required": false, "doc": "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." }, "strip_index_format": { "type": "enums.IndexFormatEnum", - "default": null, - "required": false, + "default": "None", "doc": "The enums.IndexFormat of the index buffer, which sets the primitive restart value (0xFFFF for uint16, 0xFFFFFFFF for uint32). Only allowed for strip topologies, where it is required for indexed draws and must match the format given to GPURenderCommandsMixin.set_index_buffer()." }, "front_face": { "type": "enums.FrontFaceEnum", "default": "\"ccw\"", - "required": false, "doc": "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." }, "cull_mode": { "type": "enums.CullModeEnum", "default": "\"none\"", - "required": false, "doc": "Which faces to cull, see enums.CullMode. Defaults to none." }, "unclipped_depth": { "type": "bool", "default": "False", - "required": false, "doc": "If true, primitives are not clipped by the near and far planes. Requires enums.FeatureName.depth_clip_control." } }, @@ -1648,19 +1542,16 @@ "count": { "type": "int", "default": "1", - "required": false, "doc": "The number of samples per pixel. Must be 1 or 4. The pipeline is only compatible with attachments that have a matching sample count. Defaults to 1." }, "mask": { "type": "int", "default": "0xFFFFFFFF", - "required": false, "doc": "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." }, "alpha_to_coverage_enabled": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the alpha output of the fragment shader is used to generate a coverage mask. Defaults to false." } }, @@ -1670,26 +1561,22 @@ "fields": { "module": { "type": "GPUShaderModule", - "default": null, - "required": true, + "default": "", "doc": "The GPUShaderModule containing the fragment shader code." }, "entry_point": { "type": "str", - "default": null, - "required": false, + "default": "None", "doc": "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." }, "constants": { "type": "dict[str, float]", "default": "{}", - "required": false, "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, "targets": { "type": "list[structs.ColorTargetStateStruct]", - "default": null, - "required": true, + "default": "", "doc": "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." } }, @@ -1699,20 +1586,17 @@ "fields": { "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The enums.TextureFormat of this color target. The pipeline is only compatible with render passes that use a view of this format in the corresponding color attachment." }, "blend": { "type": "structs.BlendStateStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." }, "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF", - "required": false, "doc": "Which channels are written, a combination of flags.ColorWrite. Defaults to ALL." } }, @@ -1722,14 +1606,12 @@ "fields": { "color": { "type": "structs.BlendComponentStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.BlendComponent for the color (RGB) channels." }, "alpha": { "type": "structs.BlendComponentStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.BlendComponent for the alpha channel." } }, @@ -1740,19 +1622,16 @@ "operation": { "type": "enums.BlendOperationEnum", "default": "\"add\"", - "required": false, "doc": "The enums.BlendOperation used to combine the scaled values. Defaults to add." }, "src_factor": { "type": "enums.BlendFactorEnum", "default": "\"one\"", - "required": false, "doc": "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." }, "dst_factor": { "type": "enums.BlendFactorEnum", "default": "\"zero\"", - "required": false, "doc": "The enums.BlendFactor applied to the destination (existing target value). Defaults to zero." } }, @@ -1762,62 +1641,52 @@ "fields": { "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The enums.TextureFormat of the depth-stencil attachment that this pipeline is compatible with." }, "depth_write_enabled": { "type": "bool", - "default": null, - "required": false, + "default": "None", "doc": "If true, depth values of fragments that pass the depth test are written to the attachment." }, "depth_compare": { "type": "enums.CompareFunctionEnum", - "default": null, - "required": false, + "default": "None", "doc": "The enums.CompareFunction used for the depth test." }, "stencil_front": { "type": "structs.StencilFaceStateStruct", "default": "{}", - "required": false, "doc": "A structs.StencilFaceState for front-facing primitives." }, "stencil_back": { "type": "structs.StencilFaceStateStruct", "default": "{}", - "required": false, "doc": "A structs.StencilFaceState for back-facing primitives." }, "stencil_read_mask": { "type": "int", "default": "0xFFFFFFFF", - "required": false, "doc": "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." }, "stencil_write_mask": { "type": "int", "default": "0xFFFFFFFF", - "required": false, "doc": "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." }, "depth_bias": { "type": "int", "default": "0", - "required": false, "doc": "A constant depth value added to each fragment. Defaults to 0." }, "depth_bias_slope_scale": { "type": "float", "default": "0", - "required": false, "doc": "A depth bias that scales with the slope of the primitive. Defaults to 0." }, "depth_bias_clamp": { "type": "float", "default": "0", - "required": false, "doc": "The maximum (or minimum, if negative) depth bias of a fragment. Defaults to 0." } }, @@ -1828,25 +1697,21 @@ "compare": { "type": "enums.CompareFunctionEnum", "default": "\"always\"", - "required": false, "doc": "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." }, "fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", - "required": false, "doc": "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." }, "depth_fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", - "required": false, "doc": "The enums.StencilOperation performed if the stencil test passes but the depth test fails. Defaults to keep." }, "pass_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", - "required": false, "doc": "The enums.StencilOperation performed if both the stencil and depth tests pass. Defaults to keep." } }, @@ -1856,26 +1721,22 @@ "fields": { "module": { "type": "GPUShaderModule", - "default": null, - "required": true, + "default": "", "doc": "The GPUShaderModule containing the vertex shader code." }, "entry_point": { "type": "str", - "default": null, - "required": false, + "default": "None", "doc": "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." }, "constants": { "type": "dict[str, float]", "default": "{}", - "required": false, "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, "buffers": { "type": "list[structs.VertexBufferLayoutStruct]", "default": "[]", - "required": false, "doc": "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." } }, @@ -1885,20 +1746,17 @@ "fields": { "array_stride": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The stride in bytes between consecutive elements in the buffer." }, "step_mode": { "type": "enums.VertexStepModeEnum", "default": "\"vertex\"", - "required": false, "doc": "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." }, "attributes": { "type": "list[structs.VertexAttributeStruct]", - "default": null, - "required": true, + "default": "", "doc": "A list of structs.VertexAttribute describing the attributes in each element." } }, @@ -1906,22 +1764,15 @@ }, "VertexAttribute": { "fields": { - "format": { - "type": "enums.VertexFormatEnum", - "default": null, - "required": true, - "doc": "The enums.VertexFormat of the attribute." - }, + "format": { "type": "enums.VertexFormatEnum", "default": "", "doc": "The enums.VertexFormat of the attribute." }, "offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes of the attribute from the start of an element in the buffer." }, "shader_location": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The location number of the attribute in the vertex shader (the @location attribute)." } }, @@ -1932,19 +1783,16 @@ "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes into the data where the texel data starts. Defaults to 0." }, "bytes_per_row": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row of texel blocks. Must be a multiple of 256 for buffer copies (not for GPUQueue.write_texture())." }, "rows_per_image": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The number of rows of texel blocks per image (layer or slice); times bytes_per_row it is the stride between images. Required if the copy has more than one image." } }, @@ -1955,25 +1803,21 @@ "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes into the buffer where the texel data starts. Defaults to 0." }, "bytes_per_row": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row. Must be a multiple of 256." }, "rows_per_image": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The number of rows of texel blocks per image (layer or slice). Required if the copy has more than one image." }, "buffer": { "type": "GPUBuffer", - "default": null, - "required": true, + "default": "", "doc": "The GPUBuffer that contains (or will contain) the texel data." } }, @@ -1981,28 +1825,16 @@ }, "TexelCopyTextureInfo": { "fields": { - "texture": { - "type": "GPUTexture", - "default": null, - "required": true, - "doc": "The GPUTexture to copy to or from." - }, - "mip_level": { - "type": "int", - "default": "0", - "required": false, - "doc": "The mip level to copy to or from. Defaults to 0." - }, + "texture": { "type": "GPUTexture", "default": "", "doc": "The GPUTexture to copy to or from." }, + "mip_level": { "type": "int", "default": "0", "doc": "The mip level to copy to or from. Defaults to 0." }, "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}", - "required": false, "doc": "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." }, "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", - "required": false, "doc": "Which aspect of the texture to copy, see enums.TextureAspect. Defaults to all." } }, @@ -2013,7 +1845,6 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the command buffer, used in debugging and error messages." } }, @@ -2024,7 +1855,6 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the command encoder, used in debugging and error messages." } }, @@ -2034,20 +1864,17 @@ "fields": { "query_set": { "type": "GPUQuerySet", - "default": null, - "required": true, + "default": "", "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, "beginning_of_pass_write_index": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, "end_of_pass_write_index": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } }, @@ -2058,13 +1885,11 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the compute pass, used in debugging and error messages." }, "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." } }, @@ -2074,20 +1899,17 @@ "fields": { "query_set": { "type": "GPUQuerySet", - "default": null, - "required": true, + "default": "", "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, "beginning_of_pass_write_index": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, "end_of_pass_write_index": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } }, @@ -2098,37 +1920,31 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the render pass, used in debugging and error messages." }, "color_attachments": { "type": "list[structs.RenderPassColorAttachmentStruct]", - "default": null, - "required": true, + "default": "", "doc": "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to. Attachments may not alias each other or any resource used inside the pass." }, "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." }, "occlusion_query_set": { "type": "GPUQuerySet", - "default": null, - "required": false, + "default": "None", "doc": "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." }, "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct", - "default": null, - "required": false, + "default": "None", "doc": "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." }, "max_draw_count": { "type": "int", "default": "50000000", - "required": false, "doc": "A hint for the maximum number of draw calls in the pass, used by some implementations to size internal work. The default is fine unless more draws are expected. Defaults to 50000000." } }, @@ -2138,38 +1954,32 @@ "fields": { "view": { "type": "GPUTexture | GPUTextureView", - "default": null, - "required": true, + "default": "", "doc": "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, "depth_slice": { "type": "int", - "default": null, - "required": false, + "default": "None", "doc": "For 3D textures, the index of the depth slice to render to." }, "resolve_target": { "type": "GPUTexture | GPUTextureView", - "default": null, - "required": false, + "default": "None", "doc": "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." }, "clear_value": { "type": "tuple[float, float, float, float] | structs.ColorStruct", - "default": null, - "required": false, + "default": "None", "doc": "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." }, "load_op": { "type": "enums.LoadOpEnum", - "default": null, - "required": true, + "default": "", "doc": "What to do with the existing contents at the start of the pass, see enums.LoadOp." }, "store_op": { "type": "enums.StoreOpEnum", - "default": null, - "required": true, + "default": "", "doc": "What to do with the results at the end of the pass, see enums.StoreOp." } }, @@ -2179,56 +1989,47 @@ "fields": { "view": { "type": "GPUTexture | GPUTextureView", - "default": null, - "required": true, + "default": "", "doc": "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, "depth_clear_value": { "type": "float", - "default": null, - "required": false, + "default": "None", "doc": "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." }, "depth_load_op": { "type": "enums.LoadOpEnum", - "default": null, - "required": false, + "default": "None", "doc": "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." }, "depth_store_op": { "type": "enums.StoreOpEnum", - "default": null, - "required": false, + "default": "None", "doc": "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." }, "depth_read_only": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the depth aspect is read-only in the pass (it is not written to). Defaults to false." }, "stencil_clear_value": { "type": "int", "default": "0", - "required": false, "doc": "The value to clear the stencil aspect to if stencil_load_op is clear. Truncated to the bit size of the stencil aspect (the least significant bits are kept). Defaults to 0." }, "stencil_load_op": { "type": "enums.LoadOpEnum", - "default": null, - "required": false, + "default": "None", "doc": "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." }, "stencil_store_op": { "type": "enums.StoreOpEnum", - "default": null, - "required": false, + "default": "None", "doc": "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." }, "stencil_read_only": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the stencil aspect is read-only in the pass (it is not written to). Defaults to false." } }, @@ -2239,25 +2040,21 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label, used in debugging and error messages." }, "color_formats": { "type": "list[enums.TextureFormatEnum]", - "default": null, - "required": true, + "default": "", "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments." }, "depth_stencil_format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": false, + "default": "None", "doc": "The enums.TextureFormat of the depth-stencil attachment, if any." }, "sample_count": { "type": "int", "default": "1", - "required": false, "doc": "The number of samples per pixel of the attachments. Defaults to 1." } }, @@ -2268,7 +2065,6 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the render bundle, used in debugging and error messages." } }, @@ -2279,37 +2075,31 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the render bundle encoder, used in debugging and error messages." }, "color_formats": { "type": "list[enums.TextureFormatEnum]", - "default": null, - "required": true, + "default": "", "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." }, "depth_stencil_format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": false, + "default": "None", "doc": "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." }, "sample_count": { "type": "int", "default": "1", - "required": false, "doc": "The number of samples per pixel of the attachments the bundle will be used with. Defaults to 1." }, "depth_read_only": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the bundle does not write to the depth aspect. Defaults to false." }, "stencil_read_only": { "type": "bool", "default": "False", - "required": false, "doc": "If true, the bundle does not write to the stencil aspect. Defaults to false." } }, @@ -2320,7 +2110,6 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the queue, used in debugging and error messages." } }, @@ -2331,16 +2120,14 @@ "label": { "type": "str", "default": "\"\"", - "required": false, "doc": "A human-readable label for the query set, used in debugging and error messages." }, "type": { "type": "enums.QueryTypeEnum", - "default": null, - "required": true, + "default": "", "doc": "The type of queries in the set, see enums.QueryType." }, - "count": { "type": "int", "default": null, "required": true, "doc": "The number of queries in the set." } + "count": { "type": "int", "default": "", "doc": "The number of queries in the set." } }, "doc": "Descriptor for creating a GPUQuerySet.\n\nUsed as the descriptor argument of the GPUDevice.create_query_set() method.\n" }, @@ -2349,7 +2136,6 @@ "mode": { "type": "enums.CanvasToneMappingModeEnum", "default": "\"standard\"", - "required": false, "doc": "The tone mapping mode, see enums.CanvasToneMappingMode. Defaults to standard." } }, @@ -2359,44 +2145,37 @@ "fields": { "device": { "type": "GPUDevice", - "default": null, - "required": true, + "default": "", "doc": "The GPUDevice that the canvas textures will be used with." }, "format": { "type": "enums.TextureFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The enums.TextureFormat of the canvas textures; must be one of the supported canvas formats. Use GPU.get_preferred_canvas_format() for the best choice." }, "usage": { "type": "flags.TextureUsageFlags", "default": "0x10", - "required": false, "doc": "The usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT, but that is not added automatically when usage is set explicitly, so include it to render to the canvas texture." }, "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", - "required": false, "doc": "Additional enums.TextureFormat values that views of the canvas texture may use." }, "color_space": { "type": "str", "default": "\"srgb\"", - "required": false, "doc": "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." }, "tone_mapping": { "type": "structs.CanvasToneMappingStruct", "default": "{}", - "required": false, "doc": "A structs.CanvasToneMapping that describes how the canvas content is tone mapped. May not be supported everywhere; detect support with GPUCanvasContext.get_configuration()." }, "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"", - "required": false, "doc": "How the alpha channel of the canvas is interpreted, see enums.CanvasAlphaMode. Defaults to opaque." } }, @@ -2406,8 +2185,7 @@ "fields": { "error": { "type": "GPUError", - "default": null, - "required": true, + "default": "", "doc": "The GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError) that was not captured by an error scope." } }, @@ -2415,61 +2193,35 @@ }, "Color": { "fields": { - "r": { "type": "float", "default": null, "required": true, "doc": "The red component." }, - "g": { "type": "float", "default": null, "required": true, "doc": "The green component." }, - "b": { "type": "float", "default": null, "required": true, "doc": "The blue component." }, - "a": { "type": "float", "default": null, "required": true, "doc": "The alpha component." } + "r": { "type": "float", "default": "", "doc": "The red component." }, + "g": { "type": "float", "default": "", "doc": "The green component." }, + "b": { "type": "float", "default": "", "doc": "The blue component." }, + "a": { "type": "float", "default": "", "doc": "The alpha component." } }, "doc": "An RGBA color with floating point components.\n\nCan also be given as a tuple (r, g, b, a). Used e.g. in the clear_value field of structs.RenderPassColorAttachment.\n" }, "Origin2D": { "fields": { - "x": { - "type": "int", - "default": "0", - "required": false, - "doc": "The x coordinate (horizontal). Defaults to 0." - }, - "y": { - "type": "int", - "default": "0", - "required": false, - "doc": "The y coordinate (vertical). Defaults to 0." - } + "x": { "type": "int", "default": "0", "doc": "The x coordinate (horizontal). Defaults to 0." }, + "y": { "type": "int", "default": "0", "doc": "The y coordinate (vertical). Defaults to 0." } }, "doc": "A 2D origin (offset) in a texture or image, in texels.\n\nCan also be given as a tuple (x, y).\n" }, "Origin3D": { "fields": { - "x": { - "type": "int", - "default": "0", - "required": false, - "doc": "The x coordinate (horizontal). Defaults to 0." - }, - "y": { - "type": "int", - "default": "0", - "required": false, - "doc": "The y coordinate (vertical). Defaults to 0." - }, - "z": { - "type": "int", - "default": "0", - "required": false, - "doc": "The z coordinate (depth, or array layer). Defaults to 0." - } + "x": { "type": "int", "default": "0", "doc": "The x coordinate (horizontal). Defaults to 0." }, + "y": { "type": "int", "default": "0", "doc": "The y coordinate (vertical). Defaults to 0." }, + "z": { "type": "int", "default": "0", "doc": "The z coordinate (depth, or array layer). Defaults to 0." } }, "doc": "A 3D origin (offset) in a texture, in texels.\n\nCan also be given as a tuple (x, y, z).\n" }, "Extent3D": { "fields": { - "width": { "type": "int", "default": null, "required": true, "doc": "The width of the extent." }, - "height": { "type": "int", "default": "1", "required": false, "doc": "The height of the extent. Defaults to 1." }, + "width": { "type": "int", "default": "", "doc": "The width of the extent." }, + "height": { "type": "int", "default": "1", "doc": "The height of the extent. Defaults to 1." }, "depth_or_array_layers": { "type": "int", "default": "1", - "required": false, "doc": "The depth (for 3D textures) or the number of array layers (for other textures). Defaults to 1." } }, @@ -2526,7 +2278,6 @@ "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}", - "required": false, "doc": "A structs.RequestAdapterOptions with options for selecting the adapter." } }, @@ -2560,7 +2311,6 @@ "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.DeviceDescriptor with the required features and limits." } }, @@ -2605,8 +2355,7 @@ "args": { "descriptor": { "type": "structs.BufferDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.BufferDescriptor describing the buffer." } }, @@ -2617,8 +2366,7 @@ "args": { "descriptor": { "type": "structs.TextureDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TextureDescriptor describing the texture." } }, @@ -2630,7 +2378,6 @@ "descriptor": { "type": "structs.SamplerDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." } }, @@ -2641,8 +2388,7 @@ "args": { "descriptor": { "type": "structs.BindGroupLayoutDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.BindGroupLayoutDescriptor describing the entries of the layout." } }, @@ -2653,8 +2399,7 @@ "args": { "descriptor": { "type": "structs.PipelineLayoutDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.PipelineLayoutDescriptor describing the bind group layouts." } }, @@ -2665,8 +2410,7 @@ "args": { "descriptor": { "type": "structs.BindGroupDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.BindGroupDescriptor with the layout and the resources to bind." } }, @@ -2677,8 +2421,7 @@ "args": { "descriptor": { "type": "structs.ShaderModuleDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.ShaderModuleDescriptor containing the shader code." } }, @@ -2689,8 +2432,7 @@ "args": { "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.ComputePipelineDescriptor describing the pipeline." } }, @@ -2701,8 +2443,7 @@ "args": { "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.RenderPipelineDescriptor describing the pipeline." } }, @@ -2713,8 +2454,7 @@ "args": { "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.ComputePipelineDescriptor describing the pipeline." } }, @@ -2725,8 +2465,7 @@ "args": { "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.RenderPipelineDescriptor describing the pipeline." } }, @@ -2738,7 +2477,6 @@ "descriptor": { "type": "structs.CommandEncoderDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.CommandEncoderDescriptor. Optional." } }, @@ -2749,8 +2487,7 @@ "args": { "descriptor": { "type": "structs.RenderBundleEncoderDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.RenderBundleEncoderDescriptor describing the attachment formats." } }, @@ -2761,8 +2498,7 @@ "args": { "descriptor": { "type": "structs.QuerySetDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.QuerySetDescriptor describing the type and count of queries." } }, @@ -2773,8 +2509,7 @@ "args": { "filter": { "type": "enums.ErrorFilterEnum", - "default": null, - "required": true, + "default": "", "doc": "The type of error to capture, see enums.ErrorFilter." } }, @@ -2807,20 +2542,17 @@ "args": { "mode": { "type": "flags.MapModeFlags", - "default": null, - "required": true, + "default": "", "doc": "Whether to map for reading or writing, see flags.MapMode." }, "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } }, @@ -2832,13 +2564,11 @@ "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." } }, @@ -2886,7 +2616,6 @@ "descriptor": { "type": "structs.TextureViewDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." } }, @@ -2990,11 +2719,10 @@ "constructor": { "returns": { "type": "None", "doc": "A GPUPipelineError." }, "args": { - "message": { "type": "str", "default": "\"\"", "required": false, "doc": "The human-readable error message." }, + "message": { "type": "str", "default": "\"\"", "doc": "The human-readable error message." }, "options": { "type": "structs.PipelineErrorInitStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.PipelineErrorInit with the reason of the error." } }, @@ -3012,8 +2740,7 @@ "args": { "index": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The index of the bind group (the @group number in the shader)." } }, @@ -3055,8 +2782,7 @@ "args": { "descriptor": { "type": "structs.RenderPassDescriptorStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.RenderPassDescriptor describing the attachments of the pass." } }, @@ -3068,7 +2794,6 @@ "descriptor": { "type": "structs.ComputePassDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.ComputePassDescriptor. Optional." } }, @@ -3077,24 +2802,21 @@ "copy_buffer_to_buffer": { "returns": { "type": "None", "doc": "None." }, "args": { - "source": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to copy from." }, + "source": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to copy from." }, "source_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the source buffer where the copy starts." }, - "destination": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to copy to." }, + "destination": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to copy to." }, "destination_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the destination buffer where the data is written." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The number of bytes to copy. Defaults to the size of the source buffer minus the source_offset argument of this method." } }, @@ -3105,20 +2827,17 @@ "args": { "source": { "type": "structs.TexelCopyBufferInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." }, "destination": { "type": "structs.TexelCopyTextureInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." }, "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } }, @@ -3129,20 +2848,17 @@ "args": { "source": { "type": "structs.TexelCopyTextureInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." }, "destination": { "type": "structs.TexelCopyBufferInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." }, "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } }, @@ -3153,20 +2869,17 @@ "args": { "source": { "type": "structs.TexelCopyTextureInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." }, "destination": { "type": "structs.TexelCopyTextureInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." }, "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.Extent3D (or tuple) with the size of the region to copy, in texels." } }, @@ -3175,17 +2888,15 @@ "clear_buffer": { "returns": { "type": "None", "doc": "None." }, "args": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to clear." }, + "buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to clear." }, "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } }, @@ -3194,24 +2905,13 @@ "resolve_query_set": { "returns": { "type": "None", "doc": "None." }, "args": { - "query_set": { - "type": "GPUQuerySet", - "default": null, - "required": true, - "doc": "The GPUQuerySet to read results from." - }, - "first_query": { "type": "int", "default": null, "required": true, "doc": "The index of the first query to resolve." }, - "query_count": { "type": "int", "default": null, "required": true, "doc": "The number of queries to resolve." }, - "destination": { - "type": "GPUBuffer", - "default": null, - "required": true, - "doc": "The GPUBuffer to write the results to." - }, + "query_set": { "type": "GPUQuerySet", "default": "", "doc": "The GPUQuerySet to read results from." }, + "first_query": { "type": "int", "default": "", "doc": "The index of the first query to resolve." }, + "query_count": { "type": "int", "default": "", "doc": "The number of queries to resolve." }, + "destination": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to write the results to." }, "destination_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the destination buffer where the results are written. Must be a multiple of 256." } }, @@ -3223,7 +2923,6 @@ "descriptor": { "type": "structs.CommandBufferDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.CommandBufferDescriptor. Optional." } }, @@ -3241,32 +2940,23 @@ "args": { "index": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The index of the bind group (the @group number in the shader)." }, - "bind_group": { - "type": "GPUBindGroup", - "default": null, - "required": true, - "doc": "The GPUBindGroup to set, or None to unset it." - }, + "bind_group": { "type": "GPUBindGroup", "default": "", "doc": "The GPUBindGroup to set, or None to unset it." }, "dynamic_offsets_data": { "type": "ArrayLike", - "default": null, - "required": true, + "default": "", "doc": "A list or array of offsets in bytes, one for each dynamic buffer binding, in order of binding number." }, "dynamic_offsets_data_start": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "If dynamic_offsets_data is an array, the index of the first offset to use." }, "dynamic_offsets_data_length": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "If dynamic_offsets_data is an array, the number of offsets to use." } }, @@ -3277,26 +2967,22 @@ "args": { "range_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the immediate data range where the data is written. Must be a multiple of 4." }, "data": { "type": "ArrayLike", - "default": null, - "required": true, + "default": "", "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, "data_offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, "data_size": { "type": "int", "default": "None", - "required": false, "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } }, @@ -3312,7 +2998,7 @@ "push_debug_group": { "returns": { "type": "None", "doc": "None." }, "args": { - "group_label": { "type": "str", "default": null, "required": true, "doc": "The label of the debug group." } + "group_label": { "type": "str", "default": "", "doc": "The label of the debug group." } }, "doc": "Begin a labeled debug group. Every call must be matched with a call to pop_debug_group().\n" }, @@ -3324,7 +3010,7 @@ "insert_debug_marker": { "returns": { "type": "None", "doc": "None." }, "args": { - "marker_label": { "type": "str", "default": null, "required": true, "doc": "The label of the marker." } + "marker_label": { "type": "str", "default": "", "doc": "The label of the marker." } }, "doc": "Insert a single labeled marker into the command stream.\n" } @@ -3338,52 +3024,26 @@ "set_pipeline": { "returns": { "type": "None", "doc": "None." }, "args": { - "pipeline": { - "type": "GPUComputePipeline", - "default": null, - "required": true, - "doc": "The GPUComputePipeline to use." - } + "pipeline": { "type": "GPUComputePipeline", "default": "", "doc": "The GPUComputePipeline to use." } }, "doc": "Set the GPUComputePipeline to use for subsequent dispatch commands.\n" }, "dispatch_workgroups": { "returns": { "type": "None", "doc": "None." }, "args": { - "workgroup_count_x": { - "type": "int", - "default": null, - "required": true, - "doc": "The number of workgroups in the x dimension." - }, - "workgroup_count_y": { - "type": "int", - "default": "1", - "required": false, - "doc": "The number of workgroups in the y dimension. Defaults to 1." - }, - "workgroup_count_z": { - "type": "int", - "default": "1", - "required": false, - "doc": "The number of workgroups in the z dimension. Defaults to 1." - } + "workgroup_count_x": { "type": "int", "default": "", "doc": "The number of workgroups in the x dimension." }, + "workgroup_count_y": { "type": "int", "default": "1", "doc": "The number of workgroups in the y dimension. Defaults to 1." }, + "workgroup_count_z": { "type": "int", "default": "1", "doc": "The number of workgroups in the z dimension. Defaults to 1." } }, "doc": "Run the compute shader of the current pipeline for a grid of workgroups.\n\nThe total number of invocations is the number of workgroups times the workgroup size defined in the shader.\n" }, "dispatch_workgroups_indirect": { "returns": { "type": "None", "doc": "None." }, "args": { - "indirect_buffer": { - "type": "GPUBuffer", - "default": null, - "required": true, - "doc": "The GPUBuffer that contains the workgroup counts." - }, + "indirect_buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer that contains the workgroup counts." }, "indirect_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the buffer where the counts start. Must be a multiple of 4." } }, @@ -3412,30 +3072,18 @@ "args": { "x": { "type": "float", - "default": null, - "required": true, + "default": "", "doc": "The x coordinate of the top-left corner of the viewport, in pixels." }, "y": { "type": "float", - "default": null, - "required": true, + "default": "", "doc": "The y coordinate of the top-left corner of the viewport, in pixels." }, - "width": { "type": "float", "default": null, "required": true, "doc": "The width of the viewport, in pixels." }, - "height": { "type": "float", "default": null, "required": true, "doc": "The height of the viewport, in pixels." }, - "min_depth": { - "type": "float", - "default": null, - "required": true, - "doc": "The minimum depth value of the viewport (between 0 and 1)." - }, - "max_depth": { - "type": "float", - "default": null, - "required": true, - "doc": "The maximum depth value of the viewport (between 0 and 1)." - } + "width": { "type": "float", "default": "", "doc": "The width of the viewport, in pixels." }, + "height": { "type": "float", "default": "", "doc": "The height of the viewport, in pixels." }, + "min_depth": { "type": "float", "default": "", "doc": "The minimum depth value of the viewport (between 0 and 1)." }, + "max_depth": { "type": "float", "default": "", "doc": "The maximum depth value of the viewport (between 0 and 1)." } }, "doc": "Set the viewport: the region of the attachments that the clip-space output is mapped to.\n\nDefaults to the full size of the attachments.\n" }, @@ -3444,18 +3092,16 @@ "args": { "x": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The x coordinate of the top-left corner of the rectangle, in pixels." }, "y": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The y coordinate of the top-left corner of the rectangle, in pixels." }, - "width": { "type": "int", "default": null, "required": true, "doc": "The width of the rectangle, in pixels." }, - "height": { "type": "int", "default": null, "required": true, "doc": "The height of the rectangle, in pixels." } + "width": { "type": "int", "default": "", "doc": "The width of the rectangle, in pixels." }, + "height": { "type": "int", "default": "", "doc": "The height of the rectangle, in pixels." } }, "doc": "Set the scissor rectangle: fragments outside of this rectangle are discarded.\n\nDefaults to the full size of the attachments.\n" }, @@ -3464,8 +3110,7 @@ "args": { "color": { "type": "tuple[float, float, float, float] | structs.ColorStruct", - "default": null, - "required": true, + "default": "", "doc": "The color, as a structs.Color or a tuple (r, g, b, a)." } }, @@ -3474,24 +3119,14 @@ "set_stencil_reference": { "returns": { "type": "None", "doc": "None." }, "args": { - "reference": { - "type": "int", - "default": null, - "required": true, - "doc": "The stencil reference value (an unsigned integer)." - } + "reference": { "type": "int", "default": "", "doc": "The stencil reference value (an unsigned integer)." } }, "doc": "Set the stencil reference value, used in stencil comparisons and by enums.StencilOperation.replace.\n\nDefaults to 0.\n" }, "begin_occlusion_query": { "returns": { "type": "None", "doc": "None." }, "args": { - "query_index": { - "type": "int", - "default": null, - "required": true, - "doc": "The index in the query set where the result is stored." - } + "query_index": { "type": "int", "default": "", "doc": "The index in the query set where the result is stored." } }, "doc": "Begin an occlusion query, which counts the samples that pass the depth and stencil tests.\n\nThe result is stored in the occlusion_query_set of the pass (see structs.RenderPassDescriptor).\nEnd the query with end_occlusion_query().\n" }, @@ -3505,8 +3140,7 @@ "args": { "bundles": { "type": "list[GPURenderBundle]", - "default": null, - "required": true, + "default": "", "doc": "A list of GPURenderBundle objects to execute, in order." } }, @@ -3527,40 +3161,27 @@ "set_pipeline": { "returns": { "type": "None", "doc": "None." }, "args": { - "pipeline": { - "type": "GPURenderPipeline", - "default": null, - "required": true, - "doc": "The GPURenderPipeline to use." - } + "pipeline": { "type": "GPURenderPipeline", "default": "", "doc": "The GPURenderPipeline to use." } }, "doc": "Set the GPURenderPipeline to use for subsequent draw commands.\n" }, "set_index_buffer": { "returns": { "type": "None", "doc": "None." }, "args": { - "buffer": { - "type": "GPUBuffer", - "default": null, - "required": true, - "doc": "The GPUBuffer that contains the indices." - }, + "buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer that contains the indices." }, "index_format": { "type": "enums.IndexFormatEnum", - "default": null, - "required": true, + "default": "", "doc": "The data type of the indices, see enums.IndexFormat." }, "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes in the buffer where the indices start. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } }, @@ -3571,26 +3192,22 @@ "args": { "slot": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." }, "buffer": { "type": "GPUBuffer", - "default": null, - "required": true, + "default": "", "doc": "The GPUBuffer that contains the vertex data, or None to unset the slot." }, "offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } }, @@ -3599,23 +3216,16 @@ "draw": { "returns": { "type": "None", "doc": "None." }, "args": { - "vertex_count": { "type": "int", "default": null, "required": true, "doc": "The number of vertices to draw." }, - "instance_count": { - "type": "int", - "default": "1", - "required": false, - "doc": "The number of instances to draw. Defaults to 1." - }, + "vertex_count": { "type": "int", "default": "", "doc": "The number of vertices to draw." }, + "instance_count": { "type": "int", "default": "1", "doc": "The number of instances to draw. Defaults to 1." }, "first_vertex": { "type": "int", "default": "0", - "required": false, "doc": "The index of the first vertex to draw (the offset into the vertex buffers, in vertices). Defaults to 0." }, "first_instance": { "type": "int", "default": "0", - "required": false, "doc": "The instance index of the first instance to draw. Defaults to 0." } }, @@ -3624,29 +3234,21 @@ "draw_indexed": { "returns": { "type": "None", "doc": "None." }, "args": { - "index_count": { "type": "int", "default": null, "required": true, "doc": "The number of indices to draw." }, - "instance_count": { - "type": "int", - "default": "1", - "required": false, - "doc": "The number of instances to draw. Defaults to 1." - }, + "index_count": { "type": "int", "default": "", "doc": "The number of indices to draw." }, + "instance_count": { "type": "int", "default": "1", "doc": "The number of instances to draw. Defaults to 1." }, "first_index": { "type": "int", "default": "0", - "required": false, "doc": "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." }, "base_vertex": { "type": "int", "default": "0", - "required": false, "doc": "A value added to each index before looking up the vertex. Defaults to 0." }, "first_instance": { "type": "int", "default": "0", - "required": false, "doc": "The instance index of the first instance to draw. Defaults to 0." } }, @@ -3655,16 +3257,10 @@ "draw_indirect": { "returns": { "type": "None", "doc": "None." }, "args": { - "indirect_buffer": { - "type": "GPUBuffer", - "default": null, - "required": true, - "doc": "The GPUBuffer that contains the draw parameters." - }, + "indirect_buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer that contains the draw parameters." }, "indirect_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." } }, @@ -3673,16 +3269,10 @@ "draw_indexed_indirect": { "returns": { "type": "None", "doc": "None." }, "args": { - "indirect_buffer": { - "type": "GPUBuffer", - "default": null, - "required": true, - "doc": "The GPUBuffer that contains the draw parameters." - }, + "indirect_buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer that contains the draw parameters." }, "indirect_offset": { "type": "int", - "default": null, - "required": true, + "default": "", "doc": "The offset in bytes in the buffer where the parameters start. Must be a multiple of 4." } }, @@ -3713,7 +3303,6 @@ "descriptor": { "type": "structs.RenderBundleDescriptorStruct", "default": "{}", - "required": false, "doc": "A structs.RenderBundleDescriptor. Optional." } }, @@ -3731,8 +3320,7 @@ "args": { "command_buffers": { "type": "list[GPUCommandBuffer]", - "default": null, - "required": true, + "default": "", "doc": "A list of GPUCommandBuffer objects, executed in order." } }, @@ -3746,29 +3334,21 @@ "write_buffer": { "returns": { "type": "None", "doc": "None." }, "args": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true, "doc": "The GPUBuffer to write to." }, - "buffer_offset": { - "type": "int", - "default": null, - "required": true, - "doc": "The offset in bytes in the buffer where the data is written." - }, + "buffer": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to write to." }, + "buffer_offset": { "type": "int", "default": "", "doc": "The offset in bytes in the buffer where the data is written." }, "data": { "type": "ArrayLike", - "default": null, - "required": true, + "default": "", "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, "data_offset": { "type": "int", "default": "0", - "required": false, "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, "size": { "type": "int", "default": "None", - "required": false, "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } }, @@ -3779,26 +3359,22 @@ "args": { "destination": { "type": "structs.TexelCopyTextureInfoStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to write to." }, "data": { "type": "ArrayLike", - "default": null, - "required": true, + "default": "", "doc": "The data to write, as an object that supports the buffer protocol (e.g. bytes or a numpy array)." }, "data_layout": { "type": "structs.TexelCopyBufferLayoutStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." }, "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.Extent3D (or tuple) with the size of the region to write, in texels." } }, @@ -3833,8 +3409,7 @@ "args": { "configuration": { "type": "structs.CanvasConfigurationStruct", - "default": null, - "required": true, + "default": "", "doc": "A structs.CanvasConfiguration with the device, format and other settings." } }, @@ -3891,7 +3466,7 @@ "constructor": { "returns": { "type": "None", "doc": "A GPUValidationError." }, "args": { - "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + "message": { "type": "str", "default": "", "doc": "The human-readable error message." } }, "doc": "Create a GPUValidationError.\n\nNormally these are created by the implementation rather than by user code.\n" } @@ -3905,7 +3480,7 @@ "constructor": { "returns": { "type": "None", "doc": "A GPUOutOfMemoryError." }, "args": { - "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + "message": { "type": "str", "default": "", "doc": "The human-readable error message." } }, "doc": "Create a GPUOutOfMemoryError.\n\nNormally these are created by the implementation rather than by user code.\n" } @@ -3919,7 +3494,7 @@ "constructor": { "returns": { "type": "None", "doc": "A GPUInternalError." }, "args": { - "message": { "type": "str", "default": null, "required": true, "doc": "The human-readable error message." } + "message": { "type": "str", "default": "", "doc": "The human-readable error message." } }, "doc": "Create a GPUInternalError.\n\nNormally these are created by the implementation rather than by user code.\n" } diff --git a/apigen/definitions/wgpu_api_web.json b/apigen/definitions/wgpu_api_web.json index 7b38373d..6bc68544 100644 --- a/apigen/definitions/wgpu_api_web.json +++ b/apigen/definitions/wgpu_api_web.json @@ -468,118 +468,118 @@ "structs": { "RequestAdapterOptions": { "fields": { - "feature_level": { "type": "str", "default": "\"core\"", "required": false }, - "power_preference": { "type": "enums.PowerPreferenceEnum", "default": null, "required": false }, - "force_fallback_adapter": { "type": "bool", "default": "False", "required": false }, - "xr_compatible": { "type": "bool", "default": "False", "required": false } + "feature_level": { "type": "str", "default": "\"core\"" }, + "power_preference": { "type": "enums.PowerPreferenceEnum", "default": "None" }, + "force_fallback_adapter": { "type": "bool", "default": "False" }, + "xr_compatible": { "type": "bool", "default": "False" } } }, "DeviceDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "required_features": { "type": "list[enums.FeatureNameEnum]", "default": "[]", "required": false }, - "required_limits": { "type": "dict[str, int | None]", "default": "{}", "required": false }, - "default_queue": { "type": "structs.QueueDescriptorStruct", "default": "{}", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "required_features": { "type": "list[enums.FeatureNameEnum]", "default": "[]" }, + "required_limits": { "type": "dict[str, int | None]", "default": "{}" }, + "default_queue": { "type": "structs.QueueDescriptorStruct", "default": "{}" } } }, "BufferDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "size": { "type": "int", "default": null, "required": true }, - "usage": { "type": "flags.BufferUsageFlags", "default": null, "required": true }, - "mapped_at_creation": { "type": "bool", "default": "False", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "size": { "type": "int", "default": "" }, + "usage": { "type": "flags.BufferUsageFlags", "default": "" }, + "mapped_at_creation": { "type": "bool", "default": "False" } } }, "TextureDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true }, - "mip_level_count": { "type": "int", "default": "1", "required": false }, - "sample_count": { "type": "int", "default": "1", "required": false }, - "dimension": { "type": "enums.TextureDimensionEnum", "default": "\"2d\"", "required": false }, - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, - "usage": { "type": "flags.TextureUsageFlags", "default": null, "required": true }, - "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", "required": false }, - "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": null, "required": false } + "label": { "type": "str", "default": "\"\"" }, + "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" }, + "mip_level_count": { "type": "int", "default": "1" }, + "sample_count": { "type": "int", "default": "1" }, + "dimension": { "type": "enums.TextureDimensionEnum", "default": "\"2d\"" }, + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "usage": { "type": "flags.TextureUsageFlags", "default": "" }, + "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]" }, + "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "None" } } }, "TextureViewDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, - "dimension": { "type": "enums.TextureViewDimensionEnum", "default": null, "required": false }, - "usage": { "type": "flags.TextureUsageFlags", "default": "0", "required": false }, - "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false }, - "base_mip_level": { "type": "int", "default": "0", "required": false }, - "mip_level_count": { "type": "int", "default": null, "required": false }, - "base_array_layer": { "type": "int", "default": "0", "required": false }, - "array_layer_count": { "type": "int", "default": null, "required": false }, - "swizzle": { "type": "str", "default": "\"rgba\"", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "format": { "type": "enums.TextureFormatEnum", "default": "None" }, + "dimension": { "type": "enums.TextureViewDimensionEnum", "default": "None" }, + "usage": { "type": "flags.TextureUsageFlags", "default": "0" }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" }, + "base_mip_level": { "type": "int", "default": "0" }, + "mip_level_count": { "type": "int", "default": "None" }, + "base_array_layer": { "type": "int", "default": "0" }, + "array_layer_count": { "type": "int", "default": "None" }, + "swizzle": { "type": "str", "default": "\"rgba\"" } } }, "ExternalTextureDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "source": { "type": "ArrayLike | object", "default": null, "required": true }, - "color_space": { "type": "str", "default": "\"srgb\"", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "source": { "type": "ArrayLike | object", "default": "" }, + "color_space": { "type": "str", "default": "\"srgb\"" } } }, "SamplerDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "address_mode_u": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, - "address_mode_v": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, - "address_mode_w": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"", "required": false }, - "mag_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", "required": false }, - "min_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"", "required": false }, - "mipmap_filter": { "type": "enums.MipmapFilterModeEnum", "default": "\"nearest\"", "required": false }, - "lod_min_clamp": { "type": "float", "default": "0", "required": false }, - "lod_max_clamp": { "type": "float", "default": "32", "required": false }, - "compare": { "type": "enums.CompareFunctionEnum", "default": null, "required": false }, - "max_anisotropy": { "type": "int", "default": "1", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "address_mode_u": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"" }, + "address_mode_v": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"" }, + "address_mode_w": { "type": "enums.AddressModeEnum", "default": "\"clamp-to-edge\"" }, + "mag_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"" }, + "min_filter": { "type": "enums.FilterModeEnum", "default": "\"nearest\"" }, + "mipmap_filter": { "type": "enums.MipmapFilterModeEnum", "default": "\"nearest\"" }, + "lod_min_clamp": { "type": "float", "default": "0" }, + "lod_max_clamp": { "type": "float", "default": "32" }, + "compare": { "type": "enums.CompareFunctionEnum", "default": "None" }, + "max_anisotropy": { "type": "int", "default": "1" } } }, "BindGroupLayoutDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "entries": { "type": "list[structs.BindGroupLayoutEntryStruct]", "default": null, "required": true } + "label": { "type": "str", "default": "\"\"" }, + "entries": { "type": "list[structs.BindGroupLayoutEntryStruct]", "default": "" } } }, "BindGroupLayoutEntry": { "fields": { - "binding": { "type": "int", "default": null, "required": true }, - "visibility": { "type": "flags.ShaderStageFlags", "default": null, "required": true }, - "buffer": { "type": "structs.BufferBindingLayoutStruct", "default": null, "required": false }, - "sampler": { "type": "structs.SamplerBindingLayoutStruct", "default": null, "required": false }, - "texture": { "type": "structs.TextureBindingLayoutStruct", "default": null, "required": false }, - "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct", "default": null, "required": false }, - "external_texture": { "type": "structs.ExternalTextureBindingLayoutStruct", "default": null, "required": false } + "binding": { "type": "int", "default": "" }, + "visibility": { "type": "flags.ShaderStageFlags", "default": "" }, + "buffer": { "type": "structs.BufferBindingLayoutStruct", "default": "None" }, + "sampler": { "type": "structs.SamplerBindingLayoutStruct", "default": "None" }, + "texture": { "type": "structs.TextureBindingLayoutStruct", "default": "None" }, + "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct", "default": "None" }, + "external_texture": { "type": "structs.ExternalTextureBindingLayoutStruct", "default": "None" } } }, "BufferBindingLayout": { "fields": { - "type": { "type": "enums.BufferBindingTypeEnum", "default": "\"uniform\"", "required": false }, - "has_dynamic_offset": { "type": "bool", "default": "False", "required": false }, - "min_binding_size": { "type": "int", "default": "0", "required": false } + "type": { "type": "enums.BufferBindingTypeEnum", "default": "\"uniform\"" }, + "has_dynamic_offset": { "type": "bool", "default": "False" }, + "min_binding_size": { "type": "int", "default": "0" } } }, "SamplerBindingLayout": { "fields": { - "type": { "type": "enums.SamplerBindingTypeEnum", "default": "\"filtering\"", "required": false } + "type": { "type": "enums.SamplerBindingTypeEnum", "default": "\"filtering\"" } } }, "TextureBindingLayout": { "fields": { - "sample_type": { "type": "enums.TextureSampleTypeEnum", "default": "\"float\"", "required": false }, - "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", "required": false }, - "multisampled": { "type": "bool", "default": "False", "required": false } + "sample_type": { "type": "enums.TextureSampleTypeEnum", "default": "\"float\"" }, + "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"" }, + "multisampled": { "type": "bool", "default": "False" } } }, "StorageTextureBindingLayout": { "fields": { - "access": { "type": "enums.StorageTextureAccessEnum", "default": "\"write-only\"", "required": false }, - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, - "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"", "required": false } + "access": { "type": "enums.StorageTextureAccessEnum", "default": "\"write-only\"" }, + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"" } } }, "ExternalTextureBindingLayout": { @@ -587,355 +587,350 @@ }, "BindGroupDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "layout": { "type": "GPUBindGroupLayout", "default": null, "required": true }, - "entries": { "type": "list[structs.BindGroupEntryStruct]", "default": null, "required": true } + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUBindGroupLayout", "default": "" }, + "entries": { "type": "list[structs.BindGroupEntryStruct]", "default": "" } } }, "BindGroupEntry": { "fields": { - "binding": { "type": "int", "default": null, "required": true }, + "binding": { "type": "int", "default": "" }, "resource": { "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", - "default": null, - "required": true + "default": "" } } }, "BufferBinding": { "fields": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": null, "required": false } + "buffer": { "type": "GPUBuffer", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "PipelineLayoutDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "bind_group_layouts": { "type": "list[GPUBindGroupLayout]", "default": null, "required": true }, - "immediate_size": { "type": "int", "default": "0", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "bind_group_layouts": { "type": "list[GPUBindGroupLayout]", "default": "" }, + "immediate_size": { "type": "int", "default": "0" } } }, "ShaderModuleDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "code": { "type": "str", "default": null, "required": true }, - "compilation_hints": { "type": "list[structs.ShaderModuleCompilationHintStruct]", "default": "[]", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "code": { "type": "str", "default": "" }, + "compilation_hints": { "type": "list[structs.ShaderModuleCompilationHintStruct]", "default": "[]" } } }, "ShaderModuleCompilationHint": { "fields": { - "entry_point": { "type": "str", "default": null, "required": true }, - "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": false } + "entry_point": { "type": "str", "default": "" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "None" } } }, "PipelineErrorInit": { "fields": { - "reason": { "type": "enums.PipelineErrorReasonEnum", "default": null, "required": true } + "reason": { "type": "enums.PipelineErrorReasonEnum", "default": "" } } }, "ProgrammableStage": { "fields": { - "module": { "type": "GPUShaderModule", "default": null, "required": true }, - "entry_point": { "type": "str", "default": null, "required": false }, - "constants": { "type": "dict[str, float]", "default": "{}", "required": false } + "module": { "type": "GPUShaderModule", "default": "" }, + "entry_point": { "type": "str", "default": "None" }, + "constants": { "type": "dict[str, float]", "default": "{}" } } }, "ComputePipelineDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": true }, - "compute": { "type": "structs.ProgrammableStageStruct", "default": null, "required": true } + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "" }, + "compute": { "type": "structs.ProgrammableStageStruct", "default": "" } } }, "RenderPipelineDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": null, "required": true }, - "vertex": { "type": "structs.VertexStateStruct", "default": null, "required": true }, - "primitive": { "type": "structs.PrimitiveStateStruct", "default": "{}", "required": false }, - "depth_stencil": { "type": "structs.DepthStencilStateStruct", "default": null, "required": false }, - "multisample": { "type": "structs.MultisampleStateStruct", "default": "{}", "required": false }, - "fragment": { "type": "structs.FragmentStateStruct", "default": null, "required": false } + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "" }, + "vertex": { "type": "structs.VertexStateStruct", "default": "" }, + "primitive": { "type": "structs.PrimitiveStateStruct", "default": "{}" }, + "depth_stencil": { "type": "structs.DepthStencilStateStruct", "default": "None" }, + "multisample": { "type": "structs.MultisampleStateStruct", "default": "{}" }, + "fragment": { "type": "structs.FragmentStateStruct", "default": "None" } } }, "PrimitiveState": { "fields": { - "topology": { "type": "enums.PrimitiveTopologyEnum", "default": "\"triangle-list\"", "required": false }, - "strip_index_format": { "type": "enums.IndexFormatEnum", "default": null, "required": false }, - "front_face": { "type": "enums.FrontFaceEnum", "default": "\"ccw\"", "required": false }, - "cull_mode": { "type": "enums.CullModeEnum", "default": "\"none\"", "required": false }, - "unclipped_depth": { "type": "bool", "default": "False", "required": false } + "topology": { "type": "enums.PrimitiveTopologyEnum", "default": "\"triangle-list\"" }, + "strip_index_format": { "type": "enums.IndexFormatEnum", "default": "None" }, + "front_face": { "type": "enums.FrontFaceEnum", "default": "\"ccw\"" }, + "cull_mode": { "type": "enums.CullModeEnum", "default": "\"none\"" }, + "unclipped_depth": { "type": "bool", "default": "False" } } }, "MultisampleState": { "fields": { - "count": { "type": "int", "default": "1", "required": false }, - "mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, - "alpha_to_coverage_enabled": { "type": "bool", "default": "False", "required": false } + "count": { "type": "int", "default": "1" }, + "mask": { "type": "int", "default": "0xFFFFFFFF" }, + "alpha_to_coverage_enabled": { "type": "bool", "default": "False" } } }, "FragmentState": { "fields": { - "module": { "type": "GPUShaderModule", "default": null, "required": true }, - "entry_point": { "type": "str", "default": null, "required": false }, - "constants": { "type": "dict[str, float]", "default": "{}", "required": false }, - "targets": { "type": "list[structs.ColorTargetStateStruct]", "default": null, "required": true } + "module": { "type": "GPUShaderModule", "default": "" }, + "entry_point": { "type": "str", "default": "None" }, + "constants": { "type": "dict[str, float]", "default": "{}" }, + "targets": { "type": "list[structs.ColorTargetStateStruct]", "default": "" } } }, "ColorTargetState": { "fields": { - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, - "blend": { "type": "structs.BlendStateStruct", "default": null, "required": false }, - "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF", "required": false } + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "blend": { "type": "structs.BlendStateStruct", "default": "None" }, + "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF" } } }, "BlendState": { "fields": { - "color": { "type": "structs.BlendComponentStruct", "default": null, "required": true }, - "alpha": { "type": "structs.BlendComponentStruct", "default": null, "required": true } + "color": { "type": "structs.BlendComponentStruct", "default": "" }, + "alpha": { "type": "structs.BlendComponentStruct", "default": "" } } }, "BlendComponent": { "fields": { - "operation": { "type": "enums.BlendOperationEnum", "default": "\"add\"", "required": false }, - "src_factor": { "type": "enums.BlendFactorEnum", "default": "\"one\"", "required": false }, - "dst_factor": { "type": "enums.BlendFactorEnum", "default": "\"zero\"", "required": false } + "operation": { "type": "enums.BlendOperationEnum", "default": "\"add\"" }, + "src_factor": { "type": "enums.BlendFactorEnum", "default": "\"one\"" }, + "dst_factor": { "type": "enums.BlendFactorEnum", "default": "\"zero\"" } } }, "DepthStencilState": { "fields": { - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, - "depth_write_enabled": { "type": "bool", "default": null, "required": false }, - "depth_compare": { "type": "enums.CompareFunctionEnum", "default": null, "required": false }, - "stencil_front": { "type": "structs.StencilFaceStateStruct", "default": "{}", "required": false }, - "stencil_back": { "type": "structs.StencilFaceStateStruct", "default": "{}", "required": false }, - "stencil_read_mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, - "stencil_write_mask": { "type": "int", "default": "0xFFFFFFFF", "required": false }, - "depth_bias": { "type": "int", "default": "0", "required": false }, - "depth_bias_slope_scale": { "type": "float", "default": "0", "required": false }, - "depth_bias_clamp": { "type": "float", "default": "0", "required": false } + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "depth_write_enabled": { "type": "bool", "default": "None" }, + "depth_compare": { "type": "enums.CompareFunctionEnum", "default": "None" }, + "stencil_front": { "type": "structs.StencilFaceStateStruct", "default": "{}" }, + "stencil_back": { "type": "structs.StencilFaceStateStruct", "default": "{}" }, + "stencil_read_mask": { "type": "int", "default": "0xFFFFFFFF" }, + "stencil_write_mask": { "type": "int", "default": "0xFFFFFFFF" }, + "depth_bias": { "type": "int", "default": "0" }, + "depth_bias_slope_scale": { "type": "float", "default": "0" }, + "depth_bias_clamp": { "type": "float", "default": "0" } } }, "StencilFaceState": { "fields": { - "compare": { "type": "enums.CompareFunctionEnum", "default": "\"always\"", "required": false }, - "fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false }, - "depth_fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false }, - "pass_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"", "required": false } + "compare": { "type": "enums.CompareFunctionEnum", "default": "\"always\"" }, + "fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"" }, + "depth_fail_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"" }, + "pass_op": { "type": "enums.StencilOperationEnum", "default": "\"keep\"" } } }, "VertexState": { "fields": { - "module": { "type": "GPUShaderModule", "default": null, "required": true }, - "entry_point": { "type": "str", "default": null, "required": false }, - "constants": { "type": "dict[str, float]", "default": "{}", "required": false }, - "buffers": { "type": "list[structs.VertexBufferLayoutStruct]", "default": "[]", "required": false } + "module": { "type": "GPUShaderModule", "default": "" }, + "entry_point": { "type": "str", "default": "None" }, + "constants": { "type": "dict[str, float]", "default": "{}" }, + "buffers": { "type": "list[structs.VertexBufferLayoutStruct]", "default": "[]" } } }, "VertexBufferLayout": { "fields": { - "array_stride": { "type": "int", "default": null, "required": true }, - "step_mode": { "type": "enums.VertexStepModeEnum", "default": "\"vertex\"", "required": false }, - "attributes": { "type": "list[structs.VertexAttributeStruct]", "default": null, "required": true } + "array_stride": { "type": "int", "default": "" }, + "step_mode": { "type": "enums.VertexStepModeEnum", "default": "\"vertex\"" }, + "attributes": { "type": "list[structs.VertexAttributeStruct]", "default": "" } } }, "VertexAttribute": { "fields": { - "format": { "type": "enums.VertexFormatEnum", "default": null, "required": true }, - "offset": { "type": "int", "default": null, "required": true }, - "shader_location": { "type": "int", "default": null, "required": true } + "format": { "type": "enums.VertexFormatEnum", "default": "" }, + "offset": { "type": "int", "default": "" }, + "shader_location": { "type": "int", "default": "" } } }, "TexelCopyBufferLayout": { "fields": { - "offset": { "type": "int", "default": "0", "required": false }, - "bytes_per_row": { "type": "int", "default": null, "required": false }, - "rows_per_image": { "type": "int", "default": null, "required": false } + "offset": { "type": "int", "default": "0" }, + "bytes_per_row": { "type": "int", "default": "None" }, + "rows_per_image": { "type": "int", "default": "None" } } }, "TexelCopyBufferInfo": { "fields": { - "offset": { "type": "int", "default": "0", "required": false }, - "bytes_per_row": { "type": "int", "default": null, "required": false }, - "rows_per_image": { "type": "int", "default": null, "required": false }, - "buffer": { "type": "GPUBuffer", "default": null, "required": true } + "offset": { "type": "int", "default": "0" }, + "bytes_per_row": { "type": "int", "default": "None" }, + "rows_per_image": { "type": "int", "default": "None" }, + "buffer": { "type": "GPUBuffer", "default": "" } } }, "TexelCopyTextureInfo": { "fields": { - "texture": { "type": "GPUTexture", "default": null, "required": true }, - "mip_level": { "type": "int", "default": "0", "required": false }, - "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}", "required": false }, - "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false } + "texture": { "type": "GPUTexture", "default": "" }, + "mip_level": { "type": "int", "default": "0" }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}" }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" } } }, "CopyExternalImageDestInfo": { "fields": { - "texture": { "type": "GPUTexture", "default": null, "required": true }, - "mip_level": { "type": "int", "default": "0", "required": false }, - "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}", "required": false }, - "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"", "required": false }, - "color_space": { "type": "str", "default": "\"srgb\"", "required": false }, - "premultiplied_alpha": { "type": "bool", "default": "False", "required": false } + "texture": { "type": "GPUTexture", "default": "" }, + "mip_level": { "type": "int", "default": "0" }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}" }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" }, + "color_space": { "type": "str", "default": "\"srgb\"" }, + "premultiplied_alpha": { "type": "bool", "default": "False" } } }, "CopyExternalImageSourceInfo": { "fields": { - "source": { "type": "ArrayLike | CanvasLike | object", "default": null, "required": true }, - "origin": { "type": "tuple[int, int] | structs.Origin2DStruct", "default": "{}", "required": false }, - "flip_y": { "type": "bool", "default": "False", "required": false } + "source": { "type": "ArrayLike | CanvasLike | object", "default": "" }, + "origin": { "type": "tuple[int, int] | structs.Origin2DStruct", "default": "{}" }, + "flip_y": { "type": "bool", "default": "False" } } }, "CommandBufferDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false } + "label": { "type": "str", "default": "\"\"" } } }, "CommandEncoderDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false } + "label": { "type": "str", "default": "\"\"" } } }, "ComputePassTimestampWrites": { "fields": { - "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, - "beginning_of_pass_write_index": { "type": "int", "default": null, "required": false }, - "end_of_pass_write_index": { "type": "int", "default": null, "required": false } + "query_set": { "type": "GPUQuerySet", "default": "" }, + "beginning_of_pass_write_index": { "type": "int", "default": "None" }, + "end_of_pass_write_index": { "type": "int", "default": "None" } } }, "ComputePassDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct", "default": null, "required": false } + "label": { "type": "str", "default": "\"\"" }, + "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct", "default": "None" } } }, "RenderPassTimestampWrites": { "fields": { - "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, - "beginning_of_pass_write_index": { "type": "int", "default": null, "required": false }, - "end_of_pass_write_index": { "type": "int", "default": null, "required": false } + "query_set": { "type": "GPUQuerySet", "default": "" }, + "beginning_of_pass_write_index": { "type": "int", "default": "None" }, + "end_of_pass_write_index": { "type": "int", "default": "None" } } }, "RenderPassDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "color_attachments": { "type": "list[structs.RenderPassColorAttachmentStruct]", "default": null, "required": true }, - "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct", "default": null, "required": false }, - "occlusion_query_set": { "type": "GPUQuerySet", "default": null, "required": false }, - "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct", "default": null, "required": false }, - "max_draw_count": { "type": "int", "default": "50000000", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "color_attachments": { "type": "list[structs.RenderPassColorAttachmentStruct]", "default": "" }, + "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct", "default": "None" }, + "occlusion_query_set": { "type": "GPUQuerySet", "default": "None" }, + "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct", "default": "None" }, + "max_draw_count": { "type": "int", "default": "50000000" } } }, "RenderPassColorAttachment": { "fields": { - "view": { "type": "GPUTexture | GPUTextureView", "default": null, "required": true }, - "depth_slice": { "type": "int", "default": null, "required": false }, - "resolve_target": { "type": "GPUTexture | GPUTextureView", "default": null, "required": false }, - "clear_value": { - "type": "tuple[float, float, float, float] | structs.ColorStruct", - "default": null, - "required": false - }, - "load_op": { "type": "enums.LoadOpEnum", "default": null, "required": true }, - "store_op": { "type": "enums.StoreOpEnum", "default": null, "required": true } + "view": { "type": "GPUTexture | GPUTextureView", "default": "" }, + "depth_slice": { "type": "int", "default": "None" }, + "resolve_target": { "type": "GPUTexture | GPUTextureView", "default": "None" }, + "clear_value": { "type": "tuple[float, float, float, float] | structs.ColorStruct", "default": "None" }, + "load_op": { "type": "enums.LoadOpEnum", "default": "" }, + "store_op": { "type": "enums.StoreOpEnum", "default": "" } } }, "RenderPassDepthStencilAttachment": { "fields": { - "view": { "type": "GPUTexture | GPUTextureView", "default": null, "required": true }, - "depth_clear_value": { "type": "float", "default": null, "required": false }, - "depth_load_op": { "type": "enums.LoadOpEnum", "default": null, "required": false }, - "depth_store_op": { "type": "enums.StoreOpEnum", "default": null, "required": false }, - "depth_read_only": { "type": "bool", "default": "False", "required": false }, - "stencil_clear_value": { "type": "int", "default": "0", "required": false }, - "stencil_load_op": { "type": "enums.LoadOpEnum", "default": null, "required": false }, - "stencil_store_op": { "type": "enums.StoreOpEnum", "default": null, "required": false }, - "stencil_read_only": { "type": "bool", "default": "False", "required": false } + "view": { "type": "GPUTexture | GPUTextureView", "default": "" }, + "depth_clear_value": { "type": "float", "default": "None" }, + "depth_load_op": { "type": "enums.LoadOpEnum", "default": "None" }, + "depth_store_op": { "type": "enums.StoreOpEnum", "default": "None" }, + "depth_read_only": { "type": "bool", "default": "False" }, + "stencil_clear_value": { "type": "int", "default": "0" }, + "stencil_load_op": { "type": "enums.LoadOpEnum", "default": "None" }, + "stencil_store_op": { "type": "enums.StoreOpEnum", "default": "None" }, + "stencil_read_only": { "type": "bool", "default": "False" } } }, "RenderPassLayout": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": null, "required": true }, - "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, - "sample_count": { "type": "int", "default": "1", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": "" }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": "None" }, + "sample_count": { "type": "int", "default": "1" } } }, "RenderBundleDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false } + "label": { "type": "str", "default": "\"\"" } } }, "RenderBundleEncoderDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": null, "required": true }, - "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": null, "required": false }, - "sample_count": { "type": "int", "default": "1", "required": false }, - "depth_read_only": { "type": "bool", "default": "False", "required": false }, - "stencil_read_only": { "type": "bool", "default": "False", "required": false } + "label": { "type": "str", "default": "\"\"" }, + "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": "" }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": "None" }, + "sample_count": { "type": "int", "default": "1" }, + "depth_read_only": { "type": "bool", "default": "False" }, + "stencil_read_only": { "type": "bool", "default": "False" } } }, "QueueDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false } + "label": { "type": "str", "default": "\"\"" } } }, "QuerySetDescriptor": { "fields": { - "label": { "type": "str", "default": "\"\"", "required": false }, - "type": { "type": "enums.QueryTypeEnum", "default": null, "required": true }, - "count": { "type": "int", "default": null, "required": true } + "label": { "type": "str", "default": "\"\"" }, + "type": { "type": "enums.QueryTypeEnum", "default": "" }, + "count": { "type": "int", "default": "" } } }, "CanvasToneMapping": { "fields": { - "mode": { "type": "enums.CanvasToneMappingModeEnum", "default": "\"standard\"", "required": false } + "mode": { "type": "enums.CanvasToneMappingModeEnum", "default": "\"standard\"" } } }, "CanvasConfiguration": { "fields": { - "device": { "type": "GPUDevice", "default": null, "required": true }, - "format": { "type": "enums.TextureFormatEnum", "default": null, "required": true }, - "usage": { "type": "flags.TextureUsageFlags", "default": "0x10", "required": false }, - "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]", "required": false }, - "color_space": { "type": "str", "default": "\"srgb\"", "required": false }, - "tone_mapping": { "type": "structs.CanvasToneMappingStruct", "default": "{}", "required": false }, - "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"", "required": false } + "device": { "type": "GPUDevice", "default": "" }, + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "usage": { "type": "flags.TextureUsageFlags", "default": "0x10" }, + "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]" }, + "color_space": { "type": "str", "default": "\"srgb\"" }, + "tone_mapping": { "type": "structs.CanvasToneMappingStruct", "default": "{}" }, + "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"" } } }, "UncapturedErrorEventInit": { "fields": { - "error": { "type": "GPUError", "default": null, "required": true } + "error": { "type": "GPUError", "default": "" } } }, "Color": { "fields": { - "r": { "type": "float", "default": null, "required": true }, - "g": { "type": "float", "default": null, "required": true }, - "b": { "type": "float", "default": null, "required": true }, - "a": { "type": "float", "default": null, "required": true } + "r": { "type": "float", "default": "" }, + "g": { "type": "float", "default": "" }, + "b": { "type": "float", "default": "" }, + "a": { "type": "float", "default": "" } } }, "Origin2D": { "fields": { - "x": { "type": "int", "default": "0", "required": false }, - "y": { "type": "int", "default": "0", "required": false } + "x": { "type": "int", "default": "0" }, + "y": { "type": "int", "default": "0" } } }, "Origin3D": { "fields": { - "x": { "type": "int", "default": "0", "required": false }, - "y": { "type": "int", "default": "0", "required": false }, - "z": { "type": "int", "default": "0", "required": false } + "x": { "type": "int", "default": "0" }, + "y": { "type": "int", "default": "0" }, + "z": { "type": "int", "default": "0" } } }, "Extent3D": { "fields": { - "width": { "type": "int", "default": null, "required": true }, - "height": { "type": "int", "default": "1", "required": false }, - "depth_or_array_layers": { "type": "int", "default": "1", "required": false } + "width": { "type": "int", "default": "" }, + "height": { "type": "int", "default": "1" }, + "depth_or_array_layers": { "type": "int", "default": "1" } } } }, @@ -1028,7 +1023,7 @@ "request_adapter": { "returns": { "type": "GPUAdapter" }, "args": { - "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}", "required": false } + "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}" } } }, "get_preferred_canvas_format": { @@ -1048,7 +1043,7 @@ "request_device": { "returns": { "type": "GPUDevice" }, "args": { - "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}" } } } } @@ -1071,97 +1066,97 @@ "create_buffer": { "returns": { "type": "GPUBuffer" }, "args": { - "descriptor": { "type": "structs.BufferDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.BufferDescriptorStruct", "default": "" } } }, "create_texture": { "returns": { "type": "GPUTexture" }, "args": { - "descriptor": { "type": "structs.TextureDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.TextureDescriptorStruct", "default": "" } } }, "create_sampler": { "returns": { "type": "GPUSampler" }, "args": { - "descriptor": { "type": "structs.SamplerDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.SamplerDescriptorStruct", "default": "{}" } } }, "import_external_texture": { "returns": { "type": "object" }, "args": { - "descriptor": { "type": "structs.ExternalTextureDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.ExternalTextureDescriptorStruct", "default": "" } } }, "create_bind_group_layout": { "returns": { "type": "GPUBindGroupLayout" }, "args": { - "descriptor": { "type": "structs.BindGroupLayoutDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.BindGroupLayoutDescriptorStruct", "default": "" } } }, "create_pipeline_layout": { "returns": { "type": "GPUPipelineLayout" }, "args": { - "descriptor": { "type": "structs.PipelineLayoutDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.PipelineLayoutDescriptorStruct", "default": "" } } }, "create_bind_group": { "returns": { "type": "GPUBindGroup" }, "args": { - "descriptor": { "type": "structs.BindGroupDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.BindGroupDescriptorStruct", "default": "" } } }, "create_shader_module": { "returns": { "type": "GPUShaderModule" }, "args": { - "descriptor": { "type": "structs.ShaderModuleDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.ShaderModuleDescriptorStruct", "default": "" } } }, "create_compute_pipeline": { "returns": { "type": "GPUComputePipeline" }, "args": { - "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": "" } } }, "create_render_pipeline": { "returns": { "type": "GPURenderPipeline" }, "args": { - "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": "" } } }, "create_compute_pipeline_async": { "returns": { "type": "GPUPromise[GPUComputePipeline]" }, "args": { - "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": "" } } }, "create_render_pipeline_async": { "returns": { "type": "GPUPromise[GPURenderPipeline]" }, "args": { - "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": "" } } }, "create_command_encoder": { "returns": { "type": "GPUCommandEncoder" }, "args": { - "descriptor": { "type": "structs.CommandEncoderDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.CommandEncoderDescriptorStruct", "default": "{}" } } }, "create_render_bundle_encoder": { "returns": { "type": "GPURenderBundleEncoder" }, "args": { - "descriptor": { "type": "structs.RenderBundleEncoderDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.RenderBundleEncoderDescriptorStruct", "default": "" } } }, "create_query_set": { "returns": { "type": "GPUQuerySet" }, "args": { - "descriptor": { "type": "structs.QuerySetDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.QuerySetDescriptorStruct", "default": "" } } }, "push_error_scope": { "returns": { "type": "None" }, "args": { - "filter": { "type": "enums.ErrorFilterEnum", "default": null, "required": true } + "filter": { "type": "enums.ErrorFilterEnum", "default": "" } } }, "pop_error_scope": { @@ -1181,16 +1176,16 @@ "map_async": { "returns": { "type": "GPUPromise[None]" }, "args": { - "mode": { "type": "flags.MapModeFlags", "default": null, "required": true }, - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "mode": { "type": "flags.MapModeFlags", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "get_mapped_range": { "returns": { "type": "ArrayLike" }, "args": { - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "unmap": { @@ -1220,7 +1215,7 @@ "create_view": { "returns": { "type": "GPUTextureView" }, "args": { - "descriptor": { "type": "structs.TextureViewDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.TextureViewDescriptorStruct", "default": "{}" } } }, "destroy": { @@ -1297,8 +1292,8 @@ "constructor": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": "\"\"", "required": false }, - "options": { "type": "structs.PipelineErrorInitStruct", "default": null, "required": true } + "message": { "type": "str", "default": "\"\"" }, + "options": { "type": "structs.PipelineErrorInitStruct", "default": "" } } } } @@ -1310,7 +1305,7 @@ "get_bind_group_layout": { "returns": { "type": "GPUBindGroupLayout" }, "args": { - "index": { "type": "int", "default": null, "required": true } + "index": { "type": "int", "default": "" } } } } @@ -1342,71 +1337,71 @@ "begin_render_pass": { "returns": { "type": "GPURenderPassEncoder" }, "args": { - "descriptor": { "type": "structs.RenderPassDescriptorStruct", "default": null, "required": true } + "descriptor": { "type": "structs.RenderPassDescriptorStruct", "default": "" } } }, "begin_compute_pass": { "returns": { "type": "GPUComputePassEncoder" }, "args": { - "descriptor": { "type": "structs.ComputePassDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.ComputePassDescriptorStruct", "default": "{}" } } }, "copy_buffer_to_buffer": { "returns": { "type": "None" }, "args": { - "source": { "type": "GPUBuffer", "default": null, "required": true }, - "source_offset": { "type": "int", "default": null, "required": true }, - "destination": { "type": "GPUBuffer", "default": null, "required": true }, - "destination_offset": { "type": "int", "default": null, "required": true }, - "size": { "type": "int", "default": "None", "required": false } + "source": { "type": "GPUBuffer", "default": "" }, + "source_offset": { "type": "int", "default": "" }, + "destination": { "type": "GPUBuffer", "default": "" }, + "destination_offset": { "type": "int", "default": "" }, + "size": { "type": "int", "default": "None" } } }, "copy_buffer_to_texture": { "returns": { "type": "None" }, "args": { - "source": { "type": "structs.TexelCopyBufferInfoStruct", "default": null, "required": true }, - "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, - "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + "source": { "type": "structs.TexelCopyBufferInfoStruct", "default": "" }, + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": "" }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } } }, "copy_texture_to_buffer": { "returns": { "type": "None" }, "args": { - "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, - "destination": { "type": "structs.TexelCopyBufferInfoStruct", "default": null, "required": true }, - "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": "" }, + "destination": { "type": "structs.TexelCopyBufferInfoStruct", "default": "" }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } } }, "copy_texture_to_texture": { "returns": { "type": "None" }, "args": { - "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, - "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, - "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + "source": { "type": "structs.TexelCopyTextureInfoStruct", "default": "" }, + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": "" }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } } }, "clear_buffer": { "returns": { "type": "None" }, "args": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "buffer": { "type": "GPUBuffer", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "resolve_query_set": { "returns": { "type": "None" }, "args": { - "query_set": { "type": "GPUQuerySet", "default": null, "required": true }, - "first_query": { "type": "int", "default": null, "required": true }, - "query_count": { "type": "int", "default": null, "required": true }, - "destination": { "type": "GPUBuffer", "default": null, "required": true }, - "destination_offset": { "type": "int", "default": null, "required": true } + "query_set": { "type": "GPUQuerySet", "default": "" }, + "first_query": { "type": "int", "default": "" }, + "query_count": { "type": "int", "default": "" }, + "destination": { "type": "GPUBuffer", "default": "" }, + "destination_offset": { "type": "int", "default": "" } } }, "finish": { "returns": { "type": "GPUCommandBuffer" }, "args": { - "descriptor": { "type": "structs.CommandBufferDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.CommandBufferDescriptorStruct", "default": "{}" } } } } @@ -1418,20 +1413,20 @@ "set_bind_group": { "returns": { "type": "None" }, "args": { - "index": { "type": "int", "default": null, "required": true }, - "bind_group": { "type": "GPUBindGroup", "default": null, "required": true }, - "dynamic_offsets_data": { "type": "ArrayLike", "default": null, "required": true }, - "dynamic_offsets_data_start": { "type": "int", "default": null, "required": true }, - "dynamic_offsets_data_length": { "type": "int", "default": null, "required": true } + "index": { "type": "int", "default": "" }, + "bind_group": { "type": "GPUBindGroup", "default": "" }, + "dynamic_offsets_data": { "type": "ArrayLike", "default": "" }, + "dynamic_offsets_data_start": { "type": "int", "default": "" }, + "dynamic_offsets_data_length": { "type": "int", "default": "" } } }, "set_immediates": { "returns": { "type": "None" }, "args": { - "range_offset": { "type": "int", "default": null, "required": true }, - "data": { "type": "ArrayLike", "default": null, "required": true }, - "data_offset": { "type": "int", "default": "0", "required": false }, - "data_size": { "type": "int", "default": "None", "required": false } + "range_offset": { "type": "int", "default": "" }, + "data": { "type": "ArrayLike", "default": "" }, + "data_offset": { "type": "int", "default": "0" }, + "data_size": { "type": "int", "default": "None" } } } } @@ -1443,7 +1438,7 @@ "push_debug_group": { "returns": { "type": "None" }, "args": { - "group_label": { "type": "str", "default": null, "required": true } + "group_label": { "type": "str", "default": "" } } }, "pop_debug_group": { @@ -1453,7 +1448,7 @@ "insert_debug_marker": { "returns": { "type": "None" }, "args": { - "marker_label": { "type": "str", "default": null, "required": true } + "marker_label": { "type": "str", "default": "" } } } } @@ -1465,22 +1460,22 @@ "set_pipeline": { "returns": { "type": "None" }, "args": { - "pipeline": { "type": "GPUComputePipeline", "default": null, "required": true } + "pipeline": { "type": "GPUComputePipeline", "default": "" } } }, "dispatch_workgroups": { "returns": { "type": "None" }, "args": { - "workgroup_count_x": { "type": "int", "default": null, "required": true }, - "workgroup_count_y": { "type": "int", "default": "1", "required": false }, - "workgroup_count_z": { "type": "int", "default": "1", "required": false } + "workgroup_count_x": { "type": "int", "default": "" }, + "workgroup_count_y": { "type": "int", "default": "1" }, + "workgroup_count_z": { "type": "int", "default": "1" } } }, "dispatch_workgroups_indirect": { "returns": { "type": "None" }, "args": { - "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "indirect_offset": { "type": "int", "default": null, "required": true } + "indirect_buffer": { "type": "GPUBuffer", "default": "" }, + "indirect_offset": { "type": "int", "default": "" } } }, "end": { @@ -1502,43 +1497,39 @@ "set_viewport": { "returns": { "type": "None" }, "args": { - "x": { "type": "float", "default": null, "required": true }, - "y": { "type": "float", "default": null, "required": true }, - "width": { "type": "float", "default": null, "required": true }, - "height": { "type": "float", "default": null, "required": true }, - "min_depth": { "type": "float", "default": null, "required": true }, - "max_depth": { "type": "float", "default": null, "required": true } + "x": { "type": "float", "default": "" }, + "y": { "type": "float", "default": "" }, + "width": { "type": "float", "default": "" }, + "height": { "type": "float", "default": "" }, + "min_depth": { "type": "float", "default": "" }, + "max_depth": { "type": "float", "default": "" } } }, "set_scissor_rect": { "returns": { "type": "None" }, "args": { - "x": { "type": "int", "default": null, "required": true }, - "y": { "type": "int", "default": null, "required": true }, - "width": { "type": "int", "default": null, "required": true }, - "height": { "type": "int", "default": null, "required": true } + "x": { "type": "int", "default": "" }, + "y": { "type": "int", "default": "" }, + "width": { "type": "int", "default": "" }, + "height": { "type": "int", "default": "" } } }, "set_blend_constant": { "returns": { "type": "None" }, "args": { - "color": { - "type": "tuple[float, float, float, float] | structs.ColorStruct", - "default": null, - "required": true - } + "color": { "type": "tuple[float, float, float, float] | structs.ColorStruct", "default": "" } } }, "set_stencil_reference": { "returns": { "type": "None" }, "args": { - "reference": { "type": "int", "default": null, "required": true } + "reference": { "type": "int", "default": "" } } }, "begin_occlusion_query": { "returns": { "type": "None" }, "args": { - "query_index": { "type": "int", "default": null, "required": true } + "query_index": { "type": "int", "default": "" } } }, "end_occlusion_query": { @@ -1548,7 +1539,7 @@ "execute_bundles": { "returns": { "type": "None" }, "args": { - "bundles": { "type": "list[GPURenderBundle]", "default": null, "required": true } + "bundles": { "type": "list[GPURenderBundle]", "default": "" } } }, "end": { @@ -1564,58 +1555,58 @@ "set_pipeline": { "returns": { "type": "None" }, "args": { - "pipeline": { "type": "GPURenderPipeline", "default": null, "required": true } + "pipeline": { "type": "GPURenderPipeline", "default": "" } } }, "set_index_buffer": { "returns": { "type": "None" }, "args": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "index_format": { "type": "enums.IndexFormatEnum", "default": null, "required": true }, - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "buffer": { "type": "GPUBuffer", "default": "" }, + "index_format": { "type": "enums.IndexFormatEnum", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "set_vertex_buffer": { "returns": { "type": "None" }, "args": { - "slot": { "type": "int", "default": null, "required": true }, - "buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "slot": { "type": "int", "default": "" }, + "buffer": { "type": "GPUBuffer", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "draw": { "returns": { "type": "None" }, "args": { - "vertex_count": { "type": "int", "default": null, "required": true }, - "instance_count": { "type": "int", "default": "1", "required": false }, - "first_vertex": { "type": "int", "default": "0", "required": false }, - "first_instance": { "type": "int", "default": "0", "required": false } + "vertex_count": { "type": "int", "default": "" }, + "instance_count": { "type": "int", "default": "1" }, + "first_vertex": { "type": "int", "default": "0" }, + "first_instance": { "type": "int", "default": "0" } } }, "draw_indexed": { "returns": { "type": "None" }, "args": { - "index_count": { "type": "int", "default": null, "required": true }, - "instance_count": { "type": "int", "default": "1", "required": false }, - "first_index": { "type": "int", "default": "0", "required": false }, - "base_vertex": { "type": "int", "default": "0", "required": false }, - "first_instance": { "type": "int", "default": "0", "required": false } + "index_count": { "type": "int", "default": "" }, + "instance_count": { "type": "int", "default": "1" }, + "first_index": { "type": "int", "default": "0" }, + "base_vertex": { "type": "int", "default": "0" }, + "first_instance": { "type": "int", "default": "0" } } }, "draw_indirect": { "returns": { "type": "None" }, "args": { - "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "indirect_offset": { "type": "int", "default": null, "required": true } + "indirect_buffer": { "type": "GPUBuffer", "default": "" }, + "indirect_offset": { "type": "int", "default": "" } } }, "draw_indexed_indirect": { "returns": { "type": "None" }, "args": { - "indirect_buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "indirect_offset": { "type": "int", "default": null, "required": true } + "indirect_buffer": { "type": "GPUBuffer", "default": "" }, + "indirect_offset": { "type": "int", "default": "" } } } } @@ -1638,7 +1629,7 @@ "finish": { "returns": { "type": "GPURenderBundle" }, "args": { - "descriptor": { "type": "structs.RenderBundleDescriptorStruct", "default": "{}", "required": false } + "descriptor": { "type": "structs.RenderBundleDescriptorStruct", "default": "{}" } } } } @@ -1650,7 +1641,7 @@ "submit": { "returns": { "type": "None" }, "args": { - "command_buffers": { "type": "list[GPUCommandBuffer]", "default": null, "required": true } + "command_buffers": { "type": "list[GPUCommandBuffer]", "default": "" } } }, "on_submitted_work_done": { @@ -1660,28 +1651,28 @@ "write_buffer": { "returns": { "type": "None" }, "args": { - "buffer": { "type": "GPUBuffer", "default": null, "required": true }, - "buffer_offset": { "type": "int", "default": null, "required": true }, - "data": { "type": "ArrayLike", "default": null, "required": true }, - "data_offset": { "type": "int", "default": "0", "required": false }, - "size": { "type": "int", "default": "None", "required": false } + "buffer": { "type": "GPUBuffer", "default": "" }, + "buffer_offset": { "type": "int", "default": "" }, + "data": { "type": "ArrayLike", "default": "" }, + "data_offset": { "type": "int", "default": "0" }, + "size": { "type": "int", "default": "None" } } }, "write_texture": { "returns": { "type": "None" }, "args": { - "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": null, "required": true }, - "data": { "type": "ArrayLike", "default": null, "required": true }, - "data_layout": { "type": "structs.TexelCopyBufferLayoutStruct", "default": null, "required": true }, - "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + "destination": { "type": "structs.TexelCopyTextureInfoStruct", "default": "" }, + "data": { "type": "ArrayLike", "default": "" }, + "data_layout": { "type": "structs.TexelCopyBufferLayoutStruct", "default": "" }, + "size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } } }, "copy_external_image_to_texture": { "returns": { "type": "None" }, "args": { - "source": { "type": "structs.CopyExternalImageSourceInfoStruct", "default": null, "required": true }, - "destination": { "type": "structs.CopyExternalImageDestInfoStruct", "default": null, "required": true }, - "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": null, "required": true } + "source": { "type": "structs.CopyExternalImageSourceInfoStruct", "default": "" }, + "destination": { "type": "structs.CopyExternalImageDestInfoStruct", "default": "" }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } } } } @@ -1708,7 +1699,7 @@ "configure": { "returns": { "type": "None" }, "args": { - "configuration": { "type": "structs.CanvasConfigurationStruct", "default": null, "required": true } + "configuration": { "type": "structs.CanvasConfigurationStruct", "default": "" } } }, "unconfigure": { @@ -1747,7 +1738,7 @@ "constructor": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": null, "required": true } + "message": { "type": "str", "default": "" } } } } @@ -1759,7 +1750,7 @@ "constructor": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": null, "required": true } + "message": { "type": "str", "default": "" } } } } @@ -1771,7 +1762,7 @@ "constructor": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": null, "required": true } + "message": { "type": "str", "default": "" } } } } @@ -1785,8 +1776,8 @@ "constructor": { "returns": { "type": "None" }, "args": { - "type": { "type": "str", "default": null, "required": true }, - "gpu_uncaptured_error_event_init_dict": { "type": "structs.UncapturedErrorEventInitStruct", "default": null, "required": true } + "type": { "type": "str", "default": "" }, + "gpu_uncaptured_error_event_init_dict": { "type": "structs.UncapturedErrorEventInitStruct", "default": "" } } } } diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 5de2a42c..2f08c937 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -79,14 +79,19 @@ def __init__(self, line: str, source: Literal["struct", "param"]): self.line = line.strip().strip(",;").strip() self.source = source - # Detect default value - default = None + # Detect default value, store as a str that represents a Python literal. + # Default empty string means there is no default; required arg/field. + # Note that if default *represents* an empty string, it would be '""'. + default = "" arg = self.line if "=" in arg: arg, default = arg.rsplit("=", 1) arg, default = arg.strip(), default.strip() - if default and default in ["false", "true"]: - default = default.capitalize() + if default: + if default in ["false", "true"]: + default = default.capitalize() + if default == "null": + default = "None" arg_type, arg_name = arg.strip().rsplit(" ", 1) # Handling required vs optional differs between structs fields and function params. @@ -97,10 +102,10 @@ def __init__(self, line: str, source: Literal["struct", "param"]): required = True arg_type = arg_type.split(" ", 1)[1] # required args should not have a default - assert default is None + assert not default else: required = False - # default could still be None, i.e. struct field can be omitted + default = default or "None" elif source == "param": if arg_type.startswith("optional "): required = False @@ -109,26 +114,24 @@ def __init__(self, line: str, source: Literal["struct", "param"]): else: # but otherwise they are required required = True - assert default is None + assert not default else: raise RuntimeError(f"Invalid Attribute source: {source!r}") + assert isinstance(default, str) + assert bool(default) == (not required) + self.name = arg_name self.py_name = None self.idl_type = arg_type self.py_type = "unresolved_type!" self.default = default - self.required = required def __repr__(self): return f"" def to_dict(self) -> dict: - return { - "type": self.py_type, - "default": self.default, - "required": self.required, - } + return {"type": self.py_type, "default": self.default} class Interface: diff --git a/apigen/write_api.py b/apigen/write_api.py index 862f4b0b..139576c9 100644 --- a/apigen/write_api.py +++ b/apigen/write_api.py @@ -139,9 +139,8 @@ def write_structs(structs_dict): pylines.append(f"@dataclass(kw_only=True, repr=False)\nclass {name}(Struct):") # pylines.append(f' """{indent(struct_dict["doc"])}"""') for field_name, field_dict in struct_dict["fields"].items(): - # Get type to include in code + # Get type to include in code, and massage a bit for this module raw_type = field_dict["type"] - # TODO: do these conversions earlier! code_type = raw_type.replace("GPU", "classes.GPU").replace("structs.", "") code_type = code_type.replace("list[", "Sequence[") # Get type to include in docs @@ -154,20 +153,14 @@ def write_structs(structs_dict): ): docs_type = raw_type.replace("Flags", "").replace("Enum", "") docs_type = resolve_crossrefs(f" {docs_type} ") - # Get default - # TODO: move this logic earlier; the json files should be leading! - # if field_name == "power_preference": - # breakpoint() + # Get default and massage it a bit default = field_dict["default"] if default == "[]": default = "()" elif default == "{}": default = "None" # no mutable defaults + if default == "None" and "None" not in code_type: code_type += " | None" - if not default and not field_dict["required"]: - default = "None" - if "None" not in code_type: - code_type += " | None" # Build docs doc = "" if docs_type: From b3502a9b8a9304164a9f5214fb94815a357118e4 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 27 Oct 2026 14:27:55 +0100 Subject: [PATCH 05/10] tweak filenames --- apigen/README.md | 2 +- .../definitions/{docs_ai.json => diff_docs.json} | 6 +++--- apigen/definitions/docs_dev.json | 7 ------- .../definitions/{wgpu_api_web.json => webgpu.json} | 2 +- apigen/definitions/wgpu_api.json | 2 +- apigen/extract_idl.py | 2 +- apigen/format_json.py | 2 +- apigen/merge_json.py | 14 +++++--------- 8 files changed, 13 insertions(+), 24 deletions(-) rename apigen/definitions/{docs_ai.json => diff_docs.json} (99%) delete mode 100644 apigen/definitions/docs_dev.json rename apigen/definitions/{wgpu_api_web.json => webgpu.json} (99%) diff --git a/apigen/README.md b/apigen/README.md index c5b5e0a8..198fdc43 100644 --- a/apigen/README.md +++ b/apigen/README.md @@ -24,7 +24,7 @@ There is also a CLI for ease of use, and to run the whole codegen pipeline with ## The steps that this code offers * download: download the latest webgpu.idl, this is only done manually from time to time. -* extract_idl: parse the IDL to produce 'wgpu_api_web.json'. +* extract_idl: parse the IDL to produce 'wgpu_idl.json'. * format: formats the static definitions. * merge: combines multiple definitions files into 'wgpu_api.json'. * write_api: produce API for flags, enums and structs. diff --git a/apigen/definitions/docs_ai.json b/apigen/definitions/diff_docs.json similarity index 99% rename from apigen/definitions/docs_ai.json rename to apigen/definitions/diff_docs.json index 87f91f75..2e22ee8e 100644 --- a/apigen/definitions/docs_ai.json +++ b/apigen/definitions/diff_docs.json @@ -1,8 +1,8 @@ { "meta": { - "filename": "docs_ai.json", - "description": "Complete documentation for the wgpu API, generated by Claude.", - "notes": "Claude was fed the Typescript definition ('index.d.ts', which includes docstrings) as input." + "filename": "diff_docs.json", + "description": "Complete documentation for the wgpu API.", + "notes": "This defines the base API docs. Backends add docs to their added/changed elements. This file was first populated with Claude AI, which was fed the Typescript definition ('index.d.ts' with docstrings)." }, "flags": { "BufferUsage": { diff --git a/apigen/definitions/docs_dev.json b/apigen/definitions/docs_dev.json deleted file mode 100644 index 8728e088..00000000 --- a/apigen/definitions/docs_dev.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "meta": { - "filename": "docs_dev.json", - "description": "Hand-written docs to overload the ai-generated docs where needed.", - "notes": "" - } -} diff --git a/apigen/definitions/wgpu_api_web.json b/apigen/definitions/webgpu.json similarity index 99% rename from apigen/definitions/wgpu_api_web.json rename to apigen/definitions/webgpu.json index 6bc68544..359dd0ab 100644 --- a/apigen/definitions/wgpu_api_web.json +++ b/apigen/definitions/webgpu.json @@ -1,6 +1,6 @@ { "meta": { - "filename": "wgpu_api_web.json", + "filename": "webgpu.json", "description": "Python-flavored WebGPU API, generated from 'webgpu.idl'.", "notes": "All types are converted to the Python equivalents, all names are made Pythonic snake_case, methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly." }, diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json index a032c457..29b261cc 100644 --- a/apigen/definitions/wgpu_api.json +++ b/apigen/definitions/wgpu_api.json @@ -1,7 +1,7 @@ { "meta": { "filename": "wgpu_api.json", - "description": "Definition of the base wgpu API, derived from 'wgpu_api_web.json', 'diff_base.json', 'docs_ai.json', 'docs_dev.json'.", + "description": "Definition of the base wgpu API, derived from 'webgpu.json', 'diff_base.json', 'diff_docs.json'.", "notes": "The full API, including docs, in one file. This does *not* include enums/flags/structs from any of the backends." }, "flags": { diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 2f08c937..712abef6 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -24,7 +24,7 @@ def extract_idl(): # Generate structure - fname = "wgpu_api_web.json" + fname = "webgpu.json" s = {} s["meta"] = { "filename": fname, diff --git a/apigen/format_json.py b/apigen/format_json.py index bdfd6145..e09582b7 100644 --- a/apigen/format_json.py +++ b/apigen/format_json.py @@ -8,7 +8,7 @@ def format_json(): files = [ fname for fname in os.listdir(DEFINITIONS_DIR) - if fname.endswith(".json") and fname.startswith(("diff_", "docs_")) + if fname.endswith(".json") and fname.startswith("diff_") ] for fname in files: s = read_definition_file(fname) diff --git a/apigen/merge_json.py b/apigen/merge_json.py index 60f0548a..2babe412 100644 --- a/apigen/merge_json.py +++ b/apigen/merge_json.py @@ -5,21 +5,17 @@ def merge_json(): """Merge the structure definitions into a single definition for the base API.""" # Read - api_web = read_definition_file("wgpu_api_web.json") + webgpu = read_definition_file("webgpu.json") diff_base = read_definition_file("diff_base.json") - docs_ai = read_definition_file("docs_ai.json") - docs_dev = read_definition_file("docs_dev.json") + diff_docs = read_definition_file("diff_docs.json") # Combine - api = dict_deep_merge(api_web, diff_base) - - # Insert docs - api = dict_deep_merge(api, docs_ai, allow_add=False) - api = dict_deep_merge(api, docs_dev, allow_add=False) + api = dict_deep_merge(webgpu, diff_base) + api = dict_deep_merge(api, diff_docs, allow_add=False) api["meta"] = { "filename": "wgpu_api.json", - "description": "Definition of the base wgpu API, derived from 'wgpu_api_web.json', 'diff_base.json', 'docs_ai.json', 'docs_dev.json'.", + "description": "Definition of the base wgpu API, derived from 'webgpu.json', 'diff_base.json', 'diff_docs.json'.", "notes": "The full API, including docs, in one file. This does *not* include enums/flags/structs from any of the backends.", } From d9588e9c6581ff79c5b3919f24cde5ba132fd190 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 27 Oct 2026 15:27:35 +0100 Subject: [PATCH 06/10] wip js api generator --- apigen/__init__.py | 3 ++- apigen/write_js_api.py | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 apigen/write_js_api.py diff --git a/apigen/__init__.py b/apigen/__init__.py index ad297a4b..20cc7426 100644 --- a/apigen/__init__.py +++ b/apigen/__init__.py @@ -5,5 +5,6 @@ from format_json import format_json from merge_json import merge_json from write_api import write_api +from write_js_api import write_js_api -actions = [download_idl, extract_idl, format_json, merge_json, write_api] +actions = [download_idl, extract_idl, format_json, merge_json, write_api, write_js_api] diff --git a/apigen/write_js_api.py b/apigen/write_js_api.py new file mode 100644 index 00000000..21f2cfd5 --- /dev/null +++ b/apigen/write_js_api.py @@ -0,0 +1,60 @@ +from apigen_utils import read_definition_file, write_file + +preamble = ''' +""" +JS WebGPU API, but in Python. This is what the Pyodide backend should talk to. +This code is generated from webgpu.json, which is generated from webgpu.idl. +This helps validate the Pyodide backend via MyPy. +""" +''' + + +def write_js_api(): + """Write the Python stub API for WebGPU, to use in typechecking for web backends.""" + webgpu = read_definition_file("webgpu.json") + + lines = [] + + for class_name, class_dict in webgpu["classes"].items(): + # Write classdef + bases = class_dict.get("bases", []) + bases_str = "" + if bases: + bases_str = "(" + ", ".join(bases) + ")" + lines.append(f"class {class_name}{bases_str}:") + + # Props + for prop_name, prop_dict in class_dict["properties"].items(): + lines.append(" @property") + lines.append(f" def {prop_name}(self) -> {prop_dict['type']}:") + lines.append(" ...") + lines.append("") + + # Methods + for method_name, method_dict in class_dict["methods"].items(): + args = ["self"] + for arg_name, arg_dict in method_dict["args"].items(): + arg = f"{arg_name}: {arg_dict['type']}" + if arg_dict["default"]: + arg += f" = {arg_dict['default']}" + args.append(arg) + sig = ", ".join(args) + lines.append( + f" def {method_name}({sig}) -> {method_dict['returns']['type']}:" + ) + lines.append(" ...") + lines.append("") + + if not (class_dict["properties"] or class_dict["methods"]): + lines.append(" pass") + lines.append("") + + lines.append("") + + code = preamble + "\n".join(lines) + + write_file(code, "wgpu", "backends", "js_webgpu", "webgpu_stub.py") + + +if __name__ == "__main__": + write_js_api() From 89433cd91a8f61fa40b56da40c9b5f826cead39f Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 28 Oct 2026 14:14:22 +0100 Subject: [PATCH 07/10] Start on patcher logic --- apigen/README.md | 21 +- apigen/apigen_patcher.py | 471 ++++++++++++++++++++++++++++++++ apigen/apigen_utils.py | 191 +++++++++---- apigen/patch_api.py | 37 +++ apigen/tests/test_structures.py | 13 - apigen/write_api.py | 6 +- apigen/write_js_api.py | 4 +- 7 files changed, 669 insertions(+), 74 deletions(-) create mode 100644 apigen/apigen_patcher.py create mode 100644 apigen/patch_api.py delete mode 100644 apigen/tests/test_structures.py diff --git a/apigen/README.md b/apigen/README.md index 198fdc43..35f96636 100644 --- a/apigen/README.md +++ b/apigen/README.md @@ -16,19 +16,26 @@ Each backend can define additional API surface, but uses suffixes for anything t ## Code organization -This module consists of one utility modules and then one module for each action. -These modules can be executed as a script, which is handy during development. -There is also a CLI for ease of use, and to run the whole codegen pipeline with one command. +The apigen consists of multiple "actions". Each such action is represented by a module, +which has a function with the same name that performs the action. These modules can also +be executed as a script, which is handy during development. + +The names of the actions are typically "verb-noun". Call me crazy but I named them such that +when sorted alphabetically, the order of the actions is correct :) + +There is also one utility module that all modules use. + +There is a CLI for ease of use, and to run the whole codegen pipeline with one command. ## The steps that this code offers -* download: download the latest webgpu.idl, this is only done manually from time to time. +* download_idl: download the latest webgpu.idl, this is only done manually from time to time. * extract_idl: parse the IDL to produce 'wgpu_idl.json'. -* format: formats the static definitions. -* merge: combines multiple definitions files into 'wgpu_api.json'. -* write_api: produce API for flags, enums and structs. +* format_json: formats the static definitions. +* merge_json: combines multiple definitions files into 'wgpu_api.json'. * patch_api: produce the classes and functions in _classes.py and all backends. +* write_api: produce API for flags, enums and structs. ## The API format structure diff --git a/apigen/apigen_patcher.py b/apigen/apigen_patcher.py new file mode 100644 index 00000000..e90d4bef --- /dev/null +++ b/apigen/apigen_patcher.py @@ -0,0 +1,471 @@ +import ast +import os +import tempfile +from collections import defaultdict +from functools import cache + +from apigen_utils import FormatError, format_code, read_file + + +class Patcher: + """Class to help patch a Python module. Supports iterating (over + lines, classes, properties, methods), and applying diffs (replace, + remove, insert). + """ + + def __init__(self, code=None): + self._init(code) + + def _init(self, code): + """Subclasses can call this to reset the patcher.""" + self.lines = [] + self._diffs = {} + self._classes = {} + if code: + self.lines = format_code(code, True).splitlines() # inf line length + + def remove_line(self, i): + """Remove the line at the given position. There must not have been + an action on line i. + """ + assert i not in self._diffs, f"Line {i} already has a diff" + self._diffs[i] = i, "remove" + + def insert_line(self, i, line): + """Insert a new line at the given position. It's ok if there + has already been an insertion on line i, but there must not have been + any other actions. + """ + if i in self._diffs and self._diffs[i][1] == "insert": + cur_line = self._diffs[i][2] + self._diffs[i] = i, "insert", cur_line + "\n" + line + else: + assert i not in self._diffs, f"Line {i} already has a diff" + self._diffs[i] = i, "insert", line + + def replace_line(self, i, line): + """Replace the line at the given position with another line. + There must not have been an action on line i. + """ + assert i not in self._diffs, f"Line {i} already has a diff" + self._diffs[i] = i, "replace", line + + def dumps(self, format=True): + """Return the patched result as a string.""" + lines = self.lines.copy() + # Apply diff + diffs = sorted(self._diffs.values()) + for diff in reversed(diffs): + if diff[1] == "remove": + lines.pop(diff[0]) + elif diff[1] == "insert": + lines.insert(diff[0], diff[2]) + elif diff[1] == "replace": + lines[diff[0]] = diff[2] + else: # pragma: no cover + raise ValueError(f"Unknown diff: {diff}") + # Format + text = "\n".join(lines) + if format: + try: + text = format_code(text) + except FormatError as err: # pragma: no cover + # If you get this error, it really helps to load the code + # in an IDE to see where the error is. Let's help with that ... + filename = os.path.join(tempfile.gettempdir(), "wgpu_patcher_fail.py") + with open(filename, "wb") as f: + f.write(text.encode()) + err = str(err) + err = err if len(err) < 78 else err[:77] + "…" + raise RuntimeError( + f"It appears that the patcher has generated invalid Python:" + f"\n\n {err}\n\n" + f'Wrote the generated (but unformatted) code to:\n\n "{filename}"' + ) from None + + return text + + def iter_lines(self, start_line=0): + """Generator to iterate over the lines. + Each iteration yields (line, linenr) + """ + for i in range(start_line, len(self.lines)): + line = self.lines[i] + yield line, i + + def iter_classes(self, start_line=0): + """Generator to iterate over the classes. + Each iteration yields (classname, linenr_start, linenr_end), + where linenr_end is the last line of code. + """ + current_class = None + for i in range(start_line, len(self.lines)): + line = self.lines[i] + sline = line.rstrip() + if current_class and sline: + if sline.startswith(" "): + current_class[2] = i + else: # code has less indentation -> something new + yield current_class + current_class = None + if line.startswith("class "): + name = line.split(":")[0].split("(")[0].split()[-1] + current_class = [name, i, i] + if current_class: + yield current_class + + def iter_properties(self, start_line=0): + """Generator to iterate over the properties. + Each iteration yields (classname, linenr_first, linenr_last), + where linenr_first is the line that startswith `def`, + and linenr_last is the last line of code. + """ + return self._iter_props_and_methods(start_line, True) + + def iter_methods(self, start_line=0): + """Generator to iterate over the methods. + Each iteration yields (classname, linenr_first, linenr_last) + where linenr_first is the line that startswith `def`, + and linenr_last is the last line of code. + """ + return self._iter_props_and_methods(start_line, False) + + def _iter_props_and_methods(self, start_line, find_props): + prop_mark = None + current_def = None + for i in range(start_line, len(self.lines)): + line = self.lines[i] + sline = line.rstrip() + if current_def and sline: + if sline.startswith(" "): + current_def[2] = i + else: + yield current_def + current_def = None + if sline and not sline.startswith(" "): + break # exit class + if line.startswith((" def ", " async def ")): + name = line.split("(")[0].split()[-1] + if prop_mark and find_props: + current_def = [name, i, i] + elif not prop_mark and not find_props: + current_def = [name, i, i] + if line.startswith(" @property"): + prop_mark = i + elif sline and not sline.lstrip().startswith("#"): + prop_mark = None + + if current_def: + yield current_def + + +class CommentRemover(Patcher): + """A patcher that removes comments that we add in other parsers, + to prevent accumulating comments. + """ + + def __init__( + self, triggers=("# FIXME: unknown api", "# FIXME: missing check_struct") + ): + # TODO: add "# IDL:" temporarily later to remove legacy stuff + super().__init__() + self.triggers = triggers + + def apply(self, code): + self._init(code) + for line, i in self.iter_lines(): + if line.lstrip().startswith(self.triggers): + self.remove_line(i) + + +class ApiPatcher(Patcher): + """The patcher to update an API (classes and their props and methods). + + The idea is to walk over all classes, patch it if necessary, then + walk over each of its properties and methods to patch these too. + """ + + def __init__(self, api_dict): + super().__init__() + self.api_dict = api_dict + + def apply(self, code): + self._init(code) + self._counts = {"classes": 0, "methods": 0, "properties": 0} + self.patch_classes() + stats = ", ".join(f"{self._counts[key]} {key}" for key in self._counts) + print("Patched " + stats) + + def patch_classes(self): + seen_classes = set() + + # Update existing classes in the Python code + for classname, i1, i2 in self.iter_classes(): + seen_classes.add(classname) + self._apidiffs = set() + if self.class_is_known(classname): + old_line = self.lines[i1] + new_line = self.get_class_def(classname) + if old_line != new_line: + fixme_line = "# FIXME: was " + old_line.split("class ", 1)[-1] + self.replace_line(i1, f"{fixme_line}\n{new_line}") + self.patch_properties(classname, i1 + 1, i2) + self.patch_methods(classname, i1 + 1, i2) + else: + msg = f"unknown api: class {classname}" + self.insert_line(i1, "# FIXME: " + msg) + print("Warning: " + msg) + + # Add missing classes + lines = [] + for classname in self.get_class_names(): + if classname not in seen_classes: + lines.append("# FIXME: new class to implement") + lines.append(self.get_class_def(classname)) + more_lines = [] + more_lines += self.get_missing_properties(classname, set()) + more_lines += self.get_missing_methods(classname, set()) + lines.extend(more_lines or [" pass"]) + if lines: + self.insert_line(i2 + 1, "\n".join(lines)) + + self._counts["classes"] += len(seen_classes) + + def patch_properties(self, classname, i1, i2): + seen_props = set() + + # Update existing properties in Python code + for propname, j1, j2 in self.iter_properties(i1): + seen_props.add(propname) + if self.prop_is_known(classname, propname): + old_line = self.lines[j1] + new_line = self.get_property_def(classname, propname) + if old_line != new_line: + fixme_line = " # FIXME: was " + old_line.split("def ", 1)[-1] + lines = [fixme_line, new_line] + self.replace_line(j1, "\n".join(lines)) + else: + msg = f"unknown api: prop {classname}.{propname}" + self.insert_line(j1, " # FIXME: " + msg) + print("Warning: " + msg) + + # Add missing properties for this class + lines = self.get_missing_properties(classname, seen_props) + if lines: + self.insert_line(i2 + 1, "\n".join(lines)) + + self._counts["properties"] += len(seen_props) + + def patch_methods(self, classname, i1, i2): + seen_funcs = set() + + # Update existing methods in Python code + for methodname, j1, j2 in self.iter_methods(i1): + seen_funcs.add(methodname) + if self.method_is_known(classname, methodname): + old_line = self.lines[j1] + new_line = self.get_method_def(classname, methodname) + if old_line != new_line: + fixme_line = " # FIXME: was " + old_line.split("def ", 1)[-1] + lines = [fixme_line, new_line] + self.replace_line(j1, "\n".join(lines)) + else: + msg = f"unknown api: method {classname}.{methodname}" + self.insert_line(j1, " # FIXME: " + msg) + print("Warning: " + msg) + + # Add missing methods for this class + lines = self.get_missing_methods(classname, seen_funcs) + if lines: + self.insert_line(i2 + 1, "\n".join(lines)) + + self._counts["methods"] += len(seen_funcs) + + def get_missing_properties(self, classname, seen_props): + lines = [] + for propname in self.get_prop_names(classname): + if propname not in seen_props: + lines.append(" # FIXME: new prop to implement") + lines.append(" @property") + lines.append(self.get_property_def(classname, propname)) + lines.append(" raise NotImplementedError()") + lines.append("") + return lines + + def get_missing_methods(self, classname, seen_funcs): + lines = [] + for methodname in self.get_method_names(classname): + if methodname not in seen_funcs: + lines.append(" # FIXME: new method to implement") + lines.append(self.get_method_def(classname, methodname)) + lines.append(" raise NotImplementedError()\n") + return lines + + def get_class_def(self, class_name): + class_dict = self.api_dict["classes"][class_name] + bases = class_dict.get("bases", []) + bases_str = "" + if bases: + bases_str = "(" + ", ".join(bases) + ")" + return f"class {class_name}{bases_str}:" + + def get_property_def(self, class_name, prop_name) -> str: + prop_dict = self.api_dict["classes"][class_name]["properties"][prop_name] + return f" @property\n def {prop_name}(self) -> {prop_dict['type']}:" + + def get_method_def(self, class_name, method_name) -> str: + method_dict = self.api_dict["classes"][class_name]["methods"][method_name] + args = ["self"] + for arg_name, arg_dict in method_dict["args"].items(): + arg = f"{arg_name}: {arg_dict['type']}" + if arg_dict["default"]: + arg += f" = {arg_dict['default']}" + args.append(arg) + sig = ", ".join(args) + return f" def {method_name}({sig}) -> {method_dict['returns']['type']}:" + + def class_is_known(self, class_name): + return class_name in self.api_dict["classes"] + + def prop_is_known(self, class_name, prop_name): + return prop_name in self.api_dict["classes"][class_name]["properties"] + + def method_is_known(self, class_name, method_name): + return method_name in self.api_dict["classes"][class_name]["methods"] + + def get_class_names(self): + return list(self.api_dict["classes"].keys()) + + def get_prop_names(self, class_name): + return list(self.api_dict["classes"][class_name]["properties"].keys()) + + def get_method_names(self, class_name): + return list(self.api_dict["classes"][class_name]["methods"].keys()) + + +class StructValidationChecker(Patcher): + """Checks that all structs are validated in the methods that have incoming structs.""" + + def __init__(self, api_dict): + super().__init__() + self.api_dict = api_dict + + def apply(self, code): + self._init(code) + + all_structs = set() + ignore_structs = { + "Extent3D", + "Origin3D", + } # TODO: ignore here or convert earlier? + + structure_checks = self._get_structure_checks() + + for classname, i1, i2 in self.iter_classes(): + if classname not in self.api_dict["classes"]: + continue + + # For each method ... + for methodname, j1, j2 in self.iter_methods(i1 + 1): + code = "\n".join(self.lines[j1 : j2 + 1]) + # Get signature and cut it up in words + sig_words = code.partition("(")[2].split("):")[0] + for c in "][(),\"'": + sig_words = sig_words.replace(c, " ") + # Collect incoming structs from signature + method_structs = set() + for word in sig_words.split(): + if word.startswith("structs."): + structname = word.partition(".")[2] + method_structs.update(self._get_sub_structs(structname)) + all_structs.update(method_structs) + # Collect structs being checked + try: + checked = structure_checks[classname, methodname] + except KeyError: + checked = set() + print( + f"Could not validate check_struct for {classname}.{methodname}; need another codegen run." + ) + + # Test that a matching check is done + unchecked = method_structs.difference(checked) + unchecked = list(sorted(unchecked.difference(ignore_structs))) + # Must we check, or does this method defer to another + defer_func_name = "_" + methodname + defer_line_starts = ( + f"return self.{defer_func_name[:-7]}", + f"promise = self.{defer_func_name[:-7]}", + ) + this_method_defers = any( + line.strip().startswith(defer_line_starts) + for line in code.splitlines() + ) + if not this_method_defers and unchecked: + msg = f"missing check_struct in {methodname}: {unchecked}" + self.insert_line(j1, f"# FIXME: {msg}") + print(f"ERROR: {msg}") + + # Test that we did find structs. In case our detection fails for + # some reason, this would probably catch that. + assert len(all_structs) > 10 + + def _get_sub_structs(self, structname): + # todo: how to deal with these suffixes? + # if structname.endswith("Struct"): + # structname = structname[:-6] + structnames = {structname} + for field_name, field_dict in self.api_dict.structs[structname].items(): + type_name = field_dict["type"] + if type_name in self.api_dict["structs"]: + structnames.update(self._get_sub_structs(type_name)) + return structnames + + @staticmethod + def _get_structure_checks(): + """ + Returns a map + (class_name, method_name) -> + mapping each top-level method in _api.py to the calls to check_struct made by + that method or by any helper methods called by that method. + + For now, the helper function must be methods within the same class. This code + does not yet deal with global functions or with methods in superclasses. + """ + # TODO: abstract the file, we want to do this for each backend, I suppose + module = ast.parse(read_file("wgpu", "backends", "wgpu_native", "_api.py")) + # We only care about top-level classes and their top-level methods. + top_level_methods = { + # (class_name, method_name) -> method_ast + (class_ast.name, method_ast.name): method_ast + for class_ast in module.body + if isinstance(class_ast, ast.ClassDef) + for method_ast in class_ast.body + if isinstance(method_ast, (ast.FunctionDef, ast.AsyncFunctionDef)) + } + + # (class_name, method_name) -> list of helper methods + method_helper_calls = defaultdict(list) + # (class_name, method_name) -> list of structures checked + structure_checks = defaultdict(list) + + for key, method_ast in top_level_methods.items(): + for node in ast.walk(method_ast): + if isinstance(node, ast.Call): + name = ast.unparse(node.func) + if name.startswith("self._"): + method_helper_calls[key].append(name[5:]) + if name == "check_struct": + assert isinstance(node.args[0], ast.Constant) + struct_name = node.args[0].value + assert isinstance(struct_name, str) + structure_checks[key].append(struct_name) + + @cache + def get_function_checks(class_name, method_name): + result = set(structure_checks[class_name, method_name]) + for helper_method_name in method_helper_calls[class_name, method_name]: + result.update(get_function_checks(class_name, helper_method_name)) + return sorted(result) + + return {key: get_function_checks(*key) for key in top_level_methods.keys()} diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py index 17c82ab2..4761e9e9 100644 --- a/apigen/apigen_utils.py +++ b/apigen/apigen_utils.py @@ -65,6 +65,14 @@ def to_snake_case(name, separator="_"): return name2 +def enum_name_to_value(name): + parts = name.split("_") + for i in range(len(parts)): + if parts[i] in ("d1", "d2", "d3"): + parts[i] = parts[i][::-1] + return "-".join(parts) + + def dict_deep_merge(a: dict, b: dict, allow_add: bool = True) -> dict: """Return a new dict: b merged into a, recursing into nested dicts.""" result = dict(a) @@ -84,50 +92,7 @@ def dict_deep_merge(a: dict, b: dict, allow_add: bool = True) -> dict: return result -class FormatError(Exception): - pass - - -def format_code(src, singleline=False): - """Format the given src string. If singleline is True, all function - signatures become single-line, so they can be parsed and updated. - """ - line_length = 320 if singleline else 88 - cmd = [ - sys.executable, - "-m", - "ruff", - "format", - "--line-length", - str(line_length), - "--no-cache", - "--stdin-filename", - "tmp.py", - ] - - p = subprocess.run(cmd, input=src.encode(), capture_output=True) - - if p.returncode: - stdout = p.stdout.decode(errors="ignore") - stderr = p.stderr.decode(errors="ignore") - raise FormatError( - f"Could not format source ({p.returncode}).\n\nstdout: " - + stdout - + "\n\nstderr: " - + stderr - ) - else: - result = p.stdout.decode(errors="ignore") - - # Make defs single-line. You'd think that setting the line length - # to a very high number would do the trick, but it does not. - if singleline: - result = _make_sigs_singline(result) - - return result - - -def indent(text: str, indent=4) -> str: +def indent_code(text: str, indent=4) -> str: text = text.strip() lines = [] for line in text.split("\n"): @@ -370,9 +335,135 @@ def read_definition_file(fname: str) -> dict: return structure -def enum_name_to_value(name): - parts = name.split("_") - for i in range(len(parts)): - if parts[i] in ("d1", "d2", "d3"): - parts[i] = parts[i][::-1] - return "-".join(parts) +class FormatError(Exception): + pass + + +def format_code(src, singleline=False): + """Format the given src string. If singleline is True, all function + signatures become single-line, so they can be parsed and updated. + """ + line_length = 320 if singleline else 88 + cmd = [ + sys.executable, + "-m", + "ruff", + "format", + "--line-length", + str(line_length), + "--no-cache", + "--stdin-filename", + "tmp.py", + ] + + p = subprocess.run(cmd, input=src.encode(), capture_output=True) + + if p.returncode: + stdout = p.stdout.decode(errors="ignore") + stderr = p.stderr.decode(errors="ignore") + raise FormatError( + f"Could not format source ({p.returncode}).\n\nstdout: " + + stdout + + "\n\nstderr: " + + stderr + ) + else: + result = p.stdout.decode(errors="ignore") + + # Make defs single-line. You'd think that setting the line length + # to a very high number would do the trick, but it does not. + if singleline: + result = _make_sigs_singleline(result) + + return result + + +def _make_sigs_singleline(code): + lines1 = code.splitlines() + lines2 = [] + + sig_state = 0 + sig_brace_depth = 0 + sig_line = "" + sig_comment = "" + + for line in lines1: + # Check to enter in signature-retrieval mode + if not sig_state: + if line.lstrip().startswith(("def ", "async def", "class ")): + sig_state = 1 + sig_line = "" + sig_comment = "" + sig_brace_depth = 0 + if line.lstrip().startswith("class ") and "(" not in line: + sig_state = 3 # search for closing colon directly + else: + lines2.append(line) + continue + + # If we get here, we're in a signature + + # Handle comment + line, _, c = line.partition("#") + line = line.rstrip() + c = c.strip() + if c: + sig_comment += " " + c.strip() + + if sig_state == 1: + # Find the first opening brace + i = line.find("(") + if i >= 0: + i += 1 + sig_brace_depth = 1 + sig_line += line[:i] + line = line[i:] + sig_state = 2 + + line = line.lstrip() + if sig_line.endswith(","): + line = " " + line + + if sig_state == 2: + # Resolve braces until we find the closing brace + while True: + i1 = line.find("(") + i2 = line.find(")") + if i1 >= 0 and i1 < i2: + i = i1 + 1 + sig_brace_depth += 1 + sig_line += line[:i] + line = line[i:] + elif i2 >= 0: + i = i2 + 1 + sig_brace_depth -= 1 + sig_line += line[:i] + line = line[i:] + else: + break + if sig_brace_depth == 0: + sig_state = 3 + break + + if sig_state == 3: + # Find the closing colon + i = line.find(":") + if i >= 0: + i += 1 + sig_line += line[:i] + line = line[i:] + # Finish the signature line + sig_line = sig_line.replace(", )", ")") + if sig_comment: + sig_line += " #" + sig_comment + lines2.append(sig_line) + if line.strip(): + lines2.append(" " * 12 + line.strip()) + # End the search + sig_state = 0 + line = "" + + sig_line += line + + lines2.append("") + return "\n".join(lines2) diff --git a/apigen/patch_api.py b/apigen/patch_api.py new file mode 100644 index 00000000..313fb010 --- /dev/null +++ b/apigen/patch_api.py @@ -0,0 +1,37 @@ +from apigen_patcher import ApiPatcher, CommentRemover +from apigen_utils import read_definition_file, read_file, write_file + + +def patch_api(): + """Patch the base API in _classes.py.""" + + api = read_definition_file("wgpu_api.json") + code = read_file("wgpu", "_classes.py") + + # code = format_code(code, singleline=True) ?? + + # Write __all__ + extra_public_classes = ["GPUPromise", "DrawCancelled"] + all_public_classes = [*api["classes"].keys(), *extra_public_classes] + all_public_classes.sort() + all_public_classes.remove("GPU") + all_public_classes.insert(0, "GPU") # ruff RUF022 wants it at the top + part1, found_all, part2 = code.partition("\n__all__ =") + if found_all: + part2 = part2.split("]", 1)[-1] + line = "\n__all__ = [" + line += ", ".join(f'"{name}"' for name in all_public_classes) + line += "]" + code = part1 + line + part2 + + # Patch! + for patcher in [CommentRemover(), ApiPatcher(api)]: + patcher.apply(code) + code = patcher.dumps() + + # Write result back + write_file(code, "wgpu", "_classes.py") + + +if __name__ == "__main__": + patch_api() diff --git a/apigen/tests/test_structures.py b/apigen/tests/test_structures.py deleted file mode 100644 index a20eefad..00000000 --- a/apigen/tests/test_structures.py +++ /dev/null @@ -1,13 +0,0 @@ -import os - -from apigen_utils import DEFINITIONS_DIR, read_file - -FILES = [fname for fname in os.listdir(DEFINITIONS_DIR) if fname.endswith(".json")] -BACKEND_FILES = ["diff_backend_pyodide.json", "diff_backend_wgpu.json"] - - -def check_all_definition_files(): - - for fname in FILES: - source = read_file("apigen", "definitions", fname) - s = tomllib.loads(source) diff --git a/apigen/write_api.py b/apigen/write_api.py index 139576c9..c4bbffb0 100644 --- a/apigen/write_api.py +++ b/apigen/write_api.py @@ -5,7 +5,7 @@ from apigen_utils import ( dict_deep_merge, format_code, - # indent, + # indent_code, read_definition_file, read_file, write_file, @@ -69,7 +69,7 @@ def write_flags(flags_dict): for name, flag_dict in flags_dict.items(): pylines.append(f"{name}Flags = int | str\n\n") pylines.append(f"class {name}(Flags):\n") - # pylines.append(f' """{indent(flag_dict["doc"])}"""') + # pylines.append(f' """{indent_code(flag_dict["doc"])}"""') for field_name, field_dict in flag_dict["fields"].items(): pylines.append( f" {field_name} = {field_dict['value']!r}" @@ -104,7 +104,7 @@ def write_enums(enums_dict): quoted_values = [f'"{f["value"]}"' for f in enum_dict["fields"].values()] pylines.append(f"{name}Enum = Literal[{', '.join(quoted_values)}] | str\n\n") pylines.append(f"class {name}(Enum):\n") - # pylines.append(f' """{indent(enum_dict["doc"])}"""') + # pylines.append(f' """{indent_code(enum_dict["doc"])}"""') for field_name, field_dict in enum_dict["fields"].items(): pylines.append( f' {field_name} = "{field_dict["value"]}"' diff --git a/apigen/write_js_api.py b/apigen/write_js_api.py index 21f2cfd5..b2f6a08c 100644 --- a/apigen/write_js_api.py +++ b/apigen/write_js_api.py @@ -1,4 +1,4 @@ -from apigen_utils import read_definition_file, write_file +from apigen_utils import format_code, read_definition_file, write_file preamble = ''' """ @@ -53,6 +53,8 @@ def write_js_api(): code = preamble + "\n".join(lines) + code = format_code(code) + write_file(code, "wgpu", "backends", "js_webgpu", "webgpu_stub.py") From 1dee54098ff305f836783cbb676b15cfe12d99d7 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 29 Oct 2026 11:28:27 +0100 Subject: [PATCH 08/10] Refactor a bit --- apigen/__main__.py | 21 +++++- apigen/apigen_utils.py | 17 ----- apigen/definitions/diff_docs.json | 8 +- apigen/definitions/webgpu.json | 12 +-- apigen/definitions/wgpu_api.json | 10 +-- apigen/extract_idl.py | 120 ++++++++++++++++++++++++------ 6 files changed, 132 insertions(+), 56 deletions(-) diff --git a/apigen/__main__.py b/apigen/__main__.py index 2947fd05..98ddbfd4 100644 --- a/apigen/__main__.py +++ b/apigen/__main__.py @@ -16,8 +16,9 @@ "--" + func.__name__.replace("_", "-"), action="store_true", dest=func.__name__, - help=func.__doc__, + help=func.__doc__.strip().splitlines()[0], ) + parser.add_argument( "--all", action="store_true", @@ -25,6 +26,13 @@ help="Run all steps of the codegen (except download).", ) +parser.add_argument( + "--doc", + action="store", + dest="doc", + help="Show doc on specific action.", +) + # Little trick to allow running this file as a script sys.path.insert(0, os.path.abspath(os.path.join(__file__, "..", ".."))) @@ -33,7 +41,16 @@ args = parser.parse_args() enabled = [k for k, v in vars(args).items() if v is True] - if not enabled: + if args.doc is not None: + the_action = args.doc.replace("-", "_").strip("_") + for func in actions: + if func.__name__ == the_action: + print(f"--- More info for {func.__name__}() ---\n") + print(func.__doc__) + break + else: + sys.exit(f"Unknown action {the_action!r}") + elif not enabled: parser.print_help() elif "all" in enabled: for func in actions: diff --git a/apigen/apigen_utils.py b/apigen/apigen_utils.py index 4761e9e9..6ba1d50f 100644 --- a/apigen/apigen_utils.py +++ b/apigen/apigen_utils.py @@ -48,23 +48,6 @@ def _get_line_endings(text): LE = _get_line_endings((ROOT_DIR / "apigen" / "__init__.py").read_bytes().decode()) -def to_snake_case(name, separator="_"): - """Convert a name from camelCase to snake_case. Names that already are - snake_case remain the same. - """ - name2 = "" - for c in name: - c2 = c.lower() - if c2 != c and len(name2) > 0: - prev = name2[-1] - if c2 == "d" and prev in "123": - name2 = name2[:-1] + separator + prev - elif prev != separator: - name2 += separator - name2 += c2 - return name2 - - def enum_name_to_value(name): parts = name.split("_") for i in range(len(parts)): diff --git a/apigen/definitions/diff_docs.json b/apigen/definitions/diff_docs.json index 2e22ee8e..9478cf67 100644 --- a/apigen/definitions/diff_docs.json +++ b/apigen/definitions/diff_docs.json @@ -1333,7 +1333,7 @@ "reason": { "doc": "The reason for the failure, see enums.PipelineErrorReason." } }, "methods": { - "constructor": { + "__init__": { "doc": "Create a GPUPipelineError.\n\nNormally these are created by the implementation rather than by user code.\n", "returns": { "doc": "A GPUPipelineError." }, "args": { @@ -1789,7 +1789,7 @@ "GPUValidationError": { "doc": "An error that signals that an operation did not satisfy the validation rules of the API, i.e. incorrect usage.\n\nCaptured by error scopes with enums.ErrorFilter.validation.\n", "methods": { - "constructor": { + "__init__": { "doc": "Create a GPUValidationError.\n\nNormally these are created by the implementation rather than by user code.\n", "returns": { "doc": "A GPUValidationError." }, "args": { @@ -1801,7 +1801,7 @@ "GPUOutOfMemoryError": { "doc": "An error that signals that there was not enough memory to complete an operation.\n\nCaptured by error scopes with enums.ErrorFilter.out_of_memory.\n", "methods": { - "constructor": { + "__init__": { "doc": "Create a GPUOutOfMemoryError.\n\nNormally these are created by the implementation rather than by user code.\n", "returns": { "doc": "A GPUOutOfMemoryError." }, "args": { @@ -1813,7 +1813,7 @@ "GPUInternalError": { "doc": "An error that signals that an operation failed for a reason that is not caused by incorrect usage, e.g. an implementation-specific limit.\n\nCaptured by error scopes with enums.ErrorFilter.internal.\n", "methods": { - "constructor": { + "__init__": { "doc": "Create a GPUInternalError.\n\nNormally these are created by the implementation rather than by user code.\n", "returns": { "doc": "A GPUInternalError." }, "args": { diff --git a/apigen/definitions/webgpu.json b/apigen/definitions/webgpu.json index 359dd0ab..d8fbaf2e 100644 --- a/apigen/definitions/webgpu.json +++ b/apigen/definitions/webgpu.json @@ -1289,10 +1289,10 @@ "reason": { "type": "enums.PipelineErrorReasonEnum" } }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": "\"\"" }, + "message": { "type": "str", "default": "" }, "options": { "type": "structs.PipelineErrorInitStruct", "default": "" } } } @@ -1735,7 +1735,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None" }, "args": { "message": { "type": "str", "default": "" } @@ -1747,7 +1747,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None" }, "args": { "message": { "type": "str", "default": "" } @@ -1759,7 +1759,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None" }, "args": { "message": { "type": "str", "default": "" } @@ -1773,7 +1773,7 @@ "error": { "type": "GPUError" } }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None" }, "args": { "type": { "type": "str", "default": "" }, diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json index 29b261cc..c4ed757a 100644 --- a/apigen/definitions/wgpu_api.json +++ b/apigen/definitions/wgpu_api.json @@ -2716,10 +2716,10 @@ } }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None", "doc": "A GPUPipelineError." }, "args": { - "message": { "type": "str", "default": "\"\"", "doc": "The human-readable error message." }, + "message": { "type": "str", "default": "", "doc": "The human-readable error message." }, "options": { "type": "structs.PipelineErrorInitStruct", "default": "", @@ -3463,7 +3463,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None", "doc": "A GPUValidationError." }, "args": { "message": { "type": "str", "default": "", "doc": "The human-readable error message." } @@ -3477,7 +3477,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None", "doc": "A GPUOutOfMemoryError." }, "args": { "message": { "type": "str", "default": "", "doc": "The human-readable error message." } @@ -3491,7 +3491,7 @@ "bases": [ "GPUError" ], "properties": { }, "methods": { - "constructor": { + "__init__": { "returns": { "type": "None", "doc": "A GPUInternalError." }, "args": { "message": { "type": "str", "default": "", "doc": "The human-readable error message." } diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 712abef6..7852090a 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -1,9 +1,9 @@ from typing import Literal from apigen_utils import ( + dict_deep_merge, read_definition_file, read_file, - to_snake_case, write_definition_file, ) @@ -12,10 +12,42 @@ builtins = builtins.__dict__ +# Minimal difference applied to the final structure. Intended for changes that would otherwise make the API invalid Python. +# Make GPUPipelineError.__init__() message arg not have a default, because the second arg has no default either +diff_webgpu = { + "classes": { + "GPUPipelineError": { + "methods": { + "__init__": {"args": {"message": {"default": ""}}}, + } + } + } +} + +# TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure ?? + + def extract_idl(): - """Parse the IDL specification to a structured form in json.""" + """Parse the IDL specification to a structured form in json. + + Some name changes: + + - flag "GPUMapModeFlags" -> "flags.MapMode" + - flag fields remain UPPER_SNAKE_CASE + - enum "GPUPowerPreference" -> "enums.PowerPreference" + - enum fieds are just "dashed-strings", our enums fields are snake_case, but the values match the "dashed-strings" + - struct "GPUBindGroupDescriptor" -> "structs.BindGroupDescriptor" + - struct fields "camelCase" -> "snake_case" + - class "GPUBuffer" stays that way + - methods names "camelCase" -> "snake_case" + - arg names "camelCase" -> "snake_case" - # TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure + Further: + + - types are resolved to valid Python types + - some method args are made required if followed by required args + - methods named "constructor" -> "__init__" + """ # Get the source, and parse into a structure. source = read_file("apigen", "definitions", "webgpu.idl") @@ -25,34 +57,34 @@ def extract_idl(): # Generate structure fname = "webgpu.json" - s = {} - s["meta"] = { + api = {} + api["meta"] = { "filename": fname, "description": "Python-flavored WebGPU API, generated from 'webgpu.idl'.", "notes": "All types are converted to the Python equivalents, all names are made Pythonic snake_case, methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly.", } - flags_dict = s["flags"] = {} + flags_dict = api["flags"] = {} for flag_name, d in parser.flags.items(): flag_dict = flags_dict[flag_name] = {} flag_dict["fields"] = {} for k, v in d.items(): flag_dict["fields"][k] = {"value": v} - enums_dict = s["enums"] = {} + enums_dict = api["enums"] = {} for enum_name, d in parser.enums.items(): enum_dict = enums_dict[enum_name] = {} enum_dict["fields"] = {} for k, v in d.items(): enum_dict["fields"][k] = {"value": v} - structs_dict = s["structs"] = {} + structs_dict = api["structs"] = {} for struct_name, d in parser.structs.items(): struct_dict = structs_dict[struct_name] = {} struct_dict["fields"] = {} for att in d.values(): - struct_dict["fields"][att.py_name] = att.to_dict() + struct_dict["fields"][att.name] = att.to_dict() - classes_dict = s["classes"] = {} + classes_dict = api["classes"] = {} for class_name, interface in parser.classes.items(): class_dict = classes_dict[class_name] = {} class_dict["bases"] = interface.bases @@ -61,17 +93,67 @@ def extract_idl(): class_dict["properties"][prop_name] = {"type": attr_type} # str class_dict["methods"] = {} for func in interface.methods.values(): - method_dict = class_dict["methods"][func.py_name] = {} + method_dict = class_dict["methods"][func.name] = {} method_dict["returns"] = {"type": func.return_type} method_dict["args"] = {} for attribute in func.args: - method_dict["args"][attribute.py_name] = attribute.to_dict() + method_dict["args"][attribute.name] = attribute.to_dict() + + # Convert names + make_names_pythonic(api) + api = dict_deep_merge(api, diff_webgpu) # Write (and read back as a validation step) - write_definition_file(s, fname) + write_definition_file(api, fname) read_definition_file(fname) +def make_names_pythonic(api): + # Struct field names + for _struct_name, struct_dict in api["structs"].items(): + new_fields = {} + for field_name, field_dict in struct_dict["fields"].items(): + new_fields[to_snake_case(field_name)] = field_dict + struct_dict["fields"] = new_fields + + for _class_name, class_dict in api["classes"].items(): + # Class property names + new_properties = {} + for pro_name, prop_dict in class_dict["properties"].items(): + new_properties[to_snake_case(pro_name)] = prop_dict + class_dict["properties"] = new_properties + # Class method names + new_methods = {} + for method_name, method_dict in class_dict["methods"].items(): + new_method_name = to_snake_case(method_name) + if new_method_name == "constructor": + new_method_name = "__init__" + new_methods[new_method_name] = method_dict + # Class method arg names + new_args = {} + for arg_name, arg_dict in method_dict["args"].items(): + new_args[to_snake_case(arg_name)] = arg_dict + method_dict["args"] = new_args + class_dict["methods"] = new_methods + + +def to_snake_case(name, separator="_"): + """Convert a name from camelCase to snake_case. Names that already are + snake_case remain the same. + """ + name2 = "" + for c in name: + c2 = c.lower() + if c2 != c and len(name2) > 0: + prev = name2[-1] + if c2 == "d" and prev in "123": + name2 = name2[:-1] + separator + prev + elif prev != separator: + name2 += separator + name2 += c2 + return name2 + + class Attribute: """A little object to hold a function argument or struct field.""" @@ -122,7 +204,6 @@ def __init__(self, line: str, source: Literal["struct", "param"]): assert bool(default) == (not required) self.name = arg_name - self.py_name = None self.idl_type = arg_type self.py_type = "unresolved_type!" self.default = default @@ -150,7 +231,6 @@ class Function: def __init__(self, name, line): self.name = name self.line = line - self.py_name = None self.args = None self.return_type = None @@ -434,14 +514,12 @@ def _post_process(self): for name, args in self.structs.items(): for _fieldname, arg in args.items(): arg.py_type = self.resolve_type(arg.idl_type) - arg.py_name = to_snake_case(arg.name) - # Resolve classes: attribyte types and method signatures + # Resolve classes: attribute types and method signatures for classname, interface in self.classes.items(): for idl_prop_name in list(interface.properties.keys()): - py_prop_name = to_snake_case(idl_prop_name) - interface.properties[py_prop_name] = self.resolve_type( - interface.properties.pop(idl_prop_name) + interface.properties[idl_prop_name] = self.resolve_type( + interface.properties[idl_prop_name] ) for funcname in list(interface.methods.keys()): @@ -456,9 +534,7 @@ def _post_process(self): ): # TODO: doesn't the type-resolving handle this already? return_type = f"GPUPromise[{return_type}]" for arg in args: - arg.py_name = to_snake_case(arg.name) arg.py_type = self.resolve_type(arg.idl_type) - func.py_name = to_snake_case(func.name) func.return_type = return_type or "None" func.args = args From ce51704cf74faa54710fb9b1b6c1d8186afd4403 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Thu, 29 Oct 2026 12:18:50 +0100 Subject: [PATCH 09/10] do type resolving in separate step too --- apigen/definitions/webgpu.json | 12 +- apigen/definitions/wgpu_api.json | 15 +- apigen/extract_idl.py | 365 ++++++++++++++++--------------- apigen/write_js_api.py | 2 + 4 files changed, 203 insertions(+), 191 deletions(-) diff --git a/apigen/definitions/webgpu.json b/apigen/definitions/webgpu.json index d8fbaf2e..06fcb886 100644 --- a/apigen/definitions/webgpu.json +++ b/apigen/definitions/webgpu.json @@ -1021,7 +1021,7 @@ }, "methods": { "request_adapter": { - "returns": { "type": "GPUAdapter" }, + "returns": { "type": "GPUPromise[GPUAdapter]" }, "args": { "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}" } } @@ -1041,7 +1041,7 @@ }, "methods": { "request_device": { - "returns": { "type": "GPUDevice" }, + "returns": { "type": "GPUPromise[GPUDevice]" }, "args": { "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}" } } @@ -1055,7 +1055,7 @@ "limits": { "type": "dict" }, "adapter_info": { "type": "GPUAdapterInfo" }, "queue": { "type": "GPUQueue" }, - "lost": { "type": "GPUDeviceLostInfo" }, + "lost": { "type": "GPUPromise[GPUDeviceLostInfo]" }, "onuncapturederror": { "type": "None" } }, "methods": { @@ -1160,7 +1160,7 @@ } }, "pop_error_scope": { - "returns": { "type": "GPUError" }, + "returns": { "type": "GPUPromise[GPUError]" }, "args": { } } } @@ -1259,7 +1259,7 @@ "properties": { }, "methods": { "get_compilation_info": { - "returns": { "type": "GPUCompilationInfo" }, + "returns": { "type": "GPUPromise[GPUCompilationInfo]" }, "args": { } } } @@ -1645,7 +1645,7 @@ } }, "on_submitted_work_done": { - "returns": { "type": "None" }, + "returns": { "type": "GPUPromise[None]" }, "args": { } }, "write_buffer": { diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json index c4ed757a..ea831cd5 100644 --- a/apigen/definitions/wgpu_api.json +++ b/apigen/definitions/wgpu_api.json @@ -2273,7 +2273,7 @@ }, "methods": { "request_adapter": { - "returns": { "type": "GPUAdapter", "doc": "A GPUAdapter, or None if no suitable adapter was found." }, + "returns": { "type": "GPUPromise[GPUAdapter]", "doc": "A GPUAdapter, or None if no suitable adapter was found." }, "args": { "options": { "type": "structs.RequestAdapterOptionsStruct", @@ -2306,7 +2306,7 @@ }, "methods": { "request_device": { - "returns": { "type": "GPUDevice", "doc": "A GPUDevice." }, + "returns": { "type": "GPUPromise[GPUDevice]", "doc": "A GPUDevice." }, "args": { "descriptor": { "type": "structs.DeviceDescriptorStruct", @@ -2336,7 +2336,7 @@ }, "queue": { "type": "GPUQueue", "doc": "The default GPUQueue of the device." }, "lost": { - "type": "GPUDeviceLostInfo", + "type": "GPUPromise[GPUDeviceLostInfo]", "doc": "A promise or future that stays pending for the lifetime of the device and resolves to a GPUDeviceLostInfo when the device is lost." }, "onuncapturederror": { @@ -2517,7 +2517,7 @@ }, "pop_error_scope": { "returns": { - "type": "GPUError", + "type": "GPUPromise[GPUError]", "doc": "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." }, "args": { }, @@ -2664,7 +2664,10 @@ "properties": { }, "methods": { "get_compilation_info": { - "returns": { "type": "GPUCompilationInfo", "doc": "A GPUCompilationInfo (awaitable) with the list of messages." }, + "returns": { + "type": "GPUPromise[GPUCompilationInfo]", + "doc": "A GPUCompilationInfo (awaitable) with the list of messages." + }, "args": { }, "doc": "Get diagnostic messages (errors, warnings, info) produced when compiling the shader.\n\nThe locations, order and contents of the messages are implementation-defined; in particular, they are not necessarily ordered by line number.\n" } @@ -3327,7 +3330,7 @@ "doc": "Submit a list of command buffers for execution on the GPU.\n\nEach command buffer can only be submitted once.\n" }, "on_submitted_work_done": { - "returns": { "type": "None", "doc": "None (awaitable); resolves when the submitted work is done." }, + "returns": { "type": "GPUPromise[None]", "doc": "None (awaitable); resolves when the submitted work is done." }, "args": { }, "doc": "Wait until all work that was submitted so far has been completed by the GPU.\n\nResolving also implies completion of earlier GPUBuffer.map_async() calls on buffers last used exclusively on this queue.\n" }, diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 7852090a..69d569c6 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -13,11 +13,12 @@ # Minimal difference applied to the final structure. Intended for changes that would otherwise make the API invalid Python. -# Make GPUPipelineError.__init__() message arg not have a default, because the second arg has no default either diff_webgpu = { "classes": { "GPUPipelineError": { "methods": { + # Make GPUPipelineError.__init__() message arg not have a default, + # because the second arg has no default either "__init__": {"args": {"message": {"default": ""}}}, } } @@ -30,23 +31,12 @@ def extract_idl(): """Parse the IDL specification to a structured form in json. - Some name changes: + This is done in three stages: - - flag "GPUMapModeFlags" -> "flags.MapMode" - - flag fields remain UPPER_SNAKE_CASE - - enum "GPUPowerPreference" -> "enums.PowerPreference" - - enum fieds are just "dashed-strings", our enums fields are snake_case, but the values match the "dashed-strings" - - struct "GPUBindGroupDescriptor" -> "structs.BindGroupDescriptor" - - struct fields "camelCase" -> "snake_case" - - class "GPUBuffer" stays that way - - methods names "camelCase" -> "snake_case" - - arg names "camelCase" -> "snake_case" - - Further: - - - types are resolved to valid Python types - - some method args are made required if followed by required args - - methods named "constructor" -> "__init__" + - Parsing the IDL and buil up an internal representation. + - Convert that representation to our structured API dict form. + - Resolve names, converting camelCase to snake_case, for struct fields, methods, and method arguments. + - Resolve JS types to Python types. """ # Get the source, and parse into a structure. @@ -55,7 +45,6 @@ def extract_idl(): parser.parse() # Generate structure - fname = "webgpu.json" api = {} api["meta"] = { @@ -63,6 +52,23 @@ def extract_idl(): "description": "Python-flavored WebGPU API, generated from 'webgpu.idl'.", "notes": "All types are converted to the Python equivalents, all names are made Pythonic snake_case, methods that accept a single descriptor arg are *not* yet resolved to accept the descriptor args directly.", } + api.update(build_api_dict(parser)) + + # Convert names and types + make_names_pythonic(api) + resolve_types(api, parser) + + # Some final tweaks + api = dict_deep_merge(api, diff_webgpu) + + # Write (and read back as a validation step) + write_definition_file(api, fname) + read_definition_file(fname) + + +def build_api_dict(parser): + """Build api dict from the parser's result.""" + api = {} flags_dict = api["flags"] = {} for flag_name, d in parser.flags.items(): flag_dict = flags_dict[flag_name] = {} @@ -99,16 +105,12 @@ def extract_idl(): for attribute in func.args: method_dict["args"][attribute.name] = attribute.to_dict() - # Convert names - make_names_pythonic(api) - api = dict_deep_merge(api, diff_webgpu) - - # Write (and read back as a validation step) - write_definition_file(api, fname) - read_definition_file(fname) + return api def make_names_pythonic(api): + """Convert camelCase to snake_case.""" + # Struct field names for _struct_name, struct_dict in api["structs"].items(): new_fields = {} @@ -119,9 +121,10 @@ def make_names_pythonic(api): for _class_name, class_dict in api["classes"].items(): # Class property names new_properties = {} - for pro_name, prop_dict in class_dict["properties"].items(): - new_properties[to_snake_case(pro_name)] = prop_dict + for prop_name, prop_dict in class_dict["properties"].items(): + new_properties[to_snake_case(prop_name)] = prop_dict class_dict["properties"] = new_properties + # Class method names new_methods = {} for method_name, method_dict in class_dict["methods"].items(): @@ -129,6 +132,7 @@ def make_names_pythonic(api): if new_method_name == "constructor": new_method_name = "__init__" new_methods[new_method_name] = method_dict + # Class method arg names new_args = {} for arg_name, arg_dict in method_dict["args"].items(): @@ -138,9 +142,7 @@ def make_names_pythonic(api): def to_snake_case(name, separator="_"): - """Convert a name from camelCase to snake_case. Names that already are - snake_case remain the same. - """ + """Convert a name from camelCase to snake_case. Names that already are snake_case remain the same.""" name2 = "" for c in name: c2 = c.lower() @@ -154,6 +156,155 @@ def to_snake_case(name, separator="_"): return name2 +def resolve_types(api, parser): + """Resolve JS types to Python equivalents.""" + resolver = TypeResolver(api, parser.typedefs) + resolve_type = resolver.resolve_type + + # Struct fields + for _struct_name, struct_dict in api["structs"].items(): + for _field_name, field_dict in struct_dict["fields"].items(): + field_dict["type"] = resolve_type(field_dict["type"]) + + for _class_name, class_dict in api["classes"].items(): + # Class properties + for _prop_name, prop_dict in class_dict["properties"].items(): + prop_dict["type"] = resolve_type(prop_dict["type"]) + + # Class method args and return + for _method_name, method_dict in class_dict["methods"].items(): + method_dict["returns"]["type"] = resolve_type( + method_dict["returns"]["type"] + ) + for _arg_name, arg_dict in method_dict["args"].items(): + arg_dict["type"] = resolve_type(arg_dict["type"]) + + +class TypeResolver: + typemap = { + "DOMString": "str", + "USVString": "str", + "long": "int", + "unsigned long": "int", + "unsigned long long": "int", + "[Clamp] unsigned short": "int", + "double": "float", + "boolean": "bool", + "ImageBitmap": "ArrayLike", + "ImageData": "ArrayLike", + "VideoFrame": "ArrayLike", + "AllowSharedBufferSource": "ArrayLike", + "[AllowShared] Uint32Array": "ArrayLike", + "GPUPipelineConstantValue": "float", + "GPUExternalTexture": "object", + "undefined": "None", + "ArrayBuffer": "ArrayLike", + "WGSLLanguageFeatures": "set", + "GPUSupportedFeatures": "set", + "GPUSupportedLimits": "dict", + "EventHandler": "None", + "HTMLCanvasElement": "CanvasLike", + "OffscreenCanvas": "CanvasLike", + } + + def __init__(self, apidict: dict, typedefs: dict): + self.typedefs = typedefs + self.apidict = apidict + + def resolve_type(self, typename: str) -> str: + """Resolve a type to a suitable name that is also valid so that the linter + won't complain when this is used as a type annotation. + """ + + name = typename.strip().strip("?") + + # We want the flag, not the type that is an alias for int + name = name[:-5] if name.endswith("Flags") else name + + # First resolve using typedefs that we found in the IDL + while name in self.typedefs: + new_name = self.typedefs[name] + if new_name == name: + break + name = new_name + + # Resolve to a Python type (maybe) + + name = self.typemap.get(name, name) + + # Is this a case for which we need to recurse? + if ( + name.startswith("sequence<") or name.startswith("FrozenArray<") + ) and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + name = self.resolve_type(name).strip("'") + return f"list[{name}]" + elif name.startswith("record<") and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + names = [self.resolve_type(t).strip("'") for t in name.split(",")] + return f"dict[{', '.join(names)}]" + elif " or " in name: + # Clean + name = name.strip("()") + names = [self.resolve_type(t).strip("'") for t in name.split(" or ")] + names = set(names) # de-dupe + has_none = "None" in names + names.discard("None") + names = sorted(names) + if has_none: + names.append("None") + # Triage + if len(names) == 1: + return names[0] + if ( + len(names) == 2 + and names[0] in ("list[int]", "list[float]") + and names[1].endswith("Struct") + and names[1].startswith( + ("structs.Origin", "structs.Extent", "structs.Color") + ) + ): + if names[1].endswith("ColorStruct"): + names[0] = "tuple[float, float, float, float]" + elif names[1].endswith("2DStruct"): + names[0] = "tuple[int, int]" + elif names[1].endswith("3DStruct"): + names[0] = "tuple[int, int, int]" + return " | ".join(names) + if name.startswith("Promise<") and name.endswith(">"): + subname = name.split("<")[-1].rstrip(">") + subname = self.resolve_type(subname) + return f"GPUPromise[{subname}]" + + # Triage + if name in builtins: + return name # ok + elif name in ["ArrayLike", "CanvasLike"]: + return name # virtual types + elif name in self.apidict["classes"]: + return name + elif name.startswith("HTML"): + return "object" # anything, we ignore this stuff anyway + elif name in ["PredefinedColorSpace"]: + return "str" + else: + assert name.startswith("GPU"), f"Unknown type: {name}" + name = name[3:] + name = name[:-4] if name.endswith("Dict") else name + if name in self.apidict["flags"]: + return f"flags.{name}Flags" + elif name in self.apidict["enums"]: + return f"enums.{name}Enum" + elif name in self.apidict["structs"]: + return f"structs.{name}Struct" + else: + # When this happens, update the code above or the typemap + raise RuntimeError("Encountered unknown IDL type: ", name) + + +# ------------------------------ The parser code ------------------------------ + + class Attribute: """A little object to hold a function argument or struct field.""" @@ -205,14 +356,13 @@ def __init__(self, line: str, source: Literal["struct", "param"]): self.name = arg_name self.idl_type = arg_type - self.py_type = "unresolved_type!" self.default = default def __repr__(self): return f"" def to_dict(self) -> dict: - return {"type": self.py_type, "default": self.default} + return {"type": self.idl_type, "default": self.default} class Interface: @@ -510,158 +660,15 @@ def _post_process(self): if name.endswith("Base"): self.structs.pop(name) - # Resolve struct types - for name, args in self.structs.items(): - for _fieldname, arg in args.items(): - arg.py_type = self.resolve_type(arg.idl_type) - - # Resolve classes: attribute types and method signatures - for classname, interface in self.classes.items(): - for idl_prop_name in list(interface.properties.keys()): - interface.properties[idl_prop_name] = self.resolve_type( - interface.properties[idl_prop_name] - ) - + # Resolve method signatures + for interface in self.classes.values(): for funcname in list(interface.methods.keys()): func = interface.methods[funcname] - args, return_type = self._resolve_signature( - classname, funcname, func.line - ) - if return_type: - return_type = self.resolve_type(return_type) - if funcname.lower().endswith( - "async" - ): # TODO: doesn't the type-resolving handle this already? - return_type = f"GPUPromise[{return_type}]" - for arg in args: - arg.py_type = self.resolve_type(arg.idl_type) + args, return_type = self._resolve_signature(func.line) func.return_type = return_type or "None" func.args = args - def resolve_type(self, typename) -> str: - """Resolve a type to a suitable name that is also valid so that the linter - won't complain when this is used as a type annotation. - """ - - name = typename.strip().strip("?") - - # We want the flag, not the type that is an alias for int - name = name[:-5] if name.endswith("Flags") else name - - # First resolve using typedefs that we found in the IDL - while name in self.typedefs: - new_name = self.typedefs[name] - if new_name == name: - break - name = new_name - - # Resolve to a Python type (maybe) - pythonmap = { - "DOMString": "str", - "DOMString?": "str", - "USVString": "str", - "long": "int", - "unsigned long": "int", - "unsigned long long": "int", - "[Clamp] unsigned short": "int", - "unsigned short": "int", - "GPUIntegerCoordinate": "int", - "GPUSampleMask": "int", - "GPUFenceValue": "int", - "GPUSize64": "int", - "GPUSize32": "int", - "GPUIndex32": "int", - "double": "float", - "boolean": "bool", - "object": "dict", - "ImageBitmap": "ArrayLike", - "ImageData": "ArrayLike", - "VideoFrame": "ArrayLike", - "AllowSharedBufferSource": "ArrayLike", - "[AllowShared] Uint32Array": "ArrayLike", - "GPUPipelineConstantValue": "float", - "GPUExternalTexture": "object", - "undefined": "None", - "ArrayBuffer": "ArrayLike", - "WGSLLanguageFeatures": "set", - "GPUSupportedFeatures": "set", - "GPUSupportedLimits": "dict", - "EventHandler": "None", - "HTMLCanvasElement": "CanvasLike", - "OffscreenCanvas": "CanvasLike", - } - name = pythonmap.get(name, name) - - # Is this a case for which we need to recurse? - if ( - name.startswith("sequence<") or name.startswith("FrozenArray<") - ) and name.endswith(">"): - name = name.split("<")[-1].rstrip(">") - name = self.resolve_type(name).strip("'") - return f"list[{name}]" - elif name.startswith("record<") and name.endswith(">"): - name = name.split("<")[-1].rstrip(">") - names = [self.resolve_type(t).strip("'") for t in name.split(",")] - return f"dict[{', '.join(names)}]" - elif " or " in name: - # Clean - name = name.strip("()") - names = [self.resolve_type(t).strip("'") for t in name.split(" or ")] - names = set(names) # de-dupe - has_none = "None" in names - names.discard("None") - names = sorted(names) - if has_none: - names.append("None") - # Triage - if len(names) == 1: - return names[0] - if ( - len(names) == 2 - and names[0] in ("list[int]", "list[float]") - and names[1].endswith("Struct") - and names[1].startswith( - ("structs.Origin", "structs.Extent", "structs.Color") - ) - ): - if names[1].endswith("ColorStruct"): - names[0] = "tuple[float, float, float, float]" - elif names[1].endswith("2DStruct"): - names[0] = "tuple[int, int]" - elif names[1].endswith("3DStruct"): - names[0] = "tuple[int, int, int]" - return " | ".join(names) - if name.startswith("Promise<") and name.endswith(">"): - name = name.split("<")[-1].rstrip(">") - # recursive call if there are any of the above situations? - return self.resolve_type(name) - - # Triage - if name in builtins: - return name # ok - elif name in ["ArrayLike", "CanvasLike"]: - return name # virtual types - elif name in self.classes: - return name - elif name.startswith("HTML"): - return "object" # anything, we ignore this stuff anyway - elif name in ["PredefinedColorSpace"]: - return "str" - else: - assert name.startswith("GPU"), f"Unknown type: {name}" - name = name[3:] - name = name[:-4] if name.endswith("Dict") else name - if name in self.flags: - return f"flags.{name}Flags" - elif name in self.enums: - return f"enums.{name}Enum" - elif name in self.structs: - return f"structs.{name}Struct" - else: - # When this happens, update the code above or the pythonmap - raise RuntimeError("Encountered unknown IDL type: ", name) - - def _resolve_signature(self, classname, methodname, idl_line): + def _resolve_signature(self, idl_line: str): # Get arg names and types args = idl_line.split("(", 1)[1].split(")", 1)[0].split(",") args = [Attribute(arg, "param") for arg in args if arg.strip()] diff --git a/apigen/write_js_api.py b/apigen/write_js_api.py index b2f6a08c..7dc9f4e7 100644 --- a/apigen/write_js_api.py +++ b/apigen/write_js_api.py @@ -8,6 +8,8 @@ """ ''' +# todo: replace GPUPromise -> Promise or something? + def write_js_api(): """Write the Python stub API for WebGPU, to use in typechecking for web backends.""" From b506894b02b25c712371c6c3f8f90d0bd7a34dd7 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Fri, 30 Oct 2026 09:27:43 +0100 Subject: [PATCH 10/10] Progress on making it generate the existing api --- apigen/__init__.py | 11 +- apigen/apigen_patcher.py | 51 ++++- apigen/definitions/diff_base.json | 106 ++++++++- apigen/definitions/webgpu.json | 184 +++++++-------- apigen/definitions/wgpu_api.json | 361 +++++++++++++++++++----------- apigen/extract_idl.py | 84 ++++--- apigen/merge_json.py | 28 +++ apigen/patch_api.py | 2 +- apigen/write_api.py | 1 - 9 files changed, 564 insertions(+), 264 deletions(-) diff --git a/apigen/__init__.py b/apigen/__init__.py index 20cc7426..66f931e1 100644 --- a/apigen/__init__.py +++ b/apigen/__init__.py @@ -4,7 +4,16 @@ from extract_idl import extract_idl from format_json import format_json from merge_json import merge_json +from patch_api import patch_api from write_api import write_api from write_js_api import write_js_api -actions = [download_idl, extract_idl, format_json, merge_json, write_api, write_js_api] +actions = [ + download_idl, + extract_idl, + format_json, + merge_json, + patch_api, + write_api, + write_js_api, +] diff --git a/apigen/apigen_patcher.py b/apigen/apigen_patcher.py index e90d4bef..a2e7c0c2 100644 --- a/apigen/apigen_patcher.py +++ b/apigen/apigen_patcher.py @@ -185,9 +185,14 @@ class ApiPatcher(Patcher): walk over each of its properties and methods to patch these too. """ - def __init__(self, api_dict): + known_external_classes = {"GPUPromise"} + + def __init__(self, api_dict, explode_single_args_that_are_descriptors: bool): super().__init__() self.api_dict = api_dict + self.explode_single_args_that_are_descriptors = ( + explode_single_args_that_are_descriptors + ) def apply(self, code): self._init(code) @@ -203,7 +208,9 @@ def patch_classes(self): for classname, i1, i2 in self.iter_classes(): seen_classes.add(classname) self._apidiffs = set() - if self.class_is_known(classname): + if classname in self.known_external_classes: + pass + elif self.class_is_known(classname): old_line = self.lines[i1] new_line = self.get_class_def(classname) if old_line != new_line: @@ -240,7 +247,7 @@ def patch_properties(self, classname, i1, i2): if self.prop_is_known(classname, propname): old_line = self.lines[j1] new_line = self.get_property_def(classname, propname) - if old_line != new_line: + if old_line != new_line.split("@property\n")[1]: fixme_line = " # FIXME: was " + old_line.split("def ", 1)[-1] lines = [fixme_line, new_line] self.replace_line(j1, "\n".join(lines)) @@ -269,6 +276,8 @@ def patch_methods(self, classname, i1, i2): fixme_line = " # FIXME: was " + old_line.split("def ", 1)[-1] lines = [fixme_line, new_line] self.replace_line(j1, "\n".join(lines)) + elif methodname.startswith("_"): + pass else: msg = f"unknown api: method {classname}.{methodname}" self.insert_line(j1, " # FIXME: " + msg) @@ -286,7 +295,6 @@ def get_missing_properties(self, classname, seen_props): for propname in self.get_prop_names(classname): if propname not in seen_props: lines.append(" # FIXME: new prop to implement") - lines.append(" @property") lines.append(self.get_property_def(classname, propname)) lines.append(" raise NotImplementedError()") lines.append("") @@ -316,8 +324,35 @@ def get_property_def(self, class_name, prop_name) -> str: def get_method_def(self, class_name, method_name) -> str: method_dict = self.api_dict["classes"][class_name]["methods"][method_name] args = ["self"] - for arg_name, arg_dict in method_dict["args"].items(): - arg = f"{arg_name}: {arg_dict['type']}" + args_dict = method_dict["args"] + # Maybe use descriptor field as args + if ( + self.explode_single_args_that_are_descriptors + and len(method_dict["args"]) == 1 + ): + arg_type_name = list(method_dict["args"].values())[0]["type"] + if arg_type_name.startswith("structs."): + if arg_type_name.endswith(" | None"): + arg_type_name = arg_type_name[:-7] + if arg_type_name.endswith("Struct"): + arg_type_name = arg_type_name[:-6] + args.append("*") + args_dict = self.api_dict["structs"][arg_type_name[8:]]["fields"] + # Maybe make the args non-positional + if "*" not in args: + need_star = False + previous_where_all_required = True + for arg_name, arg_dict in args_dict.items(): + if arg_dict["default"]: + previous_where_all_required = False + elif not previous_where_all_required: + need_star = True + if need_star: + args.append("*") + # Build signature + for arg_name, arg_dict in args_dict.items(): + typ = arg_dict["type"] + arg = f"{arg_name}: {typ}" if arg_dict["default"]: arg += f" = {arg_dict['default']}" args.append(arg) @@ -337,10 +372,10 @@ def get_class_names(self): return list(self.api_dict["classes"].keys()) def get_prop_names(self, class_name): - return list(self.api_dict["classes"][class_name]["properties"].keys()) + return list(self.api_dict["classes"][class_name].get("properties", {}).keys()) def get_method_names(self, class_name): - return list(self.api_dict["classes"][class_name]["methods"].keys()) + return list(self.api_dict["classes"][class_name].get("methods", {}).keys()) class StructValidationChecker(Patcher): diff --git a/apigen/definitions/diff_base.json b/apigen/definitions/diff_base.json index 1e14230e..d1bfcb96 100644 --- a/apigen/definitions/diff_base.json +++ b/apigen/definitions/diff_base.json @@ -5,14 +5,108 @@ "notes": "We mostly *remove* things that we cannot replicate on desktop. So that we get an API surface that is the intersection of what we can use on desktop and web." }, "classes": { + "GPU": { + "methods": { + "enumerate_adapters_async": { + "doc": "Get a list of adapter objects available on the current system.", + "returns": { "type": "GPUPromise[list[GPUAdapter]]" }, + "args": {} + }, + "enumerate_adapters_sync": { + "doc": "Get a list of adapter objects available on the current system.", + "returns": { "type": "list[GPUAdapter]" }, + "args": {} + }, + "get_canvas_context": { + "doc": "Get the GPUCanvasContext object for the appropriate backend.\n\nNote that the recommended way to get a context is to instead use the ``rendercanvas`` library.\n\nThe ``present_info`` dict should have a ``window`` field containing the window id. On Linux there should also be ``platform`` field to distinguish between 'wayland' and 'x11', and a ``display`` field for the display id. For the Pyodide backend, the ``window`` is the ```` object. This dict is an interface between `rendercanvas`` and ``wgpu-py``.", + "returns": { "type": "GPUCanvasContext" }, + "args": { + "present_info": { + "type": "dict", + "default": "", + "doc": "The low-level presentation info." + } + } + } + } + }, + "GPUCanvasContext": { + "properties": { + "physical_size": { + "doc": "Get the physical size of the current framebuffer.", + "type": "tuple[int, int]" + } + }, + "methods": { + "set_physical_size": { + "doc": "Set the current framebuffer physical size.", + "returns": { "type": "None" }, + "args": { + "width": { + "type": "int", + "default": "", + "doc": "The new width of the framebuffer." + }, + "height": { + "type": "int", + "default": "", + "doc": "The new height of the framebuffer." + } + } + }, + "get_preferred_format": { + "doc": "Get the preferred surface texture format.", + "returns": { "type": "enums.TextureFormat" }, + "args": { "adapter": { "type": "GPUAdapter", "default": "" } } + }, + "present": { + "doc": "Present what has been drawn to the current texture, by compositing it to the canvas.", + "returns": { "type": "None" }, + "args": {} + } + } + }, + "GPUAdapterInfo": { + "bases": ["dict"] + }, + "GPUObjectBase": { + "properties": { + "uid": { + "type": "int", + "doc": "A unique id (integer) for this object.\n\nThe value is unique to the process; in contrast to ``id(ob)``, the numbers are never reused." + } + } + }, + "GPUAdapter": { + "properties": { + "summary": { + "type": "str", + "doc": "A one-line summary of the info of this adapter (device, adapter_type, backend_type)." + } + } + }, "GPUQueue": { "methods": { "copy_external_image_to_texture": { "diff": "REMOVE" } } }, "GPUDevice": { + "properties": { + "adapter": { + "type": "GPUAdapter", + "doc": "The adapter object corresponding to this device." + } + }, "methods": { - "import_external_texture": { "diff": "REMOVE" } + "import_external_texture": { "diff": "REMOVE" }, + "create_buffer_with_data": { + "returns": { "type": "GPUBuffer" }, + "args": { + "label": { "type": "str", "default": "\"\"" }, + "data": { "type": "ArrayLike", "default": "" }, + "usage": { "type": "flags.BufferUsageFlags", "default": "" } + } + } } }, "NavigatorGPU": { "diff": "REMOVE" }, @@ -30,6 +124,16 @@ "fields": { "external_texture": { "diff": "REMOVE" } } + }, + "RequestAdapterOptions": { + "fields": { + "power_preference": { + "type": "enums.PowerPreference | None", + "default": "None" + }, + "canvas": { "type": "CanvasLike | None", "default": "None" }, + "xr_compatible": { "diff": "REMOVE" } + } } } } diff --git a/apigen/definitions/webgpu.json b/apigen/definitions/webgpu.json index 06fcb886..a796298b 100644 --- a/apigen/definitions/webgpu.json +++ b/apigen/definitions/webgpu.json @@ -469,7 +469,7 @@ "RequestAdapterOptions": { "fields": { "feature_level": { "type": "str", "default": "\"core\"" }, - "power_preference": { "type": "enums.PowerPreferenceEnum", "default": "None" }, + "power_preference": { "type": "enums.PowerPreferenceEnum | None", "default": "None" }, "force_fallback_adapter": { "type": "bool", "default": "False" }, "xr_compatible": { "type": "bool", "default": "False" } } @@ -477,9 +477,9 @@ "DeviceDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "required_features": { "type": "list[enums.FeatureNameEnum]", "default": "[]" }, - "required_limits": { "type": "dict[str, int | None]", "default": "{}" }, - "default_queue": { "type": "structs.QueueDescriptorStruct", "default": "{}" } + "required_features": { "type": "Sequence[enums.FeatureNameEnum]", "default": "()" }, + "required_limits": { "type": "dict[str, int | None] | None", "default": "None" }, + "default_queue": { "type": "structs.QueueDescriptorStruct | None", "default": "None" } } }, "BufferDescriptor": { @@ -499,21 +499,21 @@ "dimension": { "type": "enums.TextureDimensionEnum", "default": "\"2d\"" }, "format": { "type": "enums.TextureFormatEnum", "default": "" }, "usage": { "type": "flags.TextureUsageFlags", "default": "" }, - "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]" }, - "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "None" } + "view_formats": { "type": "Sequence[enums.TextureFormatEnum]", "default": "()" }, + "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum | None", "default": "None" } } }, "TextureViewDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "format": { "type": "enums.TextureFormatEnum", "default": "None" }, - "dimension": { "type": "enums.TextureViewDimensionEnum", "default": "None" }, + "format": { "type": "enums.TextureFormatEnum | None", "default": "None" }, + "dimension": { "type": "enums.TextureViewDimensionEnum | None", "default": "None" }, "usage": { "type": "flags.TextureUsageFlags", "default": "0" }, "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" }, "base_mip_level": { "type": "int", "default": "0" }, - "mip_level_count": { "type": "int", "default": "None" }, + "mip_level_count": { "type": "int | None", "default": "None" }, "base_array_layer": { "type": "int", "default": "0" }, - "array_layer_count": { "type": "int", "default": "None" }, + "array_layer_count": { "type": "int | None", "default": "None" }, "swizzle": { "type": "str", "default": "\"rgba\"" } } }, @@ -535,25 +535,25 @@ "mipmap_filter": { "type": "enums.MipmapFilterModeEnum", "default": "\"nearest\"" }, "lod_min_clamp": { "type": "float", "default": "0" }, "lod_max_clamp": { "type": "float", "default": "32" }, - "compare": { "type": "enums.CompareFunctionEnum", "default": "None" }, + "compare": { "type": "enums.CompareFunctionEnum | None", "default": "None" }, "max_anisotropy": { "type": "int", "default": "1" } } }, "BindGroupLayoutDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "entries": { "type": "list[structs.BindGroupLayoutEntryStruct]", "default": "" } + "entries": { "type": "Sequence[structs.BindGroupLayoutEntryStruct]", "default": "" } } }, "BindGroupLayoutEntry": { "fields": { "binding": { "type": "int", "default": "" }, "visibility": { "type": "flags.ShaderStageFlags", "default": "" }, - "buffer": { "type": "structs.BufferBindingLayoutStruct", "default": "None" }, - "sampler": { "type": "structs.SamplerBindingLayoutStruct", "default": "None" }, - "texture": { "type": "structs.TextureBindingLayoutStruct", "default": "None" }, - "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct", "default": "None" }, - "external_texture": { "type": "structs.ExternalTextureBindingLayoutStruct", "default": "None" } + "buffer": { "type": "structs.BufferBindingLayoutStruct | None", "default": "None" }, + "sampler": { "type": "structs.SamplerBindingLayoutStruct | None", "default": "None" }, + "texture": { "type": "structs.TextureBindingLayoutStruct | None", "default": "None" }, + "storage_texture": { "type": "structs.StorageTextureBindingLayoutStruct | None", "default": "None" }, + "external_texture": { "type": "structs.ExternalTextureBindingLayoutStruct | None", "default": "None" } } }, "BufferBindingLayout": { @@ -589,7 +589,7 @@ "fields": { "label": { "type": "str", "default": "\"\"" }, "layout": { "type": "GPUBindGroupLayout", "default": "" }, - "entries": { "type": "list[structs.BindGroupEntryStruct]", "default": "" } + "entries": { "type": "Sequence[structs.BindGroupEntryStruct]", "default": "" } } }, "BindGroupEntry": { @@ -605,13 +605,13 @@ "fields": { "buffer": { "type": "GPUBuffer", "default": "" }, "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "PipelineLayoutDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "bind_group_layouts": { "type": "list[GPUBindGroupLayout]", "default": "" }, + "bind_group_layouts": { "type": "Sequence[GPUBindGroupLayout]", "default": "" }, "immediate_size": { "type": "int", "default": "0" } } }, @@ -619,13 +619,13 @@ "fields": { "label": { "type": "str", "default": "\"\"" }, "code": { "type": "str", "default": "" }, - "compilation_hints": { "type": "list[structs.ShaderModuleCompilationHintStruct]", "default": "[]" } + "compilation_hints": { "type": "Sequence[structs.ShaderModuleCompilationHintStruct]", "default": "()" } } }, "ShaderModuleCompilationHint": { "fields": { "entry_point": { "type": "str", "default": "" }, - "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "None" } + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum | None", "default": "None" } } }, "PipelineErrorInit": { @@ -636,8 +636,8 @@ "ProgrammableStage": { "fields": { "module": { "type": "GPUShaderModule", "default": "" }, - "entry_point": { "type": "str", "default": "None" }, - "constants": { "type": "dict[str, float]", "default": "{}" } + "entry_point": { "type": "str | None", "default": "None" }, + "constants": { "type": "dict[str, float] | None", "default": "None" } } }, "ComputePipelineDescriptor": { @@ -652,16 +652,16 @@ "label": { "type": "str", "default": "\"\"" }, "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "" }, "vertex": { "type": "structs.VertexStateStruct", "default": "" }, - "primitive": { "type": "structs.PrimitiveStateStruct", "default": "{}" }, - "depth_stencil": { "type": "structs.DepthStencilStateStruct", "default": "None" }, - "multisample": { "type": "structs.MultisampleStateStruct", "default": "{}" }, - "fragment": { "type": "structs.FragmentStateStruct", "default": "None" } + "primitive": { "type": "structs.PrimitiveStateStruct | None", "default": "None" }, + "depth_stencil": { "type": "structs.DepthStencilStateStruct | None", "default": "None" }, + "multisample": { "type": "structs.MultisampleStateStruct | None", "default": "None" }, + "fragment": { "type": "structs.FragmentStateStruct | None", "default": "None" } } }, "PrimitiveState": { "fields": { "topology": { "type": "enums.PrimitiveTopologyEnum", "default": "\"triangle-list\"" }, - "strip_index_format": { "type": "enums.IndexFormatEnum", "default": "None" }, + "strip_index_format": { "type": "enums.IndexFormatEnum | None", "default": "None" }, "front_face": { "type": "enums.FrontFaceEnum", "default": "\"ccw\"" }, "cull_mode": { "type": "enums.CullModeEnum", "default": "\"none\"" }, "unclipped_depth": { "type": "bool", "default": "False" } @@ -677,15 +677,15 @@ "FragmentState": { "fields": { "module": { "type": "GPUShaderModule", "default": "" }, - "entry_point": { "type": "str", "default": "None" }, - "constants": { "type": "dict[str, float]", "default": "{}" }, - "targets": { "type": "list[structs.ColorTargetStateStruct]", "default": "" } + "entry_point": { "type": "str | None", "default": "None" }, + "constants": { "type": "dict[str, float] | None", "default": "None" }, + "targets": { "type": "Sequence[structs.ColorTargetStateStruct]", "default": "" } } }, "ColorTargetState": { "fields": { "format": { "type": "enums.TextureFormatEnum", "default": "" }, - "blend": { "type": "structs.BlendStateStruct", "default": "None" }, + "blend": { "type": "structs.BlendStateStruct | None", "default": "None" }, "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF" } } }, @@ -705,10 +705,10 @@ "DepthStencilState": { "fields": { "format": { "type": "enums.TextureFormatEnum", "default": "" }, - "depth_write_enabled": { "type": "bool", "default": "None" }, - "depth_compare": { "type": "enums.CompareFunctionEnum", "default": "None" }, - "stencil_front": { "type": "structs.StencilFaceStateStruct", "default": "{}" }, - "stencil_back": { "type": "structs.StencilFaceStateStruct", "default": "{}" }, + "depth_write_enabled": { "type": "bool | None", "default": "None" }, + "depth_compare": { "type": "enums.CompareFunctionEnum | None", "default": "None" }, + "stencil_front": { "type": "structs.StencilFaceStateStruct | None", "default": "None" }, + "stencil_back": { "type": "structs.StencilFaceStateStruct | None", "default": "None" }, "stencil_read_mask": { "type": "int", "default": "0xFFFFFFFF" }, "stencil_write_mask": { "type": "int", "default": "0xFFFFFFFF" }, "depth_bias": { "type": "int", "default": "0" }, @@ -727,16 +727,16 @@ "VertexState": { "fields": { "module": { "type": "GPUShaderModule", "default": "" }, - "entry_point": { "type": "str", "default": "None" }, - "constants": { "type": "dict[str, float]", "default": "{}" }, - "buffers": { "type": "list[structs.VertexBufferLayoutStruct]", "default": "[]" } + "entry_point": { "type": "str | None", "default": "None" }, + "constants": { "type": "dict[str, float] | None", "default": "None" }, + "buffers": { "type": "Sequence[structs.VertexBufferLayoutStruct]", "default": "()" } } }, "VertexBufferLayout": { "fields": { "array_stride": { "type": "int", "default": "" }, "step_mode": { "type": "enums.VertexStepModeEnum", "default": "\"vertex\"" }, - "attributes": { "type": "list[structs.VertexAttributeStruct]", "default": "" } + "attributes": { "type": "Sequence[structs.VertexAttributeStruct]", "default": "" } } }, "VertexAttribute": { @@ -749,15 +749,15 @@ "TexelCopyBufferLayout": { "fields": { "offset": { "type": "int", "default": "0" }, - "bytes_per_row": { "type": "int", "default": "None" }, - "rows_per_image": { "type": "int", "default": "None" } + "bytes_per_row": { "type": "int | None", "default": "None" }, + "rows_per_image": { "type": "int | None", "default": "None" } } }, "TexelCopyBufferInfo": { "fields": { "offset": { "type": "int", "default": "0" }, - "bytes_per_row": { "type": "int", "default": "None" }, - "rows_per_image": { "type": "int", "default": "None" }, + "bytes_per_row": { "type": "int | None", "default": "None" }, + "rows_per_image": { "type": "int | None", "default": "None" }, "buffer": { "type": "GPUBuffer", "default": "" } } }, @@ -765,7 +765,7 @@ "fields": { "texture": { "type": "GPUTexture", "default": "" }, "mip_level": { "type": "int", "default": "0" }, - "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}" }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct | None", "default": "None" }, "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" } } }, @@ -773,7 +773,7 @@ "fields": { "texture": { "type": "GPUTexture", "default": "" }, "mip_level": { "type": "int", "default": "0" }, - "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct", "default": "{}" }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct | None", "default": "None" }, "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" }, "color_space": { "type": "str", "default": "\"srgb\"" }, "premultiplied_alpha": { "type": "bool", "default": "False" } @@ -782,7 +782,7 @@ "CopyExternalImageSourceInfo": { "fields": { "source": { "type": "ArrayLike | CanvasLike | object", "default": "" }, - "origin": { "type": "tuple[int, int] | structs.Origin2DStruct", "default": "{}" }, + "origin": { "type": "tuple[int, int] | structs.Origin2DStruct | None", "default": "None" }, "flip_y": { "type": "bool", "default": "False" } } }, @@ -799,39 +799,39 @@ "ComputePassTimestampWrites": { "fields": { "query_set": { "type": "GPUQuerySet", "default": "" }, - "beginning_of_pass_write_index": { "type": "int", "default": "None" }, - "end_of_pass_write_index": { "type": "int", "default": "None" } + "beginning_of_pass_write_index": { "type": "int | None", "default": "None" }, + "end_of_pass_write_index": { "type": "int | None", "default": "None" } } }, "ComputePassDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct", "default": "None" } + "timestamp_writes": { "type": "structs.ComputePassTimestampWritesStruct | None", "default": "None" } } }, "RenderPassTimestampWrites": { "fields": { "query_set": { "type": "GPUQuerySet", "default": "" }, - "beginning_of_pass_write_index": { "type": "int", "default": "None" }, - "end_of_pass_write_index": { "type": "int", "default": "None" } + "beginning_of_pass_write_index": { "type": "int | None", "default": "None" }, + "end_of_pass_write_index": { "type": "int | None", "default": "None" } } }, "RenderPassDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "color_attachments": { "type": "list[structs.RenderPassColorAttachmentStruct]", "default": "" }, - "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct", "default": "None" }, - "occlusion_query_set": { "type": "GPUQuerySet", "default": "None" }, - "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct", "default": "None" }, + "color_attachments": { "type": "Sequence[structs.RenderPassColorAttachmentStruct]", "default": "" }, + "depth_stencil_attachment": { "type": "structs.RenderPassDepthStencilAttachmentStruct | None", "default": "None" }, + "occlusion_query_set": { "type": "GPUQuerySet | None", "default": "None" }, + "timestamp_writes": { "type": "structs.RenderPassTimestampWritesStruct | None", "default": "None" }, "max_draw_count": { "type": "int", "default": "50000000" } } }, "RenderPassColorAttachment": { "fields": { "view": { "type": "GPUTexture | GPUTextureView", "default": "" }, - "depth_slice": { "type": "int", "default": "None" }, - "resolve_target": { "type": "GPUTexture | GPUTextureView", "default": "None" }, - "clear_value": { "type": "tuple[float, float, float, float] | structs.ColorStruct", "default": "None" }, + "depth_slice": { "type": "int | None", "default": "None" }, + "resolve_target": { "type": "GPUTexture | GPUTextureView | None", "default": "None" }, + "clear_value": { "type": "tuple[float, float, float, float] | structs.ColorStruct | None", "default": "None" }, "load_op": { "type": "enums.LoadOpEnum", "default": "" }, "store_op": { "type": "enums.StoreOpEnum", "default": "" } } @@ -839,21 +839,21 @@ "RenderPassDepthStencilAttachment": { "fields": { "view": { "type": "GPUTexture | GPUTextureView", "default": "" }, - "depth_clear_value": { "type": "float", "default": "None" }, - "depth_load_op": { "type": "enums.LoadOpEnum", "default": "None" }, - "depth_store_op": { "type": "enums.StoreOpEnum", "default": "None" }, + "depth_clear_value": { "type": "float | None", "default": "None" }, + "depth_load_op": { "type": "enums.LoadOpEnum | None", "default": "None" }, + "depth_store_op": { "type": "enums.StoreOpEnum | None", "default": "None" }, "depth_read_only": { "type": "bool", "default": "False" }, "stencil_clear_value": { "type": "int", "default": "0" }, - "stencil_load_op": { "type": "enums.LoadOpEnum", "default": "None" }, - "stencil_store_op": { "type": "enums.StoreOpEnum", "default": "None" }, + "stencil_load_op": { "type": "enums.LoadOpEnum | None", "default": "None" }, + "stencil_store_op": { "type": "enums.StoreOpEnum | None", "default": "None" }, "stencil_read_only": { "type": "bool", "default": "False" } } }, "RenderPassLayout": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": "" }, - "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": "None" }, + "color_formats": { "type": "Sequence[enums.TextureFormatEnum]", "default": "" }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum | None", "default": "None" }, "sample_count": { "type": "int", "default": "1" } } }, @@ -865,8 +865,8 @@ "RenderBundleEncoderDescriptor": { "fields": { "label": { "type": "str", "default": "\"\"" }, - "color_formats": { "type": "list[enums.TextureFormatEnum]", "default": "" }, - "depth_stencil_format": { "type": "enums.TextureFormatEnum", "default": "None" }, + "color_formats": { "type": "Sequence[enums.TextureFormatEnum]", "default": "" }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum | None", "default": "None" }, "sample_count": { "type": "int", "default": "1" }, "depth_read_only": { "type": "bool", "default": "False" }, "stencil_read_only": { "type": "bool", "default": "False" } @@ -894,9 +894,9 @@ "device": { "type": "GPUDevice", "default": "" }, "format": { "type": "enums.TextureFormatEnum", "default": "" }, "usage": { "type": "flags.TextureUsageFlags", "default": "0x10" }, - "view_formats": { "type": "list[enums.TextureFormatEnum]", "default": "[]" }, + "view_formats": { "type": "Sequence[enums.TextureFormatEnum]", "default": "()" }, "color_space": { "type": "str", "default": "\"srgb\"" }, - "tone_mapping": { "type": "structs.CanvasToneMappingStruct", "default": "{}" }, + "tone_mapping": { "type": "structs.CanvasToneMappingStruct | None", "default": "None" }, "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"" } } }, @@ -1023,7 +1023,7 @@ "request_adapter": { "returns": { "type": "GPUPromise[GPUAdapter]" }, "args": { - "options": { "type": "structs.RequestAdapterOptionsStruct", "default": "{}" } + "options": { "type": "structs.RequestAdapterOptionsStruct | None", "default": "None" } } }, "get_preferred_canvas_format": { @@ -1043,13 +1043,13 @@ "request_device": { "returns": { "type": "GPUPromise[GPUDevice]" }, "args": { - "descriptor": { "type": "structs.DeviceDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.DeviceDescriptorStruct | None", "default": "None" } } } } }, "GPUDevice": { - "bases": [ "EventTarget", "GPUObjectBase" ], + "bases": [ "GPUObjectBase" ], "properties": { "features": { "type": "set" }, "limits": { "type": "dict" }, @@ -1078,7 +1078,7 @@ "create_sampler": { "returns": { "type": "GPUSampler" }, "args": { - "descriptor": { "type": "structs.SamplerDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.SamplerDescriptorStruct | None", "default": "None" } } }, "import_external_texture": { @@ -1138,7 +1138,7 @@ "create_command_encoder": { "returns": { "type": "GPUCommandEncoder" }, "args": { - "descriptor": { "type": "structs.CommandEncoderDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.CommandEncoderDescriptorStruct | None", "default": "None" } } }, "create_render_bundle_encoder": { @@ -1178,14 +1178,14 @@ "args": { "mode": { "type": "flags.MapModeFlags", "default": "" }, "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "get_mapped_range": { "returns": { "type": "ArrayLike" }, "args": { "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "unmap": { @@ -1215,7 +1215,7 @@ "create_view": { "returns": { "type": "GPUTextureView" }, "args": { - "descriptor": { "type": "structs.TextureViewDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.TextureViewDescriptorStruct | None", "default": "None" } } }, "destroy": { @@ -1279,7 +1279,7 @@ "GPUCompilationInfo": { "bases": [ ], "properties": { - "messages": { "type": "list[GPUCompilationMessage]" } + "messages": { "type": "Sequence[GPUCompilationMessage]" } }, "methods": { } }, @@ -1292,7 +1292,7 @@ "__init__": { "returns": { "type": "None" }, "args": { - "message": { "type": "str", "default": "" }, + "message": { "type": "str", "default": "\"\"" }, "options": { "type": "structs.PipelineErrorInitStruct", "default": "" } } } @@ -1343,7 +1343,7 @@ "begin_compute_pass": { "returns": { "type": "GPUComputePassEncoder" }, "args": { - "descriptor": { "type": "structs.ComputePassDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.ComputePassDescriptorStruct | None", "default": "None" } } }, "copy_buffer_to_buffer": { @@ -1353,7 +1353,7 @@ "source_offset": { "type": "int", "default": "" }, "destination": { "type": "GPUBuffer", "default": "" }, "destination_offset": { "type": "int", "default": "" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "copy_buffer_to_texture": { @@ -1385,7 +1385,7 @@ "args": { "buffer": { "type": "GPUBuffer", "default": "" }, "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "resolve_query_set": { @@ -1401,7 +1401,7 @@ "finish": { "returns": { "type": "GPUCommandBuffer" }, "args": { - "descriptor": { "type": "structs.CommandBufferDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.CommandBufferDescriptorStruct | None", "default": "None" } } } } @@ -1426,7 +1426,7 @@ "range_offset": { "type": "int", "default": "" }, "data": { "type": "ArrayLike", "default": "" }, "data_offset": { "type": "int", "default": "0" }, - "data_size": { "type": "int", "default": "None" } + "data_size": { "type": "int | None", "default": "None" } } } } @@ -1539,7 +1539,7 @@ "execute_bundles": { "returns": { "type": "None" }, "args": { - "bundles": { "type": "list[GPURenderBundle]", "default": "" } + "bundles": { "type": "Sequence[GPURenderBundle]", "default": "" } } }, "end": { @@ -1564,7 +1564,7 @@ "buffer": { "type": "GPUBuffer", "default": "" }, "index_format": { "type": "enums.IndexFormatEnum", "default": "" }, "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "set_vertex_buffer": { @@ -1573,7 +1573,7 @@ "slot": { "type": "int", "default": "" }, "buffer": { "type": "GPUBuffer", "default": "" }, "offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "draw": { @@ -1629,7 +1629,7 @@ "finish": { "returns": { "type": "GPURenderBundle" }, "args": { - "descriptor": { "type": "structs.RenderBundleDescriptorStruct", "default": "{}" } + "descriptor": { "type": "structs.RenderBundleDescriptorStruct | None", "default": "None" } } } } @@ -1641,7 +1641,7 @@ "submit": { "returns": { "type": "None" }, "args": { - "command_buffers": { "type": "list[GPUCommandBuffer]", "default": "" } + "command_buffers": { "type": "Sequence[GPUCommandBuffer]", "default": "" } } }, "on_submitted_work_done": { @@ -1655,7 +1655,7 @@ "buffer_offset": { "type": "int", "default": "" }, "data": { "type": "ArrayLike", "default": "" }, "data_offset": { "type": "int", "default": "0" }, - "size": { "type": "int", "default": "None" } + "size": { "type": "int | None", "default": "None" } } }, "write_texture": { diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json index ea831cd5..6adaec1e 100644 --- a/apigen/definitions/wgpu_api.json +++ b/apigen/definitions/wgpu_api.json @@ -963,7 +963,7 @@ "doc": "The feature level to request: 'core' (default) or 'compatibility'. Core implies the default limits and enums.FeatureName.core_features_and_limits; compatibility has stricter, more widely supported defaults and no features. If the implementation cannot enforce the compatibility rules it treats the request as core. If the level is not supported, no adapter is returned." }, "power_preference": { - "type": "enums.PowerPreferenceEnum", + "type": "enums.PowerPreference | None", "default": "None", "doc": "Hint for the kind of adapter to select, see enums.PowerPreference. It may influence which adapter is chosen (mainly in multi-GPU systems), but never whether an adapter is returned." }, @@ -972,11 +972,7 @@ "default": "False", "doc": "If true, only a fallback adapter may be returned (no adapter if unsupported). If false, a fallback adapter may still be returned; check the is_fallback_adapter property of GPUAdapterInfo to avoid it." }, - "xr_compatible": { - "type": "bool", - "default": "False", - "doc": "If true, the adapter must be compatible with XR (virtual/augmented reality) sessions. Mostly relevant in browsers." - } + "canvas": { "type": "CanvasLike | None", "default": "None" } }, "doc": "Options for requesting an adapter.\n\nUsed as the options argument of the GPU.request_adapter() method.\n" }, @@ -988,18 +984,18 @@ "doc": "A human-readable label for the device, used in debugging and error messages." }, "required_features": { - "type": "list[enums.FeatureNameEnum]", - "default": "[]", + "type": "Sequence[enums.FeatureNameEnum]", + "default": "()", "doc": "A list of enums.FeatureName that the device must support. The request fails if the adapter cannot provide them. Exactly this set of features, no more and no less, is allowed on the resulting device." }, "required_limits": { - "type": "dict[str, int | None]", - "default": "{}", + "type": "dict[str, int | None] | None", + "default": "None", "doc": "A mapping of limit names to the values the device requires; the request fails if the adapter cannot provide them. Unspecified limits get their default value. Validation on the device uses these exact limits, not the (possibly higher) limits of the adapter." }, "default_queue": { - "type": "structs.QueueDescriptorStruct", - "default": "{}", + "type": "structs.QueueDescriptorStruct | None", + "default": "None", "doc": "A structs.QueueDescriptor with options for the default queue of the device." } }, @@ -1060,12 +1056,12 @@ "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." }, "view_formats": { - "type": "list[enums.TextureFormatEnum]", - "default": "[]", + "type": "Sequence[enums.TextureFormatEnum]", + "default": "()", "doc": "Additional enums.TextureFormat values that views of this texture may use in GPUTexture.create_view(). They must be view-compatible with the texture format: equal, or (on devices with enums.FeatureName.core_features_and_limits) differing only in sRGB-ness. Adding formats can hurt performance on some systems, so only add what is needed." }, "texture_binding_view_dimension": { - "type": "enums.TextureViewDimensionEnum", + "type": "enums.TextureViewDimensionEnum | None", "default": "None", "doc": "Compatibility mode only: on devices without enums.FeatureName.core_features_and_limits, views of this texture must have this enums.TextureViewDimension. A default is chosen if omitted. Ignored on core devices." } @@ -1080,12 +1076,12 @@ "doc": "A human-readable label for the texture view, used in debugging and error messages." }, "format": { - "type": "enums.TextureFormatEnum", + "type": "enums.TextureFormatEnum | None", "default": "None", "doc": "The format of the view, see enums.TextureFormat. Must be the texture format or one of its view_formats. Defaults to the texture format." }, "dimension": { - "type": "enums.TextureViewDimensionEnum", + "type": "enums.TextureViewDimensionEnum | None", "default": "None", "doc": "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." }, @@ -1101,7 +1097,7 @@ }, "base_mip_level": { "type": "int", "default": "0", "doc": "The first mip level accessible via the view. Defaults to 0." }, "mip_level_count": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of mip levels accessible via the view. Defaults to all levels from base_mip_level." }, @@ -1111,7 +1107,7 @@ "doc": "The first array layer accessible via the view. Defaults to 0." }, "array_layer_count": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of array layers accessible via the view. Defaults to all layers from base_array_layer." }, @@ -1191,7 +1187,7 @@ "doc": "The maximum level of detail used when sampling. Defaults to 32." }, "compare": { - "type": "enums.CompareFunctionEnum", + "type": "enums.CompareFunctionEnum | None", "default": "None", "doc": "If set, makes this a comparison sampler using this enums.CompareFunction. Used for sampling depth textures. Filtering results of comparison samplers are implementation-dependent." }, @@ -1211,7 +1207,7 @@ "doc": "A human-readable label for the bind group layout, used in debugging and error messages." }, "entries": { - "type": "list[structs.BindGroupLayoutEntryStruct]", + "type": "Sequence[structs.BindGroupLayoutEntryStruct]", "default": "", "doc": "A list of structs.BindGroupLayoutEntry describing the resources in the bind group." } @@ -1231,22 +1227,22 @@ "doc": "The shader stages in which the resource is visible, a combination of flags.ShaderStage." }, "buffer": { - "type": "structs.BufferBindingLayoutStruct", + "type": "structs.BufferBindingLayoutStruct | None", "default": "None", "doc": "If set, a structs.BufferBindingLayout: the entry is a buffer binding." }, "sampler": { - "type": "structs.SamplerBindingLayoutStruct", + "type": "structs.SamplerBindingLayoutStruct | None", "default": "None", "doc": "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." }, "texture": { - "type": "structs.TextureBindingLayoutStruct", + "type": "structs.TextureBindingLayoutStruct | None", "default": "None", "doc": "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." }, "storage_texture": { - "type": "structs.StorageTextureBindingLayoutStruct", + "type": "structs.StorageTextureBindingLayoutStruct | None", "default": "None", "doc": "If set, a structs.StorageTextureBindingLayout: the entry is a storage texture binding." } @@ -1336,7 +1332,7 @@ "doc": "The GPUBindGroupLayout that this bind group conforms to." }, "entries": { - "type": "list[structs.BindGroupEntryStruct]", + "type": "Sequence[structs.BindGroupEntryStruct]", "default": "", "doc": "A list of structs.BindGroupEntry with the resources to bind. Must match the layout." } @@ -1367,7 +1363,7 @@ "doc": "The offset in bytes into the buffer where the binding starts. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The size in bytes of the binding. Defaults to the remainder of the buffer after offset." } @@ -1382,7 +1378,7 @@ "doc": "A human-readable label for the pipeline layout, used in debugging and error messages." }, "bind_group_layouts": { - "type": "list[GPUBindGroupLayout]", + "type": "Sequence[GPUBindGroupLayout]", "default": "", "doc": "A list of GPUBindGroupLayout (or None for unused groups) used by the pipeline. The Nth element corresponds to @group(N) in the shader." }, @@ -1403,8 +1399,8 @@ }, "code": { "type": "str", "default": "", "doc": "The shader source code, in WGSL." }, "compilation_hints": { - "type": "list[structs.ShaderModuleCompilationHintStruct]", - "default": "[]", + "type": "Sequence[structs.ShaderModuleCompilationHintStruct]", + "default": "()", "doc": "An optional list of structs.ShaderModuleCompilationHint that may help the implementation compile early. Hints only affect performance, are not validated, and only apply to the entry points they name (there is no default entry point)." } }, @@ -1414,7 +1410,7 @@ "fields": { "entry_point": { "type": "str", "default": "", "doc": "The name of the shader entry point that the hint applies to." }, "layout": { - "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum | None", "default": "None", "doc": "The GPUPipelineLayout that the entry point will be used with, or enums.AutoLayoutMode.auto (the default pipeline layout for that entry point)." } @@ -1435,13 +1431,13 @@ "fields": { "module": { "type": "GPUShaderModule", "default": "", "doc": "The GPUShaderModule containing the shader code." }, "entry_point": { - "type": "str", + "type": "str | None", "default": "None", "doc": "The name of the entry point function in the shader. Optional if the module has only one entry point for this stage." }, "constants": { - "type": "dict[str, float]", - "default": "{}", + "type": "dict[str, float] | None", + "default": "None", "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." } }, @@ -1485,22 +1481,22 @@ "doc": "A structs.VertexState describing the vertex shader and vertex buffers." }, "primitive": { - "type": "structs.PrimitiveStateStruct", - "default": "{}", + "type": "structs.PrimitiveStateStruct | None", + "default": "None", "doc": "A structs.PrimitiveState describing how primitives are assembled and rasterized." }, "depth_stencil": { - "type": "structs.DepthStencilStateStruct", + "type": "structs.DepthStencilStateStruct | None", "default": "None", "doc": "An optional structs.DepthStencilState. If omitted, the pipeline does not use a depth-stencil attachment." }, "multisample": { - "type": "structs.MultisampleStateStruct", - "default": "{}", + "type": "structs.MultisampleStateStruct | None", + "default": "None", "doc": "A structs.MultisampleState describing multisampling." }, "fragment": { - "type": "structs.FragmentStateStruct", + "type": "structs.FragmentStateStruct | None", "default": "None", "doc": "An optional structs.FragmentState describing the fragment shader and render targets. If omitted, the pipeline has no color output (e.g. for depth-only passes)." } @@ -1515,7 +1511,7 @@ "doc": "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." }, "strip_index_format": { - "type": "enums.IndexFormatEnum", + "type": "enums.IndexFormatEnum | None", "default": "None", "doc": "The enums.IndexFormat of the index buffer, which sets the primitive restart value (0xFFFF for uint16, 0xFFFFFFFF for uint32). Only allowed for strip topologies, where it is required for indexed draws and must match the format given to GPURenderCommandsMixin.set_index_buffer()." }, @@ -1565,17 +1561,17 @@ "doc": "The GPUShaderModule containing the fragment shader code." }, "entry_point": { - "type": "str", + "type": "str | None", "default": "None", "doc": "The name of the fragment entry point in the shader. Optional if the module has only one fragment entry point." }, "constants": { - "type": "dict[str, float]", - "default": "{}", + "type": "dict[str, float] | None", + "default": "None", "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, "targets": { - "type": "list[structs.ColorTargetStateStruct]", + "type": "Sequence[structs.ColorTargetStateStruct]", "default": "", "doc": "A list of structs.ColorTargetState (or None for unused slots), one for each color attachment." } @@ -1590,7 +1586,7 @@ "doc": "The enums.TextureFormat of this color target. The pipeline is only compatible with render passes that use a view of this format in the corresponding color attachment." }, "blend": { - "type": "structs.BlendStateStruct", + "type": "structs.BlendStateStruct | None", "default": "None", "doc": "An optional structs.BlendState. If omitted, blending is disabled and the fragment output replaces the target." }, @@ -1645,23 +1641,23 @@ "doc": "The enums.TextureFormat of the depth-stencil attachment that this pipeline is compatible with." }, "depth_write_enabled": { - "type": "bool", + "type": "bool | None", "default": "None", "doc": "If true, depth values of fragments that pass the depth test are written to the attachment." }, "depth_compare": { - "type": "enums.CompareFunctionEnum", + "type": "enums.CompareFunctionEnum | None", "default": "None", "doc": "The enums.CompareFunction used for the depth test." }, "stencil_front": { - "type": "structs.StencilFaceStateStruct", - "default": "{}", + "type": "structs.StencilFaceStateStruct | None", + "default": "None", "doc": "A structs.StencilFaceState for front-facing primitives." }, "stencil_back": { - "type": "structs.StencilFaceStateStruct", - "default": "{}", + "type": "structs.StencilFaceStateStruct | None", + "default": "None", "doc": "A structs.StencilFaceState for back-facing primitives." }, "stencil_read_mask": { @@ -1725,18 +1721,18 @@ "doc": "The GPUShaderModule containing the vertex shader code." }, "entry_point": { - "type": "str", + "type": "str | None", "default": "None", "doc": "The name of the vertex entry point in the shader. Optional if the module has only one vertex entry point." }, "constants": { - "type": "dict[str, float]", - "default": "{}", + "type": "dict[str, float] | None", + "default": "None", "doc": "A mapping of the identifiers of pipeline-overridable constants in the shader to the values to use. A key is the numeric id (if the shader declares one) or the name of the constant. Values are converted to the WGSL type of the constant; a failed conversion is a validation error." }, "buffers": { - "type": "list[structs.VertexBufferLayoutStruct]", - "default": "[]", + "type": "Sequence[structs.VertexBufferLayoutStruct]", + "default": "()", "doc": "A list of structs.VertexBufferLayout (or None for unused slots) describing the vertex buffers." } }, @@ -1755,7 +1751,7 @@ "doc": "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." }, "attributes": { - "type": "list[structs.VertexAttributeStruct]", + "type": "Sequence[structs.VertexAttributeStruct]", "default": "", "doc": "A list of structs.VertexAttribute describing the attributes in each element." } @@ -1786,12 +1782,12 @@ "doc": "The offset in bytes into the data where the texel data starts. Defaults to 0." }, "bytes_per_row": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row of texel blocks. Must be a multiple of 256 for buffer copies (not for GPUQueue.write_texture())." }, "rows_per_image": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of rows of texel blocks per image (layer or slice); times bytes_per_row it is the stride between images. Required if the copy has more than one image." } @@ -1806,12 +1802,12 @@ "doc": "The offset in bytes into the buffer where the texel data starts. Defaults to 0." }, "bytes_per_row": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The stride in bytes between the start of consecutive rows of texel blocks. Required if the copy has more than one row. Must be a multiple of 256." }, "rows_per_image": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of rows of texel blocks per image (layer or slice). Required if the copy has more than one image." }, @@ -1828,8 +1824,8 @@ "texture": { "type": "GPUTexture", "default": "", "doc": "The GPUTexture to copy to or from." }, "mip_level": { "type": "int", "default": "0", "doc": "The mip level to copy to or from. Defaults to 0." }, "origin": { - "type": "tuple[int, int, int] | structs.Origin3DStruct", - "default": "{}", + "type": "tuple[int, int, int] | structs.Origin3DStruct | None", + "default": "None", "doc": "The origin of the copy in the texture, as a structs.Origin3D or a tuple (x, y, z). Defaults to (0, 0, 0)." }, "aspect": { @@ -1868,12 +1864,12 @@ "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, "beginning_of_pass_write_index": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, "end_of_pass_write_index": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } @@ -1888,7 +1884,7 @@ "doc": "A human-readable label for the compute pass, used in debugging and error messages." }, "timestamp_writes": { - "type": "structs.ComputePassTimestampWritesStruct", + "type": "structs.ComputePassTimestampWritesStruct | None", "default": "None", "doc": "An optional structs.ComputePassTimestampWrites for recording timestamps of the pass." } @@ -1903,12 +1899,12 @@ "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." }, "beginning_of_pass_write_index": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The index in the query set where the timestamp at the start of the pass is written. If omitted, no timestamp is written." }, "end_of_pass_write_index": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The index in the query set where the timestamp at the end of the pass is written. If omitted, no timestamp is written." } @@ -1923,22 +1919,22 @@ "doc": "A human-readable label for the render pass, used in debugging and error messages." }, "color_attachments": { - "type": "list[structs.RenderPassColorAttachmentStruct]", + "type": "Sequence[structs.RenderPassColorAttachmentStruct]", "default": "", "doc": "A list of structs.RenderPassColorAttachment (or None for unused slots) that the pass renders to. Attachments may not alias each other or any resource used inside the pass." }, "depth_stencil_attachment": { - "type": "structs.RenderPassDepthStencilAttachmentStruct", + "type": "structs.RenderPassDepthStencilAttachmentStruct | None", "default": "None", "doc": "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." }, "occlusion_query_set": { - "type": "GPUQuerySet", + "type": "GPUQuerySet | None", "default": "None", "doc": "An optional GPUQuerySet of type enums.QueryType.occlusion, to store occlusion query results in." }, "timestamp_writes": { - "type": "structs.RenderPassTimestampWritesStruct", + "type": "structs.RenderPassTimestampWritesStruct | None", "default": "None", "doc": "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." }, @@ -1958,17 +1954,17 @@ "doc": "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, "depth_slice": { - "type": "int", + "type": "int | None", "default": "None", "doc": "For 3D textures, the index of the depth slice to render to." }, "resolve_target": { - "type": "GPUTexture | GPUTextureView", + "type": "GPUTexture | GPUTextureView | None", "default": "None", "doc": "An optional GPUTextureView to resolve the (multisampled) view into at the end of the pass." }, "clear_value": { - "type": "tuple[float, float, float, float] | structs.ColorStruct", + "type": "tuple[float, float, float, float] | structs.ColorStruct | None", "default": "None", "doc": "The color to clear the attachment to if load_op is clear, as a structs.Color or a tuple (r, g, b, a). Defaults to transparent black." }, @@ -1993,17 +1989,17 @@ "doc": "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." }, "depth_clear_value": { - "type": "float", + "type": "float | None", "default": "None", "doc": "The value to clear the depth aspect to if depth_load_op is clear. Must be between 0 and 1." }, "depth_load_op": { - "type": "enums.LoadOpEnum", + "type": "enums.LoadOpEnum | None", "default": "None", "doc": "What to do with the existing depth values at the start of the pass, see enums.LoadOp. Required unless depth_read_only is true." }, "depth_store_op": { - "type": "enums.StoreOpEnum", + "type": "enums.StoreOpEnum | None", "default": "None", "doc": "What to do with the depth values at the end of the pass, see enums.StoreOp. Required unless depth_read_only is true." }, @@ -2018,12 +2014,12 @@ "doc": "The value to clear the stencil aspect to if stencil_load_op is clear. Truncated to the bit size of the stencil aspect (the least significant bits are kept). Defaults to 0." }, "stencil_load_op": { - "type": "enums.LoadOpEnum", + "type": "enums.LoadOpEnum | None", "default": "None", "doc": "What to do with the existing stencil values at the start of the pass, see enums.LoadOp. Required unless stencil_read_only is true." }, "stencil_store_op": { - "type": "enums.StoreOpEnum", + "type": "enums.StoreOpEnum | None", "default": "None", "doc": "What to do with the stencil values at the end of the pass, see enums.StoreOp. Required unless stencil_read_only is true." }, @@ -2043,12 +2039,12 @@ "doc": "A human-readable label, used in debugging and error messages." }, "color_formats": { - "type": "list[enums.TextureFormatEnum]", + "type": "Sequence[enums.TextureFormatEnum]", "default": "", "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments." }, "depth_stencil_format": { - "type": "enums.TextureFormatEnum", + "type": "enums.TextureFormatEnum | None", "default": "None", "doc": "The enums.TextureFormat of the depth-stencil attachment, if any." }, @@ -2078,12 +2074,12 @@ "doc": "A human-readable label for the render bundle encoder, used in debugging and error messages." }, "color_formats": { - "type": "list[enums.TextureFormatEnum]", + "type": "Sequence[enums.TextureFormatEnum]", "default": "", "doc": "A list of enums.TextureFormat (or None for unused slots) of the color attachments the bundle will be used with." }, "depth_stencil_format": { - "type": "enums.TextureFormatEnum", + "type": "enums.TextureFormatEnum | None", "default": "None", "doc": "The enums.TextureFormat of the depth-stencil attachment the bundle will be used with, if any." }, @@ -2159,8 +2155,8 @@ "doc": "The usages of the canvas textures, a combination of flags.TextureUsage. Defaults to RENDER_ATTACHMENT, but that is not added automatically when usage is set explicitly, so include it to render to the canvas texture." }, "view_formats": { - "type": "list[enums.TextureFormatEnum]", - "default": "[]", + "type": "Sequence[enums.TextureFormatEnum]", + "default": "()", "doc": "Additional enums.TextureFormat values that views of the canvas texture may use." }, "color_space": { @@ -2169,8 +2165,8 @@ "doc": "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." }, "tone_mapping": { - "type": "structs.CanvasToneMappingStruct", - "default": "{}", + "type": "structs.CanvasToneMappingStruct | None", + "default": "None", "doc": "A structs.CanvasToneMapping that describes how the canvas content is tone mapped. May not be supported everywhere; detect support with GPUCanvasContext.get_configuration()." }, "alpha_mode": { @@ -2235,13 +2231,17 @@ "label": { "type": "str", "doc": "A human-readable label for the object, used in debugging and error messages. Initially taken from the label field of the descriptor used to create it." + }, + "uid": { + "type": "int", + "doc": "A unique id (integer) for this object.\n\nThe value is unique to the process; in contrast to ``id(ob)``, the numbers are never reused." } }, "methods": { }, "doc": "The base class of all GPU objects.\n\nIt provides the label property that is shared by all objects in the API.\n" }, "GPUAdapterInfo": { - "bases": [ ], + "bases": [ "dict" ], "properties": { "vendor": { "type": "str", "doc": "The name of the vendor of the adapter, e.g. 'nvidia' or 'amd'." }, "architecture": { "type": "str", "doc": "The name of the family or class of GPUs the adapter belongs to." }, @@ -2272,17 +2272,28 @@ "wgsl_language_features": { "type": "set", "doc": "The set of WGSL language features that are supported by the implementation." } }, "methods": { - "request_adapter": { + "request_adapter_async": { "returns": { "type": "GPUPromise[GPUAdapter]", "doc": "A GPUAdapter, or None if no suitable adapter was found." }, "args": { "options": { - "type": "structs.RequestAdapterOptionsStruct", - "default": "{}", + "type": "structs.RequestAdapterOptionsStruct | None", + "default": "None", "doc": "A structs.RequestAdapterOptions with options for selecting the adapter." } }, "doc": "Request a GPUAdapter, which represents a physical GPU (or a software equivalent).\n\nThe adapter can be used to inspect the capabilities (features and limits) of the GPU,\nand to request a GPUDevice. If no suitable adapter is available, None is returned.\n" }, + "request_adapter_sync": { + "returns": { "type": "GPUAdapter", "doc": "" }, + "args": { + "options": { + "type": "structs.RequestAdapterOptionsStruct | None", + "default": "None", + "doc": "A structs.RequestAdapterOptions with options for selecting the adapter." + } + }, + "doc": "The synchronous variant of request_adapter_async()." + }, "get_preferred_canvas_format": { "returns": { "type": "enums.TextureFormatEnum", @@ -2290,6 +2301,23 @@ }, "args": { }, "doc": "Get the preferred texture format for presenting to a canvas.\n\nUsing this format for the format field of structs.CanvasConfiguration avoids a conversion when presenting.\n" + }, + "enumerate_adapters_async": { + "doc": "Get a list of adapter objects available on the current system.", + "returns": { "type": "GPUPromise[list[GPUAdapter]]" }, + "args": { } + }, + "enumerate_adapters_sync": { + "doc": "Get a list of adapter objects available on the current system.", + "returns": { "type": "list[GPUAdapter]" }, + "args": { } + }, + "get_canvas_context": { + "doc": "Get the GPUCanvasContext object for the appropriate backend.\n\nNote that the recommended way to get a context is to instead use the ``rendercanvas`` library.\n\nThe ``present_info`` dict should have a ``window`` field containing the window id. On Linux there should also be ``platform`` field to distinguish between 'wayland' and 'x11', and a ``display`` field for the display id. For the Pyodide backend, the ``window`` is the ```` object. This dict is an interface between `rendercanvas`` and ``wgpu-py``.", + "returns": { "type": "GPUCanvasContext" }, + "args": { + "present_info": { "type": "dict", "default": "", "doc": "The low-level presentation info." } + } } }, "doc": "The entry point of the API.\n\nIt is used to request a GPUAdapter. In wgpu-py an instance is available as wgpu.gpu.\n" @@ -2302,25 +2330,40 @@ "info": { "type": "GPUAdapterInfo", "doc": "A GPUAdapterInfo with information about the adapter. The values are constant over time." + }, + "summary": { + "type": "str", + "doc": "A one-line summary of the info of this adapter (device, adapter_type, backend_type)." } }, "methods": { - "request_device": { + "request_device_async": { "returns": { "type": "GPUPromise[GPUDevice]", "doc": "A GPUDevice." }, "args": { "descriptor": { - "type": "structs.DeviceDescriptorStruct", - "default": "{}", + "type": "structs.DeviceDescriptorStruct | None", + "default": "None", "doc": "A structs.DeviceDescriptor with the required features and limits." } }, "doc": "Request a GPUDevice from the adapter.\n\nThe device is the main object used to create resources and to submit work. An adapter can\nonly provide a single device; if it was already used, or if the requested features or limits\nare not supported, the request fails.\n" + }, + "request_device_sync": { + "returns": { "type": "GPUDevice", "doc": "" }, + "args": { + "descriptor": { + "type": "structs.DeviceDescriptorStruct | None", + "default": "None", + "doc": "A structs.DeviceDescriptor with the required features and limits." + } + }, + "doc": "The synchronous variant of request_device_async()." } }, "doc": "Represents a physical GPU (or a software implementation of one).\n\nAn adapter can be used to inspect the capabilities of the GPU, and to request a GPUDevice,\nwhich is used to do actual work. Adapters are obtained via GPU.request_adapter().\n" }, "GPUDevice": { - "bases": [ "EventTarget", "GPUObjectBase" ], + "bases": [ "GPUObjectBase" ], "properties": { "features": { "type": "set", @@ -2342,7 +2385,8 @@ "onuncapturederror": { "type": "None", "doc": "A callback that is called with an event (see structs.UncapturedErrorEventInit) when an error occurs that is not captured by an error scope." - } + }, + "adapter": { "type": "GPUAdapter", "doc": "The adapter object corresponding to this device." } }, "methods": { "destroy": { @@ -2376,8 +2420,8 @@ "returns": { "type": "GPUSampler", "doc": "A GPUSampler." }, "args": { "descriptor": { - "type": "structs.SamplerDescriptorStruct", - "default": "{}", + "type": "structs.SamplerDescriptorStruct | None", + "default": "None", "doc": "A structs.SamplerDescriptor describing the sampler. If omitted, the defaults are used." } }, @@ -2475,8 +2519,8 @@ "returns": { "type": "GPUCommandEncoder", "doc": "A GPUCommandEncoder." }, "args": { "descriptor": { - "type": "structs.CommandEncoderDescriptorStruct", - "default": "{}", + "type": "structs.CommandEncoderDescriptorStruct | None", + "default": "None", "doc": "A structs.CommandEncoderDescriptor. Optional." } }, @@ -2515,13 +2559,26 @@ }, "doc": "Push a new error scope onto the device's error scope stack.\n\nWhile the scope is active, errors of the given type that are generated by operations on this device are\ncaptured by the scope (instead of triggering the onuncapturederror callback). Retrieve them with pop_error_scope().\n" }, - "pop_error_scope": { + "pop_error_scope_async": { "returns": { "type": "GPUPromise[GPUError]", "doc": "A GPUError (GPUValidationError, GPUOutOfMemoryError or GPUInternalError), or None if no error was captured." }, "args": { }, "doc": "Pop the most recent error scope from the stack and return an error observed by it.\n\nFails if there is no error scope to pop. Errors are only reported once all operations in the scope have been processed.\n" + }, + "pop_error_scope_sync": { + "returns": { "type": "GPUError", "doc": "" }, + "args": { }, + "doc": "The synchronous variant of pop_error_scope_async()." + }, + "create_buffer_with_data": { + "returns": { "type": "GPUBuffer" }, + "args": { + "label": { "type": "str", "default": "\"\"" }, + "data": { "type": "ArrayLike", "default": "" }, + "usage": { "type": "flags.BufferUsageFlags", "default": "" } + } } }, "doc": "The main object that is used to create GPU resources and to submit work.\n\nA device is requested from a GPUAdapter. It is a GPUObjectBase, and has a GPUQueue\n(the queue property) which is used to submit work to the GPU. Most resources\n(buffers, textures, pipelines, etc.) are created using the create_* methods of the device.\n" @@ -2551,13 +2608,34 @@ "doc": "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } }, "doc": "Map (a part of) the buffer so its memory can be accessed by the CPU.\n\nThe returned promise or future resolves when the buffer is mapped. Once mapped, use get_mapped_range()\nto access the data, and call unmap() when done to give the buffer back to the GPU.\nResolving only indicates that this buffer is mapped, not that other work has completed. However, when GPUQueue.on_submitted_work_done()\nresolves, earlier map_async() calls on buffers last used exclusively on that queue have completed.\n" }, + "map_sync": { + "returns": { "type": "None", "doc": "" }, + "args": { + "mode": { + "type": "flags.MapModeFlags", + "default": "", + "doc": "Whether to map for reading or writing, see flags.MapMode." + }, + "offset": { + "type": "int", + "default": "0", + "doc": "The offset in bytes of the range to map. Must be a multiple of 8. Defaults to 0." + }, + "size": { + "type": "int | None", + "default": "None", + "doc": "The size in bytes of the range to map. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." + } + }, + "doc": "The synchronous variant of map_async()." + }, "get_mapped_range": { "returns": { "type": "ArrayLike", "doc": "A writable memory view (e.g. a memoryview) on the mapped range." }, "args": { @@ -2567,7 +2645,7 @@ "doc": "The offset in bytes of the range, relative to the start of the buffer. Must be a multiple of 8. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The size in bytes of the range. Must be a multiple of 4. Defaults to the remainder of the mapped range after offset." } @@ -2614,8 +2692,8 @@ "returns": { "type": "GPUTextureView", "doc": "A GPUTextureView." }, "args": { "descriptor": { - "type": "structs.TextureViewDescriptorStruct", - "default": "{}", + "type": "structs.TextureViewDescriptorStruct | None", + "default": "None", "doc": "A structs.TextureViewDescriptor. If omitted, a view of the whole texture is created." } }, @@ -2663,13 +2741,18 @@ "bases": [ "GPUObjectBase" ], "properties": { }, "methods": { - "get_compilation_info": { + "get_compilation_info_async": { "returns": { "type": "GPUPromise[GPUCompilationInfo]", "doc": "A GPUCompilationInfo (awaitable) with the list of messages." }, "args": { }, "doc": "Get diagnostic messages (errors, warnings, info) produced when compiling the shader.\n\nThe locations, order and contents of the messages are implementation-defined; in particular, they are not necessarily ordered by line number.\n" + }, + "get_compilation_info_sync": { + "returns": { "type": "GPUCompilationInfo", "doc": "" }, + "args": { }, + "doc": "The synchronous variant of get_compilation_info_async()." } }, "doc": "A compiled piece of shader code (WGSL), containing one or more entry points.\n\nShader modules are created with GPUDevice.create_shader_module() and used in pipeline descriptors (see structs.ProgrammableStage).\n" @@ -2705,7 +2788,7 @@ "GPUCompilationInfo": { "bases": [ ], "properties": { - "messages": { "type": "list[GPUCompilationMessage]", "doc": "A list of GPUCompilationMessage objects." } + "messages": { "type": "Sequence[GPUCompilationMessage]", "doc": "A list of GPUCompilationMessage objects." } }, "methods": { }, "doc": "The diagnostic messages produced when compiling a shader module.\n\nObtained from GPUShaderModule.get_compilation_info().\n" @@ -2722,7 +2805,7 @@ "__init__": { "returns": { "type": "None", "doc": "A GPUPipelineError." }, "args": { - "message": { "type": "str", "default": "", "doc": "The human-readable error message." }, + "message": { "type": "str", "default": "\"\"", "doc": "The human-readable error message." }, "options": { "type": "structs.PipelineErrorInitStruct", "default": "", @@ -2795,8 +2878,8 @@ "returns": { "type": "GPUComputePassEncoder", "doc": "A GPUComputePassEncoder." }, "args": { "descriptor": { - "type": "structs.ComputePassDescriptorStruct", - "default": "{}", + "type": "structs.ComputePassDescriptorStruct | None", + "default": "None", "doc": "A structs.ComputePassDescriptor. Optional." } }, @@ -2818,7 +2901,7 @@ "doc": "The offset in bytes in the destination buffer where the data is written." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of bytes to copy. Defaults to the size of the source buffer minus the source_offset argument of this method." } @@ -2898,7 +2981,7 @@ "doc": "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The number of bytes to clear. Must be a multiple of 4. Defaults to the remainder of the buffer after offset." } @@ -2924,8 +3007,8 @@ "returns": { "type": "GPUCommandBuffer", "doc": "A GPUCommandBuffer." }, "args": { "descriptor": { - "type": "structs.CommandBufferDescriptorStruct", - "default": "{}", + "type": "structs.CommandBufferDescriptorStruct | None", + "default": "None", "doc": "A structs.CommandBufferDescriptor. Optional." } }, @@ -2984,7 +3067,7 @@ "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, "data_size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } @@ -3142,7 +3225,7 @@ "returns": { "type": "None", "doc": "None." }, "args": { "bundles": { - "type": "list[GPURenderBundle]", + "type": "Sequence[GPURenderBundle]", "default": "", "doc": "A list of GPURenderBundle objects to execute, in order." } @@ -3183,7 +3266,7 @@ "doc": "The offset in bytes in the buffer where the indices start. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } @@ -3209,7 +3292,7 @@ "doc": "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The size in bytes of the range to use. Defaults to the remainder of the buffer after offset." } @@ -3304,8 +3387,8 @@ "returns": { "type": "GPURenderBundle", "doc": "A GPURenderBundle." }, "args": { "descriptor": { - "type": "structs.RenderBundleDescriptorStruct", - "default": "{}", + "type": "structs.RenderBundleDescriptorStruct | None", + "default": "None", "doc": "A structs.RenderBundleDescriptor. Optional." } }, @@ -3322,18 +3405,23 @@ "returns": { "type": "None", "doc": "None." }, "args": { "command_buffers": { - "type": "list[GPUCommandBuffer]", + "type": "Sequence[GPUCommandBuffer]", "default": "", "doc": "A list of GPUCommandBuffer objects, executed in order." } }, "doc": "Submit a list of command buffers for execution on the GPU.\n\nEach command buffer can only be submitted once.\n" }, - "on_submitted_work_done": { + "on_submitted_work_done_async": { "returns": { "type": "GPUPromise[None]", "doc": "None (awaitable); resolves when the submitted work is done." }, "args": { }, "doc": "Wait until all work that was submitted so far has been completed by the GPU.\n\nResolving also implies completion of earlier GPUBuffer.map_async() calls on buffers last used exclusively on this queue.\n" }, + "on_submitted_work_done_sync": { + "returns": { "type": "None", "doc": "" }, + "args": { }, + "doc": "The synchronous variant of on_submitted_work_done_async()." + }, "write_buffer": { "returns": { "type": "None", "doc": "None." }, "args": { @@ -3350,7 +3438,7 @@ "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." }, "size": { - "type": "int", + "type": "int | None", "default": "None", "doc": "The amount of data to write (in elements of the data type, or bytes). Defaults to the remainder of the data after data_offset." } @@ -3404,7 +3492,8 @@ "GPUCanvasContext": { "bases": [ ], "properties": { - "canvas": { "type": "CanvasLike", "doc": "The canvas (or window/surface object) that this context belongs to." } + "canvas": { "type": "CanvasLike", "doc": "The canvas (or window/surface object) that this context belongs to." }, + "physical_size": { "doc": "Get the physical size of the current framebuffer.", "type": "tuple[int, int]" } }, "methods": { "configure": { @@ -3435,6 +3524,26 @@ "returns": { "type": "GPUTexture", "doc": "A GPUTexture." }, "args": { }, "doc": "Get the GPUTexture to render to for the current frame.\n\nThe texture has the size of the canvas, and is the texture that will be composited to the canvas next. The same GPUTexture object is returned\nuntil the frame is presented (even if it was destroyed or failed validation); a new one is returned for the next frame.\n" + }, + "set_physical_size": { + "doc": "Set the current framebuffer physical size.", + "returns": { "type": "None" }, + "args": { + "width": { "type": "int", "default": "", "doc": "The new width of the framebuffer." }, + "height": { "type": "int", "default": "", "doc": "The new height of the framebuffer." } + } + }, + "get_preferred_format": { + "doc": "Get the preferred surface texture format.", + "returns": { "type": "enums.TextureFormat" }, + "args": { + "adapter": { "type": "GPUAdapter", "default": "" } + } + }, + "present": { + "doc": "Present what has been drawn to the current texture, by compositing it to the canvas.", + "returns": { "type": "None" }, + "args": { } } }, "doc": "The connection between a canvas (or window) and the GPU, used to present rendered images.\n\nConfigure it with configure(), then each frame obtain a texture with get_current_texture(),\nrender to it, and submit the work. The result is presented when the frame ends.\n" diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py index 69d569c6..278a8ea3 100644 --- a/apigen/extract_idl.py +++ b/apigen/extract_idl.py @@ -12,18 +12,7 @@ builtins = builtins.__dict__ -# Minimal difference applied to the final structure. Intended for changes that would otherwise make the API invalid Python. -diff_webgpu = { - "classes": { - "GPUPipelineError": { - "methods": { - # Make GPUPipelineError.__init__() message arg not have a default, - # because the second arg has no default either - "__init__": {"args": {"message": {"default": ""}}}, - } - } - } -} +IGNORE_BASES = {"EventTarget"} # TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure ?? @@ -58,9 +47,6 @@ def extract_idl(): make_names_pythonic(api) resolve_types(api, parser) - # Some final tweaks - api = dict_deep_merge(api, diff_webgpu) - # Write (and read back as a validation step) write_definition_file(api, fname) read_definition_file(fname) @@ -93,7 +79,9 @@ def build_api_dict(parser): classes_dict = api["classes"] = {} for class_name, interface in parser.classes.items(): class_dict = classes_dict[class_name] = {} - class_dict["bases"] = interface.bases + class_dict["bases"] = [ + base for base in interface.bases if base not in IGNORE_BASES + ] class_dict["properties"] = {} for prop_name, attr_type in interface.properties.items(): class_dict["properties"][prop_name] = {"type": attr_type} # str @@ -211,6 +199,25 @@ def __init__(self, apidict: dict, typedefs: dict): self.typedefs = typedefs self.apidict = apidict + def split_on_or(self, name): + needle = " or " + i = 0 + level = 0 + parts = [""] + for c in name: + if c in "<[(": + level += 1 + elif c in ">])": + level -= 1 + if level == 0 and c == needle[i]: + i += 1 + if i == len(needle): + i = 0 + parts.append("") + continue + parts[-1] += c + return parts + def resolve_type(self, typename: str) -> str: """Resolve a type to a suitable name that is also valid so that the linter won't complain when this is used as a type annotation. @@ -231,34 +238,24 @@ def resolve_type(self, typename: str) -> str: # Resolve to a Python type (maybe) name = self.typemap.get(name, name) + name = name.strip() + if name and name[0] == "(" and name[-1] == ")": + name = name[1:-1].strip() - # Is this a case for which we need to recurse? - if ( - name.startswith("sequence<") or name.startswith("FrozenArray<") - ) and name.endswith(">"): - name = name.split("<")[-1].rstrip(">") - name = self.resolve_type(name).strip("'") - return f"list[{name}]" - elif name.startswith("record<") and name.endswith(">"): - name = name.split("<")[-1].rstrip(">") - names = [self.resolve_type(t).strip("'") for t in name.split(",")] - return f"dict[{', '.join(names)}]" - elif " or " in name: - # Clean - name = name.strip("()") - names = [self.resolve_type(t).strip("'") for t in name.split(" or ")] + parts = self.split_on_or(name) + if len(parts) > 1: + names = [self.resolve_type(part).strip("'") for part in parts] names = set(names) # de-dupe has_none = "None" in names names.discard("None") names = sorted(names) if has_none: names.append("None") - # Triage if len(names) == 1: return names[0] if ( len(names) == 2 - and names[0] in ("list[int]", "list[float]") + and names[0] in ("Sequence[int]", "Sequence[float]") and names[1].endswith("Struct") and names[1].startswith( ("structs.Origin", "structs.Extent", "structs.Color") @@ -271,7 +268,17 @@ def resolve_type(self, typename: str) -> str: elif names[1].endswith("3DStruct"): names[0] = "tuple[int, int, int]" return " | ".join(names) - if name.startswith("Promise<") and name.endswith(">"): + elif ( + name.startswith("sequence<") or name.startswith("FrozenArray<") + ) and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + name = self.resolve_type(name).strip("'") + return f"Sequence[{name}]" + elif name.startswith("record<") and name.endswith(">"): + name = name.split("<")[-1].rstrip(">") + names = [self.resolve_type(t).strip("'") for t in name.split(",")] + return f"dict[{', '.join(names)}]" + elif name.startswith("Promise<") and name.endswith(">"): subname = name.split("<")[-1].rstrip(">") subname = self.resolve_type(subname) return f"GPUPromise[{subname}]" @@ -291,6 +298,7 @@ def resolve_type(self, typename: str) -> str: assert name.startswith("GPU"), f"Unknown type: {name}" name = name[3:] name = name[:-4] if name.endswith("Dict") else name + # TODO: Let's remove these suffixes from our types annotations? if name in self.apidict["flags"]: return f"flags.{name}Flags" elif name in self.apidict["enums"]: @@ -354,6 +362,14 @@ def __init__(self, line: str, source: Literal["struct", "param"]): assert isinstance(default, str) assert bool(default) == (not required) + if default == "[]": + default = "()" + elif default == "{}": + default = "None" + + if default == "None" and "None" not in arg_type: + arg_type += " or None" + self.name = arg_name self.idl_type = arg_type self.default = default diff --git a/apigen/merge_json.py b/apigen/merge_json.py index 2babe412..89509b8f 100644 --- a/apigen/merge_json.py +++ b/apigen/merge_json.py @@ -1,3 +1,5 @@ +import json + from apigen_utils import dict_deep_merge, read_definition_file, write_definition_file @@ -13,6 +15,8 @@ def merge_json(): api = dict_deep_merge(webgpu, diff_base) api = dict_deep_merge(api, diff_docs, allow_add=False) + add_sync_methods(api) + api["meta"] = { "filename": "wgpu_api.json", "description": "Definition of the base wgpu API, derived from 'webgpu.json', 'diff_base.json', 'diff_docs.json'.", @@ -22,5 +26,29 @@ def merge_json(): write_definition_file(api, "wgpu_api.json") +def add_sync_methods(api: dict): + """For every async method, add a sync variant.""" + for _class_name, class_dict in api["classes"].items(): + new_methods = {} + for method_name, method_dict in class_dict["methods"].items(): + new_methods[method_name] = method_dict + type_str = method_dict["returns"]["type"] + if type_str.startswith(("GPUPromise[", "Promise[")): + base_name = method_name + if method_name.lower().endswith("async"): + base_name = base_name[:-5].rstrip("_") + if base_name in class_dict["methods"]: + continue # no need to replicate, e.g. create_compute_pipeline + sync_dict = json.loads(json.dumps(method_dict)) + sync_dict["returns"]["type"] = type_str.split("Promise[")[1].rstrip("]") + sync_dict["returns"]["doc"] = "" + sync_dict["doc"] = f"The synchronous variant of {base_name}_async()." + new_methods.pop(method_name) + new_methods[base_name + "_async"] = method_dict + new_methods[base_name + "_sync"] = sync_dict + + class_dict["methods"] = new_methods + + if __name__ == "__main__": merge_json() diff --git a/apigen/patch_api.py b/apigen/patch_api.py index 313fb010..fb7278fc 100644 --- a/apigen/patch_api.py +++ b/apigen/patch_api.py @@ -25,7 +25,7 @@ def patch_api(): code = part1 + line + part2 # Patch! - for patcher in [CommentRemover(), ApiPatcher(api)]: + for patcher in [CommentRemover(), ApiPatcher(api, True)]: patcher.apply(code) code = patcher.dumps() diff --git a/apigen/write_api.py b/apigen/write_api.py index c4bbffb0..f7296e99 100644 --- a/apigen/write_api.py +++ b/apigen/write_api.py @@ -142,7 +142,6 @@ def write_structs(structs_dict): # Get type to include in code, and massage a bit for this module raw_type = field_dict["type"] code_type = raw_type.replace("GPU", "classes.GPU").replace("structs.", "") - code_type = code_type.replace("list[", "Sequence[") # Get type to include in docs docs_type = "" if (