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 new file mode 100644 index 00000000..35f96636 --- /dev/null +++ b/apigen/README.md @@ -0,0 +1,119 @@ +# wgpu APIGEN + +## Introduction + +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. + +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. + +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. + + +## Code organization + +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_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_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 + +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 and looks a bit like 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" + } + } + } + }, + + "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": "" + } + } + } + } + } + } +} + +``` diff --git a/apigen/__init__.py b/apigen/__init__.py new file mode 100644 index 00000000..66f931e1 --- /dev/null +++ b/apigen/__init__.py @@ -0,0 +1,19 @@ +"""Code to generate the wgpu-py API.""" + +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 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, + patch_api, + write_api, + write_js_api, +] diff --git a/apigen/__main__.py b/apigen/__main__.py new file mode 100644 index 00000000..98ddbfd4 --- /dev/null +++ b/apigen/__main__.py @@ -0,0 +1,64 @@ +""" +The entrypoint / script to apply automatic patches to the code. +See README.md for more information. +""" + +import os +import sys +from argparse import ArgumentParser + +from apigen import actions + +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__.strip().splitlines()[0], + ) + +parser.add_argument( + "--all", + action="store_true", + dest="all", + 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__, "..", ".."))) + + +if __name__ == "__main__": + args = parser.parse_args() + enabled = [k for k, v in vars(args).items() if v is True] + + 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: + 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_patcher.py b/apigen/apigen_patcher.py new file mode 100644 index 00000000..a2e7c0c2 --- /dev/null +++ b/apigen/apigen_patcher.py @@ -0,0 +1,506 @@ +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. + """ + + 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) + 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 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: + 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.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)) + 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)) + elif methodname.startswith("_"): + pass + 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(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"] + 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) + 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].get("properties", {}).keys()) + + def get_method_names(self, class_name): + return list(self.api_dict["classes"][class_name].get("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 new file mode 100644 index 00000000..6ba1d50f --- /dev/null +++ b/apigen/apigen_utils.py @@ -0,0 +1,452 @@ +import json +import subprocess +import sys +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 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) + 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 + + +def indent_code(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 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 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 = json.loads(source) + + 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 ("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 + 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) + 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) + 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 + + +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/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_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_base.json b/apigen/definitions/diff_base.json new file mode 100644 index 00000000..d1bfcb96 --- /dev/null +++ b/apigen/definitions/diff_base.json @@ -0,0 +1,139 @@ +{ + "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": { + "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" }, + "create_buffer_with_data": { + "returns": { "type": "GPUBuffer" }, + "args": { + "label": { "type": "str", "default": "\"\"" }, + "data": { "type": "ArrayLike", "default": "" }, + "usage": { "type": "flags.BufferUsageFlags", "default": "" } + } + } + } + }, + "NavigatorGPU": { "diff": "REMOVE" }, + "GPUExternalTexture": { "diff": "REMOVE" }, + "GPUUncapturedErrorEvent": { "diff": "REMOVE" }, + "GPUSupportedLimits": { "diff": "REMOVE" }, + "GPUSupportedFeatures": { "diff": "REMOVE" }, + "WGSLLanguageFeatures": { "diff": "REMOVE" } + }, + "structs": { + "ExternalTextureBindingLayout": { "diff": "REMOVE" }, + "CopyExternalImageDestInfo": { "diff": "REMOVE" }, + "CopyExternalImageSourceInfo": { "diff": "REMOVE" }, + "BindGroupLayoutEntry": { + "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/diff_docs.json b/apigen/definitions/diff_docs.json new file mode 100644 index 00000000..9478cf67 --- /dev/null +++ b/apigen/definitions/diff_docs.json @@ -0,0 +1,1826 @@ +{ + "meta": { + "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": { + "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": { + "__init__": { + "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": { + "__init__": { + "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": { + "__init__": { + "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": { + "__init__": { + "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/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/webgpu.json b/apigen/definitions/webgpu.json new file mode 100644 index 00000000..a796298b --- /dev/null +++ b/apigen/definitions/webgpu.json @@ -0,0 +1,1786 @@ +{ + "meta": { + "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." + }, + "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\"" }, + "power_preference": { "type": "enums.PowerPreferenceEnum | None", "default": "None" }, + "force_fallback_adapter": { "type": "bool", "default": "False" }, + "xr_compatible": { "type": "bool", "default": "False" } + } + }, + "DeviceDescriptor": { + "fields": { + "label": { "type": "str", "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": { + "fields": { + "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": "\"\"" }, + "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": "Sequence[enums.TextureFormatEnum]", "default": "()" }, + "texture_binding_view_dimension": { "type": "enums.TextureViewDimensionEnum | None", "default": "None" } + } + }, + "TextureViewDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "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 | None", "default": "None" }, + "base_array_layer": { "type": "int", "default": "0" }, + "array_layer_count": { "type": "int | None", "default": "None" }, + "swizzle": { "type": "str", "default": "\"rgba\"" } + } + }, + "ExternalTextureDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "source": { "type": "ArrayLike | object", "default": "" }, + "color_space": { "type": "str", "default": "\"srgb\"" } + } + }, + "SamplerDescriptor": { + "fields": { + "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 | None", "default": "None" }, + "max_anisotropy": { "type": "int", "default": "1" } + } + }, + "BindGroupLayoutDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "entries": { "type": "Sequence[structs.BindGroupLayoutEntryStruct]", "default": "" } + } + }, + "BindGroupLayoutEntry": { + "fields": { + "binding": { "type": "int", "default": "" }, + "visibility": { "type": "flags.ShaderStageFlags", "default": "" }, + "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": { + "fields": { + "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\"" } + } + }, + "TextureBindingLayout": { + "fields": { + "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\"" }, + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "view_dimension": { "type": "enums.TextureViewDimensionEnum", "default": "\"2d\"" } + } + }, + "ExternalTextureBindingLayout": { + "fields": { } + }, + "BindGroupDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUBindGroupLayout", "default": "" }, + "entries": { "type": "Sequence[structs.BindGroupEntryStruct]", "default": "" } + } + }, + "BindGroupEntry": { + "fields": { + "binding": { "type": "int", "default": "" }, + "resource": { + "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", + "default": "" + } + } + }, + "BufferBinding": { + "fields": { + "buffer": { "type": "GPUBuffer", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "PipelineLayoutDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "bind_group_layouts": { "type": "Sequence[GPUBindGroupLayout]", "default": "" }, + "immediate_size": { "type": "int", "default": "0" } + } + }, + "ShaderModuleDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "code": { "type": "str", "default": "" }, + "compilation_hints": { "type": "Sequence[structs.ShaderModuleCompilationHintStruct]", "default": "()" } + } + }, + "ShaderModuleCompilationHint": { + "fields": { + "entry_point": { "type": "str", "default": "" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum | None", "default": "None" } + } + }, + "PipelineErrorInit": { + "fields": { + "reason": { "type": "enums.PipelineErrorReasonEnum", "default": "" } + } + }, + "ProgrammableStage": { + "fields": { + "module": { "type": "GPUShaderModule", "default": "" }, + "entry_point": { "type": "str | None", "default": "None" }, + "constants": { "type": "dict[str, float] | None", "default": "None" } + } + }, + "ComputePipelineDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "" }, + "compute": { "type": "structs.ProgrammableStageStruct", "default": "" } + } + }, + "RenderPipelineDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "layout": { "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", "default": "" }, + "vertex": { "type": "structs.VertexStateStruct", "default": "" }, + "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 | None", "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" }, + "mask": { "type": "int", "default": "0xFFFFFFFF" }, + "alpha_to_coverage_enabled": { "type": "bool", "default": "False" } + } + }, + "FragmentState": { + "fields": { + "module": { "type": "GPUShaderModule", "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 | None", "default": "None" }, + "write_mask": { "type": "flags.ColorWriteFlags", "default": "0xF" } + } + }, + "BlendState": { + "fields": { + "color": { "type": "structs.BlendComponentStruct", "default": "" }, + "alpha": { "type": "structs.BlendComponentStruct", "default": "" } + } + }, + "BlendComponent": { + "fields": { + "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": "" }, + "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" }, + "depth_bias_slope_scale": { "type": "float", "default": "0" }, + "depth_bias_clamp": { "type": "float", "default": "0" } + } + }, + "StencilFaceState": { + "fields": { + "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": "" }, + "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": "Sequence[structs.VertexAttributeStruct]", "default": "" } + } + }, + "VertexAttribute": { + "fields": { + "format": { "type": "enums.VertexFormatEnum", "default": "" }, + "offset": { "type": "int", "default": "" }, + "shader_location": { "type": "int", "default": "" } + } + }, + "TexelCopyBufferLayout": { + "fields": { + "offset": { "type": "int", "default": "0" }, + "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 | None", "default": "None" }, + "rows_per_image": { "type": "int | None", "default": "None" }, + "buffer": { "type": "GPUBuffer", "default": "" } + } + }, + "TexelCopyTextureInfo": { + "fields": { + "texture": { "type": "GPUTexture", "default": "" }, + "mip_level": { "type": "int", "default": "0" }, + "origin": { "type": "tuple[int, int, int] | structs.Origin3DStruct | None", "default": "None" }, + "aspect": { "type": "enums.TextureAspectEnum", "default": "\"all\"" } + } + }, + "CopyExternalImageDestInfo": { + "fields": { + "texture": { "type": "GPUTexture", "default": "" }, + "mip_level": { "type": "int", "default": "0" }, + "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" } + } + }, + "CopyExternalImageSourceInfo": { + "fields": { + "source": { "type": "ArrayLike | CanvasLike | object", "default": "" }, + "origin": { "type": "tuple[int, int] | structs.Origin2DStruct | None", "default": "None" }, + "flip_y": { "type": "bool", "default": "False" } + } + }, + "CommandBufferDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" } + } + }, + "CommandEncoderDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" } + } + }, + "ComputePassTimestampWrites": { + "fields": { + "query_set": { "type": "GPUQuerySet", "default": "" }, + "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 | None", "default": "None" } + } + }, + "RenderPassTimestampWrites": { + "fields": { + "query_set": { "type": "GPUQuerySet", "default": "" }, + "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": "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 | 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": "" } + } + }, + "RenderPassDepthStencilAttachment": { + "fields": { + "view": { "type": "GPUTexture | GPUTextureView", "default": "" }, + "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 | 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": "Sequence[enums.TextureFormatEnum]", "default": "" }, + "depth_stencil_format": { "type": "enums.TextureFormatEnum | None", "default": "None" }, + "sample_count": { "type": "int", "default": "1" } + } + }, + "RenderBundleDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" } + } + }, + "RenderBundleEncoderDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "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" } + } + }, + "QueueDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" } + } + }, + "QuerySetDescriptor": { + "fields": { + "label": { "type": "str", "default": "\"\"" }, + "type": { "type": "enums.QueryTypeEnum", "default": "" }, + "count": { "type": "int", "default": "" } + } + }, + "CanvasToneMapping": { + "fields": { + "mode": { "type": "enums.CanvasToneMappingModeEnum", "default": "\"standard\"" } + } + }, + "CanvasConfiguration": { + "fields": { + "device": { "type": "GPUDevice", "default": "" }, + "format": { "type": "enums.TextureFormatEnum", "default": "" }, + "usage": { "type": "flags.TextureUsageFlags", "default": "0x10" }, + "view_formats": { "type": "Sequence[enums.TextureFormatEnum]", "default": "()" }, + "color_space": { "type": "str", "default": "\"srgb\"" }, + "tone_mapping": { "type": "structs.CanvasToneMappingStruct | None", "default": "None" }, + "alpha_mode": { "type": "enums.CanvasAlphaModeEnum", "default": "\"opaque\"" } + } + }, + "UncapturedErrorEventInit": { + "fields": { + "error": { "type": "GPUError", "default": "" } + } + }, + "Color": { + "fields": { + "r": { "type": "float", "default": "" }, + "g": { "type": "float", "default": "" }, + "b": { "type": "float", "default": "" }, + "a": { "type": "float", "default": "" } + } + }, + "Origin2D": { + "fields": { + "x": { "type": "int", "default": "0" }, + "y": { "type": "int", "default": "0" } + } + }, + "Origin3D": { + "fields": { + "x": { "type": "int", "default": "0" }, + "y": { "type": "int", "default": "0" }, + "z": { "type": "int", "default": "0" } + } + }, + "Extent3D": { + "fields": { + "width": { "type": "int", "default": "" }, + "height": { "type": "int", "default": "1" }, + "depth_or_array_layers": { "type": "int", "default": "1" } + } + } + }, + "classes": { + "GPUObjectBase": { + "bases": [ ], + "properties": { + "label": { "type": "str" } + }, + "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": { + "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": { } + }, + "NavigatorGPU": { + "bases": [ ], + "properties": { + "gpu": { "type": "GPU" } + }, + "methods": { } + }, + "GPU": { + "bases": [ ], + "properties": { + "wgsl_language_features": { "type": "set" } + }, + "methods": { + "request_adapter": { + "returns": { "type": "GPUPromise[GPUAdapter]" }, + "args": { + "options": { "type": "structs.RequestAdapterOptionsStruct | None", "default": "None" } + } + }, + "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": "GPUPromise[GPUDevice]" }, + "args": { + "descriptor": { "type": "structs.DeviceDescriptorStruct | None", "default": "None" } + } + } + } + }, + "GPUDevice": { + "bases": [ "GPUObjectBase" ], + "properties": { + "features": { "type": "set" }, + "limits": { "type": "dict" }, + "adapter_info": { "type": "GPUAdapterInfo" }, + "queue": { "type": "GPUQueue" }, + "lost": { "type": "GPUPromise[GPUDeviceLostInfo]" }, + "onuncapturederror": { "type": "None" } + }, + "methods": { + "destroy": { + "returns": { "type": "None" }, + "args": { } + }, + "create_buffer": { + "returns": { "type": "GPUBuffer" }, + "args": { + "descriptor": { "type": "structs.BufferDescriptorStruct", "default": "" } + } + }, + "create_texture": { + "returns": { "type": "GPUTexture" }, + "args": { + "descriptor": { "type": "structs.TextureDescriptorStruct", "default": "" } + } + }, + "create_sampler": { + "returns": { "type": "GPUSampler" }, + "args": { + "descriptor": { "type": "structs.SamplerDescriptorStruct | None", "default": "None" } + } + }, + "import_external_texture": { + "returns": { "type": "object" }, + "args": { + "descriptor": { "type": "structs.ExternalTextureDescriptorStruct", "default": "" } + } + }, + "create_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout" }, + "args": { + "descriptor": { "type": "structs.BindGroupLayoutDescriptorStruct", "default": "" } + } + }, + "create_pipeline_layout": { + "returns": { "type": "GPUPipelineLayout" }, + "args": { + "descriptor": { "type": "structs.PipelineLayoutDescriptorStruct", "default": "" } + } + }, + "create_bind_group": { + "returns": { "type": "GPUBindGroup" }, + "args": { + "descriptor": { "type": "structs.BindGroupDescriptorStruct", "default": "" } + } + }, + "create_shader_module": { + "returns": { "type": "GPUShaderModule" }, + "args": { + "descriptor": { "type": "structs.ShaderModuleDescriptorStruct", "default": "" } + } + }, + "create_compute_pipeline": { + "returns": { "type": "GPUComputePipeline" }, + "args": { + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": "" } + } + }, + "create_render_pipeline": { + "returns": { "type": "GPURenderPipeline" }, + "args": { + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": "" } + } + }, + "create_compute_pipeline_async": { + "returns": { "type": "GPUPromise[GPUComputePipeline]" }, + "args": { + "descriptor": { "type": "structs.ComputePipelineDescriptorStruct", "default": "" } + } + }, + "create_render_pipeline_async": { + "returns": { "type": "GPUPromise[GPURenderPipeline]" }, + "args": { + "descriptor": { "type": "structs.RenderPipelineDescriptorStruct", "default": "" } + } + }, + "create_command_encoder": { + "returns": { "type": "GPUCommandEncoder" }, + "args": { + "descriptor": { "type": "structs.CommandEncoderDescriptorStruct | None", "default": "None" } + } + }, + "create_render_bundle_encoder": { + "returns": { "type": "GPURenderBundleEncoder" }, + "args": { + "descriptor": { "type": "structs.RenderBundleEncoderDescriptorStruct", "default": "" } + } + }, + "create_query_set": { + "returns": { "type": "GPUQuerySet" }, + "args": { + "descriptor": { "type": "structs.QuerySetDescriptorStruct", "default": "" } + } + }, + "push_error_scope": { + "returns": { "type": "None" }, + "args": { + "filter": { "type": "enums.ErrorFilterEnum", "default": "" } + } + }, + "pop_error_scope": { + "returns": { "type": "GPUPromise[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": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "get_mapped_range": { + "returns": { "type": "ArrayLike" }, + "args": { + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "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 | None", "default": "None" } + } + }, + "destroy": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPUTextureView": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPUExternalTexture": { + "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": "GPUPromise[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": "Sequence[GPUCompilationMessage]" } + }, + "methods": { } + }, + "GPUPipelineError": { + "bases": [ "DOMException" ], + "properties": { + "reason": { "type": "enums.PipelineErrorReasonEnum" } + }, + "methods": { + "__init__": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": "\"\"" }, + "options": { "type": "structs.PipelineErrorInitStruct", "default": "" } + } + } + } + }, + "GPUPipelineBase": { + "bases": [ ], + "properties": { }, + "methods": { + "get_bind_group_layout": { + "returns": { "type": "GPUBindGroupLayout" }, + "args": { + "index": { "type": "int", "default": "" } + } + } + } + }, + "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": "" } + } + }, + "begin_compute_pass": { + "returns": { "type": "GPUComputePassEncoder" }, + "args": { + "descriptor": { "type": "structs.ComputePassDescriptorStruct | None", "default": "None" } + } + }, + "copy_buffer_to_buffer": { + "returns": { "type": "None" }, + "args": { + "source": { "type": "GPUBuffer", "default": "" }, + "source_offset": { "type": "int", "default": "" }, + "destination": { "type": "GPUBuffer", "default": "" }, + "destination_offset": { "type": "int", "default": "" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "copy_buffer_to_texture": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "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": "" }, + "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": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "resolve_query_set": { + "returns": { "type": "None" }, + "args": { + "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 | None", "default": "None" } + } + } + } + }, + "GPUBindingCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_bind_group": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "data": { "type": "ArrayLike", "default": "" }, + "data_offset": { "type": "int", "default": "0" }, + "data_size": { "type": "int | None", "default": "None" } + } + } + } + }, + "GPUDebugCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "push_debug_group": { + "returns": { "type": "None" }, + "args": { + "group_label": { "type": "str", "default": "" } + } + }, + "pop_debug_group": { + "returns": { "type": "None" }, + "args": { } + }, + "insert_debug_marker": { + "returns": { "type": "None" }, + "args": { + "marker_label": { "type": "str", "default": "" } + } + } + } + }, + "GPUComputePassEncoder": { + "bases": [ "GPUObjectBase", "GPUCommandsMixin", "GPUDebugCommandsMixin", "GPUBindingCommandsMixin" ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None" }, + "args": { + "pipeline": { "type": "GPUComputePipeline", "default": "" } + } + }, + "dispatch_workgroups": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "indirect_offset": { "type": "int", "default": "" } + } + }, + "end": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPURenderPassEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "set_viewport": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "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": "" } + } + }, + "set_stencil_reference": { + "returns": { "type": "None" }, + "args": { + "reference": { "type": "int", "default": "" } + } + }, + "begin_occlusion_query": { + "returns": { "type": "None" }, + "args": { + "query_index": { "type": "int", "default": "" } + } + }, + "end_occlusion_query": { + "returns": { "type": "None" }, + "args": { } + }, + "execute_bundles": { + "returns": { "type": "None" }, + "args": { + "bundles": { "type": "Sequence[GPURenderBundle]", "default": "" } + } + }, + "end": { + "returns": { "type": "None" }, + "args": { } + } + } + }, + "GPURenderCommandsMixin": { + "bases": [ ], + "properties": { }, + "methods": { + "set_pipeline": { + "returns": { "type": "None" }, + "args": { + "pipeline": { "type": "GPURenderPipeline", "default": "" } + } + }, + "set_index_buffer": { + "returns": { "type": "None" }, + "args": { + "buffer": { "type": "GPUBuffer", "default": "" }, + "index_format": { "type": "enums.IndexFormatEnum", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "set_vertex_buffer": { + "returns": { "type": "None" }, + "args": { + "slot": { "type": "int", "default": "" }, + "buffer": { "type": "GPUBuffer", "default": "" }, + "offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "draw": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "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": "" }, + "indirect_offset": { "type": "int", "default": "" } + } + }, + "draw_indexed_indirect": { + "returns": { "type": "None" }, + "args": { + "indirect_buffer": { "type": "GPUBuffer", "default": "" }, + "indirect_offset": { "type": "int", "default": "" } + } + } + } + }, + "GPURenderBundle": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { } + }, + "GPURenderBundleEncoder": { + "bases": [ + "GPUObjectBase", + "GPUCommandsMixin", + "GPUDebugCommandsMixin", + "GPUBindingCommandsMixin", + "GPURenderCommandsMixin" + ], + "properties": { }, + "methods": { + "finish": { + "returns": { "type": "GPURenderBundle" }, + "args": { + "descriptor": { "type": "structs.RenderBundleDescriptorStruct | None", "default": "None" } + } + } + } + }, + "GPUQueue": { + "bases": [ "GPUObjectBase" ], + "properties": { }, + "methods": { + "submit": { + "returns": { "type": "None" }, + "args": { + "command_buffers": { "type": "Sequence[GPUCommandBuffer]", "default": "" } + } + }, + "on_submitted_work_done": { + "returns": { "type": "GPUPromise[None]" }, + "args": { } + }, + "write_buffer": { + "returns": { "type": "None" }, + "args": { + "buffer": { "type": "GPUBuffer", "default": "" }, + "buffer_offset": { "type": "int", "default": "" }, + "data": { "type": "ArrayLike", "default": "" }, + "data_offset": { "type": "int", "default": "0" }, + "size": { "type": "int | None", "default": "None" } + } + }, + "write_texture": { + "returns": { "type": "None" }, + "args": { + "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": "" }, + "destination": { "type": "structs.CopyExternalImageDestInfoStruct", "default": "" }, + "copy_size": { "type": "tuple[int, int, int] | structs.Extent3DStruct", "default": "" } + } + } + } + }, + "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": "" } + } + }, + "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": { + "__init__": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": "" } + } + } + } + }, + "GPUOutOfMemoryError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "__init__": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": "" } + } + } + } + }, + "GPUInternalError": { + "bases": [ "GPUError" ], + "properties": { }, + "methods": { + "__init__": { + "returns": { "type": "None" }, + "args": { + "message": { "type": "str", "default": "" } + } + } + } + }, + "GPUUncapturedErrorEvent": { + "bases": [ "Event" ], + "properties": { + "error": { "type": "GPUError" } + }, + "methods": { + "__init__": { + "returns": { "type": "None" }, + "args": { + "type": { "type": "str", "default": "" }, + "gpu_uncaptured_error_event_init_dict": { "type": "structs.UncapturedErrorEventInitStruct", "default": "" } + } + } + } + } + } +} diff --git a/apigen/definitions/wgpu_api.json b/apigen/definitions/wgpu_api.json new file mode 100644 index 00000000..6adaec1e --- /dev/null +++ b/apigen/definitions/wgpu_api.json @@ -0,0 +1,3617 @@ +{ + "meta": { + "filename": "wgpu_api.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": { + "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\"", + "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.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." + }, + "force_fallback_adapter": { + "type": "bool", + "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." + }, + "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" + }, + "DeviceDescriptor": { + "fields": { + "label": { + "type": "str", + "default": "\"\"", + "doc": "A human-readable label for the device, used in debugging and error messages." + }, + "required_features": { + "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] | 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 | None", + "default": "None", + "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": "\"\"", + "doc": "A human-readable label for the buffer, used in debugging and error messages." + }, + "size": { "type": "int", "default": "", "doc": "The size of the buffer in bytes." }, + "usage": { + "type": "flags.BufferUsageFlags", + "default": "", + "doc": "The allowed usages of the buffer, a combination of flags.BufferUsage." + }, + "mapped_at_creation": { + "type": "bool", + "default": "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": "\"\"", + "doc": "A human-readable label for the texture, used in debugging and error messages." + }, + "size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "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", "doc": "The number of mip levels. Defaults to 1." }, + "sample_count": { + "type": "int", + "default": "1", + "doc": "The number of samples per pixel, for multisampled textures. Must be 1 or 4. Defaults to 1." + }, + "dimension": { + "type": "enums.TextureDimensionEnum", + "default": "\"2d\"", + "doc": "The dimensionality of the texture, see enums.TextureDimension. Defaults to d2." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": "", + "doc": "The pixel format of the texture, see enums.TextureFormat." + }, + "usage": { + "type": "flags.TextureUsageFlags", + "default": "", + "doc": "The allowed usages of the texture, a combination of flags.TextureUsage." + }, + "view_formats": { + "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 | 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." + } + }, + "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": "\"\"", + "doc": "A human-readable label for the texture view, used in debugging and error messages." + }, + "format": { + "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 | None", + "default": "None", + "doc": "The dimensionality of the view, see enums.TextureViewDimension. Defaults to a dimension matching the texture." + }, + "usage": { + "type": "flags.TextureUsageFlags", + "default": "0", + "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\"", + "doc": "Which aspect of the texture the view refers to, see enums.TextureAspect. Defaults to all." + }, + "base_mip_level": { "type": "int", "default": "0", "doc": "The first mip level accessible via the view. Defaults to 0." }, + "mip_level_count": { + "type": "int | None", + "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", + "doc": "The first array layer accessible via the view. Defaults to 0." + }, + "array_layer_count": { + "type": "int | None", + "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\"", + "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": "\"\"", + "doc": "A human-readable label for the external texture, used in debugging and error messages." + }, + "source": { + "type": "ArrayLike | object", + "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\"", + "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": "\"\"", + "doc": "A human-readable label for the sampler, used in debugging and error messages." + }, + "address_mode_u": { + "type": "enums.AddressModeEnum", + "default": "\"clamp-to-edge\"", + "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\"", + "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\"", + "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\"", + "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\"", + "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\"", + "doc": "How to filter between mip levels, see enums.MipmapFilterMode. Defaults to nearest." + }, + "lod_min_clamp": { + "type": "float", + "default": "0", + "doc": "The minimum level of detail used when sampling. Defaults to 0." + }, + "lod_max_clamp": { + "type": "float", + "default": "32", + "doc": "The maximum level of detail used when sampling. Defaults to 32." + }, + "compare": { + "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." + }, + "max_anisotropy": { + "type": "int", + "default": "1", + "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": "\"\"", + "doc": "A human-readable label for the bind group layout, used in debugging and error messages." + }, + "entries": { + "type": "Sequence[structs.BindGroupLayoutEntryStruct]", + "default": "", + "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": "", + "doc": "The binding number, matching the @binding attribute in the shader." + }, + "visibility": { + "type": "flags.ShaderStageFlags", + "default": "", + "doc": "The shader stages in which the resource is visible, a combination of flags.ShaderStage." + }, + "buffer": { + "type": "structs.BufferBindingLayoutStruct | None", + "default": "None", + "doc": "If set, a structs.BufferBindingLayout: the entry is a buffer binding." + }, + "sampler": { + "type": "structs.SamplerBindingLayoutStruct | None", + "default": "None", + "doc": "If set, a structs.SamplerBindingLayout: the entry is a sampler binding." + }, + "texture": { + "type": "structs.TextureBindingLayoutStruct | None", + "default": "None", + "doc": "If set, a structs.TextureBindingLayout: the entry is a sampled texture binding." + }, + "storage_texture": { + "type": "structs.StorageTextureBindingLayoutStruct | None", + "default": "None", + "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\"", + "doc": "The type of buffer binding, see enums.BufferBindingType. Defaults to uniform." + }, + "has_dynamic_offset": { + "type": "bool", + "default": "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", + "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\"", + "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\"", + "doc": "The type of values returned when sampling, see enums.TextureSampleType. Defaults to float." + }, + "view_dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": "\"2d\"", + "doc": "The dimension of texture views that can be bound, see enums.TextureViewDimension. Defaults to d2." + }, + "multisampled": { + "type": "bool", + "default": "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\"", + "doc": "How the shader can access the texture, see enums.StorageTextureAccess. Defaults to write_only." + }, + "format": { + "type": "enums.TextureFormatEnum", + "default": "", + "doc": "The enums.TextureFormat that the bound texture view must have." + }, + "view_dimension": { + "type": "enums.TextureViewDimensionEnum", + "default": "\"2d\"", + "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": "\"\"", + "doc": "A human-readable label for the bind group, used in debugging and error messages." + }, + "layout": { + "type": "GPUBindGroupLayout", + "default": "", + "doc": "The GPUBindGroupLayout that this bind group conforms to." + }, + "entries": { + "type": "Sequence[structs.BindGroupEntryStruct]", + "default": "", + "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": "", + "doc": "The binding number, matching the binding field of the corresponding structs.BindGroupLayoutEntry." + }, + "resource": { + "type": "GPUBuffer | GPUSampler | GPUTexture | GPUTextureView | object | structs.BufferBindingStruct", + "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." + } + }, + "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": "", "doc": "The GPUBuffer to bind." }, + "offset": { + "type": "int", + "default": "0", + "doc": "The offset in bytes into the buffer where the binding starts. Defaults to 0." + }, + "size": { + "type": "int | None", + "default": "None", + "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": "\"\"", + "doc": "A human-readable label for the pipeline layout, used in debugging and error messages." + }, + "bind_group_layouts": { + "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." + }, + "immediate_size": { + "type": "int", + "default": "0", + "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": "\"\"", + "doc": "A human-readable label for the shader module, used in debugging and error messages." + }, + "code": { "type": "str", "default": "", "doc": "The shader source code, in WGSL." }, + "compilation_hints": { + "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)." + } + }, + "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": "", "doc": "The name of the shader entry point that the hint applies to." }, + "layout": { + "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)." + } + }, + "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": "", + "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": "", "doc": "The GPUShaderModule containing the shader code." }, + "entry_point": { + "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] | 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." + } + }, + "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": "\"\"", + "doc": "A human-readable label for the pipeline, used in debugging and error messages." + }, + "layout": { + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "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": "", + "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": "\"\"", + "doc": "A human-readable label for the pipeline, used in debugging and error messages." + }, + "layout": { + "type": "GPUPipelineLayout | enums.AutoLayoutModeEnum", + "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": "", + "doc": "A structs.VertexState describing the vertex shader and vertex buffers." + }, + "primitive": { + "type": "structs.PrimitiveStateStruct | None", + "default": "None", + "doc": "A structs.PrimitiveState describing how primitives are assembled and rasterized." + }, + "depth_stencil": { + "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 | None", + "default": "None", + "doc": "A structs.MultisampleState describing multisampling." + }, + "fragment": { + "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)." + } + }, + "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\"", + "doc": "How vertices are assembled into primitives, see enums.PrimitiveTopology. Defaults to triangle_list." + }, + "strip_index_format": { + "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()." + }, + "front_face": { + "type": "enums.FrontFaceEnum", + "default": "\"ccw\"", + "doc": "Which winding order is front-facing, see enums.FrontFace. Defaults to ccw." + }, + "cull_mode": { + "type": "enums.CullModeEnum", + "default": "\"none\"", + "doc": "Which faces to cull, see enums.CullMode. Defaults to none." + }, + "unclipped_depth": { + "type": "bool", + "default": "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", + "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", + "doc": "A bitmask that determines which samples are written to. Defaults to 0xFFFFFFFF." + }, + "alpha_to_coverage_enabled": { + "type": "bool", + "default": "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": "", + "doc": "The GPUShaderModule containing the fragment shader code." + }, + "entry_point": { + "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] | 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": "Sequence[structs.ColorTargetStateStruct]", + "default": "", + "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": "", + "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 | None", + "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", + "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": "", + "doc": "A structs.BlendComponent for the color (RGB) channels." + }, + "alpha": { + "type": "structs.BlendComponentStruct", + "default": "", + "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\"", + "doc": "The enums.BlendOperation used to combine the scaled values. Defaults to add." + }, + "src_factor": { + "type": "enums.BlendFactorEnum", + "default": "\"one\"", + "doc": "The enums.BlendFactor applied to the source (fragment shader output). Defaults to one." + }, + "dst_factor": { + "type": "enums.BlendFactorEnum", + "default": "\"zero\"", + "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": "", + "doc": "The enums.TextureFormat of the depth-stencil attachment that this pipeline is compatible with." + }, + "depth_write_enabled": { + "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 | None", + "default": "None", + "doc": "The enums.CompareFunction used for the depth test." + }, + "stencil_front": { + "type": "structs.StencilFaceStateStruct | None", + "default": "None", + "doc": "A structs.StencilFaceState for front-facing primitives." + }, + "stencil_back": { + "type": "structs.StencilFaceStateStruct | None", + "default": "None", + "doc": "A structs.StencilFaceState for back-facing primitives." + }, + "stencil_read_mask": { + "type": "int", + "default": "0xFFFFFFFF", + "doc": "Bitmask applied to the stencil values before comparison. Defaults to 0xFFFFFFFF." + }, + "stencil_write_mask": { + "type": "int", + "default": "0xFFFFFFFF", + "doc": "Bitmask that determines which bits of the stencil buffer are written. Defaults to 0xFFFFFFFF." + }, + "depth_bias": { + "type": "int", + "default": "0", + "doc": "A constant depth value added to each fragment. Defaults to 0." + }, + "depth_bias_slope_scale": { + "type": "float", + "default": "0", + "doc": "A depth bias that scales with the slope of the primitive. Defaults to 0." + }, + "depth_bias_clamp": { + "type": "float", + "default": "0", + "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\"", + "doc": "The enums.CompareFunction used to compare the stencil reference with the stencil value. Defaults to always." + }, + "fail_op": { + "type": "enums.StencilOperationEnum", + "default": "\"keep\"", + "doc": "The enums.StencilOperation performed if the stencil test fails. Defaults to keep." + }, + "depth_fail_op": { + "type": "enums.StencilOperationEnum", + "default": "\"keep\"", + "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\"", + "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": "", + "doc": "The GPUShaderModule containing the vertex shader code." + }, + "entry_point": { + "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] | 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": "Sequence[structs.VertexBufferLayoutStruct]", + "default": "()", + "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": "", + "doc": "The stride in bytes between consecutive elements in the buffer." + }, + "step_mode": { + "type": "enums.VertexStepModeEnum", + "default": "\"vertex\"", + "doc": "How often the buffer is advanced, see enums.VertexStepMode. Defaults to vertex." + }, + "attributes": { + "type": "Sequence[structs.VertexAttributeStruct]", + "default": "", + "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": "", "doc": "The enums.VertexFormat of the attribute." }, + "offset": { + "type": "int", + "default": "", + "doc": "The offset in bytes of the attribute from the start of an element in the buffer." + }, + "shader_location": { + "type": "int", + "default": "", + "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", + "doc": "The offset in bytes into the data where the texel data starts. Defaults to 0." + }, + "bytes_per_row": { + "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 | 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." + } + }, + "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", + "doc": "The offset in bytes into the buffer where the texel data starts. Defaults to 0." + }, + "bytes_per_row": { + "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 | 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." + }, + "buffer": { + "type": "GPUBuffer", + "default": "", + "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": "", "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 | 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": { + "type": "enums.TextureAspectEnum", + "default": "\"all\"", + "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": "\"\"", + "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": "\"\"", + "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": "", + "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." + }, + "beginning_of_pass_write_index": { + "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 | 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." + } + }, + "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": "\"\"", + "doc": "A human-readable label for the compute pass, used in debugging and error messages." + }, + "timestamp_writes": { + "type": "structs.ComputePassTimestampWritesStruct | None", + "default": "None", + "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": "", + "doc": "The GPUQuerySet (of type enums.QueryType.timestamp) to write the timestamps to." + }, + "beginning_of_pass_write_index": { + "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 | 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." + } + }, + "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": "\"\"", + "doc": "A human-readable label for the render pass, used in debugging and error messages." + }, + "color_attachments": { + "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 | None", + "default": "None", + "doc": "An optional structs.RenderPassDepthStencilAttachment for depth and stencil." + }, + "occlusion_query_set": { + "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 | None", + "default": "None", + "doc": "An optional structs.RenderPassTimestampWrites for recording timestamps of the pass." + }, + "max_draw_count": { + "type": "int", + "default": "50000000", + "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": "", + "doc": "The GPUTextureView to render to. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." + }, + "depth_slice": { + "type": "int | None", + "default": "None", + "doc": "For 3D textures, the index of the depth slice to render to." + }, + "resolve_target": { + "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 | 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." + }, + "load_op": { + "type": "enums.LoadOpEnum", + "default": "", + "doc": "What to do with the existing contents at the start of the pass, see enums.LoadOp." + }, + "store_op": { + "type": "enums.StoreOpEnum", + "default": "", + "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": "", + "doc": "The GPUTextureView to use as depth-stencil attachment. Its texture must have flags.TextureUsage.RENDER_ATTACHMENT." + }, + "depth_clear_value": { + "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 | 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 | 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." + }, + "depth_read_only": { + "type": "bool", + "default": "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", + "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 | 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 | 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." + }, + "stencil_read_only": { + "type": "bool", + "default": "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": "\"\"", + "doc": "A human-readable label, used in debugging and error messages." + }, + "color_formats": { + "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 | None", + "default": "None", + "doc": "The enums.TextureFormat of the depth-stencil attachment, if any." + }, + "sample_count": { + "type": "int", + "default": "1", + "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": "\"\"", + "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": "\"\"", + "doc": "A human-readable label for the render bundle encoder, used in debugging and error messages." + }, + "color_formats": { + "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 | None", + "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", + "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", + "doc": "If true, the bundle does not write to the depth aspect. Defaults to false." + }, + "stencil_read_only": { + "type": "bool", + "default": "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": "\"\"", + "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": "\"\"", + "doc": "A human-readable label for the query set, used in debugging and error messages." + }, + "type": { + "type": "enums.QueryTypeEnum", + "default": "", + "doc": "The type of queries in the set, see enums.QueryType." + }, + "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" + }, + "CanvasToneMapping": { + "fields": { + "mode": { + "type": "enums.CanvasToneMappingModeEnum", + "default": "\"standard\"", + "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": "", + "doc": "The GPUDevice that the canvas textures will be used with." + }, + "format": { + "type": "enums.TextureFormatEnum", + "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", + "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": "Sequence[enums.TextureFormatEnum]", + "default": "()", + "doc": "Additional enums.TextureFormat values that views of the canvas texture may use." + }, + "color_space": { + "type": "str", + "default": "\"srgb\"", + "doc": "The color space of the canvas, e.g. 'srgb' or 'display-p3'. Defaults to 'srgb'." + }, + "tone_mapping": { + "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": { + "type": "enums.CanvasAlphaModeEnum", + "default": "\"opaque\"", + "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": "", + "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": "", "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", "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", "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": "", "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", + "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." + }, + "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": [ "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." }, + "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_async": { + "returns": { "type": "GPUPromise[GPUAdapter]", "doc": "A GPUAdapter, or None if no suitable adapter was found." }, + "args": { + "options": { + "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", + "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" + }, + "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" + }, + "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." + }, + "summary": { + "type": "str", + "doc": "A one-line summary of the info of this adapter (device, adapter_type, backend_type)." + } + }, + "methods": { + "request_device_async": { + "returns": { "type": "GPUPromise[GPUDevice]", "doc": "A GPUDevice." }, + "args": { + "descriptor": { + "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": [ "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": "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": { + "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": { + "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": "", + "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": "", + "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 | None", + "default": "None", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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 | None", + "default": "None", + "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": "", + "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": "", + "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": "", + "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_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" + }, + "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": "", + "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": "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": { + "offset": { + "type": "int", + "default": "0", + "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 | 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." + } + }, + "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 | None", + "default": "None", + "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_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" + }, + "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": "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" + }, + "GPUPipelineError": { + "bases": [ "DOMException" ], + "properties": { + "reason": { + "type": "enums.PipelineErrorReasonEnum", + "doc": "The reason for the failure, see enums.PipelineErrorReason." + } + }, + "methods": { + "__init__": { + "returns": { "type": "None", "doc": "A GPUPipelineError." }, + "args": { + "message": { "type": "str", "default": "\"\"", "doc": "The human-readable error message." }, + "options": { + "type": "structs.PipelineErrorInitStruct", + "default": "", + "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": "", + "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": "", + "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 | None", + "default": "None", + "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": "", "doc": "The GPUBuffer to copy from." }, + "source_offset": { + "type": "int", + "default": "", + "doc": "The offset in bytes in the source buffer where the copy starts." + }, + "destination": { "type": "GPUBuffer", "default": "", "doc": "The GPUBuffer to copy to." }, + "destination_offset": { + "type": "int", + "default": "", + "doc": "The offset in bytes in the destination buffer where the data is written." + }, + "size": { + "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." + } + }, + "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": "", + "doc": "A structs.TexelCopyBufferInfo describing the buffer and the layout of the data in it." + }, + "destination": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": "", + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." + }, + "copy_size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": "", + "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": "", + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." + }, + "destination": { + "type": "structs.TexelCopyBufferInfoStruct", + "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": "", + "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": "", + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy from." + }, + "destination": { + "type": "structs.TexelCopyTextureInfoStruct", + "default": "", + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to copy to." + }, + "copy_size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": "", + "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": "", "doc": "The GPUBuffer to clear." }, + "offset": { + "type": "int", + "default": "0", + "doc": "The offset in bytes where the clearing starts. Must be a multiple of 4. Defaults to 0." + }, + "size": { + "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." + } + }, + "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": "", "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": "", + "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 | None", + "default": "None", + "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": "", + "doc": "The index of the bind group (the @group number in the shader)." + }, + "bind_group": { "type": "GPUBindGroup", "default": "", "doc": "The GPUBindGroup to set, or None to unset it." }, + "dynamic_offsets_data": { + "type": "ArrayLike", + "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": "", + "doc": "If dynamic_offsets_data is an array, the index of the first offset to use." + }, + "dynamic_offsets_data_length": { + "type": "int", + "default": "", + "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": "", + "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": "", + "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", + "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." + }, + "data_size": { + "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." + } + }, + "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": "", "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": "", "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": "", "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": "", "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": "", "doc": "The GPUBuffer that contains the workgroup counts." }, + "indirect_offset": { + "type": "int", + "default": "", + "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": "", + "doc": "The x coordinate of the top-left corner of the viewport, in pixels." + }, + "y": { + "type": "float", + "default": "", + "doc": "The y coordinate of the top-left corner of the viewport, in pixels." + }, + "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" + }, + "set_scissor_rect": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "x": { + "type": "int", + "default": "", + "doc": "The x coordinate of the top-left corner of the rectangle, in pixels." + }, + "y": { + "type": "int", + "default": "", + "doc": "The y coordinate of the top-left corner 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" + }, + "set_blend_constant": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "color": { + "type": "tuple[float, float, float, float] | structs.ColorStruct", + "default": "", + "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": "", "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": "", "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": "Sequence[GPURenderBundle]", + "default": "", + "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": "", "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": "", "doc": "The GPUBuffer that contains the indices." }, + "index_format": { + "type": "enums.IndexFormatEnum", + "default": "", + "doc": "The data type of the indices, see enums.IndexFormat." + }, + "offset": { + "type": "int", + "default": "0", + "doc": "The offset in bytes in the buffer where the indices start. Defaults to 0." + }, + "size": { + "type": "int | None", + "default": "None", + "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": "", + "doc": "The index of the vertex buffer slot, matching the index in the buffers field of structs.VertexState." + }, + "buffer": { + "type": "GPUBuffer", + "default": "", + "doc": "The GPUBuffer that contains the vertex data, or None to unset the slot." + }, + "offset": { + "type": "int", + "default": "0", + "doc": "The offset in bytes in the buffer where the vertex data starts. Defaults to 0." + }, + "size": { + "type": "int | None", + "default": "None", + "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": "", "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", + "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", + "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": "", "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", + "doc": "The position in the index buffer (in indices, not bytes) where drawing starts. Defaults to 0." + }, + "base_vertex": { + "type": "int", + "default": "0", + "doc": "A value added to each index before looking up the vertex. Defaults to 0." + }, + "first_instance": { + "type": "int", + "default": "0", + "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": "", "doc": "The GPUBuffer that contains the draw parameters." }, + "indirect_offset": { + "type": "int", + "default": "", + "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": "", "doc": "The GPUBuffer that contains the draw parameters." }, + "indirect_offset": { + "type": "int", + "default": "", + "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 | None", + "default": "None", + "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": "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_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": { + "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": "", + "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", + "doc": "The offset in the data (in elements of the data type, or bytes) where reading starts. Defaults to 0." + }, + "size": { + "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." + } + }, + "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": "", + "doc": "A structs.TexelCopyTextureInfo describing the part of the texture to write to." + }, + "data": { + "type": "ArrayLike", + "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": "", + "doc": "A structs.TexelCopyBufferLayout describing the layout of the texel data in data." + }, + "size": { + "type": "tuple[int, int, int] | structs.Extent3DStruct", + "default": "", + "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." }, + "physical_size": { "doc": "Get the physical size of the current framebuffer.", "type": "tuple[int, int]" } + }, + "methods": { + "configure": { + "returns": { "type": "None", "doc": "None." }, + "args": { + "configuration": { + "type": "structs.CanvasConfigurationStruct", + "default": "", + "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" + }, + "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" + }, + "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": { + "__init__": { + "returns": { "type": "None", "doc": "A GPUValidationError." }, + "args": { + "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" + } + }, + "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": { + "__init__": { + "returns": { "type": "None", "doc": "A GPUOutOfMemoryError." }, + "args": { + "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" + } + }, + "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": { + "__init__": { + "returns": { "type": "None", "doc": "A GPUInternalError." }, + "args": { + "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" + } + }, + "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/download_idl.py b/apigen/download_idl.py new file mode 100644 index 00000000..3c766ac2 --- /dev/null +++ b/apigen/download_idl.py @@ -0,0 +1,25 @@ +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" + ) + + 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}") + + +if __name__ == "__main__": + download_idl() diff --git a/apigen/extract_idl.py b/apigen/extract_idl.py new file mode 100644 index 00000000..278a8ea3 --- /dev/null +++ b/apigen/extract_idl.py @@ -0,0 +1,703 @@ +from typing import Literal + +from apigen_utils import ( + dict_deep_merge, + read_definition_file, + read_file, + write_definition_file, +) + +builtins = __builtins__ +if not isinstance(builtins, dict): + builtins = builtins.__dict__ + + +IGNORE_BASES = {"EventTarget"} + +# TODO: handle ARGS_TO_MAKE_OPTIONAL, in apidiff structure ?? + + +def extract_idl(): + """Parse the IDL specification to a structured form in json. + + This is done in three stages: + + - 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. + source = read_file("apigen", "definitions", "webgpu.idl") + parser = IdlParser(source) + parser.parse() + + # Generate structure + fname = "webgpu.json" + 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.", + } + api.update(build_api_dict(parser)) + + # Convert names and types + make_names_pythonic(api) + resolve_types(api, parser) + + # 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] = {} + flag_dict["fields"] = {} + for k, v in d.items(): + flag_dict["fields"][k] = {"value": v} + + 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 = 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.name] = att.to_dict() + + classes_dict = api["classes"] = {} + for class_name, interface in parser.classes.items(): + class_dict = classes_dict[class_name] = {} + 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 + class_dict["methods"] = {} + for func in interface.methods.values(): + 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.name] = attribute.to_dict() + + 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 = {} + 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 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(): + 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 + + +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 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. + """ + + 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) + name = name.strip() + if name and name[0] == "(" and name[-1] == ")": + name = name[1:-1].strip() + + 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") + if len(names) == 1: + return names[0] + if ( + len(names) == 2 + and names[0] in ("Sequence[int]", "Sequence[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) + 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}]" + + # 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 + # 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"]: + 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.""" + + def __init__(self, line: str, source: Literal["struct", "param"]): + self.line = line.strip().strip(",;").strip() + self.source = source + + # 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: + 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. + # 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 not default + else: + required = False + default = default or "None" + 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 not default + else: + raise RuntimeError(f"Invalid Attribute source: {source!r}") + + 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 + + def __repr__(self): + return f"" + + def to_dict(self) -> dict: + return {"type": self.idl_type, "default": self.default} + + +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.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. + """ + + # 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 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(func.line) + func.return_type = return_type or "None" + func.args = args + + 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()] + 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__": + extract_idl() diff --git a/apigen/format_json.py b/apigen/format_json.py new file mode 100644 index 00000000..e09582b7 --- /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_") + ] + 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..89509b8f --- /dev/null +++ b/apigen/merge_json.py @@ -0,0 +1,54 @@ +import json + +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 + webgpu = read_definition_file("webgpu.json") + diff_base = read_definition_file("diff_base.json") + diff_docs = read_definition_file("diff_docs.json") + + # Combine + 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'.", + "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") + + +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 new file mode 100644 index 00000000..fb7278fc --- /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, True)]: + patcher.apply(code) + code = patcher.dumps() + + # Write result back + write_file(code, "wgpu", "_classes.py") + + +if __name__ == "__main__": + patch_api() diff --git a/apigen/write_api.py b/apigen/write_api.py new file mode 100644 index 00000000..f7296e99 --- /dev/null +++ b/apigen/write_api.py @@ -0,0 +1,185 @@ +"""Generate the simple API from the definitions.""" + +import re + +from apigen_utils import ( + dict_deep_merge, + format_code, + # indent_code, + 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_code(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_code(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, and massage a bit for this module + raw_type = field_dict["type"] + code_type = raw_type.replace("GPU", "classes.GPU").replace("structs.", "") + # 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 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" + # 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_js_api.py b/apigen/write_js_api.py new file mode 100644 index 00000000..7dc9f4e7 --- /dev/null +++ b/apigen/write_js_api.py @@ -0,0 +1,64 @@ +from apigen_utils import format_code, 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. +""" +''' + +# todo: replace GPUPromise -> Promise or something? + + +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) + + code = format_code(code) + + write_file(code, "wgpu", "backends", "js_webgpu", "webgpu_stub.py") + + +if __name__ == "__main__": + write_js_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()