diff --git a/codegen/files.py b/codegen/files.py index 0b7c4b65..ad1a89d1 100644 --- a/codegen/files.py +++ b/codegen/files.py @@ -12,7 +12,13 @@ def read_file(*fname): """Read a file from disk using the relative filename. Line endings are normalized.""" filename = os.path.join(lib_dir, *fname) with open(filename, "rb") as f: - return f.read().decode().replace("\r\n", "\n").replace("\r", "\n") + return ( + f.read() + .decode() + .replace("\r\n", "\n") + .replace("\r", "\n") + .replace("\\\n", "") # Macros escaping a newline + ) class FileCache: diff --git a/codegen/hparser.py b/codegen/hparser.py index d6614b0f..2012f40b 100644 --- a/codegen/hparser.py +++ b/codegen/hparser.py @@ -95,14 +95,15 @@ def _parse_from_h(self): assert name1.startswith("WGPU") name = name1[4:] self.enums[name] = enum = {} - for f in code[i2 + 1 : i3].strip().strip(";").split(","): - f = remove_c_comments(f).strip() + code_block = code[i2 + 1 : i3].strip().strip(";") + block = remove_c_comments(code_block).strip() + for f in block.split(","): if not f: - continue # happens when last item has a comma + continue # no item after last comma key, _, val = f.partition("=") # Handle key key = key.strip() - assert key.startswith("WGPU") and "_" in key + assert key.startswith("WGPU") and "_" in key, f"key={key}" key = key.split("_", 1)[1] # Turn value into an int val = val.strip() @@ -120,18 +121,38 @@ def _parse_from_h(self): else: enum[key] = int(val) - # Turn some enums into flags for line in code.splitlines(): + # collect flags + # schme: typedef WGPUFlags WGPUFlagName; if line.startswith("typedef WGPUFlags "): parts = line.strip().strip(";").split() assert len(parts) == 3 name = parts[-1] - if name.endswith("Flags"): - assert name.startswith("WGPU") - name1 = name[4:-1] # xxFlags -> xxFlag - name2 = name[4:-5] # xxFlags -> xx - name = name1 if name1 in self.enums else name2 - self.flags[name] = self.enums.pop(name) + assert name.startswith("WGPU") + name = name[4:] + assert not name.endswith("Flags"), "XxxxFlags should not longer exist" + assert name not in self.enums, "flags used to look like enums" + self.flags[name] = {} + + # fill flags + # schema: static const WGPUFlagName WGPUFlagName_Value = 0x0000000000000001; + if line.startswith("static const"): + line = remove_c_comments(line).strip() + flag_name = line.removeprefix("static const").lstrip().split()[0] + flag_key, _, val = ( + line.removeprefix(f"static const {flag_name}") + .strip() + .rstrip(";") + .partition("=") + ) + # Check / normalize flag_name + assert flag_name.startswith("WGPU") + flag_name = flag_name[4:] + assert flag_name in self.flags + # Check / normalize flag_key + assert flag_key.startswith(f"WGPU{flag_name}_") + flag_key = flag_key.partition("_")[2].strip() + self.flags[flag_name][flag_key] = self._parse_val_to_int(val) # Collect structs. This is relatively easy, since we only need the C code. # But we don't deal with union structs. @@ -229,3 +250,22 @@ def _parse_from_cffi(self): while alt_name != ffi.getctype(alt_name): alt_name = ffi.getctype(alt_name) self.structs[alt_name] = self.structs[name] + + def _parse_val_to_int(self, val): + """ + little helper to parse complex values for enums. + """ + val = val.strip(" ()") + if "|" in val: + # recursively handle the "OR" values? + res_val = 0 + for sub_val in val.split("|"): + res_val |= self._parse_val_to_int(sub_val) + return res_val + if val.startswith("0x"): + return int(val, 16) + elif "<<" in val: + val1, _, val2 = val.partition("<<") + return int(val1) << int(val2) + else: + return int(val) diff --git a/codegen/tests/test_codegen_rspatcher.py b/codegen/tests/test_codegen_rspatcher.py index 29d5e0ee..3e27e462 100644 --- a/codegen/tests/test_codegen_rspatcher.py +++ b/codegen/tests/test_codegen_rspatcher.py @@ -37,7 +37,7 @@ def test_patch_structs(): """ code2 = patch_wgpu_native_backend(dedent(code1)) assert all(line[4:] in code2 for line in code1 if line.strip()) - assert "usage: WGPUBufferUsageFlags/int" in code2 + assert "usage: WGPUBufferUsage/int" in code2 assert "size: int" in code2 assert "# FIXME:" not in code2 assert code2 == patch_wgpu_native_backend(code2) # Don't stack comments @@ -53,7 +53,7 @@ def test_patch_structs(): """ code2 = patch_wgpu_native_backend(dedent(code1)) assert all(line[4:] in code2 for line in code1 if line.strip()) - assert "usage: WGPUBufferUsageFlags/int" in code2 + assert "usage: WGPUBufferUsage/int" in code2 assert "size: int" in code2 assert "# FIXME:" not in code2 @@ -72,7 +72,7 @@ def test_patch_structs(): # Missing values code1 = 'struct = new_struct_p("WGPUBufferDescriptor *",label=c_label,size=size,)' code2 = patch_wgpu_native_backend(dedent(code1)) - assert "usage: WGPUBufferUsageFlags/int" in code2 + assert "usage: WGPUBufferUsage/int" in code2 assert "# FIXME:" not in code2 assert "usage" in code2 # comment added assert code2 == patch_wgpu_native_backend(code2) # Don't stack comments @@ -80,7 +80,7 @@ def test_patch_structs(): # Too many values code1 = 'struct = new_struct_p("WGPUBufferDescriptor *",label=c_label,foo=size,)' code2 = patch_wgpu_native_backend(dedent(code1)) - assert "usage: WGPUBufferUsageFlags/int" in code2 + assert "usage: WGPUBufferUsage/int" in code2 assert "# FIXME: unknown" in code2 assert code2 == patch_wgpu_native_backend(code2) # Don't stack comments diff --git a/codegen/wgpu_native_patcher.py b/codegen/wgpu_native_patcher.py index 0773d279..330c8b0e 100644 --- a/codegen/wgpu_native_patcher.py +++ b/codegen/wgpu_native_patcher.py @@ -15,6 +15,7 @@ import re from collections import defaultdict +from itertools import chain from codegen.utils import print, format_code, Patcher, to_snake_case from codegen.hparser import get_h_parser @@ -290,13 +291,10 @@ def apply(self, code): class StructPatcher(Patcher): def apply(self, code): self._init(code) - hp = get_h_parser() - count = 0 - line_index = -1 - brace_depth = 0 for line, i in self.iter_lines(): + # detect struct definition start (only when not already inside a struct) if "new_struct_p(" in line or "new_struct(" in line: if line.lstrip().startswith("def "): continue # Implementation @@ -304,28 +302,36 @@ def apply(self, code): continue # Implementation if "new_struct_p()" in line or "new_struct()" in line: continue # Comments or docs - line_index = i j = line.index("new_struct") line = line[j:] # start brace searching from right pos - brace_depth = 0 - - if line_index >= 0: - for c in line: - if c == "#": - break - elif c == "(": - brace_depth += 1 - elif c == ")": - brace_depth -= 1 - assert brace_depth >= 0 - if brace_depth == 0: - self._validate_struct(hp, line_index, i) - count += 1 - line_index = -1 - break + # call a function to find the end and validate so we don't skip over nested structure in this loop + self._find_struct_end(line, i) + count += 1 print(f"Validated {count} C structs") + def _find_struct_end(self, first_line, start_line_index): + """ + If a struct start is found, this function will find the end of the struct and then validate it + """ + brace_depth = 0 + hp = get_h_parser() + for line, i in chain( + [(first_line, 0)], self.iter_lines(start_line=start_line_index + 1) + ): + for c in line: + if c == "#": + break + elif c == "(": + brace_depth += 1 + elif c == ")": + brace_depth -= 1 + assert brace_depth >= 0 + if brace_depth == 0: + # here we have found the end of this struct so now we can validate it. + self._validate_struct(hp, start_line_index, i) + return # we assume it always works? + def _validate_struct(self, hp, i1, i2): """Validate a specific struct usage.""" @@ -381,19 +387,32 @@ def _validate_struct(self, hp, i1, i2): self.insert_line(i1, indent + "# H: " + fields) # Check keys + brace_count = 0 keys_found = [] for j in range(2, len(lines) - 1): line = lines[j] - key = line.split("=")[0].strip() - if key.startswith("# not used:"): - key = key.split(":")[1].split("=")[0].strip() - elif key.startswith("#"): - continue - keys_found.append(key) - if key not in struct: - msg = f"unknown C struct field {struct_name}.{key}" - self.insert_line(i1 + j, f"{indent}# FIXME: {msg}") - print(f"ERROR: {msg}") + if brace_count <= 0: + # ready to find a new key candidate + key = line.split("=")[0].strip() + if key.startswith("# not used:"): + key = key.split(":")[1].split("=")[0].strip() + elif key.startswith("#"): + continue + # (still) inside a multi-line structure + for c in line.strip(): + if c == "#": + break # we can ignore this line past the comment in terms of nested structures + elif c == "(": + brace_count += 1 + elif c == ")": + brace_count -= 1 + if brace_count == 0: + # here we finished through the multi line structure + keys_found.append(key) + if key not in struct: + msg = f"unknown C struct field {struct_name}.{key}" + self.insert_line(i1 + j, f"{indent}# FIXME: {msg}") + print(f"ERROR: {msg}") # Insert comments for unused keys more_lines = [] diff --git a/tests/test_set_constant.py b/tests/test_set_constant.py index 0408a959..bd10208d 100644 --- a/tests/test_set_constant.py +++ b/tests/test_set_constant.py @@ -143,15 +143,39 @@ def test_normal_push_constants(): assert all(result == expected_result) -def test_render_bundle_push_constants_fails(): +def test_render_bundle_push_constants(): device, pipeline, render_pass_descriptor = setup_pipeline() - encoder = device.create_render_bundle_encoder( + vertex_call_buffer = device.create_buffer(size=COUNT * 4, usage="STORAGE|COPY_SRC") + bind_group = device.create_bind_group( + layout=pipeline.get_bind_group_layout(0), + entries=[ + {"binding": 0, "resource": {"buffer": vertex_call_buffer}}, + ], + ) + bundle_encoder = device.create_render_bundle_encoder( color_formats=[TextureFormat.rgba8unorm], ) - encoder.set_pipeline(pipeline) + bundle_encoder.set_pipeline(pipeline) + bundle_encoder.set_bind_group(0, bind_group) buffer = np.random.randint(0, 1_000_000, size=(2 * COUNT), dtype=np.uint32) - with pytest.raises(RuntimeError): - set_push_constants(encoder, "VERTEX", 0, COUNT * 4, buffer) + set_push_constants(bundle_encoder, "VERTEX", 0, COUNT * 4, buffer) + set_push_constants( + bundle_encoder, "FRAGMENT", COUNT * 4, COUNT * 4, buffer, COUNT * 4 + ) + bundle_encoder.draw(COUNT) + render_bundle = bundle_encoder.finish() + + # a different encoder to execute the bundle + encoder = device.create_command_encoder() + this_pass = encoder.begin_render_pass(**render_pass_descriptor) + this_pass.execute_bundles([render_bundle]) + this_pass.end() + device.queue.submit([encoder.finish()]) + + info_view = device.queue.read_buffer(vertex_call_buffer) + result = np.frombuffer(info_view, dtype=np.uint32) + expected_result = buffer[0:COUNT] + buffer[COUNT:] + assert all(result == expected_result) def test_bad_set_push_constants(): diff --git a/tests/test_wgpu_native_buffer.py b/tests/test_wgpu_native_buffer.py index 298e6bbc..21bc0ae0 100644 --- a/tests/test_wgpu_native_buffer.py +++ b/tests/test_wgpu_native_buffer.py @@ -549,9 +549,14 @@ def test_create_buffer_with_data(size): @pytest.mark.skip -def test_show_bug_wgpu_native_305_still_not_fixed(): - # When this bug is fixed, we can remove READ_NOSYNC, and just tread "READ" as if - # it were READ_NOSYNC. No need to handle the command buffer. +def test_that_passes_when_bug_wgpu_native_305_is_fixed(): + # See https://github.com/gfx-rs/wgpu-native/issues/305 + # If the bug is still there, this test will fail. Therefore its skipped. + # If this test passes (on multiple machines) the bug is likely fixed. + # When this bug is fixed, we can remove the command-buffer trick in _api.py, + # and enable this test to detect regressions. + + # Update device = wgpu.utils.get_default_device() data1 = b"abcdefghijkl" diff --git a/tests/test_wgpu_native_errors.py b/tests/test_wgpu_native_errors.py index 15006d77..90447787 100644 --- a/tests/test_wgpu_native_errors.py +++ b/tests/test_wgpu_native_errors.py @@ -67,14 +67,14 @@ def test_parse_shader_error2(caplog): Caused by: In wgpuDeviceCreateShaderModule - Shader '' parsing error: expected ',', found ';' + Shader '' parsing error: expected `,`, found ";" ┌─ wgsl:2:38 │ 2 │ @location(0) texcoord : vec2; - │ ^ expected ',' + │ ^ expected `,` - expected ',', found ';' + expected `,`, found ";" """ code = dedent(code) @@ -103,16 +103,14 @@ def test_parse_shader_error3(caplog): Caused by: In wgpuDeviceCreateShaderModule - Shader '' parsing error: unknown scalar type: 'f3' + Shader '' parsing error: unknown type: `f3` ┌─ wgsl:3:39 │ 3 │ @builtin(position) position: vec4, - │ ^^ unknown scalar type - │ - = note: Valid scalar types are f32, f64, i32, u32, bool + │ ^^ unknown type - unknown scalar type: 'f3' + unknown type: `f3` """ code = dedent(code) @@ -183,16 +181,19 @@ def test_validate_shader_error1(caplog): Caused by: In wgpuDeviceCreateShaderModule - Shader validation error: + Shader validation error: Entry point vs_main at Vertex is invalid ┌─ :10:20 │ 10 │ out.position = matrics * out.position; │ ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [7] + │ + = Expression [7] is invalid + = Operation Multiply can't work with [4] (of type Matrix { columns: Quad, rows: Quad, scalar: Scalar { kind: Float, width: 4 } }) and [6] (of type Vector { size: Tri, scalar: Scalar { kind: Float, width: 4 } }) Entry point vs_main at Vertex is invalid Expression [7] is invalid - Operation Multiply can't work with [4] and [6] + Operation Multiply can't work with [4] (of type Matrix { columns: Quad, rows: Quad, scalar: Scalar { kind: Float, width: 4 } }) and [6] (of type Vector { size: Tri, scalar: Scalar { kind: Float, width: 4 } }) """ code = dedent(code) @@ -233,11 +234,13 @@ def test_validate_shader_error2(caplog): Caused by: In wgpuDeviceCreateShaderModule - Shader validation error: + Shader validation error: Entry point fs_main at Vertex is invalid ┌─ :9:16 │ 9 │ return vec3(1.0, 0.0, 1.0); │ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [8] + │ + = The `return` value Some([8]) does not match the function return value Entry point fs_main at Vertex is invalid diff --git a/tests_mem/test_objects.py b/tests_mem/test_objects.py index 5a53a8cb..94303bbc 100644 --- a/tests_mem/test_objects.py +++ b/tests_mem/test_objects.py @@ -103,7 +103,8 @@ def test_release_buffer(n): @create_and_release def test_release_command_buffer(n): - # Note: a command encoder can only be used once (it gets destroyed on finish()) + # Note: a command encoder can only be used once (it gets destroyed on finish()), see test below. + # Finishing returns a command buffer, which gets destroyed on submit() to the queue. yield { "expected_counts_after_create": { "CommandBuffer": (n, n), @@ -112,7 +113,10 @@ def test_release_command_buffer(n): for i in range(n): command_encoder = DEVICE.create_command_encoder() - yield command_encoder.finish() + command_buffer = command_encoder.finish() + yield command_buffer + # to destroy the command buffer we submit it + DEVICE.queue.submit([command_buffer]) @create_and_release @@ -374,6 +378,20 @@ def test_release_texture_view(n): yield texture.create_view() +@create_and_release +def test_release_pipeline_cache(n): + # not implemented in wgpu-native yet + # part of CreateRenderPipeline and CreateComputePipeline + # https://github.com/gfx-rs/wgpu-native/blob/v24.0.0.1/src/lib.rs#L1988 + # https://github.com/gfx-rs/wgpu-native/blob/v24.0.0.1/src/lib.rs#L2292 + yield { + "expected_counts_after_create": { + "PipelineCache": (n, 0), + }, + } + pytest.skip("Not implemented in wgpu-native") + + # %% The end diff --git a/wgpu/_classes.py b/wgpu/_classes.py index b8a4834b..e63daa1c 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -1006,13 +1006,9 @@ def create_pipeline_layout( raise NotImplementedError() # IDL: GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); -> USVString label = "", required USVString code, object sourceMap, sequence compilationHints = [] + @apidiff.change("compilation_hints got removed, IDL outdated.") def create_shader_module( - self, - *, - label: str = "", - code: str, - source_map: dict = optional, - compilation_hints: List[structs.ShaderModuleCompilationHint] = [], + self, *, label: str = "", code: str, source_map: dict = optional ): """Create a `GPUShaderModule` object from shader source. @@ -1026,6 +1022,8 @@ def create_shader_module( 'comp', 'vert' or 'frag'. For SpirV the code must be bytes. compilation_hints: currently unused. """ + # TODO: compilation_hints has been removed: https://github.com/webgpu-native/webgpu-headers/pull/337 + # uses @apidiff in _classes.py for now, but .idl should be updated raise NotImplementedError() # IDL: GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); -> USVString label = "", required (GPUPipelineLayout or GPUAutoLayoutMode) layout, required GPUProgrammableStage compute diff --git a/wgpu/backends/wgpu_native/__init__.py b/wgpu/backends/wgpu_native/__init__.py index e6689007..19f2b2c9 100644 --- a/wgpu/backends/wgpu_native/__init__.py +++ b/wgpu/backends/wgpu_native/__init__.py @@ -11,8 +11,8 @@ # The wgpu-native version that we target/expect -__version__ = "22.1.0.5" -__commit_sha__ = "fad19f5990d8eb9a6e942eb957344957193fe66d" +__version__ = "24.0.0.2" +__commit_sha__ = "a96fbecc2ef8f7fdf0bd1762b88508799471c923" version_info = tuple(map(int, __version__.split("."))) # noqa: RUF048 _check_expected_version(version_info) # produces a warning on mismatch diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index 70304b9c..e6737a44 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -78,6 +78,8 @@ def print_struct(s, indent=""): print(indent + key + ": null") elif "'char *'" in repr(val): print(indent + key + ":", ffi.string(val).decode()) + elif "WGPUStringView" in repr(val): + print(indent + key + ":", from_c_string_view(val)) elif " *'" in repr(val): print(indent + key + ": pointer") elif "struct WGPU" in repr(val): @@ -233,12 +235,12 @@ def _get_override_constant_entries(field): for key, value in constants.items(): assert isinstance(key, (str, int)) assert isinstance(value, (int, float, bool)) - # H: nextInChain: WGPUChainedStruct *, key: char *, value: float + # H: nextInChain: WGPUChainedStruct *, key: WGPUStringView, value: float c_constant_entry = new_struct( "WGPUConstantEntry", - key=to_c_string(str(key)), - value=float(value), # not used: nextInChain + key=to_c_string_view(str(key)), + value=float(value), ) c_constant_entries.append(c_constant_entry) # We need to return and hold onto c_constant_entries in order to prevent the C @@ -247,23 +249,51 @@ def _get_override_constant_entries(field): return c_constants, c_constant_entries -def to_c_string(string: str): - return ffi.new("char []", string.encode()) - - -def to_c_string_or_null(string: Optional[str]): - return ffi.NULL if string is None else ffi.new("char []", string.encode()) - - -_empty_label = ffi.new("char []", b"") +# H: data: char *, length: int +_null_string = new_struct( + "WGPUStringView", + data=ffi.NULL, + length=lib.WGPU_STRLEN, +) +# H: data: char *, length: int +_empty_string = new_struct( + "WGPUStringView", + data=ffi.NULL, + length=0, +) -def to_c_label(label): - """Get the C representation of a label.""" - if not label: - return _empty_label +def to_c_string_view(string: str): + """Turn a string into a "WGPUStringView. None becomes the null-string.""" + if string is None: + # The null-string. wgpu-core interprets this different from the empty sting, + # e.g. when not-setting the trace path, it should be the null-string. + return _null_string + elif not string: + # The empty string + return _empty_string else: - return to_c_string(label) + # A string with nonzero length + data = ffi.new("char []", string.encode()) # includes null terminator! + # length = len(data) - 1 # explicit length (minus null terminator) + length = lib.WGPU_STRLEN # Zero-terminated string + # H: data: char *, length: int + return new_struct( + "WGPUStringView", + data=data, + length=length, + ) + + +def from_c_string_view(struct): + if not struct or struct.data == ffi.NULL or struct.length == 0: + return "" + elif struct.length == lib.WGPU_STRLEN: + # null-terminated + return ffi.string(struct.data).decode(errors="ignore") + else: + # explicit length + return ffi.string(struct.data, struct.length).decode(errors="ignore") def feature_flag_to_feature_names(flag): @@ -289,30 +319,70 @@ def _get_limits(id: int, device: bool = False, adapter: bool = False): """Gets the limits for a device or an adapter""" assert device + adapter == 1 # exactly one is set - # H: chain: WGPUChainedStructOut, limits: WGPUNativeLimits - c_supported_limits_extras = new_struct_p( - "WGPUSupportedLimitsExtras *", - # not used: chain - # not used: limits + # H: chain: WGPUChainedStructOut, maxPushConstantSize: int, maxNonSamplerBindings: int + c_limits_native = new_struct( + "WGPUNativeLimits", + # H: next: WGPUChainedStructOut *, sType: WGPUSType + chain=new_struct( + "WGPUChainedStructOut", + # not used: next + sType=lib.WGPUSType_NativeLimits, + ), + # not used: maxPushConstantSize + # not used: maxNonSamplerBindings ) - c_supported_limits_extras.chain.sType = lib.WGPUSType_SupportedLimitsExtras - # H: nextInChain: WGPUChainedStructOut *, limits: WGPULimits - c_supported_limits = new_struct_p( - "WGPUSupportedLimits *", - nextInChain=ffi.cast("WGPUChainedStructOut *", c_supported_limits_extras), - # not used: limits + # H: nextInChain: WGPUChainedStructOut *, maxTextureDimension1D: int, maxTextureDimension2D: int, maxTextureDimension3D: int, maxTextureArrayLayers: int, maxBindGroups: int, maxBindGroupsPlusVertexBuffers: int, maxBindingsPerBindGroup: int, maxDynamicUniformBuffersPerPipelineLayout: int, maxDynamicStorageBuffersPerPipelineLayout: int, maxSampledTexturesPerShaderStage: int, maxSamplersPerShaderStage: int, maxStorageBuffersPerShaderStage: int, maxStorageTexturesPerShaderStage: int, maxUniformBuffersPerShaderStage: int, maxUniformBufferBindingSize: int, maxStorageBufferBindingSize: int, minUniformBufferOffsetAlignment: int, minStorageBufferOffsetAlignment: int, maxVertexBuffers: int, maxBufferSize: int, maxVertexAttributes: int, maxVertexBufferArrayStride: int, maxInterStageShaderVariables: int, maxColorAttachments: int, maxColorAttachmentBytesPerSample: int, maxComputeWorkgroupStorageSize: int, maxComputeInvocationsPerWorkgroup: int, maxComputeWorkgroupSizeX: int, maxComputeWorkgroupSizeY: int, maxComputeWorkgroupSizeZ: int, maxComputeWorkgroupsPerDimension: int + c_limits = new_struct_p( + "WGPULimits *", + nextInChain=ffi.addressof(c_limits_native, "chain"), + # not used: maxTextureDimension1D + # not used: maxTextureDimension2D + # not used: maxTextureDimension3D + # not used: maxTextureArrayLayers + # not used: maxBindGroups + # not used: maxBindGroupsPlusVertexBuffers + # not used: maxBindingsPerBindGroup + # not used: maxDynamicUniformBuffersPerPipelineLayout + # not used: maxDynamicStorageBuffersPerPipelineLayout + # not used: maxSampledTexturesPerShaderStage + # not used: maxSamplersPerShaderStage + # not used: maxStorageBuffersPerShaderStage + # not used: maxStorageTexturesPerShaderStage + # not used: maxUniformBuffersPerShaderStage + # not used: maxUniformBufferBindingSize + # not used: maxStorageBufferBindingSize + # not used: minUniformBufferOffsetAlignment + # not used: minStorageBufferOffsetAlignment + # not used: maxVertexBuffers + # not used: maxBufferSize + # not used: maxVertexAttributes + # not used: maxVertexBufferArrayStride + # not used: maxInterStageShaderVariables + # not used: maxColorAttachments + # not used: maxColorAttachmentBytesPerSample + # not used: maxComputeWorkgroupStorageSize + # not used: maxComputeInvocationsPerWorkgroup + # not used: maxComputeWorkgroupSizeX + # not used: maxComputeWorkgroupSizeY + # not used: maxComputeWorkgroupSizeZ + # not used: maxComputeWorkgroupsPerDimension ) if adapter: - # H: WGPUBool f(WGPUAdapter adapter, WGPUSupportedLimits * limits) - libf.wgpuAdapterGetLimits(id, c_supported_limits) + # H: WGPUStatus f(WGPUAdapter adapter, WGPULimits * limits) + status = libf.wgpuAdapterGetLimits(id, c_limits) + if status != lib.WGPUStatus_Success: + raise RuntimeError("Error calling wgpuAdapterGetLimits") else: - # H: WGPUBool f(WGPUDevice device, WGPUSupportedLimits * limits) - libf.wgpuDeviceGetLimits(id, c_supported_limits) + # H: WGPUStatus f(WGPUDevice device, WGPULimits * limits) + status = libf.wgpuDeviceGetLimits(id, c_limits) + if status != lib.WGPUStatus_Success: + raise RuntimeError("Error calling wgpuDeviceGetLimits") key_value_pairs = [ - (to_snake_case(name, "-"), getattr(c_limits, name)) - for c_limits in (c_supported_limits.limits, c_supported_limits_extras.limits) - for name in dir(c_limits) + (to_snake_case(name, "-"), getattr(limits, name)) + for limits in (c_limits, c_limits_native) + for name in dir(limits) + if "chain" not in name.lower() # Skip the pointers ] limits = dict(sorted(key_value_pairs)) return limits @@ -333,12 +403,8 @@ def _get_features(id: int, device: bool = False, adapter: bool = False): # Standard features for f in sorted(enums.FeatureName): - if f in [ - "clip-distances", - "dual-source-blending", - "texture-compression-bc-sliced-3d", - ]: - continue # not supported by wgpu-native yet + # if f in not_supported_by_wgpu_native: + # continue if has_feature(enummap[f"FeatureName.{f}"]): features.add(f) @@ -453,33 +519,48 @@ def _request_adapter( # ----- Request adapter - # H: nextInChain: WGPUChainedStruct *, compatibleSurface: WGPUSurface, powerPreference: WGPUPowerPreference, backendType: WGPUBackendType, forceFallbackAdapter: WGPUBool/int + # H: nextInChain: WGPUChainedStruct *, featureLevel: WGPUFeatureLevel, powerPreference: WGPUPowerPreference, forceFallbackAdapter: WGPUBool/int, backendType: WGPUBackendType, compatibleSurface: WGPUSurface struct = new_struct_p( "WGPURequestAdapterOptions *", + # not used: nextInChain compatibleSurface=surface_id, powerPreference=power_preference or "high-performance", forceFallbackAdapter=bool(force_fallback_adapter), backendType=backend, - # not used: nextInChain + # not used: featureLevel ) - @ffi.callback("void(WGPURequestAdapterStatus, WGPUAdapter, char *, void *)") - def callback(status, result, message, _userdata): - if status != 0: - msg = "-" if message == ffi.NULL else ffi.string(message).decode() + @ffi.callback( + "void(WGPURequestAdapterStatus, WGPUAdapter, WGPUStringView, void *, void *)" + ) + def request_adapter_callback(status, result, c_message, _userdata1, _userdata2): + if status != lib.WGPURequestAdapterStatus_Success: + msg = from_c_string_view(c_message) awaitable.set_error(f"Request adapter failed ({status}): {msg}") else: awaitable.set_result(result) + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPURequestAdapterCallback, userdata1: void*, userdata2: void* + callback_info = new_struct( + "WGPURequestAdapterCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=request_adapter_callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(adapter_id): return self._create_adapter(adapter_id) # Note that although we claim this is an asynchronous method, the callback # happens within libf.wgpuInstanceRequestAdapter - awaitable = WgpuAwaitable("request_adapter", callback, finalizer) + awaitable = WgpuAwaitable( + "request_adapter", request_adapter_callback, finalizer + ) - # H: void f(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, void * userdata) - libf.wgpuInstanceRequestAdapter(get_wgpu_instance(), struct, callback, ffi.NULL) + # H: WGPUFuture f(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) + libf.wgpuInstanceRequestAdapter(get_wgpu_instance(), struct, callback_info) return awaitable @@ -511,7 +592,7 @@ def _enumerate_adapters(self): def _create_adapter(self, adapter_id): # ----- Get adapter info - # H: nextInChain: WGPUChainedStructOut *, vendor: char *, architecture: char *, device: char *, description: char *, backendType: WGPUBackendType, adapterType: WGPUAdapterType, vendorID: int, deviceID: int + # H: nextInChain: WGPUChainedStructOut *, vendor: WGPUStringView, architecture: WGPUStringView, device: WGPUStringView, description: WGPUStringView, backendType: WGPUBackendType, adapterType: WGPUAdapterType, vendorID: int, deviceID: int c_info = new_struct_p( "WGPUAdapterInfo *", # not used: nextInChain @@ -525,14 +606,14 @@ def _create_adapter(self, adapter_id): # not used: deviceID ) - # H: void f(WGPUAdapter adapter, WGPUAdapterInfo * info) - libf.wgpuAdapterGetInfo(adapter_id, c_info) + # H: WGPUStatus f(WGPUAdapter adapter, WGPUAdapterInfo * info) + status = libf.wgpuAdapterGetInfo(adapter_id, c_info) + if status != lib.WGPUStatus_Success: + raise RuntimeError("Error calling wgpuAdapterGetInfo") def to_py_str(key): - char_p = getattr(c_info, key) - if char_p: - return ffi.string(char_p).decode(errors="ignore") - return "" + string_view = getattr(c_info, key) + return from_c_string_view(string_view) # Populate a dict according to the WebGPU spec: https://gpuweb.github.io/gpuweb/#gpuadapterinfo # And add all other info we get from wgpu-native too. @@ -605,7 +686,7 @@ def _get_capabilities_screen(self, adapter): "present_modes": ["fifo"], } - # H: nextInChain: WGPUChainedStructOut *, usages: WGPUTextureUsageFlags/int, formatCount: int, formats: WGPUTextureFormat *, presentModeCount: int, presentModes: WGPUPresentMode *, alphaModeCount: int, alphaModes: WGPUCompositeAlphaMode * + # H: nextInChain: WGPUChainedStructOut *, usages: WGPUTextureUsage/int, formatCount: int, formats: WGPUTextureFormat *, presentModeCount: int, presentModes: WGPUPresentMode *, alphaModeCount: int, alphaModes: WGPUCompositeAlphaMode * c_capabilities = new_struct_p( "WGPUSurfaceCapabilities *", # not used: nextInChain @@ -618,8 +699,10 @@ def _get_capabilities_screen(self, adapter): # not used: alphaModes ) - # H: void f(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) - libf.wgpuSurfaceGetCapabilities(surface_id, adapter_id, c_capabilities) + # H: WGPUStatus f(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) + status = libf.wgpuSurfaceGetCapabilities(surface_id, adapter_id, c_capabilities) + if status != lib.WGPUStatus_Success: + raise RuntimeError("Error calling wgpuSurfaceGetCapabilities") # Convert to Python. capabilities = {} @@ -719,9 +802,10 @@ def _configure_screen( # Prepare config object - # H: nextInChain: WGPUChainedStruct *, device: WGPUDevice, format: WGPUTextureFormat, usage: WGPUTextureUsageFlags/int, viewFormatCount: int, viewFormats: WGPUTextureFormat *, alphaMode: WGPUCompositeAlphaMode, width: int, height: int, presentMode: WGPUPresentMode + # H: nextInChain: WGPUChainedStruct *, device: WGPUDevice, format: WGPUTextureFormat, usage: WGPUTextureUsage/int, width: int, height: int, viewFormatCount: int, viewFormats: WGPUTextureFormat *, alphaMode: WGPUCompositeAlphaMode, presentMode: WGPUPresentMode self._wgpu_config = new_struct_p( "WGPUSurfaceConfiguration *", + # not used: nextInChain device=device._internal, format=format, usage=usage, @@ -731,7 +815,6 @@ def _configure_screen( width=0, height=0, presentMode=c_present_mode, - # not used: nextInChain ) def _configure_screen_real(self, width, height): @@ -775,11 +858,11 @@ def _create_texture_screen(self): # Try to obtain a texture. # `If it fails, depending on status, we reconfigure and try again. - # H: texture: WGPUTexture, suboptimal: WGPUBool/int, status: WGPUSurfaceGetCurrentTextureStatus + # H: nextInChain: WGPUChainedStructOut *, texture: WGPUTexture, status: WGPUSurfaceGetCurrentTextureStatus surface_texture = new_struct_p( "WGPUSurfaceTexture *", + # not used: nextInChain # not used: texture - # not used: suboptimal # not used: status ) @@ -788,8 +871,12 @@ def _create_texture_screen(self): libf.wgpuSurfaceGetCurrentTexture(surface_id, surface_texture) status = surface_texture.status texture_id = surface_texture.texture - if status == lib.WGPUSurfaceGetCurrentTextureStatus_Success: - break # success + if status == lib.WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal: + break # Yay! Everything is good and we can render this frame. + elif status == lib.WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal: + # Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + logger.warning("The surface texture is suboptimal.") + break if texture_id: # H: void f(WGPUTexture texture) libf.wgpuTextureRelease(texture_id) @@ -807,6 +894,7 @@ def _create_texture_screen(self): else: # WGPUSurfaceGetCurrentTextureStatus_OutOfMemory # WGPUSurfaceGetCurrentTextureStatus_DeviceLost + # WGPUSurfaceGetCurrentTextureStatus_Error # Or if this is the second attempt. raise RuntimeError(f"Cannot get surface texture ({status}).") @@ -814,10 +902,6 @@ def _create_texture_screen(self): if not texture_id: raise RuntimeError("Cannot get surface texture (no texture)") - # Things look good, but texture may still be suboptimal, whatever that means - if surface_texture.suboptimal: - logger.warning("The surface texture is suboptimal.") - # Wrap it in a Python texture object # But we can also read them from the texture @@ -837,14 +921,14 @@ def _create_texture_screen(self): # H: WGPUTextureFormat f(WGPUTexture texture) c_format = libf.wgpuTextureGetFormat(texture_id) format = enum_int2str["TextureFormat"][c_format] - # H: WGPUTextureUsageFlags f(WGPUTexture texture) + # H: WGPUTextureUsage f(WGPUTexture texture) usage = libf.wgpuTextureGetUsage(texture_id) label = "" # Cannot yet set label, because it's not implemented in wgpu-native # label = "surface-texture" - # H: void f(WGPUTexture texture, char const * label) - # libf.wgpuTextureSetLabel(texture_id, to_c_label(label)) + # H: void f(WGPUTexture texture, WGPUStringView label) + # libf.wgpuTextureSetLabel(texture_id, to_c_string_view(label)) tex_info = { "size": (width, height, depth), @@ -859,8 +943,10 @@ def _create_texture_screen(self): return GPUTexture(label, texture_id, device, tex_info) def _present_screen(self): - # H: void f(WGPUSurface surface) - libf.wgpuSurfacePresent(self._surface_id) + # H: WGPUStatus f(WGPUSurface surface) + status = libf.wgpuSurfacePresent(self._surface_id) + if status != lib.WGPUStatus_Success: + raise RuntimeError("Error calling wgpuSurfacePresent") def _release(self): self._drop_texture() @@ -966,21 +1052,42 @@ def _request_device( # ----- Set limits - # H: chain: WGPUChainedStruct, limits: WGPUNativeLimits - c_required_limits_extras = new_struct_p( - "WGPURequiredLimitsExtras *", - # not used: chain - # not used: limits - ) - c_required_limits_extras.chain.sType = lib.WGPUSType_RequiredLimitsExtras - # H: nextInChain: WGPUChainedStruct *, limits: WGPULimits + # H: nextInChain: WGPUChainedStructOut *, maxTextureDimension1D: int, maxTextureDimension2D: int, maxTextureDimension3D: int, maxTextureArrayLayers: int, maxBindGroups: int, maxBindGroupsPlusVertexBuffers: int, maxBindingsPerBindGroup: int, maxDynamicUniformBuffersPerPipelineLayout: int, maxDynamicStorageBuffersPerPipelineLayout: int, maxSampledTexturesPerShaderStage: int, maxSamplersPerShaderStage: int, maxStorageBuffersPerShaderStage: int, maxStorageTexturesPerShaderStage: int, maxUniformBuffersPerShaderStage: int, maxUniformBufferBindingSize: int, maxStorageBufferBindingSize: int, minUniformBufferOffsetAlignment: int, minStorageBufferOffsetAlignment: int, maxVertexBuffers: int, maxBufferSize: int, maxVertexAttributes: int, maxVertexBufferArrayStride: int, maxInterStageShaderVariables: int, maxColorAttachments: int, maxColorAttachmentBytesPerSample: int, maxComputeWorkgroupStorageSize: int, maxComputeInvocationsPerWorkgroup: int, maxComputeWorkgroupSizeX: int, maxComputeWorkgroupSizeY: int, maxComputeWorkgroupSizeZ: int, maxComputeWorkgroupsPerDimension: int c_required_limits = new_struct_p( - "WGPURequiredLimits *", - nextInChain=ffi.cast("WGPUChainedStruct*", c_required_limits_extras), - # not used: limits + "WGPULimits *", + # not used: nextInChain + # not used: maxTextureDimension1D + # not used: maxTextureDimension2D + # not used: maxTextureDimension3D + # not used: maxTextureArrayLayers + # not used: maxBindGroups + # not used: maxBindGroupsPlusVertexBuffers + # not used: maxBindingsPerBindGroup + # not used: maxDynamicUniformBuffersPerPipelineLayout + # not used: maxDynamicStorageBuffersPerPipelineLayout + # not used: maxSampledTexturesPerShaderStage + # not used: maxSamplersPerShaderStage + # not used: maxStorageBuffersPerShaderStage + # not used: maxStorageTexturesPerShaderStage + # not used: maxUniformBuffersPerShaderStage + # not used: maxUniformBufferBindingSize + # not used: maxStorageBufferBindingSize + # not used: minUniformBufferOffsetAlignment + # not used: minStorageBufferOffsetAlignment + # not used: maxVertexBuffers + # not used: maxBufferSize + # not used: maxVertexAttributes + # not used: maxVertexBufferArrayStride + # not used: maxInterStageShaderVariables + # not used: maxColorAttachments + # not used: maxColorAttachmentBytesPerSample + # not used: maxComputeWorkgroupStorageSize + # not used: maxComputeInvocationsPerWorkgroup + # not used: maxComputeWorkgroupSizeX + # not used: maxComputeWorkgroupSizeY + # not used: maxComputeWorkgroupSizeZ + # not used: maxComputeWorkgroupsPerDimension ) - c_limits = c_required_limits.limits - c_limits_extras = c_required_limits_extras.limits def canonicalize_limit_name(name): if name in self._limits: @@ -1005,35 +1112,48 @@ def canonicalize_limit_name(name): # setting it to {}, but the loop below goes just a little bit faster. required_limits = self._limits - for limit in (c_limits, c_limits_extras): - for key in dir(limit): - snake_key = to_snake_case(key, "-") - # Use the value in required_limits if it exists. Otherwise, the old value - try: - value = required_limits[snake_key] - except KeyError: - value = self._limits[snake_key] - setattr(limit, key, value) + for key in dir(c_required_limits): + snake_key = to_snake_case(key, "-") + # Skip the pointers + if "chain" in snake_key: + continue + # Use the value in required_limits if it exists. Otherwise, the old value + try: + value = required_limits[snake_key] + except KeyError: + value = self._limits[snake_key] + setattr(c_required_limits, key, value) + + # the native only limits are passed in via the next-in-chain struct + # H: chain: WGPUChainedStructOut, maxPushConstantSize: int, maxNonSamplerBindings: int + c_required_limits_native = new_struct( + "WGPUNativeLimits", + maxPushConstantSize=required_limits.get("max-push-constant-size", 0), + maxNonSamplerBindings=required_limits.get("max-non-sampler-bindings", 0), + # not used: chain + ) + c_required_limits_native.chain.next = ffi.NULL + c_required_limits_native.chain.sType = lib.WGPUSType_NativeLimits + + c_required_limits.nextInChain = ffi.addressof(c_required_limits_native, "chain") # ---- Set queue descriptor # Note that the default_queue arg is a descriptor (dict for QueueDescriptor), but is currently empty :) check_struct("QueueDescriptor", {}) - # H: nextInChain: WGPUChainedStruct *, label: char * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView queue_struct = new_struct( "WGPUQueueDescriptor", - label=to_c_label("default_queue"), # not used: nextInChain + label=to_c_string_view("default_queue"), ) # ----- Compose device descriptor extras - c_trace_path = ffi.NULL - if trace_path: # no-cover - c_trace_path = to_c_string(trace_path) + c_trace_path = to_c_string_view(trace_path if trace_path else None) - # H: chain: WGPUChainedStruct, tracePath: char * + # H: chain: WGPUChainedStruct, tracePath: WGPUStringView extras = new_struct_p( "WGPUDeviceExtras *", tracePath=c_trace_path, @@ -1043,60 +1163,87 @@ def canonicalize_limit_name(name): # ----- Device lost - @ffi.callback("void(WGPUDeviceLostReason, char *, void *)") - def device_lost_callback(c_reason, c_message, userdata): + @ffi.callback( + "void(WGPUDevice const *, WGPUDeviceLostReason, WGPUStringView, void *, void *)" + ) + def device_lost_callback(c_device, c_reason, c_message, userdata1, userdata2): reason = enum_int2str["DeviceLostReason"].get(c_reason, "Unknown") - message = ffi.string(c_message).decode(errors="ignore") - msg = f"The WGPU device was lost ({reason}):\n{message}" + msg = from_c_string_view(c_message) # This is afaik an error that cannot usually be attributed to a specific call, # so we cannot raise it as an error. We log it instead. # WebGPU provides (promise-based) API for user-code to handle the error. # We might want to do something similar, once we have async figured out. - error_handler.log_error(msg) + error_handler.log_error(f"The WGPU device was lost ({reason}):\n{msg}") + + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPUDeviceLostCallback, userdata1: void*, userdata2: void* + device_lost_callback_info = new_struct( + "WGPUDeviceLostCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowSpontaneous, + callback=device_lost_callback, + # not used: userdata1 + # not used: userdata2 + ) # ----- Uncaptured error # TODO: For some errors (seen for errors in wgsl, but not for some others) the error gets logged via the logger as well (duplicate). Probably an issue with wgpu-core. - @ffi.callback("void(WGPUErrorType, char *, void *)") - def uncaptured_error_callback(c_type, c_message, userdata): + @ffi.callback( + "void(WGPUDevice const *, WGPUErrorType, WGPUStringView, void *, void *)" + ) + def uncaptured_error_callback( + c_device, c_type, c_message, userdata1, userdata2 + ): error_type = enum_int2str["ErrorType"].get(c_type, "Unknown") - message = ffi.string(c_message).decode(errors="ignore") - message = "\n".join(line.rstrip() for line in message.splitlines()) - error_handler.handle_error(error_type, message) + msg = from_c_string_view(c_message) + msg = "\n".join(line.rstrip() for line in msg.splitlines()) + error_handler.handle_error(error_type, msg) - # H: nextInChain: WGPUChainedStruct *, callback: WGPUErrorCallback, userdata: void * + # H: nextInChain: WGPUChainedStruct *, callback: WGPUUncapturedErrorCallback, userdata1: void*, userdata2: void* uncaptured_error_callback_info = new_struct( "WGPUUncapturedErrorCallbackInfo", - callback=uncaptured_error_callback, - userdata=ffi.NULL, # not used: nextInChain + callback=uncaptured_error_callback, + # not used: userdata1 + # not used: userdata2 ) # ----- Request device - # H: nextInChain: WGPUChainedStruct *, label: char *, requiredFeatureCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *, defaultQueue: WGPUQueueDescriptor, deviceLostCallback: WGPUDeviceLostCallback, deviceLostUserdata: void *, uncapturedErrorCallbackInfo: WGPUUncapturedErrorCallbackInfo + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, requiredFeatureCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPULimits *, defaultQueue: WGPUQueueDescriptor, deviceLostCallbackInfo: WGPUDeviceLostCallbackInfo, uncapturedErrorCallbackInfo: WGPUUncapturedErrorCallbackInfo struct = new_struct_p( "WGPUDeviceDescriptor *", - label=to_c_label(label), nextInChain=ffi.cast("WGPUChainedStruct * ", extras), + label=to_c_string_view(label), requiredFeatureCount=len(c_features), requiredFeatures=new_array("WGPUFeatureName[]", c_features), requiredLimits=c_required_limits, defaultQueue=queue_struct, - deviceLostCallback=device_lost_callback, + deviceLostCallbackInfo=device_lost_callback_info, uncapturedErrorCallbackInfo=uncaptured_error_callback_info, - # not used: deviceLostUserdata ) - @ffi.callback("void(WGPURequestDeviceStatus, WGPUDevice, char *, void *)") - def callback(status, result, message, userdata): - if status != 0: - msg = "-" if message == ffi.NULL else ffi.string(message).decode() + @ffi.callback( + "void(WGPURequestDeviceStatus, WGPUDevice, WGPUStringView, void *, void *)" + ) + def request_device_callback(status, result, c_message, userdata1, userdata2): + if status != lib.WGPURequestDeviceStatus_Success: + msg = from_c_string_view(c_message) awaitable.set_error(f"Request device failed ({status}): {msg}") else: awaitable.set_result(result) + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPURequestDeviceCallback, userdata1: void*, userdata2: void* + callback_info = new_struct( + "WGPURequestDeviceCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=request_device_callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(device_id): limits = _get_limits(device_id, device=True) features = _get_features(device_id, device=True) @@ -1112,10 +1259,10 @@ def finalizer(device_id): return device - awaitable = WgpuAwaitable("request_device", callback, finalizer) + awaitable = WgpuAwaitable("request_device", request_device_callback, finalizer) - # H: void f(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, void * userdata) - libf.wgpuAdapterRequestDevice(self._internal, struct, callback, ffi.NULL) + # H: WGPUFuture f(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) + libf.wgpuAdapterRequestDevice(self._internal, struct, callback_info) return awaitable @@ -1132,17 +1279,18 @@ class GPUDevice(classes.GPUDevice, GPUObjectBase): # This flag should be deleted once create_compute_pipeline_async() and # create_render_pipeline_async() are actually implemented in the wgpu-native library. + # they now exist in the header, but are still unimplemented: https://github.com/gfx-rs/wgpu-native/blob/f29ebee88362934f8f9fab530f3ccb7fde2d49a9/src/unimplemented.rs#L66-L82 _CREATE_PIPELINE_ASYNC_IS_IMPLEMENTED = False def _poll(self): # Internal function if self._internal: - # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) + # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * wrappedSubmissionIndex) libf.wgpuDevicePoll(self._internal, False, ffi.NULL) def _poll_wait(self): if self._internal: - # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) + # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * wrappedSubmissionIndex) libf.wgpuDevicePoll(self._internal, True, ffi.NULL) def create_buffer( @@ -1159,14 +1307,14 @@ def _create_buffer(self, label, size, usage, mapped_at_creation): # Create a buffer object if isinstance(usage, str): usage = str_flag_to_int(flags.BufferUsage, usage) - # H: nextInChain: WGPUChainedStruct *, label: char *, usage: WGPUBufferUsageFlags/int, size: int, mappedAtCreation: WGPUBool/int + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, usage: WGPUBufferUsage/int, size: int, mappedAtCreation: WGPUBool/int struct = new_struct_p( "WGPUBufferDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), size=size, usage=int(usage), mappedAtCreation=mapped_at_creation, - # not used: nextInChain ) map_state = ( enums.BufferMapState.mapped @@ -1225,17 +1373,17 @@ def create_texture( sample_count = 1 sample_count = int(sample_count) - # H: nextInChain: WGPUChainedStruct *, label: char *, usage: WGPUTextureUsageFlags/int, dimension: WGPUTextureDimension, size: WGPUExtent3D, format: WGPUTextureFormat, mipLevelCount: int, sampleCount: int, viewFormatCount: int, viewFormats: WGPUTextureFormat * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, usage: WGPUTextureUsage/int, dimension: WGPUTextureDimension, size: WGPUExtent3D, format: WGPUTextureFormat, mipLevelCount: int, sampleCount: int, viewFormatCount: int, viewFormats: WGPUTextureFormat * struct = new_struct_p( "WGPUTextureDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), size=c_size, mipLevelCount=mip_level_count, sampleCount=sample_count, dimension=dimension, format=format, usage=usage, - # not used: nextInChain # not used: viewFormatCount # not used: viewFormats ) @@ -1269,10 +1417,11 @@ def create_sampler( compare: enums.CompareFunction = optional, max_anisotropy: int = 1, ): - # H: nextInChain: WGPUChainedStruct *, label: char *, addressModeU: WGPUAddressMode, addressModeV: WGPUAddressMode, addressModeW: WGPUAddressMode, magFilter: WGPUFilterMode, minFilter: WGPUFilterMode, mipmapFilter: WGPUMipmapFilterMode, lodMinClamp: float, lodMaxClamp: float, compare: WGPUCompareFunction, maxAnisotropy: int + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, addressModeU: WGPUAddressMode, addressModeV: WGPUAddressMode, addressModeW: WGPUAddressMode, magFilter: WGPUFilterMode, minFilter: WGPUFilterMode, mipmapFilter: WGPUMipmapFilterMode, lodMinClamp: float, lodMaxClamp: float, compare: WGPUCompareFunction, maxAnisotropy: int struct = new_struct_p( "WGPUSamplerDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), addressModeU=address_mode_u, addressModeV=address_mode_v, addressModeW=address_mode_w, @@ -1283,7 +1432,6 @@ def create_sampler( lodMaxClamp=lod_max_clamp, compare=0 if compare is None else compare, # 0 means undefined maxAnisotropy=max_anisotropy, - # not used: nextInChain ) # H: WGPUSampler f(WGPUDevice device, WGPUSamplerDescriptor const * descriptor) @@ -1306,10 +1454,10 @@ def create_bind_group_layout( # H: nextInChain: WGPUChainedStruct *, type: WGPUBufferBindingType, hasDynamicOffset: WGPUBool/int, minBindingSize: int buffer = new_struct( "WGPUBufferBindingLayout", + # not used: nextInChain type=info.get("type", "uniform"), hasDynamicOffset=info.get("has_dynamic_offset", False), minBindingSize=min_binding_size, - # not used: nextInChain ) elif "sampler" in entry: # It may be an empty dictionary info = entry["sampler"] @@ -1317,8 +1465,8 @@ def create_bind_group_layout( # H: nextInChain: WGPUChainedStruct *, type: WGPUSamplerBindingType sampler = new_struct( "WGPUSamplerBindingLayout", - type=info.get("type", "filtering"), # not used: nextInChain + type=info.get("type", "filtering"), ) elif "texture" in entry: # It may be an empty dictionary info = entry["texture"] @@ -1331,10 +1479,10 @@ def create_bind_group_layout( # H: nextInChain: WGPUChainedStruct *, sampleType: WGPUTextureSampleType, viewDimension: WGPUTextureViewDimension, multisampled: WGPUBool/int texture = new_struct( "WGPUTextureBindingLayout", + # not used: nextInChain sampleType=info.get("sample_type", "float"), viewDimension=view_dimension, multisampled=info.get("multisampled", False), - # not used: nextInChain ) elif "storage_texture" in entry: # format is required, so not empty info = entry["storage_texture"] @@ -1347,10 +1495,10 @@ def create_bind_group_layout( # H: nextInChain: WGPUChainedStruct *, access: WGPUStorageTextureAccess, format: WGPUTextureFormat, viewDimension: WGPUTextureViewDimension storage_texture = new_struct( "WGPUStorageTextureBindingLayout", + # not used: nextInChain access=info.get("access", "write-only"), viewDimension=view_dimension, format=info["format"], - # not used: nextInChain ) else: raise ValueError( @@ -1361,26 +1509,26 @@ def create_bind_group_layout( visibility = entry["visibility"] if isinstance(visibility, str): visibility = str_flag_to_int(flags.ShaderStage, visibility) - # H: nextInChain: WGPUChainedStruct *, binding: int, visibility: WGPUShaderStageFlags/int, buffer: WGPUBufferBindingLayout, sampler: WGPUSamplerBindingLayout, texture: WGPUTextureBindingLayout, storageTexture: WGPUStorageTextureBindingLayout + # H: nextInChain: WGPUChainedStruct *, binding: int, visibility: WGPUShaderStage/int, buffer: WGPUBufferBindingLayout, sampler: WGPUSamplerBindingLayout, texture: WGPUTextureBindingLayout, storageTexture: WGPUStorageTextureBindingLayout c_entry = new_struct( "WGPUBindGroupLayoutEntry", + # not used: nextInChain binding=int(entry["binding"]), visibility=int(visibility), buffer=buffer, sampler=sampler, texture=texture, storageTexture=storage_texture, - # not used: nextInChain ) c_entries_list.append(c_entry) - # H: nextInChain: WGPUChainedStruct *, label: char *, entryCount: int, entries: WGPUBindGroupLayoutEntry * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, entryCount: int, entries: WGPUBindGroupLayoutEntry * struct = new_struct_p( "WGPUBindGroupLayoutDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), entries=new_array("WGPUBindGroupLayoutEntry[]", c_entries_list), entryCount=len(c_entries_list), - # not used: nextInChain ) # Note: wgpu-core re-uses BindGroupLayouts with the same (or similar @@ -1412,50 +1560,50 @@ def create_bind_group( # H: nextInChain: WGPUChainedStruct *, binding: int, buffer: WGPUBuffer, offset: int, size: int, sampler: WGPUSampler, textureView: WGPUTextureView c_entry = new_struct( "WGPUBindGroupEntry", + # not used: nextInChain binding=int(entry["binding"]), buffer=ffi.NULL, offset=0, size=0, sampler=resource._internal, textureView=ffi.NULL, - # not used: nextInChain ) elif isinstance(resource, GPUTextureView): # H: nextInChain: WGPUChainedStruct *, binding: int, buffer: WGPUBuffer, offset: int, size: int, sampler: WGPUSampler, textureView: WGPUTextureView c_entry = new_struct( "WGPUBindGroupEntry", + # not used: nextInChain binding=int(entry["binding"]), buffer=ffi.NULL, offset=0, size=0, sampler=ffi.NULL, textureView=resource._internal, - # not used: nextInChain ) elif isinstance(resource, dict): # Buffer binding # H: nextInChain: WGPUChainedStruct *, binding: int, buffer: WGPUBuffer, offset: int, size: int, sampler: WGPUSampler, textureView: WGPUTextureView c_entry = new_struct( "WGPUBindGroupEntry", + # not used: nextInChain binding=int(entry["binding"]), buffer=resource["buffer"]._internal, offset=resource.get("offset", 0), size=resource.get("size", lib.WGPU_WHOLE_SIZE), sampler=ffi.NULL, textureView=ffi.NULL, - # not used: nextInChain ) else: raise TypeError(f"Unexpected resource type {type(resource)}") c_entries_list.append(c_entry) - # H: nextInChain: WGPUChainedStruct *, label: char *, layout: WGPUBindGroupLayout, entryCount: int, entries: WGPUBindGroupEntry * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, layout: WGPUBindGroupLayout, entryCount: int, entries: WGPUBindGroupEntry * struct = new_struct_p( "WGPUBindGroupDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), layout=layout._internal, entries=new_array("WGPUBindGroupEntry[]", c_entries_list), entryCount=len(c_entries_list), - # not used: nextInChain ) # H: WGPUBindGroup f(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) @@ -1500,13 +1648,13 @@ def _create_pipeline_layout( c_pipeline_layout_extras.chain.sType = lib.WGPUSType_PipelineLayoutExtras next_in_chain = ffi.cast("WGPUChainedStruct *", c_pipeline_layout_extras) - # H: nextInChain: WGPUChainedStruct *, label: char *, bindGroupLayoutCount: int, bindGroupLayouts: WGPUBindGroupLayout * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, bindGroupLayoutCount: int, bindGroupLayouts: WGPUBindGroupLayout * struct = new_struct_p( "WGPUPipelineLayoutDescriptor *", - label=to_c_label(label), + nextInChain=next_in_chain, + label=to_c_string_view(label), bindGroupLayouts=c_layout_array, bindGroupLayoutCount=len(bind_group_layouts), - nextInChain=next_in_chain, ) # H: WGPUPipelineLayout f(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) @@ -1514,16 +1662,8 @@ def _create_pipeline_layout( return GPUPipelineLayout(label, id, self) def create_shader_module( - self, - *, - label: str = "", - code: str, - source_map: dict = optional, - compilation_hints: List[structs.ShaderModuleCompilationHint] = [], + self, *, label: str = "", code: str, source_map: dict = optional ): - if compilation_hints: - for hint in compilation_hints: - check_struct("ShaderModuleCompilationHint", hint) if isinstance(code, str): looks_like_wgsl = any( x in code for x in ("@compute", "@vertex", "@fragment") @@ -1544,17 +1684,18 @@ def create_shader_module( defines = [] if c_stage == flags.ShaderStage.VERTEX: defines.append( - # H: name: char *, value: char * + # H: name: WGPUStringView, value: WGPUStringView new_struct( "WGPUShaderDefine", - name=to_c_string("gl_VertexID"), - value=to_c_string("gl_VertexIndex"), + name=to_c_string_view("gl_VertexID"), + value=to_c_string_view("gl_VertexIndex"), ) ) - # H: chain: WGPUChainedStruct, stage: WGPUShaderStage, code: char *, defineCount: int, defines: WGPUShaderDefine * + # note, GLSL is a wgpu-native feature and still uses the older structure! + # H: chain: WGPUChainedStruct, stage: WGPUShaderStage/int, code: WGPUStringView, defineCount: int, defines: WGPUShaderDefine * source_struct = new_struct_p( "WGPUShaderModuleGLSLDescriptor *", - code=to_c_string(code), + code=to_c_string_view(code), stage=c_stage, defineCount=len(defines), defines=new_array("WGPUShaderDefine[]", defines), @@ -1564,14 +1705,14 @@ def create_shader_module( source_struct[0].chain.sType = lib.WGPUSType_ShaderModuleGLSLDescriptor else: # === WGSL - # H: chain: WGPUChainedStruct, code: char * + # H: chain: WGPUChainedStruct, code: WGPUStringView source_struct = new_struct_p( - "WGPUShaderModuleWGSLDescriptor *", - code=to_c_string(code), + "WGPUShaderSourceWGSL *", # not used: chain + code=to_c_string_view(code), ) source_struct[0].chain.next = ffi.NULL - source_struct[0].chain.sType = lib.WGPUSType_ShaderModuleWGSLDescriptor + source_struct[0].chain.sType = lib.WGPUSType_ShaderSourceWGSL elif isinstance(code, bytes): # === Spirv data = code @@ -1584,26 +1725,23 @@ def create_shader_module( data_u32 = ffi.cast("uint32_t *", data_u8) # H: chain: WGPUChainedStruct, codeSize: int, code: uint32_t * source_struct = new_struct_p( - "WGPUShaderModuleSPIRVDescriptor *", - code=data_u32, - codeSize=len(data) // 4, + "WGPUShaderSourceSPIRV *", # not used: chain + codeSize=len(data) // 4, + code=data_u32, ) source_struct[0].chain.next = ffi.NULL - source_struct[0].chain.sType = lib.WGPUSType_ShaderModuleSPIRVDescriptor + source_struct[0].chain.sType = lib.WGPUSType_ShaderSourceSPIRV else: raise TypeError( "Shader code must be str for WGSL or GLSL, or bytes for SpirV." ) - # Note, we could give hints here that specify entrypoint and pipelinelayout before compiling - # H: nextInChain: WGPUChainedStruct *, label: char *, hintCount: int, hints: WGPUShaderModuleCompilationHint * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView struct = new_struct_p( "WGPUShaderModuleDescriptor *", - label=to_c_label(label), nextInChain=ffi.cast("WGPUChainedStruct *", source_struct), - hintCount=0, - hints=ffi.NULL, + label=to_c_string_view(label), ) # H: WGPUShaderModule f(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) id = libf.wgpuDeviceCreateShaderModule(self._internal, struct) @@ -1640,15 +1778,25 @@ async def create_compute_pipeline_async( # This code is virtually identical to the code in create_render_pipeline_async. # Can they be merged?? @ffi.callback( - "void(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, char *, void *)" + "void(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, char *, void *, void *)" ) - def callback(status, result, message, _userdata): - if status != 0: - msg = "-" if message == ffi.NULL else ffi.string(message).decode() + def callback(status, result, c_message, _userdata1, _userdata2): + if status != lib.WGPUCreatePipelineAsyncStatus_Success: + msg = from_c_string_view(c_message) awaitable.set_error(f"create_compute_pipeline failed ({status}): {msg}") else: awaitable.set_result(result) + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPUCreateComputePipelineAsyncCallback, userdata1: void*, userdata2: void* + callback_info = new_struct( + "WGPUCreateComputePipelineAsyncCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(id): return GPUComputePipeline(label, id, self) @@ -1656,9 +1804,9 @@ def finalizer(id): "create_compute_pipeline", callback, finalizer, self._device._poll ) - # H: void f(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, void * userdata) + # H: WGPUFuture f(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) libf.wgpuDeviceCreateComputePipelineAsync( - self._internal, descriptor, callback, ffi.NULL + self._internal, descriptor, callback_info ) return await awaitable @@ -1671,14 +1819,14 @@ def _create_compute_pipeline_descriptor( ): check_struct("ProgrammableStage", compute) c_constants, c_constant_entries = _get_override_constant_entries(compute) - # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: char *, constantCount: int, constants: WGPUConstantEntry * + # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: WGPUStringView, constantCount: int, constants: WGPUConstantEntry * c_compute_stage = new_struct( "WGPUProgrammableStageDescriptor", + # not used: nextInChain module=compute["module"]._internal, - entryPoint=to_c_string_or_null(compute.get("entry_point")), + entryPoint=to_c_string_view(compute.get("entry_point")), constantCount=len(c_constant_entries), constants=c_constants, - # not used: nextInChain ) if isinstance(layout, GPUPipelineLayout): @@ -1690,13 +1838,13 @@ def _create_compute_pipeline_descriptor( "create_compute_pipeline() 'layout' arg must be a GPUPipelineLayout or 'auto'" ) - # H: nextInChain: WGPUChainedStruct *, label: char *, layout: WGPUPipelineLayout, compute: WGPUProgrammableStageDescriptor + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, layout: WGPUPipelineLayout, compute: WGPUProgrammableStageDescriptor struct = new_struct_p( "WGPUComputePipelineDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), layout=layout_id, compute=c_compute_stage, - # not used: nextInChain ) return struct @@ -1740,15 +1888,25 @@ async def create_render_pipeline_async( return GPURenderPipeline(label, id, self) @ffi.callback( - "void(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, char *, void *)" + "void(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, WGPUStringView, void *, void *)" ) - def callback(status, result, message, _userdata): - if status != 0: - msg = "-" if message == ffi.NULL else ffi.string(message).decode() + def callback(status, result, c_message, _userdata1, _userdata2): + if status != lib.WGPUCreatePipelineAsyncStatus_Success: + msg = from_c_string_view(c_message) awaitable.set_error(f"Create renderPipeline failed ({status}): {msg}") else: awaitable.set_result(result) + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPUCreateRenderPipelineAsyncCallback, userdata1: void*, userdata2: void* + callback_info = new_struct( + "WGPUCreateRenderPipelineAsyncCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(id): return GPURenderPipeline(label, id, self) @@ -1756,9 +1914,11 @@ def finalizer(id): "create_render_pipeline", callback, finalizer, self._device._poll ) - # H: void f(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, void * userdata) + # H: WGPUFuture f(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) libf.wgpuDeviceCreateRenderPipelineAsync( - self._internal, descriptor, callback, ffi.NULL + self._internal, + descriptor, + callback_info, ) return await awaitable @@ -1789,26 +1949,27 @@ def _create_render_pipeline_descriptor( "WGPUVertexBufferLayout[]", c_vertex_buffer_layout_list ) c_vertex_constants, c_vertex_entries = _get_override_constant_entries(vertex) - # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: char *, constantCount: int, constants: WGPUConstantEntry *, bufferCount: int, buffers: WGPUVertexBufferLayout * + # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: WGPUStringView, constantCount: int, constants: WGPUConstantEntry *, bufferCount: int, buffers: WGPUVertexBufferLayout * c_vertex_state = new_struct( "WGPUVertexState", + # not used: nextInChain module=vertex["module"]._internal, - entryPoint=to_c_string_or_null(vertex.get("entry_point")), - buffers=c_vertex_buffer_descriptors_array, - bufferCount=len(c_vertex_buffer_layout_list), + entryPoint=to_c_string_view(vertex.get("entry_point")), constantCount=len(c_vertex_entries), constants=c_vertex_constants, - # not used: nextInChain + bufferCount=len(c_vertex_buffer_layout_list), + buffers=c_vertex_buffer_descriptors_array, ) - # H: nextInChain: WGPUChainedStruct *, topology: WGPUPrimitiveTopology, stripIndexFormat: WGPUIndexFormat, frontFace: WGPUFrontFace, cullMode: WGPUCullMode + # H: nextInChain: WGPUChainedStruct *, topology: WGPUPrimitiveTopology, stripIndexFormat: WGPUIndexFormat, frontFace: WGPUFrontFace, cullMode: WGPUCullMode, unclippedDepth: WGPUBool/int c_primitive_state = new_struct( "WGPUPrimitiveState", + # not used: nextInChain topology=primitive.get("topology", "triangle-list"), stripIndexFormat=primitive.get("strip_index_format", 0), frontFace=primitive.get("front_face", "ccw"), cullMode=primitive.get("cull_mode", "none"), - # not used: nextInChain + # not used: unclippedDepth ) c_depth_stencil_state = ffi.NULL @@ -1818,10 +1979,10 @@ def _create_render_pipeline_descriptor( # H: nextInChain: WGPUChainedStruct *, count: int, mask: int, alphaToCoverageEnabled: WGPUBool/int c_multisample_state = new_struct( "WGPUMultisampleState", + # not used: nextInChain count=multisample.get("count", 1), mask=multisample.get("mask", 0xFFFFFFFF), alphaToCoverageEnabled=multisample.get("alpha_to_coverage_enabled", False), - # not used: nextInChain ) c_fragment_state = ffi.NULL @@ -1837,16 +1998,16 @@ def _create_render_pipeline_descriptor( c_fragment_constants, c_fragment_entries = _get_override_constant_entries( fragment ) - # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: char *, constantCount: int, constants: WGPUConstantEntry *, targetCount: int, targets: WGPUColorTargetState * + # H: nextInChain: WGPUChainedStruct *, module: WGPUShaderModule, entryPoint: WGPUStringView, constantCount: int, constants: WGPUConstantEntry *, targetCount: int, targets: WGPUColorTargetState * c_fragment_state = new_struct_p( "WGPUFragmentState *", + # not used: nextInChain module=fragment["module"]._internal, - entryPoint=to_c_string_or_null(fragment.get("entry_point")), - targets=c_color_targets_array, - targetCount=len(c_color_targets_list), + entryPoint=to_c_string_view(fragment.get("entry_point")), constantCount=len(c_fragment_entries), constants=c_fragment_constants, - # not used: nextInChain + targetCount=len(c_color_targets_list), + targets=c_color_targets_array, ) if isinstance(layout, GPUPipelineLayout): @@ -1858,17 +2019,17 @@ def _create_render_pipeline_descriptor( "create_render_pipeline() 'layout' arg must be a GPUPipelineLayout or 'auto'" ) - # H: nextInChain: WGPUChainedStruct *, label: char *, layout: WGPUPipelineLayout, vertex: WGPUVertexState, primitive: WGPUPrimitiveState, depthStencil: WGPUDepthStencilState *, multisample: WGPUMultisampleState, fragment: WGPUFragmentState * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, layout: WGPUPipelineLayout, vertex: WGPUVertexState, primitive: WGPUPrimitiveState, depthStencil: WGPUDepthStencilState *, multisample: WGPUMultisampleState, fragment: WGPUFragmentState * struct = new_struct_p( "WGPURenderPipelineDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), layout=layout_id, vertex=c_vertex_state, primitive=c_primitive_state, depthStencil=c_depth_stencil_state, multisample=c_multisample_state, fragment=c_fragment_state, - # not used: nextInChain ) return struct @@ -1895,13 +2056,13 @@ def _create_color_target_state(self, target): color=c_color_blend, alpha=c_alpha_blend, ) - # H: nextInChain: WGPUChainedStruct *, format: WGPUTextureFormat, blend: WGPUBlendState *, writeMask: WGPUColorWriteMaskFlags/int + # H: nextInChain: WGPUChainedStruct *, format: WGPUTextureFormat, blend: WGPUBlendState *, writeMask: WGPUColorWriteMask/int c_color_state = new_struct( "WGPUColorTargetState", + # not used: nextInChain format=target["format"], blend=c_blend, writeMask=target.get("write_mask", 0xF), - # not used: nextInChain ) return c_color_state @@ -1917,7 +2078,7 @@ def _create_vertex_buffer_layout(self, buffer_des): ) c_attributes_list.append(c_attribute) c_attributes_array = new_array("WGPUVertexAttribute[]", c_attributes_list) - # H: arrayStride: int, stepMode: WGPUVertexStepMode, attributeCount: int, attributes: WGPUVertexAttribute * + # H: stepMode: WGPUVertexStepMode, arrayStride: int, attributeCount: int, attributes: WGPUVertexAttribute * c_vertex_buffer_descriptor = new_struct( "WGPUVertexBufferLayout", arrayStride=buffer_des["array_stride"], @@ -1950,9 +2111,10 @@ def _create_depth_stencil_state(self, depth_stencil): depthFailOp=stencil_back.get("depth_fail_op", "keep"), passOp=stencil_back.get("pass_op", "keep"), ) - # H: nextInChain: WGPUChainedStruct *, format: WGPUTextureFormat, depthWriteEnabled: WGPUBool/int, depthCompare: WGPUCompareFunction, stencilFront: WGPUStencilFaceState, stencilBack: WGPUStencilFaceState, stencilReadMask: int, stencilWriteMask: int, depthBias: int, depthBiasSlopeScale: float, depthBiasClamp: float + # H: nextInChain: WGPUChainedStruct *, format: WGPUTextureFormat, depthWriteEnabled: WGPUOptionalBool, depthCompare: WGPUCompareFunction, stencilFront: WGPUStencilFaceState, stencilBack: WGPUStencilFaceState, stencilReadMask: int, stencilWriteMask: int, depthBias: int, depthBiasSlopeScale: float, depthBiasClamp: float c_depth_stencil_state = new_struct_p( "WGPUDepthStencilState *", + # not used: nextInChain format=depth_stencil["format"], depthWriteEnabled=bool(depth_stencil.get("depth_write_enabled", False)), depthCompare=depth_stencil.get("depth_compare", "always"), @@ -1963,16 +2125,15 @@ def _create_depth_stencil_state(self, depth_stencil): depthBias=depth_stencil.get("depth_bias", 0), depthBiasSlopeScale=depth_stencil.get("depth_bias_slope_scale", 0), depthBiasClamp=depth_stencil.get("depth_bias_clamp", 0), - # not used: nextInChain ) return c_depth_stencil_state def create_command_encoder(self, *, label: str = ""): - # H: nextInChain: WGPUChainedStruct *, label: char * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView struct = new_struct_p( "WGPUCommandEncoderDescriptor *", - label=to_c_label(label), # not used: nextInChain + label=to_c_string_view(label), ) # H: WGPUCommandEncoder f(WGPUDevice device, WGPUCommandEncoderDescriptor const * descriptor) @@ -1995,17 +2156,17 @@ def create_render_bundle_encoder( c_color_formats = new_array("WGPUTextureFormat[]", color_formats_list) color_formats_count = len(color_formats_list) - # H: nextInChain: WGPUChainedStruct *, label: char *, colorFormatCount: int, colorFormats: WGPUTextureFormat *, depthStencilFormat: WGPUTextureFormat, sampleCount: int, depthReadOnly: WGPUBool/int, stencilReadOnly: WGPUBool/int + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, colorFormatCount: int, colorFormats: WGPUTextureFormat *, depthStencilFormat: WGPUTextureFormat, sampleCount: int, depthReadOnly: WGPUBool/int, stencilReadOnly: WGPUBool/int render_bundle_encoder_descriptor = new_struct_p( "WGPURenderBundleEncoderDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), colorFormatCount=color_formats_count, colorFormats=c_color_formats, depthStencilFormat=depth_stencil_format or 0, sampleCount=sample_count, depthReadOnly=depth_read_only, stencilReadOnly=stencil_read_only, - # not used: nextInChain ) # H: WGPURenderBundleEncoder f(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) render_bundle_encoder_id = libf.wgpuDeviceCreateRenderBundleEncoder( @@ -2047,13 +2208,13 @@ def _create_query_set(self, label, type, count, statistics): ) next_in_chain = ffi.cast("WGPUChainedStruct *", query_set_descriptor_extras) - # H: nextInChain: WGPUChainedStruct *, label: char *, type: WGPUQueryType, count: int + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, type: WGPUQueryType, count: int query_set_descriptor = new_struct_p( "WGPUQuerySetDescriptor *", - label=to_c_label(label), + nextInChain=next_in_chain, + label=to_c_string_view(label), type=type, count=count, - nextInChain=next_in_chain, ) # H: WGPUQuerySet f(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) @@ -2095,7 +2256,7 @@ def __init__(self, label, internal, device, size, usage, map_state): self._mapped_status = 0, self.size, flags.MapMode.WRITE def _get_size(self): - # H: WGPUBufferUsageFlags f(WGPUBuffer buffer) + # H: WGPUBufferUsage f(WGPUBuffer buffer) return libf.wgpuBufferGetUsage(self._internal) def _check_range(self, offset, size): @@ -2166,25 +2327,42 @@ def _map(self, mode, offset=0, size=None): # Setup awaitable - @ffi.callback("void(WGPUBufferMapAsyncStatus, void*)") - def callback(status, _user_data): - if status != 0: - awaitable.set_error(f"Could not map buffer ({status}).") + @ffi.callback("void(WGPUMapAsyncStatus, WGPUStringView, void *, void *)") + def buffer_map_callback(status, c_message, _userdata1, _userdata2): + if status != lib.WGPUMapAsyncStatus_Success: + msg = from_c_string_view(c_message) + awaitable.set_error(f"Could not map buffer ({status} : {msg}).") else: awaitable.set_result(status) + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPUBufferMapCallback, userdata1: void*, userdata2: void* + buffer_map_callback_info = new_struct( + "WGPUBufferMapCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=buffer_map_callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(_status): self._map_state = enums.BufferMapState.mapped self._mapped_status = offset, offset + size, mode self._mapped_memoryviews = [] - awaitable = WgpuAwaitable("buffer.map", callback, finalizer, self._device._poll) + awaitable = WgpuAwaitable( + "buffer.map", buffer_map_callback, finalizer, self._device._poll + ) # Map it self._map_state = enums.BufferMapState.pending - # H: void f(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, void * userdata) + # H: WGPUFuture f(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) libf.wgpuBufferMapAsync( - self._internal, map_mode, offset, size, callback, ffi.NULL + self._internal, + map_mode, + offset, + size, + buffer_map_callback_info, ) return awaitable @@ -2346,10 +2524,13 @@ def create_view( elif dimension in ("2d-array", "cube-array"): array_layer_count = self._tex_info["size"][2] - base_array_layer - # H: nextInChain: WGPUChainedStruct *, label: char *, format: WGPUTextureFormat, dimension: WGPUTextureViewDimension, baseMipLevel: int, mipLevelCount: int, baseArrayLayer: int, arrayLayerCount: int, aspect: WGPUTextureAspect + usage = lib.WGPUTextureUsage_None # assuming none means use the texture's usage + + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, format: WGPUTextureFormat, dimension: WGPUTextureViewDimension, baseMipLevel: int, mipLevelCount: int, baseArrayLayer: int, arrayLayerCount: int, aspect: WGPUTextureAspect, usage: WGPUTextureUsage/int struct = new_struct_p( "WGPUTextureViewDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), format=format, dimension=dimension, aspect=aspect, @@ -2357,7 +2538,7 @@ def create_view( mipLevelCount=mip_level_count, baseArrayLayer=base_array_layer, arrayLayerCount=array_layer_count, - # not used: nextInChain + usage=usage, ) # H: WGPUTextureView f(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor) @@ -2426,7 +2607,7 @@ def _get_compilation_info(self): # else: # pass # - # H: void f(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, void * userdata) + # H: WGPUFuture f(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) # libf.wgpuShaderModuleGetCompilationInfo(self._internal, callback, ffi.NULL) # # self._device._poll() @@ -2543,7 +2724,9 @@ def _set_push_constants(self, visibility, offset, size_in_bytes, data, data_offs raise ValueError("size_in_bytes + data_offset is too large") c_data = ffi.cast("void *", address) # do we want to add data_offset? - # H: void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void const * data) + # H: void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data) + # H: void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data) + # H: void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data) function = type(self)._set_push_constants_function if function is None: self._not_implemented("set_push_constants") @@ -2552,6 +2735,7 @@ def _set_push_constants(self, visibility, offset, size_in_bytes, data, data_offs def _begin_pipeline_statistics_query(self, query_set, query_index): # H: void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) # H: void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) + # H: void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex) function = type(self)._begin_pipeline_statistics_query_function if function is None: self._not_implemented("begin_pipeline_statistics") @@ -2560,6 +2744,7 @@ def _begin_pipeline_statistics_query(self, query_set, query_index): def _end_pipeline_statistics_query(self): # H: void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder) # H: void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder) + # H: void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder) function = type(self)._end_pipeline_statistics_query_function if function is None: self._not_implemented("end_pipeline_statistics") @@ -2572,11 +2757,11 @@ def _not_implemented(self, name) -> NoReturn: class GPUDebugCommandsMixin(classes.GPUDebugCommandsMixin): # whole class is likely going to be solved better: https://github.com/pygfx/wgpu-py/pull/546 def push_debug_group(self, group_label: str): - c_group_label = to_c_string(group_label) - # H: void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) - # H: void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) - # H: void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) - # H: void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) + c_group_label = to_c_string_view(group_label) + # H: void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) + # H: void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) + # H: void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) + # H: void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) function = type(self)._push_debug_group_function function(self._internal, c_group_label) @@ -2589,11 +2774,11 @@ def pop_debug_group(self): function(self._internal) def insert_debug_marker(self, marker_label: str): - c_marker_label = to_c_string(marker_label) - # H: void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) - # H: void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) - # H: void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) - # H: void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) + c_marker_label = to_c_string_view(marker_label) + # H: void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) + # H: void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) + # H: void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) + # H: void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) function = type(self)._insert_debug_marker_function function(self._internal, c_marker_label) @@ -2718,12 +2903,12 @@ def begin_compute_pass( "end_of_pass_write_index", lib.WGPU_QUERY_SET_INDEX_UNDEFINED ), ) - # H: nextInChain: WGPUChainedStruct *, label: char *, timestampWrites: WGPUComputePassTimestampWrites * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, timestampWrites: WGPUComputePassTimestampWrites * struct = new_struct_p( "WGPUComputePassDescriptor *", - label=to_c_label(label), - timestampWrites=c_timestamp_writes_struct, # not used: nextInChain + label=to_c_string_view(label), + timestampWrites=c_timestamp_writes_struct, ) # H: WGPUComputePassEncoder f(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor) raw_encoder = libf.wgpuCommandEncoderBeginComputePass(self._internal, struct) @@ -2774,16 +2959,16 @@ def begin_render_pass( if occlusion_query_set is not None: c_occlusion_query_set = occlusion_query_set._internal - # H: nextInChain: WGPUChainedStruct *, label: char *, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet, timestampWrites: WGPURenderPassTimestampWrites * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet, timestampWrites: WGPURenderPassTimestampWrites * struct = new_struct_p( "WGPURenderPassDescriptor *", - label=to_c_label(label), + # not used: nextInChain + label=to_c_string_view(label), colorAttachments=c_color_attachments_array, colorAttachmentCount=len(c_color_attachments_list), depthStencilAttachment=c_depth_stencil_attachment, timestampWrites=c_timestamp_writes_struct, occlusionQuerySet=c_occlusion_query_set, - # not used: nextInChain ) # H: WGPURenderPassEncoder f(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) @@ -2817,6 +3002,7 @@ def _create_render_pass_color_attachment(self, color_attachment): # H: nextInChain: WGPUChainedStruct *, view: WGPUTextureView, depthSlice: int, resolveTarget: WGPUTextureView, loadOp: WGPULoadOp, storeOp: WGPUStoreOp, clearValue: WGPUColor c_attachment = new_struct( "WGPURenderPassColorAttachment", + # not used: nextInChain view=texture_view_id, resolveTarget=c_resolve_target, loadOp=color_attachment["load_op"], @@ -2824,7 +3010,6 @@ def _create_render_pass_color_attachment(self, color_attachment): clearValue=c_clear_value, depthSlice=lib.WGPU_DEPTH_SLICE_UNDEFINED, # not implemented yet # not used: resolveTarget - # not used: nextInChain ) return c_attachment @@ -2960,17 +3145,17 @@ def copy_buffer_to_texture( size = _tuple_from_extent3d(copy_size) + # H: layout: WGPUTexelCopyBufferLayout, buffer: WGPUBuffer c_source = new_struct_p( - "WGPUImageCopyBuffer *", - buffer=source["buffer"]._internal, - # H: nextInChain: WGPUChainedStruct *, offset: int, bytesPerRow: int, rowsPerImage: int + "WGPUTexelCopyBufferInfo *", + # H: offset: int, bytesPerRow: int, rowsPerImage: int layout=new_struct( - "WGPUTextureDataLayout", + "WGPUTexelCopyBufferLayout", offset=int(source.get("offset", 0)), bytesPerRow=bytes_per_row, rowsPerImage=int(source.get("rows_per_image", size[1])), - # not used: nextInChain ), + buffer=source["buffer"]._internal, ) ori = _tuple_from_origin3d(destination) @@ -2981,14 +3166,13 @@ def copy_buffer_to_texture( y=ori[1], z=ori[2], ) - # H: nextInChain: WGPUChainedStruct *, texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect + # H: texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect c_destination = new_struct_p( - "WGPUImageCopyTexture *", + "WGPUTexelCopyTextureInfo *", texture=destination["texture"]._internal, mipLevel=int(destination.get("mip_level", 0)), origin=c_origin, aspect=enums.TextureAspect.all, - # not used: nextInChain ) # H: width: int, height: int, depthOrArrayLayers: int @@ -2999,7 +3183,7 @@ def copy_buffer_to_texture( depthOrArrayLayers=size[2], ) - # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) + # H: void f(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) libf.wgpuCommandEncoderCopyBufferToTexture( self._internal, c_source, @@ -3035,27 +3219,26 @@ def copy_texture_to_buffer( y=ori[1], z=ori[2], ) - # H: nextInChain: WGPUChainedStruct *, texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect + # H: texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect c_source = new_struct_p( - "WGPUImageCopyTexture *", + "WGPUTexelCopyTextureInfo *", texture=source["texture"]._internal, mipLevel=int(source.get("mip_level", 0)), origin=c_origin, aspect=0, - # not used: nextInChain ) + # H: layout: WGPUTexelCopyBufferLayout, buffer: WGPUBuffer c_destination = new_struct_p( - "WGPUImageCopyBuffer *", - buffer=destination["buffer"]._internal, - # H: nextInChain: WGPUChainedStruct *, offset: int, bytesPerRow: int, rowsPerImage: int + "WGPUTexelCopyBufferInfo *", + # H: offset: int, bytesPerRow: int, rowsPerImage: int layout=new_struct( - "WGPUTextureDataLayout", + "WGPUTexelCopyBufferLayout", offset=int(destination.get("offset", 0)), bytesPerRow=bytes_per_row, rowsPerImage=int(destination.get("rows_per_image", size[1])), - # not used: nextInChain ), + buffer=destination["buffer"]._internal, ) # H: width: int, height: int, depthOrArrayLayers: int @@ -3066,7 +3249,7 @@ def copy_texture_to_buffer( depthOrArrayLayers=size[2], ) - # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) + # H: void f(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) libf.wgpuCommandEncoderCopyTextureToBuffer( self._internal, c_source, @@ -3096,13 +3279,12 @@ def copy_texture_to_texture( y=ori[1], z=ori[2], ) - # H: nextInChain: WGPUChainedStruct *, texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect + # H: texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect c_source = new_struct_p( - "WGPUImageCopyTexture *", + "WGPUTexelCopyTextureInfo *", texture=source["texture"]._internal, mipLevel=int(source.get("mip_level", 0)), origin=c_origin1, - # not used: nextInChain # not used: aspect ) @@ -3114,13 +3296,12 @@ def copy_texture_to_texture( y=ori[1], z=ori[2], ) - # H: nextInChain: WGPUChainedStruct *, texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect + # H: texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect c_destination = new_struct_p( - "WGPUImageCopyTexture *", + "WGPUTexelCopyTextureInfo *", texture=destination["texture"]._internal, mipLevel=int(destination.get("mip_level", 0)), origin=c_origin2, - # not used: nextInChain # not used: aspect ) @@ -3133,7 +3314,7 @@ def copy_texture_to_texture( depthOrArrayLayers=size[2], ) - # H: void f(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) + # H: void f(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) libf.wgpuCommandEncoderCopyTextureToTexture( self._internal, c_source, @@ -3142,11 +3323,11 @@ def copy_texture_to_texture( ) def finish(self, *, label: str = ""): - # H: nextInChain: WGPUChainedStruct *, label: char * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView struct = new_struct_p( "WGPUCommandBufferDescriptor *", - label=to_c_label(label), # not used: nextInChain + label=to_c_string_view(label), ) # H: WGPUCommandBuffer f(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor) id = libf.wgpuCommandEncoderFinish(self._internal, struct) @@ -3188,7 +3369,7 @@ class GPUComputePassEncoder( _set_bind_group_function = libf.wgpuComputePassEncoderSetBindGroup _begin_pipeline_statistics_query_function = libf.wgpuComputePassEncoderBeginPipelineStatisticsQuery # fmt: skip _end_pipeline_statistics_query_function = libf.wgpuComputePassEncoderEndPipelineStatisticsQuery # fmt: skip - _set_push_constants_function = None # coming soon + _set_push_constants_function = libf.wgpuComputePassEncoderSetPushConstants # GPUObjectBaseMixin _release_function = libf.wgpuComputePassEncoderRelease @@ -3359,9 +3540,9 @@ class GPURenderBundleEncoder( # GPUBindingCommandsMixin _set_bind_group_function = libf.wgpuRenderBundleEncoderSetBindGroup - _set_push_constants_function = None - _begin_pipeline_statistics_query_function = None - _end_pipeline_statistics_query_function = None + _set_push_constants_function = libf.wgpuRenderBundleEncoderSetPushConstants + _begin_pipeline_statistics_query_function = libf.wgpuRenderPassEncoderBeginPipelineStatisticsQuery # fmt: skip + _end_pipeline_statistics_query_function = libf.wgpuRenderPassEncoderEndPipelineStatisticsQuery # fmt: skip # GPURenderCommandsMixin _set_pipeline_function = libf.wgpuRenderBundleEncoderSetPipeline @@ -3376,11 +3557,11 @@ class GPURenderBundleEncoder( _release_function = libf.wgpuRenderBundleEncoderRelease def finish(self, *, label: str = ""): - # H: nextInChain: WGPUChainedStruct *, label: char * + # H: nextInChain: WGPUChainedStruct *, label: WGPUStringView struct = new_struct_p( "WGPURenderBundleDescriptor *", - label=to_c_label(label), # not used: nextInChain + label=to_c_string_view(label), ) # H: WGPURenderBundle f(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderBundleDescriptor const * descriptor) id = libf.wgpuRenderBundleEncoderFinish(self._internal, struct) @@ -3519,23 +3700,21 @@ def write_texture( y=ori[1], z=ori[2], ) - # H: nextInChain: WGPUChainedStruct *, texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect + # H: texture: WGPUTexture, mipLevel: int, origin: WGPUOrigin3D, aspect: WGPUTextureAspect c_destination = new_struct_p( - "WGPUImageCopyTexture *", + "WGPUTexelCopyTextureInfo *", texture=destination["texture"]._internal, mipLevel=destination.get("mip_level", 0), origin=c_origin, aspect=enums.TextureAspect.all, - # not used: nextInChain ) - # H: nextInChain: WGPUChainedStruct *, offset: int, bytesPerRow: int, rowsPerImage: int + # H: offset: int, bytesPerRow: int, rowsPerImage: int c_data_layout = new_struct_p( - "WGPUTextureDataLayout *", + "WGPUTexelCopyBufferLayout *", offset=data_layout.get("offset", 0), bytesPerRow=data_layout["bytes_per_row"], rowsPerImage=data_layout.get("rows_per_image", size[1]), - # not used: nextInChain ) # H: width: int, height: int, depthOrArrayLayers: int @@ -3546,7 +3725,7 @@ def write_texture( depthOrArrayLayers=size[2], ) - # H: void f(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) + # H: void f(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) libf.wgpuQueueWriteTexture( self._internal, c_destination, c_data, data_length, c_data_layout, c_size ) @@ -3655,25 +3834,40 @@ async def on_submitted_work_done_async(self): await awaitable def _on_submitted_work_done(self): - @ffi.callback("void(WGPUQueueWorkDoneStatus, void*)") - def callback(status, _user_data_p): - if status == 0: + @ffi.callback("void(WGPUQueueWorkDoneStatus, void *, void *)") + def work_done_callback(status, _userdata1, _userdata2): + if status == lib.WGPUQueueWorkDoneStatus_Success: awaitable.set_result(True) else: - result = {1: "Error", 2: "Unknown", 3: "DeviceLost"}.get( - status, "Other" - ) + result = { + lib.WGPUQueueWorkDoneStatus_InstanceDropped: "InstanceDropped", + lib.WGPUQueueWorkDoneStatus_Error: "Error", + lib.WGPUQueueWorkDoneStatus_Unknown: "Unknown", + }.get(status, "Other") awaitable.set_error(f"Queue work done status: {result}") + # H: nextInChain: WGPUChainedStruct *, mode: WGPUCallbackMode, callback: WGPUQueueWorkDoneCallback, userdata1: void*, userdata2: void* + work_done_callback_info = new_struct( + "WGPUQueueWorkDoneCallbackInfo", + # not used: nextInChain + mode=lib.WGPUCallbackMode_AllowProcessEvents, + callback=work_done_callback, + # not used: userdata1 + # not used: userdata2 + ) + def finalizer(_value): return None awaitable = WgpuAwaitable( - "on_submitted_work_done", callback, finalizer, self._device._poll_wait + "on_submitted_work_done", + work_done_callback, + finalizer, + self._device._poll_wait, ) - # H: void f(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, void * userdata) - libf.wgpuQueueOnSubmittedWorkDone(self._internal, callback, ffi.NULL) + # H: WGPUFuture f(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) + libf.wgpuQueueOnSubmittedWorkDone(self._internal, work_done_callback_info) return awaitable diff --git a/wgpu/backends/wgpu_native/_ffi.py b/wgpu/backends/wgpu_native/_ffi.py index 3a97ca67..00a76dd5 100644 --- a/wgpu/backends/wgpu_native/_ffi.py +++ b/wgpu/backends/wgpu_native/_ffi.py @@ -33,13 +33,27 @@ def _get_wgpu_header(*filenames): # Read files lines1 = [] for filename in filenames: - with open(filename) as f: - lines1.extend(f.readlines()) + with open(filename, "rb") as f: + lines1.extend(f.read().decode().replace("\\\n", "").splitlines(True)) # Deal with pre-processor commands, because cffi cannot handle them. # Just removing them, plus a few extra lines, seems to do the trick. lines2 = [] for line in lines1: - if line.startswith("#define ") and len(line.split()) > 2 and "0x" in line: + if ( + line.startswith("#define ") + and len(line.split()) > 2 + and ("0x" in line or "_MAX" in line) + ): + # pattern to find: #define WGPU_CONSTANT (0x1234) + # we use ffi.sizeof() to hopefully get the correct max sizes per platform + max_size = hex((1 << ffi.sizeof("size_t") * 8) - 1) + max_32 = hex((1 << ffi.sizeof("uint32_t") * 8) - 1) + max_64 = hex((1 << ffi.sizeof("uint64_t") * 8) - 1) + line = ( + line.replace("SIZE_MAX", max_size) + .replace("UINT32_MAX", max_32) + .replace("UINT64_MAX", max_64) + ) line = line.replace("(", "").replace(")", "") elif line.startswith("#"): continue @@ -176,12 +190,12 @@ def _check_expected_version(version_info): ) -@ffi.callback("void(WGPULogLevel, char *, void *)") -def _logger_callback(level, c_msg, userdata): +@ffi.callback("void(WGPULogLevel, WGPUStringView, void *)") +def _logger_callback(level, message, userdata): """Called when Rust emits a log message.""" # Make a copy of the msg. Rust reclaims the memory when this returns try: - msg = ffi.string(c_msg).decode(errors="ignore") + msg = ffi.string(message.data, message.length).decode(errors="ignore") except Exception: if sys.is_finalizing(): return # Python is shutting down diff --git a/wgpu/backends/wgpu_native/_helpers.py b/wgpu/backends/wgpu_native/_helpers.py index 95b62827..7a6d0f94 100644 --- a/wgpu/backends/wgpu_native/_helpers.py +++ b/wgpu/backends/wgpu_native/_helpers.py @@ -106,10 +106,10 @@ def get_surface_id_from_info(present_info): if sys.platform.startswith("win"): # no-cover GetModuleHandle = ctypes.windll.kernel32.GetModuleHandleW # noqa: N806 - struct = ffi.new("WGPUSurfaceDescriptorFromWindowsHWND *") + struct = ffi.new("WGPUSurfaceSourceWindowsHWND *") struct.hinstance = ffi.cast("void *", GetModuleHandle(lib_path)) struct.hwnd = ffi.cast("void *", int(present_info["window"])) - struct.chain.sType = lib.WGPUSType_SurfaceDescriptorFromWindowsHWND + struct.chain.sType = lib.WGPUSType_SurfaceSourceWindowsHWND elif sys.platform.startswith("darwin"): # no-cover # This is what the triangle example from wgpu-native does: @@ -158,28 +158,28 @@ def get_surface_id_from_info(present_info): cv.setLayer(metal_layer) cv.setWantsLayer(True) - struct = ffi.new("WGPUSurfaceDescriptorFromMetalLayer *") + struct = ffi.new("WGPUSurfaceSourceMetalLayer *") struct.layer = ffi.cast("void *", metal_layer.ptr.value) - struct.chain.sType = lib.WGPUSType_SurfaceDescriptorFromMetalLayer + struct.chain.sType = lib.WGPUSType_SurfaceSourceMetalLayer elif sys.platform.startswith("linux"): # no-cover platform = present_info.get("platform", "x11") if platform == "x11": - struct = ffi.new("WGPUSurfaceDescriptorFromXlibWindow *") + struct = ffi.new("WGPUSurfaceSourceXlibWindow *") struct.display = ffi.cast("void *", present_info["display"]) struct.window = int(present_info["window"]) - struct.chain.sType = lib.WGPUSType_SurfaceDescriptorFromXlibWindow + struct.chain.sType = lib.WGPUSType_SurfaceSourceXlibWindow elif platform == "wayland": - struct = ffi.new("WGPUSurfaceDescriptorFromWaylandSurface *") + struct = ffi.new("WGPUSurfaceSourceWaylandSurface *") struct.display = ffi.cast("void *", present_info["display"]) struct.surface = ffi.cast("void *", present_info["window"]) - struct.chain.sType = lib.WGPUSType_SurfaceDescriptorFromWaylandSurface + struct.chain.sType = lib.WGPUSType_SurfaceSourceWaylandSurface elif platform == "xcb": # todo: xcb untested - struct = ffi.new("WGPUSurfaceDescriptorFromXcbWindow *") + struct = ffi.new("WGPUSurfaceSourceXCBWindow *") struct.connection = ffi.cast("void *", present_info["connection"]) # ?? struct.window = int(present_info["window"]) - struct.chain.sType = lib.WGPUSType_SurfaceDescriptorFromXlibWindow + struct.chain.sType = lib.WGPUSType_SurfaceSourceXCBWindow else: raise RuntimeError("Unexpected Linux surface platform '{platform}'.") @@ -187,7 +187,7 @@ def get_surface_id_from_info(present_info): raise RuntimeError("Cannot get surface id: unsupported platform.") surface_descriptor = ffi.new("WGPUSurfaceDescriptor *") - surface_descriptor.label = ffi.NULL + surface_descriptor.label.data = ffi.NULL # not setting label for now surface_descriptor.nextInChain = ffi.cast("WGPUChainedStruct *", struct) return lib.wgpuInstanceCreateSurface(get_wgpu_instance(), surface_descriptor) @@ -478,24 +478,21 @@ def generate_report(): "allocated": struct.surfaces.numAllocated, "kept": struct.surfaces.numKeptFromUser, "released": struct.surfaces.numReleasedFromUser, - "error": struct.surfaces.numError, "element_size": struct.surfaces.elementSize, } - for backend in ("vulkan", "metal", "dx12", "gl"): - c_hub_report = getattr(struct, backend) - report[backend] = {} - for key in dir(c_hub_report): - c_registry_report = getattr(c_hub_report, key) - registry_report = { - "allocated": c_registry_report.numAllocated, - "kept": c_registry_report.numKeptFromUser, - "released": c_registry_report.numReleasedFromUser, - "error": c_registry_report.numError, - "element_size": c_registry_report.elementSize, - } - # if any(x!=0 for x in registry_report.values()): - report[backend][key] = registry_report + c_hub_report = struct.hub + report["hub"] = {} + for key in dir(c_hub_report): + c_registry_report = getattr(c_hub_report, key) + registry_report = { + "allocated": c_registry_report.numAllocated, + "kept": c_registry_report.numKeptFromUser, + "released": c_registry_report.numReleasedFromUser, + "element_size": c_registry_report.elementSize, + } + # if any(x!=0 for x in registry_report.values()): + report["hub"][key] = registry_report return report @@ -503,7 +500,7 @@ def generate_report(): class WgpuNativeCountsDiagnostics(DiagnosticsBase): def get_subscript(self): text = "" - text += " * The a, k, r, e are allocated, kept, released, and error, respectively.\n" + text += " * The a, k, r are allocated, kept, and released, respectively.\n" text += " * Reported memory does not include buffer/texture data.\n" return text @@ -514,9 +511,8 @@ def get_dict(self): # Names in the root of the report (backend-less) root_names = ["surfaces"] - # Get per-backend names and a list of backends - names = list(native_report["vulkan"].keys()) - backends = [name for name in native_report.keys() if name not in root_names] + # Get names and for other objects + names = list(native_report["hub"].keys()) # Get a mapping from native names to wgpu-py names name_map = {"surfaces": "CanvasContext"} @@ -532,17 +528,7 @@ def get_dict(self): # the number of objects "allocated" by wgpu-core. In practice, # wgpu-core can keep objects around for re-use, which is why "allocated" # and released" are not in this equation. - fields_to_add = ["kept", "error"] - - # Establish what backends are active - active_backends = [] - for backend in backends: - total = 0 - for name in names: - d = native_report[backend][name] - total += sum(d[k] for k in fields_to_add) - if total > 0: - active_backends.append(backend) + fields_to_add = ["kept"] # Process names in the root for name in root_names: @@ -552,39 +538,36 @@ def get_dict(self): "a": d["allocated"], "k": d["kept"], "r": d["released"], - "e": d["error"], "el_size": d["element_size"], } # Store in report report_name = name_map[name] result[report_name]["count"] = subtotal_count result[report_name]["mem"] = subtotal_count * d["element_size"] - result[report_name]["backend"] = {"": impl} + result[report_name]["hub"] = {"": impl} - # Iterate over backends + # Iterate over names for name in names: total_count = 0 total_mem = 0 implementations = {} - for backend in active_backends: - d = native_report[backend][name] - subtotal_count = sum(d[k] for k in fields_to_add) - subtotal_mem = subtotal_count * d["element_size"] - impl = { - "a": d["allocated"], - "k": d["kept"], - "r": d["released"], - "e": d["error"], - "el_size": d["element_size"], - } - total_count += subtotal_count - total_mem += subtotal_mem - implementations[backend] = impl + d = native_report["hub"][name] + subtotal_count = sum(d[k] for k in fields_to_add) + subtotal_mem = subtotal_count * d["element_size"] + impl = { + "a": d["allocated"], + "k": d["kept"], + "r": d["released"], + "el_size": d["element_size"], + } + total_count += subtotal_count + total_mem += subtotal_mem + implementations["hub"] = impl # Store in report report_name = name_map[name] result[report_name]["count"] = total_count result[report_name]["mem"] = total_mem - result[report_name]["backend"] = implementations + result[report_name]["hub"] = implementations # Add totals totals = {} diff --git a/wgpu/backends/wgpu_native/_mappings.py b/wgpu/backends/wgpu_native/_mappings.py index 976671cc..8087b23c 100644 --- a/wgpu/backends/wgpu_native/_mappings.py +++ b/wgpu/backends/wgpu_native/_mappings.py @@ -3,107 +3,114 @@ # THIS CODE IS AUTOGENERATED - DO NOT EDIT -# There are 236 enum mappings +# There are 243 enum mappings enummap = { - "AddressMode.clamp-to-edge": 2, - "AddressMode.mirror-repeat": 1, - "AddressMode.repeat": 0, - "BlendFactor.constant": 11, - "BlendFactor.dst": 6, - "BlendFactor.dst-alpha": 8, - "BlendFactor.one": 1, - "BlendFactor.one-minus-constant": 12, - "BlendFactor.one-minus-dst": 7, - "BlendFactor.one-minus-dst-alpha": 9, - "BlendFactor.one-minus-src": 3, - "BlendFactor.one-minus-src-alpha": 5, - "BlendFactor.src": 2, - "BlendFactor.src-alpha": 4, - "BlendFactor.src-alpha-saturated": 10, - "BlendFactor.zero": 0, - "BlendOperation.add": 0, - "BlendOperation.max": 4, - "BlendOperation.min": 3, - "BlendOperation.reverse-subtract": 2, - "BlendOperation.subtract": 1, - "BufferBindingType.read-only-storage": 3, - "BufferBindingType.storage": 2, - "BufferBindingType.uniform": 1, - "BufferMapState.mapped": 2, - "BufferMapState.pending": 1, - "BufferMapState.unmapped": 0, + "AddressMode.clamp-to-edge": 1, + "AddressMode.mirror-repeat": 3, + "AddressMode.repeat": 2, + "BlendFactor.constant": 12, + "BlendFactor.dst": 7, + "BlendFactor.dst-alpha": 9, + "BlendFactor.one": 2, + "BlendFactor.one-minus-constant": 13, + "BlendFactor.one-minus-dst": 8, + "BlendFactor.one-minus-dst-alpha": 10, + "BlendFactor.one-minus-src": 4, + "BlendFactor.one-minus-src-alpha": 6, + "BlendFactor.one-minus-src1": 15, + "BlendFactor.one-minus-src1-alpha": 17, + "BlendFactor.src": 3, + "BlendFactor.src-alpha": 5, + "BlendFactor.src-alpha-saturated": 11, + "BlendFactor.src1": 14, + "BlendFactor.src1-alpha": 16, + "BlendFactor.zero": 1, + "BlendOperation.add": 1, + "BlendOperation.max": 5, + "BlendOperation.min": 4, + "BlendOperation.reverse-subtract": 3, + "BlendOperation.subtract": 2, + "BufferBindingType.read-only-storage": 4, + "BufferBindingType.storage": 3, + "BufferBindingType.uniform": 2, + "BufferMapState.mapped": 3, + "BufferMapState.pending": 2, + "BufferMapState.unmapped": 1, "CompareFunction.always": 8, - "CompareFunction.equal": 6, - "CompareFunction.greater": 4, - "CompareFunction.greater-equal": 5, + "CompareFunction.equal": 3, + "CompareFunction.greater": 5, + "CompareFunction.greater-equal": 7, "CompareFunction.less": 2, - "CompareFunction.less-equal": 3, + "CompareFunction.less-equal": 4, "CompareFunction.never": 1, - "CompareFunction.not-equal": 7, - "CompilationMessageType.error": 0, - "CompilationMessageType.info": 2, - "CompilationMessageType.warning": 1, - "CullMode.back": 2, - "CullMode.front": 1, - "CullMode.none": 0, + "CompareFunction.not-equal": 6, + "CompilationMessageType.error": 1, + "CompilationMessageType.info": 3, + "CompilationMessageType.warning": 2, + "CullMode.back": 3, + "CullMode.front": 2, + "CullMode.none": 1, "DeviceLostReason.destroyed": 2, "DeviceLostReason.unknown": 1, - "ErrorFilter.internal": 2, - "ErrorFilter.out-of-memory": 1, - "ErrorFilter.validation": 0, - "FeatureName.bgra8unorm-storage": 10, + "ErrorFilter.internal": 3, + "ErrorFilter.out-of-memory": 2, + "ErrorFilter.validation": 1, + "FeatureName.bgra8unorm-storage": 12, + "FeatureName.clip-distances": 15, "FeatureName.depth-clip-control": 1, "FeatureName.depth32float-stencil8": 2, - "FeatureName.float32-filterable": 11, - "FeatureName.indirect-first-instance": 7, - "FeatureName.rg11b10ufloat-renderable": 9, - "FeatureName.shader-f16": 8, - "FeatureName.texture-compression-astc": 6, + "FeatureName.dual-source-blending": 16, + "FeatureName.float32-filterable": 13, + "FeatureName.indirect-first-instance": 9, + "FeatureName.rg11b10ufloat-renderable": 11, + "FeatureName.shader-f16": 10, + "FeatureName.texture-compression-astc": 7, "FeatureName.texture-compression-bc": 4, - "FeatureName.texture-compression-etc2": 5, + "FeatureName.texture-compression-bc-sliced-3d": 5, + "FeatureName.texture-compression-etc2": 6, "FeatureName.timestamp-query": 3, - "FilterMode.linear": 1, - "FilterMode.nearest": 0, - "FrontFace.ccw": 0, - "FrontFace.cw": 1, + "FilterMode.linear": 2, + "FilterMode.nearest": 1, + "FrontFace.ccw": 1, + "FrontFace.cw": 2, "IndexFormat.uint16": 1, "IndexFormat.uint32": 2, - "LoadOp.clear": 1, - "LoadOp.load": 2, - "MipmapFilterMode.linear": 1, - "MipmapFilterMode.nearest": 0, + "LoadOp.clear": 2, + "LoadOp.load": 1, + "MipmapFilterMode.linear": 2, + "MipmapFilterMode.nearest": 1, "PowerPreference.high-performance": 2, "PowerPreference.low-power": 1, - "PrimitiveTopology.line-list": 1, - "PrimitiveTopology.line-strip": 2, - "PrimitiveTopology.point-list": 0, - "PrimitiveTopology.triangle-list": 3, - "PrimitiveTopology.triangle-strip": 4, - "QueryType.occlusion": 0, - "QueryType.timestamp": 1, - "SamplerBindingType.comparison": 3, - "SamplerBindingType.filtering": 1, - "SamplerBindingType.non-filtering": 2, - "StencilOperation.decrement-clamp": 5, - "StencilOperation.decrement-wrap": 7, - "StencilOperation.increment-clamp": 4, - "StencilOperation.increment-wrap": 6, - "StencilOperation.invert": 3, - "StencilOperation.keep": 0, - "StencilOperation.replace": 2, - "StencilOperation.zero": 1, - "StorageTextureAccess.read-only": 2, - "StorageTextureAccess.read-write": 3, - "StorageTextureAccess.write-only": 1, + "PrimitiveTopology.line-list": 2, + "PrimitiveTopology.line-strip": 3, + "PrimitiveTopology.point-list": 1, + "PrimitiveTopology.triangle-list": 4, + "PrimitiveTopology.triangle-strip": 5, + "QueryType.occlusion": 1, + "QueryType.timestamp": 2, + "SamplerBindingType.comparison": 4, + "SamplerBindingType.filtering": 2, + "SamplerBindingType.non-filtering": 3, + "StencilOperation.decrement-clamp": 6, + "StencilOperation.decrement-wrap": 8, + "StencilOperation.increment-clamp": 5, + "StencilOperation.increment-wrap": 7, + "StencilOperation.invert": 4, + "StencilOperation.keep": 1, + "StencilOperation.replace": 3, + "StencilOperation.zero": 2, + "StorageTextureAccess.read-only": 3, + "StorageTextureAccess.read-write": 4, + "StorageTextureAccess.write-only": 2, "StoreOp.discard": 2, "StoreOp.store": 1, - "TextureAspect.all": 0, - "TextureAspect.depth-only": 2, - "TextureAspect.stencil-only": 1, - "TextureDimension.1d": 0, - "TextureDimension.2d": 1, - "TextureDimension.3d": 2, + "TextureAspect.all": 1, + "TextureAspect.depth-only": 3, + "TextureAspect.stencil-only": 2, + "TextureDimension.1d": 1, + "TextureDimension.2d": 2, + "TextureDimension.3d": 3, "TextureFormat.astc-10x10-unorm": 90, "TextureFormat.astc-10x10-unorm-srgb": 91, "TextureFormat.astc-10x5-unorm": 84, @@ -199,49 +206,49 @@ "TextureFormat.rgba8unorm": 18, "TextureFormat.rgba8unorm-srgb": 19, "TextureFormat.stencil8": 38, - "TextureSampleType.depth": 3, - "TextureSampleType.float": 1, - "TextureSampleType.sint": 4, - "TextureSampleType.uint": 5, - "TextureSampleType.unfilterable-float": 2, + "TextureSampleType.depth": 4, + "TextureSampleType.float": 2, + "TextureSampleType.sint": 5, + "TextureSampleType.uint": 6, + "TextureSampleType.unfilterable-float": 3, "TextureViewDimension.1d": 1, "TextureViewDimension.2d": 2, "TextureViewDimension.2d-array": 3, "TextureViewDimension.3d": 6, "TextureViewDimension.cube": 4, "TextureViewDimension.cube-array": 5, - "VertexFormat.float16x2": 17, - "VertexFormat.float16x4": 18, - "VertexFormat.float32": 19, - "VertexFormat.float32x2": 20, - "VertexFormat.float32x3": 21, - "VertexFormat.float32x4": 22, - "VertexFormat.sint16x2": 11, - "VertexFormat.sint16x4": 12, - "VertexFormat.sint32": 27, - "VertexFormat.sint32x2": 28, - "VertexFormat.sint32x3": 29, - "VertexFormat.sint32x4": 30, - "VertexFormat.sint8x2": 3, - "VertexFormat.sint8x4": 4, - "VertexFormat.snorm16x2": 15, - "VertexFormat.snorm16x4": 16, - "VertexFormat.snorm8x2": 7, - "VertexFormat.snorm8x4": 8, - "VertexFormat.uint16x2": 9, - "VertexFormat.uint16x4": 10, - "VertexFormat.uint32": 23, - "VertexFormat.uint32x2": 24, - "VertexFormat.uint32x3": 25, - "VertexFormat.uint32x4": 26, - "VertexFormat.uint8x2": 1, - "VertexFormat.uint8x4": 2, - "VertexFormat.unorm16x2": 13, - "VertexFormat.unorm16x4": 14, - "VertexFormat.unorm8x2": 5, - "VertexFormat.unorm8x4": 6, - "VertexStepMode.instance": 1, - "VertexStepMode.vertex": 0, + "VertexFormat.float16x2": 26, + "VertexFormat.float16x4": 27, + "VertexFormat.float32": 28, + "VertexFormat.float32x2": 29, + "VertexFormat.float32x3": 30, + "VertexFormat.float32x4": 31, + "VertexFormat.sint16x2": 17, + "VertexFormat.sint16x4": 18, + "VertexFormat.sint32": 36, + "VertexFormat.sint32x2": 37, + "VertexFormat.sint32x3": 38, + "VertexFormat.sint32x4": 39, + "VertexFormat.sint8x2": 5, + "VertexFormat.sint8x4": 6, + "VertexFormat.snorm16x2": 23, + "VertexFormat.snorm16x4": 24, + "VertexFormat.snorm8x2": 11, + "VertexFormat.snorm8x4": 12, + "VertexFormat.uint16x2": 14, + "VertexFormat.uint16x4": 15, + "VertexFormat.uint32": 32, + "VertexFormat.uint32x2": 33, + "VertexFormat.uint32x3": 34, + "VertexFormat.uint32x4": 35, + "VertexFormat.uint8x2": 2, + "VertexFormat.uint8x4": 3, + "VertexFormat.unorm16x2": 20, + "VertexFormat.unorm16x4": 21, + "VertexFormat.unorm8x2": 8, + "VertexFormat.unorm8x4": 9, + "VertexStepMode.instance": 3, + "VertexStepMode.vertex": 2, } # There are 47 struct-field enum mappings @@ -255,7 +262,6 @@ "CompilationMessage.type": "CompilationMessageType", "DepthStencilState.depthCompare": "CompareFunction", "DepthStencilState.format": "TextureFormat", - "ImageCopyTexture.aspect": "TextureAspect", "PrimitiveState.cullMode": "CullMode", "PrimitiveState.frontFace": "FrontFace", "PrimitiveState.stripIndexFormat": "IndexFormat", @@ -285,6 +291,7 @@ "StorageTextureBindingLayout.format": "TextureFormat", "StorageTextureBindingLayout.viewDimension": "TextureViewDimension", "SurfaceConfiguration.format": "TextureFormat", + "TexelCopyTextureInfo.aspect": "TextureAspect", "TextureBindingLayout.sampleType": "TextureSampleType", "TextureBindingLayout.viewDimension": "TextureViewDimension", "TextureDescriptor.dimension": "TextureDimension", @@ -324,6 +331,7 @@ "mappable-primary-buffers": 196622, "buffer-binding-array": 196623, "uniform-buffer-and-storage-texture-array-non-uniform-indexing": 196624, + "spirv-shader-passthrough": 196631, "vertex-attribute64bit": 196633, "texture-format-nv12": 196634, "ray-tracing-acceleration-structure": 196635, @@ -332,6 +340,11 @@ "shader-i16": 196638, "shader-primitive-index": 196639, "shader-early-depth-test": 196640, + "subgroup": 196641, + "subgroup-vertex": 196642, + "subgroup-barrier": 196643, + "timestamp-query-inside-encoders": 196644, + "timestamp-query-inside-passes": 196645, }, "PipelineStatisticName": { "vertex-shader-invocations": 0, @@ -355,22 +368,23 @@ 8: "OpenGLES", }, "AdapterType": { - 0: "DiscreteGPU", - 1: "IntegratedGPU", - 2: "CPU", - 3: "Unknown", + 1: "DiscreteGPU", + 2: "IntegratedGPU", + 3: "CPU", + 4: "Unknown", }, "ErrorType": { - 0: "NoError", - 1: "Validation", - 2: "OutOfMemory", - 3: "Internal", - 4: "Unknown", - 5: "DeviceLost", + 1: "NoError", + 2: "Validation", + 3: "OutOfMemory", + 4: "Internal", + 5: "Unknown", }, "DeviceLostReason": { 1: "unknown", 2: "destroyed", + 3: "InstanceDropped", + 4: "FailedCreation", }, "TextureFormat": { 0: "Undefined", @@ -471,15 +485,17 @@ 95: "astc-12x12-unorm-srgb", }, "TextureDimension": { - 0: "1d", - 1: "2d", - 2: "3d", + 0: "Undefined", + 1: "1d", + 2: "2d", + 3: "3d", }, "PresentMode": { - 0: "Fifo", - 1: "FifoRelaxed", - 2: "Immediate", - 3: "Mailbox", + 0: "Undefined", + 1: "Fifo", + 2: "FifoRelaxed", + 3: "Immediate", + 4: "Mailbox", }, "CompositeAlphaMode": { 0: "Auto", diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index 279fba39..db2393a5 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -2,8 +2,8 @@ ## Preparing * The webgpu.idl defines 37 classes with 75 functions * The webgpu.idl defines 5 flags, 34 enums, 60 structs -* The wgpu.h defines 199 functions -* The wgpu.h defines 7 flags, 52 enums, 93 structs +* The wgpu.h defines 211 functions +* The wgpu.h defines 7 flags, 58 enums, 101 structs ## Updating API * Wrote 5 flags to flags.py * Wrote 34 enums to enums.py @@ -12,7 +12,7 @@ * Diffs for GPU: add enumerate_adapters_async, add enumerate_adapters_sync, change get_preferred_canvas_format, change request_adapter_async, change request_adapter_sync * Diffs for GPUCanvasContext: add get_preferred_format, add present * Diffs for GPUAdapter: add summary -* Diffs for GPUDevice: add adapter, add create_buffer_with_data, hide import_external_texture, hide lost_async, hide lost_sync, hide onuncapturederror, hide pop_error_scope_async, hide pop_error_scope_sync, hide push_error_scope +* Diffs for GPUDevice: add adapter, add create_buffer_with_data, change create_shader_module, hide import_external_texture, hide lost_async, hide lost_sync, hide onuncapturederror, hide pop_error_scope_async, hide pop_error_scope_sync, hide push_error_scope * Diffs for GPUBuffer: add read_mapped, add write_mapped, hide get_mapped_range * Diffs for GPUTexture: add size * Diffs for GPUTextureView: add size, add texture @@ -22,19 +22,12 @@ ### Patching API for backends/wgpu_native/_api.py * Validated 37 classes, 121 methods, 0 properties ## Validating backends/wgpu_native/_api.py -* Enum field FeatureName.texture-compression-bc-sliced-3d missing in wgpu.h -* Enum field FeatureName.clip-distances missing in wgpu.h -* Enum field FeatureName.dual-source-blending missing in wgpu.h * Enum PipelineErrorReason missing in wgpu.h * Enum AutoLayoutMode missing in wgpu.h -* Enum field BlendFactor.src1 missing in wgpu.h -* Enum field BlendFactor.one-minus-src1 missing in wgpu.h -* Enum field BlendFactor.src1-alpha missing in wgpu.h -* Enum field BlendFactor.one-minus-src1-alpha missing in wgpu.h * Enum field VertexFormat.unorm10-10-10-2 missing in wgpu.h * Enum CanvasAlphaMode missing in wgpu.h * Enum CanvasToneMappingMode missing in wgpu.h -* Wrote 236 enum mappings and 47 struct-field mappings to wgpu_native/_mappings.py -* Validated 142 C function calls -* Not using 64 C functions -* Validated 82 C structs +* Wrote 243 enum mappings and 47 struct-field mappings to wgpu_native/_mappings.py +* Validated 146 C function calls +* Not using 74 C functions +* Validated 95 C structs diff --git a/wgpu/resources/webgpu.h b/wgpu/resources/webgpu.h index cb423fc0..084ac1bb 100644 --- a/wgpu/resources/webgpu.h +++ b/wgpu/resources/webgpu.h @@ -1,6 +1,6 @@ /** * Copyright 2019-2023 WebGPU-Native developers - * + * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,7 +8,7 @@ /** * \mainpage - * + * * **Important:** *This documentation is a Work In Progress.* * * This is the home of WebGPU C API specification. We define here the standard @@ -55,42 +55,91 @@ #include #include +#define _wgpu_COMMA , +#if defined(__cplusplus) +# if __cplusplus >= 201103L +# define _wgpu_MAKE_INIT_STRUCT(type, value) (type value) +# else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +# endif +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define _wgpu_MAKE_INIT_STRUCT(type, value) ((type) value) +#else +# define _wgpu_MAKE_INIT_STRUCT(type, value) value +#endif + /** * \defgroup Constants * \brief Constants. - * + * * @{ */ -#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL) -#define WGPU_DEPTH_SLICE_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL) -#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL) -#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL) -#define WGPU_QUERY_SET_INDEX_UNDEFINED (0xffffffffUL) +#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX) +#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) +#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX) +#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX) +#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX) #define WGPU_WHOLE_MAP_SIZE (SIZE_MAX) -#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL) +#define WGPU_WHOLE_SIZE (UINT64_MAX) /** @} */ /** - * \defgroup Typedefs - * \brief Utility typedefs. - * + * \defgroup UtilityTypes Utility Types + * * @{ */ -typedef uint32_t WGPUFlags; +typedef uint64_t WGPUFlags; typedef uint32_t WGPUBool; +/** + * Nullable value defining a pointer+length view into a UTF-8 encoded string. + * + * Values passed into the API may use the special length value @ref WGPU_STRLEN + * to indicate a null-terminated string. + * Non-null values passed out of the API (for example as callback arguments) + * always provide an explicit length and **may or may not be null-terminated**. + * + * Some inputs to the API accept null values. Those which do not accept null + * values "default" to the empty string when null values are passed. + * + * Values are encoded as follows: + * - `{NULL, WGPU_STRLEN}`: the null value. + * - `{non_null_pointer, WGPU_STRLEN}`: a null-terminated string view. + * - `{any, 0}`: the empty string. + * - `{NULL, non_zero_length}`: not allowed (null dereference). + * - `{non_null_pointer, non_zero_length}`: an explictly-sized string view with + * size `non_zero_length` (in bytes). + * + * For info on how this is used in various places, see \ref Strings. + */ +typedef struct WGPUStringView { + char const * WGPU_NULLABLE data; + size_t length; +} WGPUStringView; + +/** + * Sentinel value used in @ref WGPUStringView to indicate that the pointer + * is to a null-terminated string, rather than an explicitly-sized string. + */ +#define WGPU_STRLEN SIZE_MAX + +#define WGPU_STRING_VIEW_INIT _wgpu_MAKE_INIT_STRUCT(WGPUStringView, { \ + /*.data=*/NULL _wgpu_COMMA \ + /*.length=*/WGPU_STRLEN _wgpu_COMMA \ +}) + /** @} */ /** * \defgroup Objects * \brief Opaque, non-dispatchable handles to WebGPU objects. - * + * * @{ */ typedef struct WGPUAdapterImpl* WGPUAdapter WGPU_OBJECT_ATTRIBUTE; @@ -112,6 +161,9 @@ typedef struct WGPURenderPassEncoderImpl* WGPURenderPassEncoder WGPU_OBJECT_ATTR typedef struct WGPURenderPipelineImpl* WGPURenderPipeline WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUSamplerImpl* WGPUSampler WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUShaderModuleImpl* WGPUShaderModule WGPU_OBJECT_ATTRIBUTE; +/** + * An object used to continuously present image data to the user, see @ref Surfaces for more details. + */ typedef struct WGPUSurfaceImpl* WGPUSurface WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureImpl* WGPUTexture WGPU_OBJECT_ATTRIBUTE; typedef struct WGPUTextureViewImpl* WGPUTextureView WGPU_OBJECT_ATTRIBUTE; @@ -131,43 +183,43 @@ struct WGPUCompilationMessage; struct WGPUComputePassTimestampWrites; struct WGPUConstantEntry; struct WGPUExtent3D; -struct WGPUInstanceDescriptor; +struct WGPUFuture; +struct WGPUInstanceCapabilities; struct WGPULimits; struct WGPUMultisampleState; struct WGPUOrigin3D; struct WGPUPipelineLayoutDescriptor; -struct WGPUPrimitiveDepthClipControl; struct WGPUPrimitiveState; struct WGPUQuerySetDescriptor; struct WGPUQueueDescriptor; struct WGPURenderBundleDescriptor; struct WGPURenderBundleEncoderDescriptor; struct WGPURenderPassDepthStencilAttachment; -struct WGPURenderPassDescriptorMaxDrawCount; +struct WGPURenderPassMaxDrawCount; struct WGPURenderPassTimestampWrites; struct WGPURequestAdapterOptions; struct WGPUSamplerBindingLayout; struct WGPUSamplerDescriptor; -struct WGPUShaderModuleCompilationHint; -struct WGPUShaderModuleSPIRVDescriptor; -struct WGPUShaderModuleWGSLDescriptor; +struct WGPUShaderModuleDescriptor; +struct WGPUShaderSourceSPIRV; +struct WGPUShaderSourceWGSL; struct WGPUStencilFaceState; struct WGPUStorageTextureBindingLayout; +struct WGPUSupportedFeatures; +struct WGPUSupportedWGSLLanguageFeatures; struct WGPUSurfaceCapabilities; struct WGPUSurfaceConfiguration; struct WGPUSurfaceDescriptor; -struct WGPUSurfaceDescriptorFromAndroidNativeWindow; -struct WGPUSurfaceDescriptorFromCanvasHTMLSelector; -struct WGPUSurfaceDescriptorFromMetalLayer; -struct WGPUSurfaceDescriptorFromWaylandSurface; -struct WGPUSurfaceDescriptorFromWindowsHWND; -struct WGPUSurfaceDescriptorFromXcbWindow; -struct WGPUSurfaceDescriptorFromXlibWindow; +struct WGPUSurfaceSourceAndroidNativeWindow; +struct WGPUSurfaceSourceMetalLayer; +struct WGPUSurfaceSourceWaylandSurface; +struct WGPUSurfaceSourceWindowsHWND; +struct WGPUSurfaceSourceXCBWindow; +struct WGPUSurfaceSourceXlibWindow; struct WGPUSurfaceTexture; +struct WGPUTexelCopyBufferLayout; struct WGPUTextureBindingLayout; -struct WGPUTextureDataLayout; struct WGPUTextureViewDescriptor; -struct WGPUUncapturedErrorCallbackInfo; struct WGPUVertexAttribute; struct WGPUBindGroupDescriptor; struct WGPUBindGroupLayoutEntry; @@ -175,47 +227,67 @@ struct WGPUBlendState; struct WGPUCompilationInfo; struct WGPUComputePassDescriptor; struct WGPUDepthStencilState; -struct WGPUImageCopyBuffer; -struct WGPUImageCopyTexture; +struct WGPUDeviceDescriptor; +struct WGPUFutureWaitInfo; +struct WGPUInstanceDescriptor; struct WGPUProgrammableStageDescriptor; struct WGPURenderPassColorAttachment; -struct WGPURequiredLimits; -struct WGPUShaderModuleDescriptor; -struct WGPUSupportedLimits; +struct WGPUTexelCopyBufferInfo; +struct WGPUTexelCopyTextureInfo; struct WGPUTextureDescriptor; struct WGPUVertexBufferLayout; struct WGPUBindGroupLayoutDescriptor; struct WGPUColorTargetState; struct WGPUComputePipelineDescriptor; -struct WGPUDeviceDescriptor; struct WGPURenderPassDescriptor; struct WGPUVertexState; struct WGPUFragmentState; struct WGPURenderPipelineDescriptor; +// Callback info structure forward declarations +struct WGPUBufferMapCallbackInfo; +struct WGPUCompilationInfoCallbackInfo; +struct WGPUCreateComputePipelineAsyncCallbackInfo; +struct WGPUCreateRenderPipelineAsyncCallbackInfo; +struct WGPUDeviceLostCallbackInfo; +struct WGPUPopErrorScopeCallbackInfo; +struct WGPUQueueWorkDoneCallbackInfo; +struct WGPURequestAdapterCallbackInfo; +struct WGPURequestDeviceCallbackInfo; +struct WGPUUncapturedErrorCallbackInfo; + /** * \defgroup Enumerations * \brief Enums. - * + * * @{ */ typedef enum WGPUAdapterType { - WGPUAdapterType_DiscreteGPU = 0x00000000, - WGPUAdapterType_IntegratedGPU = 0x00000001, - WGPUAdapterType_CPU = 0x00000002, - WGPUAdapterType_Unknown = 0x00000003, + WGPUAdapterType_DiscreteGPU = 0x00000001, + WGPUAdapterType_IntegratedGPU = 0x00000002, + WGPUAdapterType_CPU = 0x00000003, + WGPUAdapterType_Unknown = 0x00000004, WGPUAdapterType_Force32 = 0x7FFFFFFF } WGPUAdapterType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUAddressMode { - WGPUAddressMode_Repeat = 0x00000000, - WGPUAddressMode_MirrorRepeat = 0x00000001, - WGPUAddressMode_ClampToEdge = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUAddressMode_Undefined = 0x00000000, + WGPUAddressMode_ClampToEdge = 0x00000001, + WGPUAddressMode_Repeat = 0x00000002, + WGPUAddressMode_MirrorRepeat = 0x00000003, WGPUAddressMode_Force32 = 0x7FFFFFFF } WGPUAddressMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBackendType { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUBackendType_Undefined = 0x00000000, WGPUBackendType_Null = 0x00000001, WGPUBackendType_WebGPU = 0x00000002, @@ -229,165 +301,277 @@ typedef enum WGPUBackendType { } WGPUBackendType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendFactor { - WGPUBlendFactor_Zero = 0x00000000, - WGPUBlendFactor_One = 0x00000001, - WGPUBlendFactor_Src = 0x00000002, - WGPUBlendFactor_OneMinusSrc = 0x00000003, - WGPUBlendFactor_SrcAlpha = 0x00000004, - WGPUBlendFactor_OneMinusSrcAlpha = 0x00000005, - WGPUBlendFactor_Dst = 0x00000006, - WGPUBlendFactor_OneMinusDst = 0x00000007, - WGPUBlendFactor_DstAlpha = 0x00000008, - WGPUBlendFactor_OneMinusDstAlpha = 0x00000009, - WGPUBlendFactor_SrcAlphaSaturated = 0x0000000A, - WGPUBlendFactor_Constant = 0x0000000B, - WGPUBlendFactor_OneMinusConstant = 0x0000000C, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendFactor_Undefined = 0x00000000, + WGPUBlendFactor_Zero = 0x00000001, + WGPUBlendFactor_One = 0x00000002, + WGPUBlendFactor_Src = 0x00000003, + WGPUBlendFactor_OneMinusSrc = 0x00000004, + WGPUBlendFactor_SrcAlpha = 0x00000005, + WGPUBlendFactor_OneMinusSrcAlpha = 0x00000006, + WGPUBlendFactor_Dst = 0x00000007, + WGPUBlendFactor_OneMinusDst = 0x00000008, + WGPUBlendFactor_DstAlpha = 0x00000009, + WGPUBlendFactor_OneMinusDstAlpha = 0x0000000A, + WGPUBlendFactor_SrcAlphaSaturated = 0x0000000B, + WGPUBlendFactor_Constant = 0x0000000C, + WGPUBlendFactor_OneMinusConstant = 0x0000000D, + WGPUBlendFactor_Src1 = 0x0000000E, + WGPUBlendFactor_OneMinusSrc1 = 0x0000000F, + WGPUBlendFactor_Src1Alpha = 0x00000010, + WGPUBlendFactor_OneMinusSrc1Alpha = 0x00000011, WGPUBlendFactor_Force32 = 0x7FFFFFFF } WGPUBlendFactor WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBlendOperation { - WGPUBlendOperation_Add = 0x00000000, - WGPUBlendOperation_Subtract = 0x00000001, - WGPUBlendOperation_ReverseSubtract = 0x00000002, - WGPUBlendOperation_Min = 0x00000003, - WGPUBlendOperation_Max = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBlendOperation_Undefined = 0x00000000, + WGPUBlendOperation_Add = 0x00000001, + WGPUBlendOperation_Subtract = 0x00000002, + WGPUBlendOperation_ReverseSubtract = 0x00000003, + WGPUBlendOperation_Min = 0x00000004, + WGPUBlendOperation_Max = 0x00000005, WGPUBlendOperation_Force32 = 0x7FFFFFFF } WGPUBlendOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUBufferBindingType { - WGPUBufferBindingType_Undefined = 0x00000000, - WGPUBufferBindingType_Uniform = 0x00000001, - WGPUBufferBindingType_Storage = 0x00000002, - WGPUBufferBindingType_ReadOnlyStorage = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUBufferBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUBufferBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUBufferBindingType_Undefined = 0x00000001, + WGPUBufferBindingType_Uniform = 0x00000002, + WGPUBufferBindingType_Storage = 0x00000003, + WGPUBufferBindingType_ReadOnlyStorage = 0x00000004, WGPUBufferBindingType_Force32 = 0x7FFFFFFF } WGPUBufferBindingType WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUBufferMapAsyncStatus { - WGPUBufferMapAsyncStatus_Success = 0x00000000, - WGPUBufferMapAsyncStatus_ValidationError = 0x00000001, - WGPUBufferMapAsyncStatus_Unknown = 0x00000002, - WGPUBufferMapAsyncStatus_DeviceLost = 0x00000003, - WGPUBufferMapAsyncStatus_DestroyedBeforeCallback = 0x00000004, - WGPUBufferMapAsyncStatus_UnmappedBeforeCallback = 0x00000005, - WGPUBufferMapAsyncStatus_MappingAlreadyPending = 0x00000006, - WGPUBufferMapAsyncStatus_OffsetOutOfRange = 0x00000007, - WGPUBufferMapAsyncStatus_SizeOutOfRange = 0x00000008, - WGPUBufferMapAsyncStatus_Force32 = 0x7FFFFFFF -} WGPUBufferMapAsyncStatus WGPU_ENUM_ATTRIBUTE; - typedef enum WGPUBufferMapState { - WGPUBufferMapState_Unmapped = 0x00000000, - WGPUBufferMapState_Pending = 0x00000001, - WGPUBufferMapState_Mapped = 0x00000002, + WGPUBufferMapState_Unmapped = 0x00000001, + WGPUBufferMapState_Pending = 0x00000002, + WGPUBufferMapState_Mapped = 0x00000003, WGPUBufferMapState_Force32 = 0x7FFFFFFF } WGPUBufferMapState WGPU_ENUM_ATTRIBUTE; +/** + * The callback mode controls how a callback for an asynchronous operation may be fired. See @ref Asynchronous-Operations for how these are used. + */ +typedef enum WGPUCallbackMode { + /** + * `0x00000001`. + * Callbacks created with `WGPUCallbackMode_WaitAnyOnly`: + * - fire when the asynchronous operation's future is passed to a call to `::wgpuInstanceWaitAny` + * AND the operation has already completed or it completes inside the call to `::wgpuInstanceWaitAny`. + */ + WGPUCallbackMode_WaitAnyOnly = 0x00000001, + /** + * `0x00000002`. + * Callbacks created with `WGPUCallbackMode_AllowProcessEvents`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_WaitAnyOnly` + * - fire inside a call to `::wgpuInstanceProcessEvents` if the asynchronous operation is complete. + */ + WGPUCallbackMode_AllowProcessEvents = 0x00000002, + /** + * `0x00000003`. + * Callbacks created with `WGPUCallbackMode_AllowSpontaneous`: + * - fire for the same reasons as callbacks created with `WGPUCallbackMode_AllowProcessEvents` + * - **may** fire spontaneously on an arbitrary or application thread, when the WebGPU implementations discovers that the asynchronous operation is complete. + * + * Implementations _should_ fire spontaneous callbacks as soon as possible. + * + * @note Because spontaneous callbacks may fire at an arbitrary time on an arbitrary thread, applications should take extra care when acquiring locks or mutating state inside the callback. It undefined behavior to re-entrantly call into the webgpu.h API if the callback fires while inside the callstack of another webgpu.h function that is not `wgpuInstanceWaitAny` or `wgpuInstanceProcessEvents`. + */ + WGPUCallbackMode_AllowSpontaneous = 0x00000003, + WGPUCallbackMode_Force32 = 0x7FFFFFFF +} WGPUCallbackMode WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUCompareFunction { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUCompareFunction_Undefined = 0x00000000, WGPUCompareFunction_Never = 0x00000001, WGPUCompareFunction_Less = 0x00000002, - WGPUCompareFunction_LessEqual = 0x00000003, - WGPUCompareFunction_Greater = 0x00000004, - WGPUCompareFunction_GreaterEqual = 0x00000005, - WGPUCompareFunction_Equal = 0x00000006, - WGPUCompareFunction_NotEqual = 0x00000007, + WGPUCompareFunction_Equal = 0x00000003, + WGPUCompareFunction_LessEqual = 0x00000004, + WGPUCompareFunction_Greater = 0x00000005, + WGPUCompareFunction_NotEqual = 0x00000006, + WGPUCompareFunction_GreaterEqual = 0x00000007, WGPUCompareFunction_Always = 0x00000008, WGPUCompareFunction_Force32 = 0x7FFFFFFF } WGPUCompareFunction WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationInfoRequestStatus { - WGPUCompilationInfoRequestStatus_Success = 0x00000000, - WGPUCompilationInfoRequestStatus_Error = 0x00000001, - WGPUCompilationInfoRequestStatus_DeviceLost = 0x00000002, - WGPUCompilationInfoRequestStatus_Unknown = 0x00000003, + WGPUCompilationInfoRequestStatus_Success = 0x00000001, + WGPUCompilationInfoRequestStatus_InstanceDropped = 0x00000002, + WGPUCompilationInfoRequestStatus_Error = 0x00000003, + WGPUCompilationInfoRequestStatus_Unknown = 0x00000004, WGPUCompilationInfoRequestStatus_Force32 = 0x7FFFFFFF } WGPUCompilationInfoRequestStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCompilationMessageType { - WGPUCompilationMessageType_Error = 0x00000000, - WGPUCompilationMessageType_Warning = 0x00000001, - WGPUCompilationMessageType_Info = 0x00000002, + WGPUCompilationMessageType_Error = 0x00000001, + WGPUCompilationMessageType_Warning = 0x00000002, + WGPUCompilationMessageType_Info = 0x00000003, WGPUCompilationMessageType_Force32 = 0x7FFFFFFF } WGPUCompilationMessageType WGPU_ENUM_ATTRIBUTE; +/** + * Describes how frames are composited with other contents on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUCompositeAlphaMode { + /** + * `0x00000000`. + * Lets the WebGPU implementation choose the best mode (supported, and with the best performance) between @ref WGPUCompositeAlphaMode_Opaque or @ref WGPUCompositeAlphaMode_Inherit. + */ WGPUCompositeAlphaMode_Auto = 0x00000000, + /** + * `0x00000001`. + * The alpha component of the image is ignored and teated as if it is always 1.0. + */ WGPUCompositeAlphaMode_Opaque = 0x00000001, + /** + * `0x00000002`. + * The alpha component is respected and non-alpha components are assumed to be already multiplied with the alpha component. For example, (0.5, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Premultiplied = 0x00000002, + /** + * `0x00000003`. + * The alpha component is respected and non-alpha components are assumed to NOT be already multiplied with the alpha component. For example, (1.0, 0, 0, 0.5) is semi-transparent bright red. + */ WGPUCompositeAlphaMode_Unpremultiplied = 0x00000003, + /** + * `0x00000004`. + * The handling of the alpha component is unknown to WebGPU and should be handled by the application using system-specific APIs. This mode may be unavailable (for example on Wasm). + */ WGPUCompositeAlphaMode_Inherit = 0x00000004, WGPUCompositeAlphaMode_Force32 = 0x7FFFFFFF } WGPUCompositeAlphaMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCreatePipelineAsyncStatus { - WGPUCreatePipelineAsyncStatus_Success = 0x00000000, - WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000001, - WGPUCreatePipelineAsyncStatus_InternalError = 0x00000002, - WGPUCreatePipelineAsyncStatus_DeviceLost = 0x00000003, - WGPUCreatePipelineAsyncStatus_DeviceDestroyed = 0x00000004, + WGPUCreatePipelineAsyncStatus_Success = 0x00000001, + WGPUCreatePipelineAsyncStatus_InstanceDropped = 0x00000002, + WGPUCreatePipelineAsyncStatus_ValidationError = 0x00000003, + WGPUCreatePipelineAsyncStatus_InternalError = 0x00000004, WGPUCreatePipelineAsyncStatus_Unknown = 0x00000005, WGPUCreatePipelineAsyncStatus_Force32 = 0x7FFFFFFF } WGPUCreatePipelineAsyncStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUCullMode { - WGPUCullMode_None = 0x00000000, - WGPUCullMode_Front = 0x00000001, - WGPUCullMode_Back = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUCullMode_Undefined = 0x00000000, + WGPUCullMode_None = 0x00000001, + WGPUCullMode_Front = 0x00000002, + WGPUCullMode_Back = 0x00000003, WGPUCullMode_Force32 = 0x7FFFFFFF } WGPUCullMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUDeviceLostReason { WGPUDeviceLostReason_Unknown = 0x00000001, WGPUDeviceLostReason_Destroyed = 0x00000002, + WGPUDeviceLostReason_InstanceDropped = 0x00000003, + WGPUDeviceLostReason_FailedCreation = 0x00000004, WGPUDeviceLostReason_Force32 = 0x7FFFFFFF } WGPUDeviceLostReason WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorFilter { - WGPUErrorFilter_Validation = 0x00000000, - WGPUErrorFilter_OutOfMemory = 0x00000001, - WGPUErrorFilter_Internal = 0x00000002, + WGPUErrorFilter_Validation = 0x00000001, + WGPUErrorFilter_OutOfMemory = 0x00000002, + WGPUErrorFilter_Internal = 0x00000003, WGPUErrorFilter_Force32 = 0x7FFFFFFF } WGPUErrorFilter WGPU_ENUM_ATTRIBUTE; typedef enum WGPUErrorType { - WGPUErrorType_NoError = 0x00000000, - WGPUErrorType_Validation = 0x00000001, - WGPUErrorType_OutOfMemory = 0x00000002, - WGPUErrorType_Internal = 0x00000003, - WGPUErrorType_Unknown = 0x00000004, - WGPUErrorType_DeviceLost = 0x00000005, + WGPUErrorType_NoError = 0x00000001, + WGPUErrorType_Validation = 0x00000002, + WGPUErrorType_OutOfMemory = 0x00000003, + WGPUErrorType_Internal = 0x00000004, + WGPUErrorType_Unknown = 0x00000005, WGPUErrorType_Force32 = 0x7FFFFFFF } WGPUErrorType WGPU_ENUM_ATTRIBUTE; +/** + * See @ref WGPURequestAdapterOptions::featureLevel. + */ +typedef enum WGPUFeatureLevel { + /** + * `0x00000001`. + * "Compatibility" profile which can be supported on OpenGL ES 3.1. + */ + WGPUFeatureLevel_Compatibility = 0x00000001, + /** + * `0x00000002`. + * "Core" profile which can be supported on Vulkan/Metal/D3D12. + */ + WGPUFeatureLevel_Core = 0x00000002, + WGPUFeatureLevel_Force32 = 0x7FFFFFFF +} WGPUFeatureLevel WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUFeatureName { WGPUFeatureName_Undefined = 0x00000000, WGPUFeatureName_DepthClipControl = 0x00000001, WGPUFeatureName_Depth32FloatStencil8 = 0x00000002, WGPUFeatureName_TimestampQuery = 0x00000003, WGPUFeatureName_TextureCompressionBC = 0x00000004, - WGPUFeatureName_TextureCompressionETC2 = 0x00000005, - WGPUFeatureName_TextureCompressionASTC = 0x00000006, - WGPUFeatureName_IndirectFirstInstance = 0x00000007, - WGPUFeatureName_ShaderF16 = 0x00000008, - WGPUFeatureName_RG11B10UfloatRenderable = 0x00000009, - WGPUFeatureName_BGRA8UnormStorage = 0x0000000A, - WGPUFeatureName_Float32Filterable = 0x0000000B, + WGPUFeatureName_TextureCompressionBCSliced3D = 0x00000005, + WGPUFeatureName_TextureCompressionETC2 = 0x00000006, + WGPUFeatureName_TextureCompressionASTC = 0x00000007, + WGPUFeatureName_TextureCompressionASTCSliced3D = 0x00000008, + WGPUFeatureName_IndirectFirstInstance = 0x00000009, + WGPUFeatureName_ShaderF16 = 0x0000000A, + WGPUFeatureName_RG11B10UfloatRenderable = 0x0000000B, + WGPUFeatureName_BGRA8UnormStorage = 0x0000000C, + WGPUFeatureName_Float32Filterable = 0x0000000D, + WGPUFeatureName_Float32Blendable = 0x0000000E, + WGPUFeatureName_ClipDistances = 0x0000000F, + WGPUFeatureName_DualSourceBlending = 0x00000010, WGPUFeatureName_Force32 = 0x7FFFFFFF } WGPUFeatureName WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFilterMode { - WGPUFilterMode_Nearest = 0x00000000, - WGPUFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFilterMode_Undefined = 0x00000000, + WGPUFilterMode_Nearest = 0x00000001, + WGPUFilterMode_Linear = 0x00000002, WGPUFilterMode_Force32 = 0x7FFFFFFF } WGPUFilterMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUFrontFace { - WGPUFrontFace_CCW = 0x00000000, - WGPUFrontFace_CW = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUFrontFace_Undefined = 0x00000000, + WGPUFrontFace_CCW = 0x00000001, + WGPUFrontFace_CW = 0x00000002, WGPUFrontFace_Force32 = 0x7FFFFFFF } WGPUFrontFace WGPU_ENUM_ATTRIBUTE; typedef enum WGPUIndexFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUIndexFormat_Undefined = 0x00000000, WGPUIndexFormat_Uint16 = 0x00000001, WGPUIndexFormat_Uint32 = 0x00000002, @@ -395,147 +579,318 @@ typedef enum WGPUIndexFormat { } WGPUIndexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPULoadOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPULoadOp_Undefined = 0x00000000, - WGPULoadOp_Clear = 0x00000001, - WGPULoadOp_Load = 0x00000002, + WGPULoadOp_Load = 0x00000001, + WGPULoadOp_Clear = 0x00000002, WGPULoadOp_Force32 = 0x7FFFFFFF } WGPULoadOp WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUMapAsyncStatus { + WGPUMapAsyncStatus_Success = 0x00000001, + WGPUMapAsyncStatus_InstanceDropped = 0x00000002, + WGPUMapAsyncStatus_Error = 0x00000003, + WGPUMapAsyncStatus_Aborted = 0x00000004, + WGPUMapAsyncStatus_Unknown = 0x00000005, + WGPUMapAsyncStatus_Force32 = 0x7FFFFFFF +} WGPUMapAsyncStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUMipmapFilterMode { - WGPUMipmapFilterMode_Nearest = 0x00000000, - WGPUMipmapFilterMode_Linear = 0x00000001, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUMipmapFilterMode_Undefined = 0x00000000, + WGPUMipmapFilterMode_Nearest = 0x00000001, + WGPUMipmapFilterMode_Linear = 0x00000002, WGPUMipmapFilterMode_Force32 = 0x7FFFFFFF } WGPUMipmapFilterMode WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUOptionalBool { + WGPUOptionalBool_False = 0x00000000, + WGPUOptionalBool_True = 0x00000001, + WGPUOptionalBool_Undefined = 0x00000002, + WGPUOptionalBool_Force32 = 0x7FFFFFFF +} WGPUOptionalBool WGPU_ENUM_ATTRIBUTE; + +typedef enum WGPUPopErrorScopeStatus { + /** + * `0x00000001`. + * The error scope stack was successfully popped and a result was reported. + */ + WGPUPopErrorScopeStatus_Success = 0x00000001, + WGPUPopErrorScopeStatus_InstanceDropped = 0x00000002, + /** + * `0x00000003`. + * The error scope stack could not be popped, because it was empty. + */ + WGPUPopErrorScopeStatus_EmptyStack = 0x00000003, + WGPUPopErrorScopeStatus_Force32 = 0x7FFFFFFF +} WGPUPopErrorScopeStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUPowerPreference { + /** + * `0x00000000`. + * No preference. (See also @ref SentinelValues.) + */ WGPUPowerPreference_Undefined = 0x00000000, WGPUPowerPreference_LowPower = 0x00000001, WGPUPowerPreference_HighPerformance = 0x00000002, WGPUPowerPreference_Force32 = 0x7FFFFFFF } WGPUPowerPreference WGPU_ENUM_ATTRIBUTE; +/** + * Describes when and in which order frames are presented on the screen when `::wgpuSurfacePresent` is called. + */ typedef enum WGPUPresentMode { - WGPUPresentMode_Fifo = 0x00000000, - WGPUPresentMode_FifoRelaxed = 0x00000001, - WGPUPresentMode_Immediate = 0x00000002, - WGPUPresentMode_Mailbox = 0x00000003, + /** + * `0x00000000`. + * Present mode is not specified. Use the default. + */ + WGPUPresentMode_Undefined = 0x00000000, + /** + * `0x00000001`. + * The presentation of the image to the user waits for the next vertical blanking period to update in a first-in, first-out manner. + * Tearing cannot be observed and frame-loop will be limited to the display's refresh rate. + * This is the only mode that's always available. + */ + WGPUPresentMode_Fifo = 0x00000001, + /** + * `0x00000002`. + * The presentation of the image to the user tries to wait for the next vertical blanking period but may decide to not wait if a frame is presented late. + * Tearing can sometimes be observed but late-frame don't produce a full-frame stutter in the presentation. + * This is still a first-in, first-out mechanism so a frame-loop will be limited to the display's refresh rate. + */ + WGPUPresentMode_FifoRelaxed = 0x00000002, + /** + * `0x00000003`. + * The presentation of the image to the user is updated immediately without waiting for a vertical blank. + * Tearing can be observed but latency is minimized. + */ + WGPUPresentMode_Immediate = 0x00000003, + /** + * `0x00000004`. + * The presentation of the image to the user waits for the next vertical blanking period to update to the latest provided image. + * Tearing cannot be observed and a frame-loop is not limited to the display's refresh rate. + */ + WGPUPresentMode_Mailbox = 0x00000004, WGPUPresentMode_Force32 = 0x7FFFFFFF } WGPUPresentMode WGPU_ENUM_ATTRIBUTE; typedef enum WGPUPrimitiveTopology { - WGPUPrimitiveTopology_PointList = 0x00000000, - WGPUPrimitiveTopology_LineList = 0x00000001, - WGPUPrimitiveTopology_LineStrip = 0x00000002, - WGPUPrimitiveTopology_TriangleList = 0x00000003, - WGPUPrimitiveTopology_TriangleStrip = 0x00000004, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUPrimitiveTopology_Undefined = 0x00000000, + WGPUPrimitiveTopology_PointList = 0x00000001, + WGPUPrimitiveTopology_LineList = 0x00000002, + WGPUPrimitiveTopology_LineStrip = 0x00000003, + WGPUPrimitiveTopology_TriangleList = 0x00000004, + WGPUPrimitiveTopology_TriangleStrip = 0x00000005, WGPUPrimitiveTopology_Force32 = 0x7FFFFFFF } WGPUPrimitiveTopology WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueryType { - WGPUQueryType_Occlusion = 0x00000000, - WGPUQueryType_Timestamp = 0x00000001, + WGPUQueryType_Occlusion = 0x00000001, + WGPUQueryType_Timestamp = 0x00000002, WGPUQueryType_Force32 = 0x7FFFFFFF } WGPUQueryType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUQueueWorkDoneStatus { - WGPUQueueWorkDoneStatus_Success = 0x00000000, - WGPUQueueWorkDoneStatus_Error = 0x00000001, - WGPUQueueWorkDoneStatus_Unknown = 0x00000002, - WGPUQueueWorkDoneStatus_DeviceLost = 0x00000003, + WGPUQueueWorkDoneStatus_Success = 0x00000001, + WGPUQueueWorkDoneStatus_InstanceDropped = 0x00000002, + WGPUQueueWorkDoneStatus_Error = 0x00000003, + WGPUQueueWorkDoneStatus_Unknown = 0x00000004, WGPUQueueWorkDoneStatus_Force32 = 0x7FFFFFFF } WGPUQueueWorkDoneStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestAdapterStatus { - WGPURequestAdapterStatus_Success = 0x00000000, - WGPURequestAdapterStatus_Unavailable = 0x00000001, - WGPURequestAdapterStatus_Error = 0x00000002, - WGPURequestAdapterStatus_Unknown = 0x00000003, + WGPURequestAdapterStatus_Success = 0x00000001, + WGPURequestAdapterStatus_InstanceDropped = 0x00000002, + WGPURequestAdapterStatus_Unavailable = 0x00000003, + WGPURequestAdapterStatus_Error = 0x00000004, + WGPURequestAdapterStatus_Unknown = 0x00000005, WGPURequestAdapterStatus_Force32 = 0x7FFFFFFF } WGPURequestAdapterStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPURequestDeviceStatus { - WGPURequestDeviceStatus_Success = 0x00000000, - WGPURequestDeviceStatus_Error = 0x00000001, - WGPURequestDeviceStatus_Unknown = 0x00000002, + WGPURequestDeviceStatus_Success = 0x00000001, + WGPURequestDeviceStatus_InstanceDropped = 0x00000002, + WGPURequestDeviceStatus_Error = 0x00000003, + WGPURequestDeviceStatus_Unknown = 0x00000004, WGPURequestDeviceStatus_Force32 = 0x7FFFFFFF } WGPURequestDeviceStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSType { - WGPUSType_Invalid = 0x00000000, - WGPUSType_SurfaceDescriptorFromMetalLayer = 0x00000001, - WGPUSType_SurfaceDescriptorFromWindowsHWND = 0x00000002, - WGPUSType_SurfaceDescriptorFromXlibWindow = 0x00000003, - WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector = 0x00000004, - WGPUSType_ShaderModuleSPIRVDescriptor = 0x00000005, - WGPUSType_ShaderModuleWGSLDescriptor = 0x00000006, - WGPUSType_PrimitiveDepthClipControl = 0x00000007, - WGPUSType_SurfaceDescriptorFromWaylandSurface = 0x00000008, - WGPUSType_SurfaceDescriptorFromAndroidNativeWindow = 0x00000009, - WGPUSType_SurfaceDescriptorFromXcbWindow = 0x0000000A, - WGPUSType_RenderPassDescriptorMaxDrawCount = 0x0000000F, + WGPUSType_ShaderSourceSPIRV = 0x00000001, + WGPUSType_ShaderSourceWGSL = 0x00000002, + WGPUSType_RenderPassMaxDrawCount = 0x00000003, + WGPUSType_SurfaceSourceMetalLayer = 0x00000004, + WGPUSType_SurfaceSourceWindowsHWND = 0x00000005, + WGPUSType_SurfaceSourceXlibWindow = 0x00000006, + WGPUSType_SurfaceSourceWaylandSurface = 0x00000007, + WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008, + WGPUSType_SurfaceSourceXCBWindow = 0x00000009, WGPUSType_Force32 = 0x7FFFFFFF } WGPUSType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUSamplerBindingType { - WGPUSamplerBindingType_Undefined = 0x00000000, - WGPUSamplerBindingType_Filtering = 0x00000001, - WGPUSamplerBindingType_NonFiltering = 0x00000002, - WGPUSamplerBindingType_Comparison = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUSamplerBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUSamplerBindingType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUSamplerBindingType_Undefined = 0x00000001, + WGPUSamplerBindingType_Filtering = 0x00000002, + WGPUSamplerBindingType_NonFiltering = 0x00000003, + WGPUSamplerBindingType_Comparison = 0x00000004, WGPUSamplerBindingType_Force32 = 0x7FFFFFFF } WGPUSamplerBindingType WGPU_ENUM_ATTRIBUTE; +/** + * Status code returned (synchronously) from many operations. Generally + * indicates an invalid input like an unknown enum value or @ref OutStructChainError. + * Read the function's documentation for specific error conditions. + */ +typedef enum WGPUStatus { + WGPUStatus_Success = 0x00000001, + WGPUStatus_Error = 0x00000002, + WGPUStatus_Force32 = 0x7FFFFFFF +} WGPUStatus WGPU_ENUM_ATTRIBUTE; + typedef enum WGPUStencilOperation { - WGPUStencilOperation_Keep = 0x00000000, - WGPUStencilOperation_Zero = 0x00000001, - WGPUStencilOperation_Replace = 0x00000002, - WGPUStencilOperation_Invert = 0x00000003, - WGPUStencilOperation_IncrementClamp = 0x00000004, - WGPUStencilOperation_DecrementClamp = 0x00000005, - WGPUStencilOperation_IncrementWrap = 0x00000006, - WGPUStencilOperation_DecrementWrap = 0x00000007, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStencilOperation_Undefined = 0x00000000, + WGPUStencilOperation_Keep = 0x00000001, + WGPUStencilOperation_Zero = 0x00000002, + WGPUStencilOperation_Replace = 0x00000003, + WGPUStencilOperation_Invert = 0x00000004, + WGPUStencilOperation_IncrementClamp = 0x00000005, + WGPUStencilOperation_DecrementClamp = 0x00000006, + WGPUStencilOperation_IncrementWrap = 0x00000007, + WGPUStencilOperation_DecrementWrap = 0x00000008, WGPUStencilOperation_Force32 = 0x7FFFFFFF } WGPUStencilOperation WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStorageTextureAccess { - WGPUStorageTextureAccess_Undefined = 0x00000000, - WGPUStorageTextureAccess_WriteOnly = 0x00000001, - WGPUStorageTextureAccess_ReadOnly = 0x00000002, - WGPUStorageTextureAccess_ReadWrite = 0x00000003, + /** + * `0x00000000`. + * Indicates that this @ref WGPUStorageTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUStorageTextureAccess_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUStorageTextureAccess_Undefined = 0x00000001, + WGPUStorageTextureAccess_WriteOnly = 0x00000002, + WGPUStorageTextureAccess_ReadOnly = 0x00000003, + WGPUStorageTextureAccess_ReadWrite = 0x00000004, WGPUStorageTextureAccess_Force32 = 0x7FFFFFFF } WGPUStorageTextureAccess WGPU_ENUM_ATTRIBUTE; typedef enum WGPUStoreOp { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUStoreOp_Undefined = 0x00000000, WGPUStoreOp_Store = 0x00000001, WGPUStoreOp_Discard = 0x00000002, WGPUStoreOp_Force32 = 0x7FFFFFFF } WGPUStoreOp WGPU_ENUM_ATTRIBUTE; +/** + * The status enum for `::wgpuSurfaceGetCurrentTexture`. + */ typedef enum WGPUSurfaceGetCurrentTextureStatus { - WGPUSurfaceGetCurrentTextureStatus_Success = 0x00000000, - WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000001, - WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000002, - WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000003, - WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000004, - WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000005, + /** + * `0x00000001`. + * Yay! Everything is good and we can render this frame. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal = 0x00000001, + /** + * `0x00000002`. + * Still OK - the surface can present the frame, but in a suboptimal way. The surface may need reconfiguration. + */ + WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal = 0x00000002, + /** + * `0x00000003`. + * Some operation timed out while trying to acquire the frame. + */ + WGPUSurfaceGetCurrentTextureStatus_Timeout = 0x00000003, + /** + * `0x00000004`. + * The surface is too different to be used, compared to when it was originally created. + */ + WGPUSurfaceGetCurrentTextureStatus_Outdated = 0x00000004, + /** + * `0x00000005`. + * The connection to whatever owns the surface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_Lost = 0x00000005, + /** + * `0x00000006`. + * The system ran out of memory. + */ + WGPUSurfaceGetCurrentTextureStatus_OutOfMemory = 0x00000006, + /** + * `0x00000007`. + * The @ref WGPUDevice configured on the @ref WGPUSurface was lost. + */ + WGPUSurfaceGetCurrentTextureStatus_DeviceLost = 0x00000007, + /** + * `0x00000008`. + * The surface is not configured, or there was an @ref OutStructChainError. + */ + WGPUSurfaceGetCurrentTextureStatus_Error = 0x00000008, WGPUSurfaceGetCurrentTextureStatus_Force32 = 0x7FFFFFFF } WGPUSurfaceGetCurrentTextureStatus WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureAspect { - WGPUTextureAspect_All = 0x00000000, - WGPUTextureAspect_StencilOnly = 0x00000001, - WGPUTextureAspect_DepthOnly = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureAspect_Undefined = 0x00000000, + WGPUTextureAspect_All = 0x00000001, + WGPUTextureAspect_StencilOnly = 0x00000002, + WGPUTextureAspect_DepthOnly = 0x00000003, WGPUTextureAspect_Force32 = 0x7FFFFFFF } WGPUTextureAspect WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureDimension { - WGPUTextureDimension_1D = 0x00000000, - WGPUTextureDimension_2D = 0x00000001, - WGPUTextureDimension_3D = 0x00000002, + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureDimension_Undefined = 0x00000000, + WGPUTextureDimension_1D = 0x00000001, + WGPUTextureDimension_2D = 0x00000002, + WGPUTextureDimension_3D = 0x00000003, WGPUTextureDimension_Force32 = 0x7FFFFFFF } WGPUTextureDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureFormat { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureFormat_Undefined = 0x00000000, WGPUTextureFormat_R8Unorm = 0x00000001, WGPUTextureFormat_R8Snorm = 0x00000002, @@ -636,16 +991,31 @@ typedef enum WGPUTextureFormat { } WGPUTextureFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureSampleType { - WGPUTextureSampleType_Undefined = 0x00000000, - WGPUTextureSampleType_Float = 0x00000001, - WGPUTextureSampleType_UnfilterableFloat = 0x00000002, - WGPUTextureSampleType_Depth = 0x00000003, - WGPUTextureSampleType_Sint = 0x00000004, - WGPUTextureSampleType_Uint = 0x00000005, + /** + * `0x00000000`. + * Indicates that this @ref WGPUTextureBindingLayout member of + * its parent @ref WGPUBindGroupLayoutEntry is not used. + * (See also @ref SentinelValues.) + */ + WGPUTextureSampleType_BindingNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUTextureSampleType_Undefined = 0x00000001, + WGPUTextureSampleType_Float = 0x00000002, + WGPUTextureSampleType_UnfilterableFloat = 0x00000003, + WGPUTextureSampleType_Depth = 0x00000004, + WGPUTextureSampleType_Sint = 0x00000005, + WGPUTextureSampleType_Uint = 0x00000006, WGPUTextureSampleType_Force32 = 0x7FFFFFFF } WGPUTextureSampleType WGPU_ENUM_ATTRIBUTE; typedef enum WGPUTextureViewDimension { + /** + * `0x00000000`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ WGPUTextureViewDimension_Undefined = 0x00000000, WGPUTextureViewDimension_1D = 0x00000001, WGPUTextureViewDimension_2D = 0x00000002, @@ -657,148 +1027,241 @@ typedef enum WGPUTextureViewDimension { } WGPUTextureViewDimension WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexFormat { - WGPUVertexFormat_Undefined = 0x00000000, - WGPUVertexFormat_Uint8x2 = 0x00000001, - WGPUVertexFormat_Uint8x4 = 0x00000002, - WGPUVertexFormat_Sint8x2 = 0x00000003, - WGPUVertexFormat_Sint8x4 = 0x00000004, - WGPUVertexFormat_Unorm8x2 = 0x00000005, - WGPUVertexFormat_Unorm8x4 = 0x00000006, - WGPUVertexFormat_Snorm8x2 = 0x00000007, - WGPUVertexFormat_Snorm8x4 = 0x00000008, - WGPUVertexFormat_Uint16x2 = 0x00000009, - WGPUVertexFormat_Uint16x4 = 0x0000000A, - WGPUVertexFormat_Sint16x2 = 0x0000000B, - WGPUVertexFormat_Sint16x4 = 0x0000000C, - WGPUVertexFormat_Unorm16x2 = 0x0000000D, - WGPUVertexFormat_Unorm16x4 = 0x0000000E, - WGPUVertexFormat_Snorm16x2 = 0x0000000F, - WGPUVertexFormat_Snorm16x4 = 0x00000010, - WGPUVertexFormat_Float16x2 = 0x00000011, - WGPUVertexFormat_Float16x4 = 0x00000012, - WGPUVertexFormat_Float32 = 0x00000013, - WGPUVertexFormat_Float32x2 = 0x00000014, - WGPUVertexFormat_Float32x3 = 0x00000015, - WGPUVertexFormat_Float32x4 = 0x00000016, - WGPUVertexFormat_Uint32 = 0x00000017, - WGPUVertexFormat_Uint32x2 = 0x00000018, - WGPUVertexFormat_Uint32x3 = 0x00000019, - WGPUVertexFormat_Uint32x4 = 0x0000001A, - WGPUVertexFormat_Sint32 = 0x0000001B, - WGPUVertexFormat_Sint32x2 = 0x0000001C, - WGPUVertexFormat_Sint32x3 = 0x0000001D, - WGPUVertexFormat_Sint32x4 = 0x0000001E, + WGPUVertexFormat_Uint8 = 0x00000001, + WGPUVertexFormat_Uint8x2 = 0x00000002, + WGPUVertexFormat_Uint8x4 = 0x00000003, + WGPUVertexFormat_Sint8 = 0x00000004, + WGPUVertexFormat_Sint8x2 = 0x00000005, + WGPUVertexFormat_Sint8x4 = 0x00000006, + WGPUVertexFormat_Unorm8 = 0x00000007, + WGPUVertexFormat_Unorm8x2 = 0x00000008, + WGPUVertexFormat_Unorm8x4 = 0x00000009, + WGPUVertexFormat_Snorm8 = 0x0000000A, + WGPUVertexFormat_Snorm8x2 = 0x0000000B, + WGPUVertexFormat_Snorm8x4 = 0x0000000C, + WGPUVertexFormat_Uint16 = 0x0000000D, + WGPUVertexFormat_Uint16x2 = 0x0000000E, + WGPUVertexFormat_Uint16x4 = 0x0000000F, + WGPUVertexFormat_Sint16 = 0x00000010, + WGPUVertexFormat_Sint16x2 = 0x00000011, + WGPUVertexFormat_Sint16x4 = 0x00000012, + WGPUVertexFormat_Unorm16 = 0x00000013, + WGPUVertexFormat_Unorm16x2 = 0x00000014, + WGPUVertexFormat_Unorm16x4 = 0x00000015, + WGPUVertexFormat_Snorm16 = 0x00000016, + WGPUVertexFormat_Snorm16x2 = 0x00000017, + WGPUVertexFormat_Snorm16x4 = 0x00000018, + WGPUVertexFormat_Float16 = 0x00000019, + WGPUVertexFormat_Float16x2 = 0x0000001A, + WGPUVertexFormat_Float16x4 = 0x0000001B, + WGPUVertexFormat_Float32 = 0x0000001C, + WGPUVertexFormat_Float32x2 = 0x0000001D, + WGPUVertexFormat_Float32x3 = 0x0000001E, + WGPUVertexFormat_Float32x4 = 0x0000001F, + WGPUVertexFormat_Uint32 = 0x00000020, + WGPUVertexFormat_Uint32x2 = 0x00000021, + WGPUVertexFormat_Uint32x3 = 0x00000022, + WGPUVertexFormat_Uint32x4 = 0x00000023, + WGPUVertexFormat_Sint32 = 0x00000024, + WGPUVertexFormat_Sint32x2 = 0x00000025, + WGPUVertexFormat_Sint32x3 = 0x00000026, + WGPUVertexFormat_Sint32x4 = 0x00000027, + WGPUVertexFormat_Unorm10_10_10_2 = 0x00000028, + WGPUVertexFormat_Unorm8x4BGRA = 0x00000029, WGPUVertexFormat_Force32 = 0x7FFFFFFF } WGPUVertexFormat WGPU_ENUM_ATTRIBUTE; typedef enum WGPUVertexStepMode { - WGPUVertexStepMode_Vertex = 0x00000000, - WGPUVertexStepMode_Instance = 0x00000001, - WGPUVertexStepMode_VertexBufferNotUsed = 0x00000002, + /** + * `0x00000000`. + * This @ref WGPUVertexBufferLayout is a "hole" in the @ref WGPUVertexState `buffers` array. + * (See also @ref SentinelValues.) + */ + WGPUVertexStepMode_VertexBufferNotUsed = 0x00000000, + /** + * `0x00000001`. + * Indicates no value is passed for this argument. See @ref SentinelValues. + */ + WGPUVertexStepMode_Undefined = 0x00000001, + WGPUVertexStepMode_Vertex = 0x00000002, + WGPUVertexStepMode_Instance = 0x00000003, WGPUVertexStepMode_Force32 = 0x7FFFFFFF } WGPUVertexStepMode WGPU_ENUM_ATTRIBUTE; -typedef enum WGPUWGSLFeatureName { - WGPUWGSLFeatureName_Undefined = 0x00000000, - WGPUWGSLFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, - WGPUWGSLFeatureName_Packed4x8IntegerDotProduct = 0x00000002, - WGPUWGSLFeatureName_UnrestrictedPointerParameters = 0x00000003, - WGPUWGSLFeatureName_PointerCompositeAccess = 0x00000004, - WGPUWGSLFeatureName_Force32 = 0x7FFFFFFF -} WGPUWGSLFeatureName WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUWGSLLanguageFeatureName { + WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures = 0x00000001, + WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct = 0x00000002, + WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters = 0x00000003, + WGPUWGSLLanguageFeatureName_PointerCompositeAccess = 0x00000004, + WGPUWGSLLanguageFeatureName_Force32 = 0x7FFFFFFF +} WGPUWGSLLanguageFeatureName WGPU_ENUM_ATTRIBUTE; + +/** + * Status returned from a call to ::wgpuInstanceWaitAny. + */ +typedef enum WGPUWaitStatus { + /** + * `0x00000001`. + * At least one WGPUFuture completed successfully. + */ + WGPUWaitStatus_Success = 0x00000001, + /** + * `0x00000002`. + * No WGPUFutures completed within the timeout. + */ + WGPUWaitStatus_TimedOut = 0x00000002, + /** + * `0x00000003`. + * A @ref Timed-Wait was performed when WGPUInstanceFeatures::timedWaitAnyEnable is false. + */ + WGPUWaitStatus_UnsupportedTimeout = 0x00000003, + /** + * `0x00000004`. + * The number of futures waited on in a @ref Timed-Wait is greater than the supported WGPUInstanceFeatures::timedWaitAnyMaxCount. + */ + WGPUWaitStatus_UnsupportedCount = 0x00000004, + /** + * `0x00000005`. + * An invalid wait was performed with @ref Mixed-Sources. + */ + WGPUWaitStatus_UnsupportedMixedSources = 0x00000005, + WGPUWaitStatus_Force32 = 0x7FFFFFFF +} WGPUWaitStatus WGPU_ENUM_ATTRIBUTE; /** @} */ /** * \defgroup Bitflags - * \brief Enum used as bit flags. - * + * \brief Type and constant definitions for bitflag types. + * * @{ */ -typedef enum WGPUBufferUsage { - WGPUBufferUsage_None = 0x00000000, - WGPUBufferUsage_MapRead = 0x00000001, - WGPUBufferUsage_MapWrite = 0x00000002, - WGPUBufferUsage_CopySrc = 0x00000004, - WGPUBufferUsage_CopyDst = 0x00000008, - WGPUBufferUsage_Index = 0x00000010, - WGPUBufferUsage_Vertex = 0x00000020, - WGPUBufferUsage_Uniform = 0x00000040, - WGPUBufferUsage_Storage = 0x00000080, - WGPUBufferUsage_Indirect = 0x00000100, - WGPUBufferUsage_QueryResolve = 0x00000200, - WGPUBufferUsage_Force32 = 0x7FFFFFFF -} WGPUBufferUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUBufferUsageFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUColorWriteMask { - WGPUColorWriteMask_None = 0x00000000, - WGPUColorWriteMask_Red = 0x00000001, - WGPUColorWriteMask_Green = 0x00000002, - WGPUColorWriteMask_Blue = 0x00000004, - WGPUColorWriteMask_Alpha = 0x00000008, - WGPUColorWriteMask_All = WGPUColorWriteMask_None | WGPUColorWriteMask_Red | WGPUColorWriteMask_Green | WGPUColorWriteMask_Blue | WGPUColorWriteMask_Alpha, - WGPUColorWriteMask_Force32 = 0x7FFFFFFF -} WGPUColorWriteMask WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUColorWriteMaskFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUMapMode { - WGPUMapMode_None = 0x00000000, - WGPUMapMode_Read = 0x00000001, - WGPUMapMode_Write = 0x00000002, - WGPUMapMode_Force32 = 0x7FFFFFFF -} WGPUMapMode WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUMapModeFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUShaderStage { - WGPUShaderStage_None = 0x00000000, - WGPUShaderStage_Vertex = 0x00000001, - WGPUShaderStage_Fragment = 0x00000002, - WGPUShaderStage_Compute = 0x00000004, - WGPUShaderStage_Force32 = 0x7FFFFFFF -} WGPUShaderStage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUShaderStageFlags WGPU_ENUM_ATTRIBUTE; - -typedef enum WGPUTextureUsage { - WGPUTextureUsage_None = 0x00000000, - WGPUTextureUsage_CopySrc = 0x00000001, - WGPUTextureUsage_CopyDst = 0x00000002, - WGPUTextureUsage_TextureBinding = 0x00000004, - WGPUTextureUsage_StorageBinding = 0x00000008, - WGPUTextureUsage_RenderAttachment = 0x00000010, - WGPUTextureUsage_Force32 = 0x7FFFFFFF -} WGPUTextureUsage WGPU_ENUM_ATTRIBUTE; -typedef WGPUFlags WGPUTextureUsageFlags WGPU_ENUM_ATTRIBUTE; +typedef WGPUFlags WGPUBufferUsage; +static const WGPUBufferUsage WGPUBufferUsage_None = 0x0000000000000000; +static const WGPUBufferUsage WGPUBufferUsage_MapRead = 0x0000000000000001; +static const WGPUBufferUsage WGPUBufferUsage_MapWrite = 0x0000000000000002; +static const WGPUBufferUsage WGPUBufferUsage_CopySrc = 0x0000000000000004; +static const WGPUBufferUsage WGPUBufferUsage_CopyDst = 0x0000000000000008; +static const WGPUBufferUsage WGPUBufferUsage_Index = 0x0000000000000010; +static const WGPUBufferUsage WGPUBufferUsage_Vertex = 0x0000000000000020; +static const WGPUBufferUsage WGPUBufferUsage_Uniform = 0x0000000000000040; +static const WGPUBufferUsage WGPUBufferUsage_Storage = 0x0000000000000080; +static const WGPUBufferUsage WGPUBufferUsage_Indirect = 0x0000000000000100; +static const WGPUBufferUsage WGPUBufferUsage_QueryResolve = 0x0000000000000200; + +typedef WGPUFlags WGPUColorWriteMask; +static const WGPUColorWriteMask WGPUColorWriteMask_None = 0x0000000000000000; +static const WGPUColorWriteMask WGPUColorWriteMask_Red = 0x0000000000000001; +static const WGPUColorWriteMask WGPUColorWriteMask_Green = 0x0000000000000002; +static const WGPUColorWriteMask WGPUColorWriteMask_Blue = 0x0000000000000004; +static const WGPUColorWriteMask WGPUColorWriteMask_Alpha = 0x0000000000000008; +static const WGPUColorWriteMask WGPUColorWriteMask_All = 0x000000000000000F /* Red | Green | Blue | Alpha */; + +typedef WGPUFlags WGPUMapMode; +static const WGPUMapMode WGPUMapMode_None = 0x0000000000000000; +static const WGPUMapMode WGPUMapMode_Read = 0x0000000000000001; +static const WGPUMapMode WGPUMapMode_Write = 0x0000000000000002; + +typedef WGPUFlags WGPUShaderStage; +static const WGPUShaderStage WGPUShaderStage_None = 0x0000000000000000; +static const WGPUShaderStage WGPUShaderStage_Vertex = 0x0000000000000001; +static const WGPUShaderStage WGPUShaderStage_Fragment = 0x0000000000000002; +static const WGPUShaderStage WGPUShaderStage_Compute = 0x0000000000000004; + +typedef WGPUFlags WGPUTextureUsage; +static const WGPUTextureUsage WGPUTextureUsage_None = 0x0000000000000000; +static const WGPUTextureUsage WGPUTextureUsage_CopySrc = 0x0000000000000001; +static const WGPUTextureUsage WGPUTextureUsage_CopyDst = 0x0000000000000002; +static const WGPUTextureUsage WGPUTextureUsage_TextureBinding = 0x0000000000000004; +static const WGPUTextureUsage WGPUTextureUsage_StorageBinding = 0x0000000000000008; +static const WGPUTextureUsage WGPUTextureUsage_RenderAttachment = 0x0000000000000010; /** @} */ typedef void (*WGPUProc)(void) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceLostCallback)(WGPUDeviceLostReason reason, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUErrorCallback)(WGPUErrorType type, char const * message, void * userdata) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup Callbacks * \brief Callbacks through which asynchronous functions return. - * + * * @{ */ - -typedef void (*WGPUAdapterRequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUBufferMapAsyncCallback)(WGPUBufferMapAsyncStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUDeviceCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUInstanceRequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, char const * message, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUQueueOnSubmittedWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUShaderModuleGetCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; - +/** + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUBufferMapCallback)(WGPUMapAsyncStatus status, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param compilationInfo + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUCompilationInfoCallback)(WGPUCompilationInfoRequestStatus status, struct WGPUCompilationInfo const * compilationInfo, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateComputePipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param pipeline + * This parameter is @ref PassedWithOwnership. + */ +typedef void (*WGPUCreateRenderPipelineAsyncCallback)(WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline pipeline, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * Reference to the device which was lost. If, and only if, the `reason` is @ref WGPUDeviceLostReason_FailedCreation, this is a non-null pointer to a null @ref WGPUDevice. + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUDeviceLostCallback)(WGPUDevice const * device, WGPUDeviceLostReason reason, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param status + * See @ref WGPUPopErrorScopeStatus. + * + * @param type + * The type of the error caught by the scope, or @ref WGPUErrorType_NoError if there was none. + * If the `status` is not @ref WGPUPopErrorScopeStatus_Success, this is @ref WGPUErrorType_NoError. + * + * @param message + * If the `type` is not @ref WGPUErrorType_NoError, this is a non-empty @ref LocalizableHumanReadableMessageString; + * otherwise, this is an empty string. + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUPopErrorScopeCallback)(WGPUPopErrorScopeStatus status, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +typedef void (*WGPUQueueWorkDoneCallback)(WGPUQueueWorkDoneStatus status, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param adapter + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestAdapterCallback)(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPURequestDeviceCallback)(WGPURequestDeviceStatus status, WGPUDevice device, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param device + * This parameter is @ref PassedWithoutOwnership. + * + * @param message + * This parameter is @ref PassedWithoutOwnership. + */ +typedef void (*WGPUUncapturedErrorCallback)(WGPUDevice const * device, WGPUErrorType type, WGPUStringView message, WGPU_NULLABLE void* userdata1, WGPU_NULLABLE void* userdata2) WGPU_FUNCTION_ATTRIBUTE; /** @} */ /** * \defgroup ChainedStructures Chained Structures * \brief Structures used to extend descriptors. - * + * * @{ */ @@ -818,15 +1281,115 @@ typedef struct WGPUChainedStructOut { /** * \defgroup Structures * \brief Descriptors and other transparent structures. - * + * + * @{ + */ + + /** + * \defgroup WGPUCallbackInfo + * \brief Callback info structures that are used in asynchronous functions. + * * @{ */ +typedef struct WGPUBufferMapCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUBufferMapCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUBufferMapCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCompilationInfoCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCompilationInfoCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCompilationInfoCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateComputePipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateComputePipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateComputePipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUCreateRenderPipelineAsyncCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUCreateRenderPipelineAsyncCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUCreateRenderPipelineAsyncCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUDeviceLostCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUDeviceLostCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUDeviceLostCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUPopErrorScopeCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUPopErrorScopeCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUPopErrorScopeCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUQueueWorkDoneCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPUQueueWorkDoneCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUQueueWorkDoneCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestAdapterCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestAdapterCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestAdapterCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPURequestDeviceCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUCallbackMode mode; + WGPURequestDeviceCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPURequestDeviceCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUUncapturedErrorCallbackInfo { + WGPUChainedStruct const * nextInChain; + WGPUUncapturedErrorCallback callback; + WGPU_NULLABLE void* userdata1; + WGPU_NULLABLE void* userdata2; +} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; + +/** @} */ + typedef struct WGPUAdapterInfo { WGPUChainedStructOut * nextInChain; - char const * vendor; - char const * architecture; - char const * device; - char const * description; + /** + * This is an \ref OutputString. + */ + WGPUStringView vendor; + /** + * This is an \ref OutputString. + */ + WGPUStringView architecture; + /** + * This is an \ref OutputString. + */ + WGPUStringView device; + /** + * This is an \ref OutputString. + */ + WGPUStringView description; WGPUBackendType backendType; WGPUAdapterType adapterType; uint32_t vendorID; @@ -858,8 +1421,11 @@ typedef struct WGPUBufferBindingLayout { typedef struct WGPUBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUBufferUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUBufferUsage usage; uint64_t size; WGPUBool mappedAtCreation; } WGPUBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -873,25 +1439,48 @@ typedef struct WGPUColor { typedef struct WGPUCommandBufferDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandBufferDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCommandEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUCommandEncoderDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUCompilationMessage { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * message; + /** + * A @ref LocalizableHumanReadableMessageString. + * + * This is an \ref OutputString. + */ + WGPUStringView message; + /** + * Severity level of the message. + */ WGPUCompilationMessageType type; + /** + * Line number where the message is attached, starting at 1. + */ uint64_t lineNum; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the line, starting at 1. + */ uint64_t linePos; + /** + * Offset in UTF-8 code units (bytes) from the beginning of the shader code, starting at 0. + */ uint64_t offset; + /** + * Length in UTF-8 code units (bytes) of the span the message corresponds to. + */ uint64_t length; - uint64_t utf16LinePos; - uint64_t utf16Offset; - uint64_t utf16Length; } WGPUCompilationMessage WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePassTimestampWrites { @@ -902,7 +1491,10 @@ typedef struct WGPUComputePassTimestampWrites { typedef struct WGPUConstantEntry { WGPUChainedStruct const * nextInChain; - char const * key; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView key; double value; } WGPUConstantEntry WGPU_STRUCTURE_ATTRIBUTE; @@ -912,11 +1504,35 @@ typedef struct WGPUExtent3D { uint32_t depthOrArrayLayers; } WGPUExtent3D WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUInstanceDescriptor { - WGPUChainedStruct const * nextInChain; -} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; +/** + * Opaque handle to an asynchronous operation. See @ref Asynchronous-Operations for more information. + */ +typedef struct WGPUFuture { + /** + * Opaque id of the @ref WGPUFuture + */ + uint64_t id; +} WGPUFuture WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Features enabled on the WGPUInstance + */ +typedef struct WGPUInstanceCapabilities { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; + /** + * Enable use of ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + WGPUBool timedWaitAnyEnable; + /** + * The maximum number @ref WGPUFutureWaitInfo supported in a call to ::wgpuInstanceWaitAny with `timeoutNS > 0`. + */ + size_t timedWaitAnyMaxCount; +} WGPUInstanceCapabilities WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPULimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut * nextInChain; uint32_t maxTextureDimension1D; uint32_t maxTextureDimension2D; uint32_t maxTextureDimension3D; @@ -939,7 +1555,6 @@ typedef struct WGPULimits { uint64_t maxBufferSize; uint32_t maxVertexAttributes; uint32_t maxVertexBufferArrayStride; - uint32_t maxInterStageShaderComponents; uint32_t maxInterStageShaderVariables; uint32_t maxColorAttachments; uint32_t maxColorAttachmentBytesPerSample; @@ -966,44 +1581,55 @@ typedef struct WGPUOrigin3D { typedef struct WGPUPipelineLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t bindGroupLayoutCount; WGPUBindGroupLayout const * bindGroupLayouts; } WGPUPipelineLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUPrimitiveDepthClipControl { - WGPUChainedStruct chain; - WGPUBool unclippedDepth; -} WGPUPrimitiveDepthClipControl WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUPrimitiveState { WGPUChainedStruct const * nextInChain; WGPUPrimitiveTopology topology; WGPUIndexFormat stripIndexFormat; WGPUFrontFace frontFace; WGPUCullMode cullMode; + WGPUBool unclippedDepth; } WGPUPrimitiveState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQuerySetDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUQueryType type; uint32_t count; } WGPUQuerySetDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUQueueDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUQueueDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPURenderBundleDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderBundleEncoderDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorFormatCount; WGPUTextureFormat const * colorFormats; WGPUTextureFormat depthStencilFormat; @@ -1024,10 +1650,10 @@ typedef struct WGPURenderPassDepthStencilAttachment { WGPUBool stencilReadOnly; } WGPURenderPassDepthStencilAttachment WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURenderPassDescriptorMaxDrawCount { +typedef struct WGPURenderPassMaxDrawCount { WGPUChainedStruct chain; uint64_t maxDrawCount; -} WGPURenderPassDescriptorMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; +} WGPURenderPassMaxDrawCount WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPURenderPassTimestampWrites { WGPUQuerySet querySet; @@ -1037,10 +1663,28 @@ typedef struct WGPURenderPassTimestampWrites { typedef struct WGPURequestAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE WGPUSurface compatibleSurface; + /** + * "Feature level" for the adapter request. If an adapter is returned, it must support the features and limits in the requested feature level. + * + * Implementations may ignore @ref WGPUFeatureLevel_Compatibility and provide @ref WGPUFeatureLevel_Core instead. @ref WGPUFeatureLevel_Core is the default in the JS API, but in C, this field is **required** (must not be undefined). + */ + WGPUFeatureLevel featureLevel; WGPUPowerPreference powerPreference; - WGPUBackendType backendType; + /** + * If true, requires the adapter to be a "fallback" adapter as defined by the JS spec. + * If this is not possible, the request returns null. + */ WGPUBool forceFallbackAdapter; + /** + * If set, requires the adapter to have a particular backend type. + * If this is not possible, the request returns null. + */ + WGPUBackendType backendType; + /** + * If set, requires the adapter to be able to output to a particular surface. + * If this is not possible, the request returns null. + */ + WGPU_NULLABLE WGPUSurface compatibleSurface; } WGPURequestAdapterOptions WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUSamplerBindingLayout { @@ -1050,7 +1694,10 @@ typedef struct WGPUSamplerBindingLayout { typedef struct WGPUSamplerDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUAddressMode addressModeU; WGPUAddressMode addressModeV; WGPUAddressMode addressModeW; @@ -1063,22 +1710,27 @@ typedef struct WGPUSamplerDescriptor { uint16_t maxAnisotropy; } WGPUSamplerDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleCompilationHint { +typedef struct WGPUShaderModuleDescriptor { WGPUChainedStruct const * nextInChain; - char const * entryPoint; - WGPUPipelineLayout layout; -} WGPUShaderModuleCompilationHint WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; +} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleSPIRVDescriptor { +typedef struct WGPUShaderSourceSPIRV { WGPUChainedStruct chain; uint32_t codeSize; uint32_t const * code; -} WGPUShaderModuleSPIRVDescriptor WGPU_STRUCTURE_ATTRIBUTE; +} WGPUShaderSourceSPIRV WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUShaderModuleWGSLDescriptor { +typedef struct WGPUShaderSourceWGSL { WGPUChainedStruct chain; - char const * code; -} WGPUShaderModuleWGSLDescriptor WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView code; +} WGPUShaderSourceWGSL WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUStencilFaceState { WGPUCompareFunction compare; @@ -1094,80 +1746,207 @@ typedef struct WGPUStorageTextureBindingLayout { WGPUTextureViewDimension viewDimension; } WGPUStorageTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUSupportedFeatures { + size_t featureCount; + WGPUFeatureName const * features; +} WGPUSupportedFeatures WGPU_STRUCTURE_ATTRIBUTE; + +typedef struct WGPUSupportedWGSLLanguageFeatures { + size_t featureCount; + WGPUWGSLLanguageFeatureName const * features; +} WGPUSupportedWGSLLanguageFeatures WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Filled by `::wgpuSurfaceGetCapabilities` with what's supported for `::wgpuSurfaceConfigure` for a pair of @ref WGPUSurface and @ref WGPUAdapter. + */ typedef struct WGPUSurfaceCapabilities { WGPUChainedStructOut * nextInChain; - WGPUTextureUsageFlags usages; + /** + * The bit set of supported @ref WGPUTextureUsage bits. + * Guaranteed to contain @ref WGPUTextureUsage_RenderAttachment. + */ + WGPUTextureUsage usages; + /** + * A list of supported @ref WGPUTextureFormat values, in order of preference. + */ size_t formatCount; WGPUTextureFormat const * formats; + /** + * A list of supported @ref WGPUPresentMode values. + * Guaranteed to contain @ref WGPUPresentMode_Fifo. + */ size_t presentModeCount; WGPUPresentMode const * presentModes; + /** + * A list of supported @ref WGPUCompositeAlphaMode values. + * @ref WGPUCompositeAlphaMode_Auto will be an alias for the first element and will never be present in this array. + */ size_t alphaModeCount; WGPUCompositeAlphaMode const * alphaModes; } WGPUSurfaceCapabilities WGPU_STRUCTURE_ATTRIBUTE; +/** + * Options to `::wgpuSurfaceConfigure` for defining how a @ref WGPUSurface will be rendered to and presented to the user. + * See @ref Surface-Configuration for more details. + */ typedef struct WGPUSurfaceConfiguration { WGPUChainedStruct const * nextInChain; + /** + * The @ref WGPUDevice to use to render to surface's textures. + */ WGPUDevice device; + /** + * The @ref WGPUTextureFormat of the surface's textures. + */ WGPUTextureFormat format; - WGPUTextureUsageFlags usage; + /** + * The @ref WGPUTextureUsage of the surface's textures. + */ + WGPUTextureUsage usage; + /** + * The width of the surface's textures. + */ + uint32_t width; + /** + * The height of the surface's textures. + */ + uint32_t height; + /** + * The additional @ref WGPUTextureFormat for @ref WGPUTextureView format reinterpretation of the surface's textures. + */ size_t viewFormatCount; WGPUTextureFormat const * viewFormats; + /** + * How the surface's frames will be composited on the screen. + */ WGPUCompositeAlphaMode alphaMode; - uint32_t width; - uint32_t height; + /** + * When and in which order the surface's frames will be shown on the screen. Defaults to @ref WGPUPresentMode_Fifo. + */ WGPUPresentMode presentMode; } WGPUSurfaceConfiguration WGPU_STRUCTURE_ATTRIBUTE; +/** + * The root descriptor for the creation of an @ref WGPUSurface with `::wgpuInstanceCreateSurface`. + * It isn't sufficient by itself and must have one of the `WGPUSurfaceSource*` in its chain. + * See @ref Surface-Creation for more details. + */ typedef struct WGPUSurfaceDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * Label used to refer to the object. + * + * This is a \ref NonNullInputString. + */ + WGPUStringView label; } WGPUSurfaceDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromAndroidNativeWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an Android [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window). + */ +typedef struct WGPUSurfaceSourceAndroidNativeWindow { WGPUChainedStruct chain; + /** + * The pointer to the [`ANativeWindow`](https://developer.android.com/ndk/reference/group/a-native-window) that will be wrapped by the @ref WGPUSurface. + */ void * window; -} WGPUSurfaceDescriptorFromAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; - -typedef struct WGPUSurfaceDescriptorFromCanvasHTMLSelector { - WGPUChainedStruct chain; - char const * selector; -} WGPUSurfaceDescriptorFromCanvasHTMLSelector WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceAndroidNativeWindow WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromMetalLayer { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc). + */ +typedef struct WGPUSurfaceSourceMetalLayer { WGPUChainedStruct chain; + /** + * The pointer to the [`CAMetalLayer`](https://developer.apple.com/documentation/quartzcore/cametallayer?language=objc) that will be wrapped by the @ref WGPUSurface. + */ void * layer; -} WGPUSurfaceDescriptorFromMetalLayer WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceMetalLayer WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromWaylandSurface { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a [Wayland](https://wayland.freedesktop.org/) [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface). + */ +typedef struct WGPUSurfaceSourceWaylandSurface { WGPUChainedStruct chain; + /** + * A [`wl_display`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_display) for this Wayland instance. + */ void * display; + /** + * A [`wl_surface`](https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface) that will be wrapped by the @ref WGPUSurface + */ void * surface; -} WGPUSurfaceDescriptorFromWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWaylandSurface WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromWindowsHWND { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping a Windows [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd). + */ +typedef struct WGPUSurfaceSourceWindowsHWND { WGPUChainedStruct chain; + /** + * The [`HINSTANCE`](https://learn.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point) for this application. + * Most commonly `GetModuleHandle(nullptr)`. + */ void * hinstance; + /** + * The [`HWND`](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd) that will be wrapped by the @ref WGPUSurface. + */ void * hwnd; -} WGPUSurfaceDescriptorFromWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceWindowsHWND WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromXcbWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [XCB](https://xcb.freedesktop.org/) `xcb_window_t`. + */ +typedef struct WGPUSurfaceSourceXCBWindow { WGPUChainedStruct chain; + /** + * The `xcb_connection_t` for the connection to the X server. + */ void * connection; + /** + * The `xcb_window_t` for the window that will be wrapped by the @ref WGPUSurface. + */ uint32_t window; -} WGPUSurfaceDescriptorFromXcbWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXCBWindow WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSurfaceDescriptorFromXlibWindow { +/** + * Chained in @ref WGPUSurfaceDescriptor to make an @ref WGPUSurface wrapping an [Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) `Window`. + */ +typedef struct WGPUSurfaceSourceXlibWindow { WGPUChainedStruct chain; + /** + * A pointer to the [`Display`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Opening_the_Display) connected to the X server. + */ void * display; + /** + * The [`Window`](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Creating_Windows) that will be wrapped by the @ref WGPUSurface. + */ uint64_t window; -} WGPUSurfaceDescriptorFromXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +} WGPUSurfaceSourceXlibWindow WGPU_STRUCTURE_ATTRIBUTE; +/** + * Queried each frame from a @ref WGPUSurface to get a @ref WGPUTexture to render to along with some metadata. + * See @ref Surface-Presenting for more details. + */ typedef struct WGPUSurfaceTexture { + WGPUChainedStructOut * nextInChain; + /** + * The @ref WGPUTexture representing the frame that will be shown on the surface. + * It is @ref ReturnedWithOwnership from @ref wgpuSurfaceGetCurrentTexture. + */ WGPUTexture texture; - WGPUBool suboptimal; + /** + * Whether the call to `::wgpuSurfaceGetCurrentTexture` succeeded and a hint as to why it might not have. + */ WGPUSurfaceGetCurrentTextureStatus status; } WGPUSurfaceTexture WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferLayout { + uint64_t offset; + uint32_t bytesPerRow; + uint32_t rowsPerImage; +} WGPUTexelCopyBufferLayout WGPU_STRUCTURE_ATTRIBUTE; + typedef struct WGPUTextureBindingLayout { WGPUChainedStruct const * nextInChain; WGPUTextureSampleType sampleType; @@ -1175,16 +1954,12 @@ typedef struct WGPUTextureBindingLayout { WGPUBool multisampled; } WGPUTextureBindingLayout WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUTextureDataLayout { - WGPUChainedStruct const * nextInChain; - uint64_t offset; - uint32_t bytesPerRow; - uint32_t rowsPerImage; -} WGPUTextureDataLayout WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUTextureViewDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUTextureFormat format; WGPUTextureViewDimension dimension; uint32_t baseMipLevel; @@ -1192,14 +1967,9 @@ typedef struct WGPUTextureViewDescriptor { uint32_t baseArrayLayer; uint32_t arrayLayerCount; WGPUTextureAspect aspect; + WGPUTextureUsage usage; } WGPUTextureViewDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUUncapturedErrorCallbackInfo { - WGPUChainedStruct const * nextInChain; - WGPUErrorCallback callback; - void * userdata; -} WGPUUncapturedErrorCallbackInfo WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPUVertexAttribute { WGPUVertexFormat format; uint64_t offset; @@ -1208,7 +1978,10 @@ typedef struct WGPUVertexAttribute { typedef struct WGPUBindGroupDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPUBindGroupLayout layout; size_t entryCount; WGPUBindGroupEntry const * entries; @@ -1217,7 +1990,7 @@ typedef struct WGPUBindGroupDescriptor { typedef struct WGPUBindGroupLayoutEntry { WGPUChainedStruct const * nextInChain; uint32_t binding; - WGPUShaderStageFlags visibility; + WGPUShaderStage visibility; WGPUBufferBindingLayout buffer; WGPUSamplerBindingLayout sampler; WGPUTextureBindingLayout texture; @@ -1237,14 +2010,17 @@ typedef struct WGPUCompilationInfo { typedef struct WGPUComputePassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUComputePassTimestampWrites const * timestampWrites; } WGPUComputePassDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUDepthStencilState { WGPUChainedStruct const * nextInChain; WGPUTextureFormat format; - WGPUBool depthWriteEnabled; + WGPUOptionalBool depthWriteEnabled; WGPUCompareFunction depthCompare; WGPUStencilFaceState stencilFront; WGPUStencilFaceState stencilBack; @@ -1255,24 +2031,49 @@ typedef struct WGPUDepthStencilState { float depthBiasClamp; } WGPUDepthStencilState WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyBuffer { +typedef struct WGPUDeviceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTextureDataLayout layout; - WGPUBuffer buffer; -} WGPUImageCopyBuffer WGPU_STRUCTURE_ATTRIBUTE; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + size_t requiredFeatureCount; + WGPUFeatureName const * requiredFeatures; + WGPU_NULLABLE WGPULimits const * requiredLimits; + WGPUQueueDescriptor defaultQueue; + WGPUDeviceLostCallbackInfo deviceLostCallbackInfo; + WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; +} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; + +/** + * Struct holding a future to wait on, and a `completed` boolean flag. + */ +typedef struct WGPUFutureWaitInfo { + /** + * The future to wait on. + */ + WGPUFuture future; + /** + * Whether or not the future completed. + */ + WGPUBool completed; +} WGPUFutureWaitInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUImageCopyTexture { +typedef struct WGPUInstanceDescriptor { WGPUChainedStruct const * nextInChain; - WGPUTexture texture; - uint32_t mipLevel; - WGPUOrigin3D origin; - WGPUTextureAspect aspect; -} WGPUImageCopyTexture WGPU_STRUCTURE_ATTRIBUTE; + /** + * Instance features to enable + */ + WGPUInstanceCapabilities features; +} WGPUInstanceDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUProgrammableStageDescriptor { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; } WGPUProgrammableStageDescriptor WGPU_STRUCTURE_ATTRIBUTE; @@ -1287,27 +2088,25 @@ typedef struct WGPURenderPassColorAttachment { WGPUColor clearValue; } WGPURenderPassColorAttachment WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPURequiredLimits { - WGPUChainedStruct const * nextInChain; - WGPULimits limits; -} WGPURequiredLimits WGPU_STRUCTURE_ATTRIBUTE; - -typedef struct WGPUShaderModuleDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t hintCount; - WGPUShaderModuleCompilationHint const * hints; -} WGPUShaderModuleDescriptor WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyBufferInfo { + WGPUTexelCopyBufferLayout layout; + WGPUBuffer buffer; +} WGPUTexelCopyBufferInfo WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUSupportedLimits { - WGPUChainedStructOut * nextInChain; - WGPULimits limits; -} WGPUSupportedLimits WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUTexelCopyTextureInfo { + WGPUTexture texture; + uint32_t mipLevel; + WGPUOrigin3D origin; + WGPUTextureAspect aspect; +} WGPUTexelCopyTextureInfo WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUTextureDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - WGPUTextureUsageFlags usage; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; + WGPUTextureUsage usage; WGPUTextureDimension dimension; WGPUExtent3D size; WGPUTextureFormat format; @@ -1318,48 +2117,55 @@ typedef struct WGPUTextureDescriptor { } WGPUTextureDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUVertexBufferLayout { - uint64_t arrayStride; + /** + * The step mode for the vertex buffer. If @ref WGPUVertexStepMode_VertexBufferNotUsed, + * indicates a "hole" in the parent @ref WGPUVertexState `buffers` array: + * the pipeline does not use a vertex buffer at this `location`. + */ WGPUVertexStepMode stepMode; + uint64_t arrayStride; size_t attributeCount; WGPUVertexAttribute const * attributes; } WGPUVertexBufferLayout WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUBindGroupLayoutDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t entryCount; WGPUBindGroupLayoutEntry const * entries; } WGPUBindGroupLayoutDescriptor WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUColorTargetState { WGPUChainedStruct const * nextInChain; + /** + * The texture format of the target. If @ref WGPUTextureFormat_Undefined, + * indicates a "hole" in the parent @ref WGPUFragmentState `targets` array: + * the pipeline does not output a value at this `location`. + */ WGPUTextureFormat format; WGPU_NULLABLE WGPUBlendState const * blend; - WGPUColorWriteMaskFlags writeMask; + WGPUColorWriteMask writeMask; } WGPUColorTargetState WGPU_STRUCTURE_ATTRIBUTE; typedef struct WGPUComputePipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUProgrammableStageDescriptor compute; } WGPUComputePipelineDescriptor WGPU_STRUCTURE_ATTRIBUTE; -typedef struct WGPUDeviceDescriptor { - WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; - size_t requiredFeatureCount; - WGPUFeatureName const * requiredFeatures; - WGPU_NULLABLE WGPURequiredLimits const * requiredLimits; - WGPUQueueDescriptor defaultQueue; - WGPUDeviceLostCallback deviceLostCallback; - void * deviceLostUserdata; - WGPUUncapturedErrorCallbackInfo uncapturedErrorCallbackInfo; -} WGPUDeviceDescriptor WGPU_STRUCTURE_ATTRIBUTE; - typedef struct WGPURenderPassDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; size_t colorAttachmentCount; WGPURenderPassColorAttachment const * colorAttachments; WGPU_NULLABLE WGPURenderPassDepthStencilAttachment const * depthStencilAttachment; @@ -1370,7 +2176,10 @@ typedef struct WGPURenderPassDescriptor { typedef struct WGPUVertexState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t bufferCount; @@ -1380,7 +2189,10 @@ typedef struct WGPUVertexState { typedef struct WGPUFragmentState { WGPUChainedStruct const * nextInChain; WGPUShaderModule module; - WGPU_NULLABLE char const * entryPoint; + /** + * This is a \ref NullableInputString. + */ + WGPUStringView entryPoint; size_t constantCount; WGPUConstantEntry const * constants; size_t targetCount; @@ -1389,7 +2201,10 @@ typedef struct WGPUFragmentState { typedef struct WGPURenderPipelineDescriptor { WGPUChainedStruct const * nextInChain; - WGPU_NULLABLE char const * label; + /** + * This is a \ref NonNullInputString. + */ + WGPUStringView label; WGPU_NULLABLE WGPUPipelineLayout layout; WGPUVertexState vertex; WGPUPrimitiveState primitive; @@ -1406,236 +2221,1007 @@ extern "C" { #if !defined(WGPU_SKIP_PROCS) +/** + * Proc pointer type for @ref wgpuCreateInstance: + * > @copydoc wgpuCreateInstance + */ typedef WGPUInstance (*WGPUProcCreateInstance)(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetInstanceCapabilities: + * > @copydoc wgpuGetInstanceCapabilities + */ +typedef WGPUStatus (*WGPUProcGetInstanceCapabilities)(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuGetProcAddress: + * > @copydoc wgpuGetProcAddress + */ +typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; // Procs of Adapter -typedef size_t (*WGPUProcAdapterEnumerateFeatures)(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetFeatures: + * > @copydoc wgpuAdapterGetFeatures + */ +typedef void (*WGPUProcAdapterGetFeatures)(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetInfo: + * > @copydoc wgpuAdapterGetInfo + */ +typedef WGPUStatus (*WGPUProcAdapterGetInfo)(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterGetLimits: + * > @copydoc wgpuAdapterGetLimits + */ +typedef WGPUStatus (*WGPUProcAdapterGetLimits)(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterHasFeature: + * > @copydoc wgpuAdapterHasFeature + */ typedef WGPUBool (*WGPUProcAdapterHasFeature)(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcAdapterReference)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRequestDevice: + * > @copydoc wgpuAdapterRequestDevice + */ +typedef WGPUFuture (*WGPUProcAdapterRequestDevice)(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterAddRef. + * > @copydoc wgpuAdapterAddRef + */ +typedef void (*WGPUProcAdapterAddRef)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuAdapterRelease. + * > @copydoc wgpuAdapterRelease + */ typedef void (*WGPUProcAdapterRelease)(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; // Procs of AdapterInfo +/** + * Proc pointer type for @ref wgpuAdapterInfoFreeMembers: + * > @copydoc wgpuAdapterInfoFreeMembers + */ typedef void (*WGPUProcAdapterInfoFreeMembers)(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroup -typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupReference)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupSetLabel: + * > @copydoc wgpuBindGroupSetLabel + */ +typedef void (*WGPUProcBindGroupSetLabel)(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupAddRef. + * > @copydoc wgpuBindGroupAddRef + */ +typedef void (*WGPUProcBindGroupAddRef)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupRelease. + * > @copydoc wgpuBindGroupRelease + */ typedef void (*WGPUProcBindGroupRelease)(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; // Procs of BindGroupLayout -typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBindGroupLayoutReference)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutSetLabel: + * > @copydoc wgpuBindGroupLayoutSetLabel + */ +typedef void (*WGPUProcBindGroupLayoutSetLabel)(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutAddRef. + * > @copydoc wgpuBindGroupLayoutAddRef + */ +typedef void (*WGPUProcBindGroupLayoutAddRef)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBindGroupLayoutRelease. + * > @copydoc wgpuBindGroupLayoutRelease + */ typedef void (*WGPUProcBindGroupLayoutRelease)(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of Buffer +/** + * Proc pointer type for @ref wgpuBufferDestroy: + * > @copydoc wgpuBufferDestroy + */ typedef void (*WGPUProcBufferDestroy)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetConstMappedRange: + * > @copydoc wgpuBufferGetConstMappedRange + */ typedef void const * (*WGPUProcBufferGetConstMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMapState: + * > @copydoc wgpuBufferGetMapState + */ typedef WGPUBufferMapState (*WGPUProcBufferGetMapState)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetMappedRange: + * > @copydoc wgpuBufferGetMappedRange + */ typedef void * (*WGPUProcBufferGetMappedRange)(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetSize: + * > @copydoc wgpuBufferGetSize + */ typedef uint64_t (*WGPUProcBufferGetSize)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBufferUsageFlags (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferReference)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; - -// Procs of CommandBuffer -typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandBufferReference)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferGetUsage: + * > @copydoc wgpuBufferGetUsage + */ +typedef WGPUBufferUsage (*WGPUProcBufferGetUsage)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferMapAsync: + * > @copydoc wgpuBufferMapAsync + */ +typedef WGPUFuture (*WGPUProcBufferMapAsync)(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferSetLabel: + * > @copydoc wgpuBufferSetLabel + */ +typedef void (*WGPUProcBufferSetLabel)(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferUnmap: + * > @copydoc wgpuBufferUnmap + */ +typedef void (*WGPUProcBufferUnmap)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferAddRef. + * > @copydoc wgpuBufferAddRef + */ +typedef void (*WGPUProcBufferAddRef)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuBufferRelease. + * > @copydoc wgpuBufferRelease + */ +typedef void (*WGPUProcBufferRelease)(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of CommandBuffer +/** + * Proc pointer type for @ref wgpuCommandBufferSetLabel: + * > @copydoc wgpuCommandBufferSetLabel + */ +typedef void (*WGPUProcCommandBufferSetLabel)(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferAddRef. + * > @copydoc wgpuCommandBufferAddRef + */ +typedef void (*WGPUProcCommandBufferAddRef)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandBufferRelease. + * > @copydoc wgpuCommandBufferRelease + */ typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; // Procs of CommandEncoder +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginComputePass: + * > @copydoc wgpuCommandEncoderBeginComputePass + */ typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderBeginRenderPass: + * > @copydoc wgpuCommandEncoderBeginRenderPass + */ typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderClearBuffer: + * > @copydoc wgpuCommandEncoderClearBuffer + */ typedef void (*WGPUProcCommandEncoderClearBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToBuffer: + * > @copydoc wgpuCommandEncoderCopyBufferToBuffer + */ typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyBufferToTexture: + * > @copydoc wgpuCommandEncoderCopyBufferToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToBuffer: + * > @copydoc wgpuCommandEncoderCopyTextureToBuffer + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderCopyTextureToTexture: + * > @copydoc wgpuCommandEncoderCopyTextureToTexture + */ +typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderFinish: + * > @copydoc wgpuCommandEncoderFinish + */ typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderInsertDebugMarker: + * > @copydoc wgpuCommandEncoderInsertDebugMarker + */ +typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPopDebugGroup: + * > @copydoc wgpuCommandEncoderPopDebugGroup + */ typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderPushDebugGroup: + * > @copydoc wgpuCommandEncoderPushDebugGroup + */ +typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderResolveQuerySet: + * > @copydoc wgpuCommandEncoderResolveQuerySet + */ typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderSetLabel: + * > @copydoc wgpuCommandEncoderSetLabel + */ +typedef void (*WGPUProcCommandEncoderSetLabel)(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderWriteTimestamp: + * > @copydoc wgpuCommandEncoderWriteTimestamp + */ typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcCommandEncoderReference)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderAddRef. + * > @copydoc wgpuCommandEncoderAddRef + */ +typedef void (*WGPUProcCommandEncoderAddRef)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuCommandEncoderRelease. + * > @copydoc wgpuCommandEncoderRelease + */ typedef void (*WGPUProcCommandEncoderRelease)(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePassEncoder +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroups: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroups + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroups)(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderDispatchWorkgroupsIndirect: + * > @copydoc wgpuComputePassEncoderDispatchWorkgroupsIndirect + */ typedef void (*WGPUProcComputePassEncoderDispatchWorkgroupsIndirect)(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderEnd: + * > @copydoc wgpuComputePassEncoderEnd + */ typedef void (*WGPUProcComputePassEncoderEnd)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderInsertDebugMarker: + * > @copydoc wgpuComputePassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcComputePassEncoderInsertDebugMarker)(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPopDebugGroup: + * > @copydoc wgpuComputePassEncoderPopDebugGroup + */ typedef void (*WGPUProcComputePassEncoderPopDebugGroup)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderPushDebugGroup: + * > @copydoc wgpuComputePassEncoderPushDebugGroup + */ +typedef void (*WGPUProcComputePassEncoderPushDebugGroup)(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetBindGroup: + * > @copydoc wgpuComputePassEncoderSetBindGroup + */ typedef void (*WGPUProcComputePassEncoderSetBindGroup)(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetLabel: + * > @copydoc wgpuComputePassEncoderSetLabel + */ +typedef void (*WGPUProcComputePassEncoderSetLabel)(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderSetPipeline: + * > @copydoc wgpuComputePassEncoderSetPipeline + */ typedef void (*WGPUProcComputePassEncoderSetPipeline)(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePassEncoderReference)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderAddRef. + * > @copydoc wgpuComputePassEncoderAddRef + */ +typedef void (*WGPUProcComputePassEncoderAddRef)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePassEncoderRelease. + * > @copydoc wgpuComputePassEncoderRelease + */ typedef void (*WGPUProcComputePassEncoderRelease)(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of ComputePipeline +/** + * Proc pointer type for @ref wgpuComputePipelineGetBindGroupLayout: + * > @copydoc wgpuComputePipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcComputePipelineGetBindGroupLayout)(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcComputePipelineReference)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineSetLabel: + * > @copydoc wgpuComputePipelineSetLabel + */ +typedef void (*WGPUProcComputePipelineSetLabel)(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineAddRef. + * > @copydoc wgpuComputePipelineAddRef + */ +typedef void (*WGPUProcComputePipelineAddRef)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuComputePipelineRelease. + * > @copydoc wgpuComputePipelineRelease + */ typedef void (*WGPUProcComputePipelineRelease)(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Device +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroup: + * > @copydoc wgpuDeviceCreateBindGroup + */ typedef WGPUBindGroup (*WGPUProcDeviceCreateBindGroup)(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBindGroupLayout: + * > @copydoc wgpuDeviceCreateBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcDeviceCreateBindGroupLayout)(WGPUDevice device, WGPUBindGroupLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateBuffer: + * > @copydoc wgpuDeviceCreateBuffer + */ typedef WGPUBuffer (*WGPUProcDeviceCreateBuffer)(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateCommandEncoder: + * > @copydoc wgpuDeviceCreateCommandEncoder + */ typedef WGPUCommandEncoder (*WGPUProcDeviceCreateCommandEncoder)(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipeline: + * > @copydoc wgpuDeviceCreateComputePipeline + */ typedef WGPUComputePipeline (*WGPUProcDeviceCreateComputePipeline)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateComputePipelineAsync: + * > @copydoc wgpuDeviceCreateComputePipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateComputePipelineAsync)(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreatePipelineLayout: + * > @copydoc wgpuDeviceCreatePipelineLayout + */ typedef WGPUPipelineLayout (*WGPUProcDeviceCreatePipelineLayout)(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateQuerySet: + * > @copydoc wgpuDeviceCreateQuerySet + */ typedef WGPUQuerySet (*WGPUProcDeviceCreateQuerySet)(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderBundleEncoder: + * > @copydoc wgpuDeviceCreateRenderBundleEncoder + */ typedef WGPURenderBundleEncoder (*WGPUProcDeviceCreateRenderBundleEncoder)(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipeline: + * > @copydoc wgpuDeviceCreateRenderPipeline + */ typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateRenderPipelineAsync: + * > @copydoc wgpuDeviceCreateRenderPipelineAsync + */ +typedef WGPUFuture (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateSampler: + * > @copydoc wgpuDeviceCreateSampler + */ typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateShaderModule: + * > @copydoc wgpuDeviceCreateShaderModule + */ typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceCreateTexture: + * > @copydoc wgpuDeviceCreateTexture + */ typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceDestroy: + * > @copydoc wgpuDeviceDestroy + */ typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetAdapterInfo: + * > @copydoc wgpuDeviceGetAdapterInfo + */ +typedef WGPUAdapterInfo (*WGPUProcDeviceGetAdapterInfo)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetFeatures: + * > @copydoc wgpuDeviceGetFeatures + */ +typedef void (*WGPUProcDeviceGetFeatures)(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLimits: + * > @copydoc wgpuDeviceGetLimits + */ +typedef WGPUStatus (*WGPUProcDeviceGetLimits)(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetLostFuture: + * > @copydoc wgpuDeviceGetLostFuture + */ +typedef WGPUFuture (*WGPUProcDeviceGetLostFuture)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceGetQueue: + * > @copydoc wgpuDeviceGetQueue + */ typedef WGPUQueue (*WGPUProcDeviceGetQueue)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceHasFeature: + * > @copydoc wgpuDeviceHasFeature + */ typedef WGPUBool (*WGPUProcDeviceHasFeature)(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePopErrorScope: + * > @copydoc wgpuDevicePopErrorScope + */ +typedef WGPUFuture (*WGPUProcDevicePopErrorScope)(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDevicePushErrorScope: + * > @copydoc wgpuDevicePushErrorScope + */ typedef void (*WGPUProcDevicePushErrorScope)(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcDeviceReference)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceSetLabel: + * > @copydoc wgpuDeviceSetLabel + */ +typedef void (*WGPUProcDeviceSetLabel)(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceAddRef. + * > @copydoc wgpuDeviceAddRef + */ +typedef void (*WGPUProcDeviceAddRef)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuDeviceRelease. + * > @copydoc wgpuDeviceRelease + */ typedef void (*WGPUProcDeviceRelease)(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; // Procs of Instance +/** + * Proc pointer type for @ref wgpuInstanceCreateSurface: + * > @copydoc wgpuInstanceCreateSurface + */ typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceGetWGSLLanguageFeatures: + * > @copydoc wgpuInstanceGetWGSLLanguageFeatures + */ +typedef WGPUStatus (*WGPUProcInstanceGetWGSLLanguageFeatures)(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceHasWGSLLanguageFeature: + * > @copydoc wgpuInstanceHasWGSLLanguageFeature + */ +typedef WGPUBool (*WGPUProcInstanceHasWGSLLanguageFeature)(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceProcessEvents: + * > @copydoc wgpuInstanceProcessEvents + */ typedef void (*WGPUProcInstanceProcessEvents)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcInstanceReference)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRequestAdapter: + * > @copydoc wgpuInstanceRequestAdapter + */ +typedef WGPUFuture (*WGPUProcInstanceRequestAdapter)(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceWaitAny: + * > @copydoc wgpuInstanceWaitAny + */ +typedef WGPUWaitStatus (*WGPUProcInstanceWaitAny)(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceAddRef. + * > @copydoc wgpuInstanceAddRef + */ +typedef void (*WGPUProcInstanceAddRef)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuInstanceRelease. + * > @copydoc wgpuInstanceRelease + */ typedef void (*WGPUProcInstanceRelease)(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; // Procs of PipelineLayout -typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcPipelineLayoutReference)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutSetLabel: + * > @copydoc wgpuPipelineLayoutSetLabel + */ +typedef void (*WGPUProcPipelineLayoutSetLabel)(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutAddRef. + * > @copydoc wgpuPipelineLayoutAddRef + */ +typedef void (*WGPUProcPipelineLayoutAddRef)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuPipelineLayoutRelease. + * > @copydoc wgpuPipelineLayoutRelease + */ typedef void (*WGPUProcPipelineLayoutRelease)(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; // Procs of QuerySet +/** + * Proc pointer type for @ref wgpuQuerySetDestroy: + * > @copydoc wgpuQuerySetDestroy + */ typedef void (*WGPUProcQuerySetDestroy)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetCount: + * > @copydoc wgpuQuerySetGetCount + */ typedef uint32_t (*WGPUProcQuerySetGetCount)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetGetType: + * > @copydoc wgpuQuerySetGetType + */ typedef WGPUQueryType (*WGPUProcQuerySetGetType)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQuerySetReference)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetSetLabel: + * > @copydoc wgpuQuerySetSetLabel + */ +typedef void (*WGPUProcQuerySetSetLabel)(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetAddRef. + * > @copydoc wgpuQuerySetAddRef + */ +typedef void (*WGPUProcQuerySetAddRef)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQuerySetRelease. + * > @copydoc wgpuQuerySetRelease + */ typedef void (*WGPUProcQuerySetRelease)(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; // Procs of Queue -typedef void (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueOnSubmittedWorkDone: + * > @copydoc wgpuQueueOnSubmittedWorkDone + */ +typedef WGPUFuture (*WGPUProcQueueOnSubmittedWorkDone)(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSetLabel: + * > @copydoc wgpuQueueSetLabel + */ +typedef void (*WGPUProcQueueSetLabel)(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueSubmit: + * > @copydoc wgpuQueueSubmit + */ typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteBuffer: + * > @copydoc wgpuQueueWriteBuffer + */ typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcQueueReference)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueWriteTexture: + * > @copydoc wgpuQueueWriteTexture + */ +typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueAddRef. + * > @copydoc wgpuQueueAddRef + */ +typedef void (*WGPUProcQueueAddRef)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuQueueRelease. + * > @copydoc wgpuQueueRelease + */ typedef void (*WGPUProcQueueRelease)(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundle -typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleReference)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleSetLabel: + * > @copydoc wgpuRenderBundleSetLabel + */ +typedef void (*WGPUProcRenderBundleSetLabel)(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleAddRef. + * > @copydoc wgpuRenderBundleAddRef + */ +typedef void (*WGPUProcRenderBundleAddRef)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleRelease. + * > @copydoc wgpuRenderBundleRelease + */ typedef void (*WGPUProcRenderBundleRelease)(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderBundleEncoder +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDraw: + * > @copydoc wgpuRenderBundleEncoderDraw + */ typedef void (*WGPUProcRenderBundleEncoderDraw)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexed: + * > @copydoc wgpuRenderBundleEncoderDrawIndexed + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexed)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndexedIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderDrawIndirect: + * > @copydoc wgpuRenderBundleEncoderDrawIndirect + */ typedef void (*WGPUProcRenderBundleEncoderDrawIndirect)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderFinish: + * > @copydoc wgpuRenderBundleEncoderFinish + */ typedef WGPURenderBundle (*WGPUProcRenderBundleEncoderFinish)(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderInsertDebugMarker: + * > @copydoc wgpuRenderBundleEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderBundleEncoderInsertDebugMarker)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPopDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderBundleEncoderPopDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderPushDebugGroup: + * > @copydoc wgpuRenderBundleEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderBundleEncoderPushDebugGroup)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetBindGroup: + * > @copydoc wgpuRenderBundleEncoderSetBindGroup + */ typedef void (*WGPUProcRenderBundleEncoderSetBindGroup)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetIndexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetIndexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetLabel: + * > @copydoc wgpuRenderBundleEncoderSetLabel + */ +typedef void (*WGPUProcRenderBundleEncoderSetLabel)(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetPipeline: + * > @copydoc wgpuRenderBundleEncoderSetPipeline + */ typedef void (*WGPUProcRenderBundleEncoderSetPipeline)(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderSetVertexBuffer: + * > @copydoc wgpuRenderBundleEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderBundleEncoderSetVertexBuffer)(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderBundleEncoderReference)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderAddRef. + * > @copydoc wgpuRenderBundleEncoderAddRef + */ +typedef void (*WGPUProcRenderBundleEncoderAddRef)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderBundleEncoderRelease. + * > @copydoc wgpuRenderBundleEncoderRelease + */ typedef void (*WGPUProcRenderBundleEncoderRelease)(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPassEncoder +/** + * Proc pointer type for @ref wgpuRenderPassEncoderBeginOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderBeginOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderBeginOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDraw: + * > @copydoc wgpuRenderPassEncoderDraw + */ typedef void (*WGPUProcRenderPassEncoderDraw)(WGPURenderPassEncoder renderPassEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexed: + * > @copydoc wgpuRenderPassEncoderDrawIndexed + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexed)(WGPURenderPassEncoder renderPassEncoder, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndexedIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndexedIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndexedIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderDrawIndirect: + * > @copydoc wgpuRenderPassEncoderDrawIndirect + */ typedef void (*WGPUProcRenderPassEncoderDrawIndirect)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEnd: + * > @copydoc wgpuRenderPassEncoderEnd + */ typedef void (*WGPUProcRenderPassEncoderEnd)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderEndOcclusionQuery: + * > @copydoc wgpuRenderPassEncoderEndOcclusionQuery + */ typedef void (*WGPUProcRenderPassEncoderEndOcclusionQuery)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderExecuteBundles: + * > @copydoc wgpuRenderPassEncoderExecuteBundles + */ typedef void (*WGPUProcRenderPassEncoderExecuteBundles)(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderInsertDebugMarker: + * > @copydoc wgpuRenderPassEncoderInsertDebugMarker + */ +typedef void (*WGPUProcRenderPassEncoderInsertDebugMarker)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPopDebugGroup: + * > @copydoc wgpuRenderPassEncoderPopDebugGroup + */ typedef void (*WGPUProcRenderPassEncoderPopDebugGroup)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderPushDebugGroup: + * > @copydoc wgpuRenderPassEncoderPushDebugGroup + */ +typedef void (*WGPUProcRenderPassEncoderPushDebugGroup)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBindGroup: + * > @copydoc wgpuRenderPassEncoderSetBindGroup + */ typedef void (*WGPUProcRenderPassEncoderSetBindGroup)(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetBlendConstant: + * > @copydoc wgpuRenderPassEncoderSetBlendConstant + */ typedef void (*WGPUProcRenderPassEncoderSetBlendConstant)(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetIndexBuffer: + * > @copydoc wgpuRenderPassEncoderSetIndexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetIndexBuffer)(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetLabel: + * > @copydoc wgpuRenderPassEncoderSetLabel + */ +typedef void (*WGPUProcRenderPassEncoderSetLabel)(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetPipeline: + * > @copydoc wgpuRenderPassEncoderSetPipeline + */ typedef void (*WGPUProcRenderPassEncoderSetPipeline)(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetScissorRect: + * > @copydoc wgpuRenderPassEncoderSetScissorRect + */ typedef void (*WGPUProcRenderPassEncoderSetScissorRect)(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetStencilReference: + * > @copydoc wgpuRenderPassEncoderSetStencilReference + */ typedef void (*WGPUProcRenderPassEncoderSetStencilReference)(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetVertexBuffer: + * > @copydoc wgpuRenderPassEncoderSetVertexBuffer + */ typedef void (*WGPUProcRenderPassEncoderSetVertexBuffer)(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderSetViewport: + * > @copydoc wgpuRenderPassEncoderSetViewport + */ typedef void (*WGPUProcRenderPassEncoderSetViewport)(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPassEncoderReference)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderAddRef. + * > @copydoc wgpuRenderPassEncoderAddRef + */ +typedef void (*WGPUProcRenderPassEncoderAddRef)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPassEncoderRelease. + * > @copydoc wgpuRenderPassEncoderRelease + */ typedef void (*WGPUProcRenderPassEncoderRelease)(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; // Procs of RenderPipeline +/** + * Proc pointer type for @ref wgpuRenderPipelineGetBindGroupLayout: + * > @copydoc wgpuRenderPipelineGetBindGroupLayout + */ typedef WGPUBindGroupLayout (*WGPUProcRenderPipelineGetBindGroupLayout)(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcRenderPipelineReference)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineSetLabel: + * > @copydoc wgpuRenderPipelineSetLabel + */ +typedef void (*WGPUProcRenderPipelineSetLabel)(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineAddRef. + * > @copydoc wgpuRenderPipelineAddRef + */ +typedef void (*WGPUProcRenderPipelineAddRef)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuRenderPipelineRelease. + * > @copydoc wgpuRenderPipelineRelease + */ typedef void (*WGPUProcRenderPipelineRelease)(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; // Procs of Sampler -typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSamplerReference)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerSetLabel: + * > @copydoc wgpuSamplerSetLabel + */ +typedef void (*WGPUProcSamplerSetLabel)(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerAddRef. + * > @copydoc wgpuSamplerAddRef + */ +typedef void (*WGPUProcSamplerAddRef)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSamplerRelease. + * > @copydoc wgpuSamplerRelease + */ typedef void (*WGPUProcSamplerRelease)(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; // Procs of ShaderModule -typedef void (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcShaderModuleReference)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleGetCompilationInfo: + * > @copydoc wgpuShaderModuleGetCompilationInfo + */ +typedef WGPUFuture (*WGPUProcShaderModuleGetCompilationInfo)(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleSetLabel: + * > @copydoc wgpuShaderModuleSetLabel + */ +typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleAddRef. + * > @copydoc wgpuShaderModuleAddRef + */ +typedef void (*WGPUProcShaderModuleAddRef)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuShaderModuleRelease. + * > @copydoc wgpuShaderModuleRelease + */ typedef void (*WGPUProcShaderModuleRelease)(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +// Procs of SupportedFeatures +/** + * Proc pointer type for @ref wgpuSupportedFeaturesFreeMembers: + * > @copydoc wgpuSupportedFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedFeaturesFreeMembers)(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; + +// Procs of SupportedWGSLLanguageFeatures +/** + * Proc pointer type for @ref wgpuSupportedWGSLLanguageFeaturesFreeMembers: + * > @copydoc wgpuSupportedWGSLLanguageFeaturesFreeMembers + */ +typedef void (*WGPUProcSupportedWGSLLanguageFeaturesFreeMembers)(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; + // Procs of Surface +/** + * Proc pointer type for @ref wgpuSurfaceConfigure: + * > @copydoc wgpuSurfaceConfigure + */ typedef void (*WGPUProcSurfaceConfigure)(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCapabilities: + * > @copydoc wgpuSurfaceGetCapabilities + */ +typedef WGPUStatus (*WGPUProcSurfaceGetCapabilities)(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceGetCurrentTexture: + * > @copydoc wgpuSurfaceGetCurrentTexture + */ typedef void (*WGPUProcSurfaceGetCurrentTexture)(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfacePresent: + * > @copydoc wgpuSurfacePresent + */ +typedef WGPUStatus (*WGPUProcSurfacePresent)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceSetLabel: + * > @copydoc wgpuSurfaceSetLabel + */ +typedef void (*WGPUProcSurfaceSetLabel)(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceUnconfigure: + * > @copydoc wgpuSurfaceUnconfigure + */ typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcSurfaceReference)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceAddRef. + * > @copydoc wgpuSurfaceAddRef + */ +typedef void (*WGPUProcSurfaceAddRef)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuSurfaceRelease. + * > @copydoc wgpuSurfaceRelease + */ typedef void (*WGPUProcSurfaceRelease)(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; // Procs of SurfaceCapabilities +/** + * Proc pointer type for @ref wgpuSurfaceCapabilitiesFreeMembers: + * > @copydoc wgpuSurfaceCapabilitiesFreeMembers + */ typedef void (*WGPUProcSurfaceCapabilitiesFreeMembers)(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; // Procs of Texture +/** + * Proc pointer type for @ref wgpuTextureCreateView: + * > @copydoc wgpuTextureCreateView + */ typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureDestroy: + * > @copydoc wgpuTextureDestroy + */ typedef void (*WGPUProcTextureDestroy)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDepthOrArrayLayers: + * > @copydoc wgpuTextureGetDepthOrArrayLayers + */ typedef uint32_t (*WGPUProcTextureGetDepthOrArrayLayers)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetDimension: + * > @copydoc wgpuTextureGetDimension + */ typedef WGPUTextureDimension (*WGPUProcTextureGetDimension)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetFormat: + * > @copydoc wgpuTextureGetFormat + */ typedef WGPUTextureFormat (*WGPUProcTextureGetFormat)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetHeight: + * > @copydoc wgpuTextureGetHeight + */ typedef uint32_t (*WGPUProcTextureGetHeight)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetMipLevelCount: + * > @copydoc wgpuTextureGetMipLevelCount + */ typedef uint32_t (*WGPUProcTextureGetMipLevelCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetSampleCount: + * > @copydoc wgpuTextureGetSampleCount + */ typedef uint32_t (*WGPUProcTextureGetSampleCount)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef WGPUTextureUsageFlags (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetUsage: + * > @copydoc wgpuTextureGetUsage + */ +typedef WGPUTextureUsage (*WGPUProcTextureGetUsage)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureGetWidth: + * > @copydoc wgpuTextureGetWidth + */ typedef uint32_t (*WGPUProcTextureGetWidth)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureReference)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureSetLabel: + * > @copydoc wgpuTextureSetLabel + */ +typedef void (*WGPUProcTextureSetLabel)(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureAddRef. + * > @copydoc wgpuTextureAddRef + */ +typedef void (*WGPUProcTextureAddRef)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureRelease. + * > @copydoc wgpuTextureRelease + */ typedef void (*WGPUProcTextureRelease)(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; // Procs of TextureView -typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -typedef void (*WGPUProcTextureViewReference)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewSetLabel: + * > @copydoc wgpuTextureViewSetLabel + */ +typedef void (*WGPUProcTextureViewSetLabel)(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewAddRef. + * > @copydoc wgpuTextureViewAddRef + */ +typedef void (*WGPUProcTextureViewAddRef)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +/** + * Proc pointer type for @ref wgpuTextureViewRelease. + * > @copydoc wgpuTextureViewRelease + */ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; #endif // !defined(WGPU_SKIP_PROCS) @@ -1644,11 +3230,28 @@ typedef void (*WGPUProcTextureViewRelease)(WGPUTextureView textureView) WGPU_FUN /** * \defgroup GlobalFunctions Global Functions * \brief Functions that are not specific to an object. - * + * * @{ */ +/** + * Create a WGPUInstance + */ WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPU_NULLABLE WGPUInstanceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName) WGPU_FUNCTION_ATTRIBUTE; +/** + * Query the supported instance capabilities. + * + * @param capabilities + * The supported instance capabilities + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuGetInstanceCapabilities(WGPUInstanceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the "procedure address" (function pointer) of the named function. + * The result must be cast to the appropriate proc pointer type. + */ +WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUStringView procName) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1656,22 +3259,39 @@ WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName /** * \defgroup Methods * \brief Functions that are relative to a specific object. - * + * * @{ */ /** * \defgroup WGPUAdapterMethods WGPUAdapter methods * \brief Functions whose first argument has type WGPUAdapter. - * + * * @{ */ -WGPU_EXPORT size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuAdapterGetLimits(WGPUAdapter adapter, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUFeatureName values supported by the adapter. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuAdapterGetFeatures(WGPUAdapter adapter, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param info + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetInfo(WGPUAdapter adapter, WGPUAdapterInfo * info) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuAdapterGetLimits(WGPUAdapter adapter, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuAdapterHasFeature(WGPUAdapter adapter, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPUAdapterRequestDeviceCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuAdapterReference(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuAdapterRequestDevice(WGPUAdapter adapter, WGPU_NULLABLE WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuAdapterAddRef(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1680,9 +3300,12 @@ WGPU_EXPORT void wgpuAdapterRelease(WGPUAdapter adapter) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUAdapterInfoMethods WGPUAdapterInfo methods * \brief Functions whose first argument has type WGPUAdapterInfo. - * + * * @{ */ +/** + * Frees array members of WGPUAdapterInfo which were allocated by the API. + */ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1691,11 +3314,11 @@ WGPU_EXPORT void wgpuAdapterInfoFreeMembers(WGPUAdapterInfo adapterInfo) WGPU_FU /** * \defgroup WGPUBindGroupMethods WGPUBindGroup methods * \brief Functions whose first argument has type WGPUBindGroup. - * + * * @{ */ -WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupReference(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupAddRef(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1704,11 +3327,11 @@ WGPU_EXPORT void wgpuBindGroupRelease(WGPUBindGroup bindGroup) WGPU_FUNCTION_ATT /** * \defgroup WGPUBindGroupLayoutMethods WGPUBindGroupLayout methods * \brief Functions whose first argument has type WGPUBindGroupLayout. - * + * * @{ */ -WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBindGroupLayoutReference(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBindGroupLayoutAddRef(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1717,19 +3340,49 @@ WGPU_EXPORT void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout) /** * \defgroup WGPUBufferMethods WGPUBuffer methods * \brief Functions whose first argument has type WGPUBuffer. - * + * * @{ */ WGPU_EXPORT void wgpuBufferDestroy(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a const pointer to beginning of the mapped range. + * It must not be written; writing to this range causes undefined behavior. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * **except** for overlaps with other *const* ranges, which are allowed in C. + * (JS does not allow this because const ranges do not exist.) + */ WGPU_EXPORT void const * wgpuBufferGetConstMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBufferMapState wgpuBufferGetMapState(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +/** + * @param offset + * Byte offset relative to the beginning of the buffer. + * + * @param size + * Byte size of the range to get. The returned pointer is valid for exactly this many bytes. + * + * @returns + * Returns a mutable pointer to beginning of the mapped range. + * Returns `NULL` with @ref ImplementationDefinedLogging if: + * + * - There is any content-timeline error as defined in the WebGPU specification for `getMappedRange()` (alignments, overlaps, etc.) + * - The buffer is not mapped with @ref WGPUMapMode_Write. + */ WGPU_EXPORT void * wgpuBufferGetMappedRange(WGPUBuffer buffer, size_t offset, size_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint64_t wgpuBufferGetSize(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBufferUsageFlags wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBufferUsage wgpuBufferGetUsage(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapMode mode, size_t offset, size_t size, WGPUBufferMapCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferSetLabel(WGPUBuffer buffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferUnmap(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuBufferReference(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuBufferAddRef(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1738,11 +3391,11 @@ WGPU_EXPORT void wgpuBufferRelease(WGPUBuffer buffer) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPUCommandBufferMethods WGPUCommandBuffer methods * \brief Functions whose first argument has type WGPUCommandBuffer. - * + * * @{ */ -WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandBufferReference(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandBufferAddRef(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1751,24 +3404,24 @@ WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer) WGPU_ /** * \defgroup WGPUCommandEncoderMethods WGPUCommandEncoder methods * \brief Functions whose first argument has type WGPUCommandEncoder. - * + * * @{ */ WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUComputePassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderClearBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyBufferInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyBufferInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTexelCopyTextureInfo const * source, WGPUTexelCopyTextureInfo const * destination, WGPUExtent3D const * copySize) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPU_NULLABLE WGPUCommandBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderResolveQuerySet(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderSetLabel(WGPUCommandEncoder commandEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderWriteTimestamp(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuCommandEncoderReference(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuCommandEncoderAddRef(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1777,19 +3430,19 @@ WGPU_EXPORT void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder) WG /** * \defgroup WGPUComputePassEncoderMethods WGPUComputePassEncoder methods * \brief Functions whose first argument has type WGPUComputePassEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroups(WGPUComputePassEncoder computePassEncoder, uint32_t workgroupCountX, uint32_t workgroupCountY, uint32_t workgroupCountZ) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderDispatchWorkgroupsIndirect(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderEnd(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderPopDebugGroup(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetBindGroup(WGPUComputePassEncoder computePassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderSetLabel(WGPUComputePassEncoder computePassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderSetPipeline(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePassEncoderReference(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePassEncoderAddRef(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1798,12 +3451,12 @@ WGPU_EXPORT void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePas /** * \defgroup WGPUComputePipelineMethods WGPUComputePipeline methods * \brief Functions whose first argument has type WGPUComputePipeline. - * + * * @{ */ WGPU_EXPORT WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuComputePipelineReference(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuComputePipelineAddRef(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1812,7 +3465,7 @@ WGPU_EXPORT void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline) /** * \defgroup WGPUDeviceMethods WGPUDevice methods * \brief Functions whose first argument has type WGPUDevice. - * + * * @{ */ WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -1820,24 +3473,40 @@ WGPU_EXPORT WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice devic WGPU_EXPORT WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, WGPUBufferDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, WGPU_NULLABLE WGPUCommandEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUDeviceCreateComputePipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, WGPUPipelineLayoutDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, WGPUQuerySetDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, WGPURenderBundleEncoderDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUDeviceCreateRenderPipelineAsyncCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPU_NULLABLE WGPUSamplerDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuDeviceGetLimits(WGPUDevice device, WGPUSupportedLimits * limits) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUAdapterInfo wgpuDeviceGetAdapterInfo(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUFeatureName values supported by the device. + * + * @param features + * This parameter is @ref ReturnedWithOwnership. + */ +WGPU_EXPORT void wgpuDeviceGetFeatures(WGPUDevice device, WGPUSupportedFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuDeviceGetLimits(WGPUDevice device, WGPULimits * limits) WGPU_FUNCTION_ATTRIBUTE; +/** + * @returns + * The @ref WGPUFuture for the device-lost event of the device. + */ +WGPU_EXPORT WGPUFuture wgpuDeviceGetLostFuture(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueue wgpuDeviceGetQueue(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUBool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDevicePopErrorScope(WGPUDevice device, WGPUErrorCallback callback, void * userdata) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuDevicePopErrorScope(WGPUDevice device, WGPUPopErrorScopeCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDevicePushErrorScope(WGPUDevice device, WGPUErrorFilter filter) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuDeviceReference(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceSetLabel(WGPUDevice device, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuDeviceAddRef(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1846,14 +3515,38 @@ WGPU_EXPORT void wgpuDeviceRelease(WGPUDevice device) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPUInstanceMethods WGPUInstance methods * \brief Functions whose first argument has type WGPUInstance. - * + * * @{ */ +/** + * Creates a @ref WGPUSurface, see @ref Surface-Creation for more details. + * + * @param descriptor + * The description of the @ref WGPUSurface to create. + * + * @returns + * A new @ref WGPUSurface for this descriptor (or an error @ref WGPUSurface). + */ WGPU_EXPORT WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Get the list of @ref WGPUWGSLLanguageFeatureName values supported by the instance. + */ +WGPU_EXPORT WGPUStatus wgpuInstanceGetWGSLLanguageFeatures(WGPUInstance instance, WGPUSupportedWGSLLanguageFeatures * features) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUBool wgpuInstanceHasWGSLLanguageFeature(WGPUInstance instance, WGPUWGSLLanguageFeatureName feature) WGPU_FUNCTION_ATTRIBUTE; +/** + * Processes asynchronous events on this `WGPUInstance`, calling any callbacks for asynchronous operations created with `::WGPUCallbackMode_AllowProcessEvents`. + * + * See @ref Process-Events for more information. + */ WGPU_EXPORT void wgpuInstanceProcessEvents(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPUInstanceRequestAdapterCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuInstanceReference(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuInstanceRequestAdapter(WGPUInstance instance, WGPU_NULLABLE WGPURequestAdapterOptions const * options, WGPURequestAdapterCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +/** + * Wait for at least one WGPUFuture in `futures` to complete, and call callbacks of the respective completed asynchronous operations. + * + * See @ref Wait-Any for more information. + */ +WGPU_EXPORT WGPUWaitStatus wgpuInstanceWaitAny(WGPUInstance instance, size_t futureCount, WGPU_NULLABLE WGPUFutureWaitInfo * futures, uint64_t timeoutNS) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuInstanceAddRef(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1862,11 +3555,11 @@ WGPU_EXPORT void wgpuInstanceRelease(WGPUInstance instance) WGPU_FUNCTION_ATTRIB /** * \defgroup WGPUPipelineLayoutMethods WGPUPipelineLayout methods * \brief Functions whose first argument has type WGPUPipelineLayout. - * + * * @{ */ -WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuPipelineLayoutReference(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuPipelineLayoutAddRef(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1875,14 +3568,14 @@ WGPU_EXPORT void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout) WG /** * \defgroup WGPUQuerySetMethods WGPUQuerySet methods * \brief Functions whose first argument has type WGPUQuerySet. - * + * * @{ */ WGPU_EXPORT void wgpuQuerySetDestroy(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuQuerySetGetCount(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPUQueryType wgpuQuerySetGetType(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQuerySetReference(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetSetLabel(WGPUQuerySet querySet, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQuerySetAddRef(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1891,15 +3584,19 @@ WGPU_EXPORT void wgpuQuerySetRelease(WGPUQuerySet querySet) WGPU_FUNCTION_ATTRIB /** * \defgroup WGPUQueueMethods WGPUQueue methods * \brief Functions whose first argument has type WGPUQueue. - * + * * @{ */ -WGPU_EXPORT void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueOnSubmittedWorkDoneCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, WGPUQueueWorkDoneCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueSetLabel(WGPUQueue queue, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) WGPU_FUNCTION_ATTRIBUTE; +/** + * Produces a @ref DeviceError both content-timeline (`size` alignment) and device-timeline + * errors defined by the WebGPU specification. + */ WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUTexelCopyTextureInfo const * destination, void const * data, size_t dataSize, WGPUTexelCopyBufferLayout const * dataLayout, WGPUExtent3D const * writeSize) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuQueueAddRef(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1908,11 +3605,11 @@ WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue) WGPU_FUNCTION_ATTRIBUTE; /** * \defgroup WGPURenderBundleMethods WGPURenderBundle methods * \brief Functions whose first argument has type WGPURenderBundle. - * + * * @{ */ -WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleReference(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleAddRef(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1921,7 +3618,7 @@ WGPU_EXPORT void wgpuRenderBundleRelease(WGPURenderBundle renderBundle) WGPU_FUN /** * \defgroup WGPURenderBundleEncoderMethods WGPURenderBundleEncoder methods * \brief Functions whose first argument has type WGPURenderBundleEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) WGPU_FUNCTION_ATTRIBUTE; @@ -1929,15 +3626,15 @@ WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexed(WGPURenderBundleEncoder rend WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndexedIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderDrawIndirect(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, WGPU_NULLABLE WGPURenderBundleDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderPopDebugGroup(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderPushDebugGroup(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetBindGroup(WGPURenderBundleEncoder renderBundleEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetIndexBuffer(WGPURenderBundleEncoder renderBundleEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderSetLabel(WGPURenderBundleEncoder renderBundleEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetPipeline(WGPURenderBundleEncoder renderBundleEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderSetVertexBuffer(WGPURenderBundleEncoder renderBundleEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderBundleEncoderReference(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderBundleEncoderAddRef(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1946,7 +3643,7 @@ WGPU_EXPORT void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBu /** * \defgroup WGPURenderPassEncoderMethods WGPURenderPassEncoder methods * \brief Functions whose first argument has type WGPURenderPassEncoder. - * + * * @{ */ WGPU_EXPORT void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) WGPU_FUNCTION_ATTRIBUTE; @@ -1957,19 +3654,19 @@ WGPU_EXPORT void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderP WGPU_EXPORT void wgpuRenderPassEncoderEnd(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderEndOcclusionQuery(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderExecuteBundles(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, char const * markerLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderInsertDebugMarker(WGPURenderPassEncoder renderPassEncoder, WGPUStringView markerLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderPopDebugGroup(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, char const * groupLabel) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderPushDebugGroup(WGPURenderPassEncoder renderPassEncoder, WGPUStringView groupLabel) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBindGroup(WGPURenderPassEncoder renderPassEncoder, uint32_t groupIndex, WGPU_NULLABLE WGPUBindGroup group, size_t dynamicOffsetCount, uint32_t const * dynamicOffsets) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetBlendConstant(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetIndexBuffer(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer buffer, WGPUIndexFormat format, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, char const * label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderSetLabel(WGPURenderPassEncoder renderPassEncoder, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetScissorRect(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetStencilReference(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetVertexBuffer(WGPURenderPassEncoder renderPassEncoder, uint32_t slot, WGPU_NULLABLE WGPUBuffer buffer, uint64_t offset, uint64_t size) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderSetViewport(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPassEncoderReference(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPassEncoderAddRef(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1978,12 +3675,12 @@ WGPU_EXPORT void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEn /** * \defgroup WGPURenderPipelineMethods WGPURenderPipeline methods * \brief Functions whose first argument has type WGPURenderPipeline. - * + * * @{ */ WGPU_EXPORT WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuRenderPipelineReference(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuRenderPipelineAddRef(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -1992,11 +3689,11 @@ WGPU_EXPORT void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline) WG /** * \defgroup WGPUSamplerMethods WGPUSampler methods * \brief Functions whose first argument has type WGPUSampler. - * + * * @{ */ -WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSamplerReference(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerSetLabel(WGPUSampler sampler, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSamplerAddRef(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2005,30 +3702,108 @@ WGPU_EXPORT void wgpuSamplerRelease(WGPUSampler sampler) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUShaderModuleMethods WGPUShaderModule methods * \brief Functions whose first argument has type WGPUShaderModule. - * + * * @{ */ -WGPU_EXPORT void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUShaderModuleGetCompilationInfoCallback callback, WGPU_NULLABLE void * userdata) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuShaderModuleReference(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUFuture wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallbackInfo callbackInfo) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuShaderModuleAddRef(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuShaderModuleRelease(WGPUShaderModule shaderModule) WGPU_FUNCTION_ATTRIBUTE; /** @} */ +/** + * \defgroup WGPUSupportedFeaturesMethods WGPUSupportedFeatures methods + * \brief Functions whose first argument has type WGPUSupportedFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedFeaturesFreeMembers(WGPUSupportedFeatures supportedFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + +/** + * \defgroup WGPUSupportedWGSLLanguageFeaturesMethods WGPUSupportedWGSLLanguageFeatures methods + * \brief Functions whose first argument has type WGPUSupportedWGSLLanguageFeatures. + * + * @{ + */ +/** + * Frees array members of WGPUSupportedWGSLLanguageFeatures which were allocated by the API. + */ +WGPU_EXPORT void wgpuSupportedWGSLLanguageFeaturesFreeMembers(WGPUSupportedWGSLLanguageFeatures supportedWGSLLanguageFeatures) WGPU_FUNCTION_ATTRIBUTE; +/** @} */ + + + /** * \defgroup WGPUSurfaceMethods WGPUSurface methods * \brief Functions whose first argument has type WGPUSurface. - * + * * @{ */ +/** + * Configures parameters for rendering to `surface`. + * Produces a @ref DeviceError for all content-timeline errors defined by the WebGPU specification. + * + * See @ref Surface-Configuration for more details. + * + * @param config + * The new configuration to use. + */ WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * config) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Provides information on how `adapter` is able to use `surface`. + * See @ref Surface-Capabilities for more details. + * + * @param adapter + * The @ref WGPUAdapter to get capabilities for presenting to this @ref WGPUSurface. + * + * @param capabilities + * The structure to fill capabilities in. + * It may contain memory allocations so `::wgpuSurfaceCapabilitiesFreeMembers` must be called to avoid memory leaks. + * This parameter is @ref ReturnedWithOwnership. + * + * @returns + * Indicates if there was an @ref OutStructChainError. + */ +WGPU_EXPORT WGPUStatus wgpuSurfaceGetCapabilities(WGPUSurface surface, WGPUAdapter adapter, WGPUSurfaceCapabilities * capabilities) WGPU_FUNCTION_ATTRIBUTE; +/** + * Returns the @ref WGPUTexture to render to `surface` this frame along with metadata on the frame. + * Returns `NULL` and @ref WGPUSurfaceGetCurrentTextureStatus_Error if the surface is not configured. + * + * See @ref Surface-Presenting for more details. + * + * @param surfaceTexture + * The structure to fill the @ref WGPUTexture and metadata in. + */ WGPU_EXPORT void wgpuSurfaceGetCurrentTexture(WGPUSurface surface, WGPUSurfaceTexture * surfaceTexture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, char const * label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Shows `surface`'s current texture to the user. + * See @ref Surface-Presenting for more details. + * + * @returns + * Returns @ref WGPUStatus_Error if the surface doesn't have a current texture. + */ +WGPU_EXPORT WGPUStatus wgpuSurfacePresent(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +/** + * Modifies the label used to refer to `surface`. + * + * @param label + * The new label. + */ +WGPU_EXPORT void wgpuSurfaceSetLabel(WGPUSurface surface, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +/** + * Removes the configuration for `surface`. + * See @ref Surface-Configuration for more details. + */ WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuSurfaceReference(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuSurfaceAddRef(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2037,9 +3812,12 @@ WGPU_EXPORT void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUSurfaceCapabilitiesMethods WGPUSurfaceCapabilities methods * \brief Functions whose first argument has type WGPUSurfaceCapabilities. - * + * * @{ */ +/** + * Frees array members of WGPUSurfaceCapabilities which were allocated by the API. + */ WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surfaceCapabilities) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2048,7 +3826,7 @@ WGPU_EXPORT void wgpuSurfaceCapabilitiesFreeMembers(WGPUSurfaceCapabilities surf /** * \defgroup WGPUTextureMethods WGPUTexture methods * \brief Functions whose first argument has type WGPUTexture. - * + * * @{ */ WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPU_NULLABLE WGPUTextureViewDescriptor const * descriptor) WGPU_FUNCTION_ATTRIBUTE; @@ -2059,10 +3837,10 @@ WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture) WGPU_FUN WGPU_EXPORT uint32_t wgpuTextureGetHeight(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetMipLevelCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetSampleCount(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT WGPUTextureUsageFlags wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT uint32_t wgpuTextureGetWidth(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureReference(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureSetLabel(WGPUTexture texture, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureAddRef(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE; /** @} */ @@ -2071,11 +3849,11 @@ WGPU_EXPORT void wgpuTextureRelease(WGPUTexture texture) WGPU_FUNCTION_ATTRIBUTE /** * \defgroup WGPUTextureViewMethods WGPUTextureView methods * \brief Functions whose first argument has type WGPUTextureView. - * + * * @{ */ -WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, char const * label) WGPU_FUNCTION_ATTRIBUTE; -WGPU_EXPORT void wgpuTextureViewReference(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewSetLabel(WGPUTextureView textureView, WGPUStringView label) WGPU_FUNCTION_ATTRIBUTE; +WGPU_EXPORT void wgpuTextureViewAddRef(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; WGPU_EXPORT void wgpuTextureViewRelease(WGPUTextureView textureView) WGPU_FUNCTION_ATTRIBUTE; /** @} */ diff --git a/wgpu/resources/wgpu.h b/wgpu/resources/wgpu.h index 28a51f62..6cee9d15 100644 --- a/wgpu/resources/wgpu.h +++ b/wgpu/resources/wgpu.h @@ -6,10 +6,9 @@ typedef enum WGPUNativeSType { // Start at 0003 since that's allocated range for wgpu-native WGPUSType_DeviceExtras = 0x00030001, - WGPUSType_RequiredLimitsExtras = 0x00030002, + WGPUSType_NativeLimits = 0x00030002, WGPUSType_PipelineLayoutExtras = 0x00030003, WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, - WGPUSType_SupportedLimitsExtras = 0x00030005, WGPUSType_InstanceExtras = 0x00030006, WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, @@ -31,8 +30,6 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, WGPUNativeFeature_TextureFormat16bitNorm = 0x0003000B, WGPUNativeFeature_TextureCompressionAstcHdr = 0x0003000C, - // TODO: requires wgpu.h api change - // WGPUNativeFeature_TimestampQueryInsidePasses = 0x0003000D, WGPUNativeFeature_MappablePrimaryBuffers = 0x0003000E, WGPUNativeFeature_BufferBindingArray = 0x0003000F, WGPUNativeFeature_UniformBufferAndStorageTextureArrayNonUniformIndexing = 0x00030010, @@ -43,7 +40,7 @@ typedef enum WGPUNativeFeature { // WGPUNativeFeature_PolygonModePoint = 0x00030014, // WGPUNativeFeature_ConservativeRasterization = 0x00030015, // WGPUNativeFeature_ClearTexture = 0x00030016, - // WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, + WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, // WGPUNativeFeature_Multiview = 0x00030018, WGPUNativeFeature_VertexAttribute64bit = 0x00030019, WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, @@ -53,6 +50,11 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_ShaderI16 = 0x0003001E, WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, + WGPUNativeFeature_Subgroup = 0x00030021, + WGPUNativeFeature_SubgroupVertex = 0x00030022, + WGPUNativeFeature_SubgroupBarrier = 0x00030023, + WGPUNativeFeature_TimestampQueryInsideEncoders = 0x00030024, + WGPUNativeFeature_TimestampQueryInsidePasses = 0x00030025, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; @@ -66,30 +68,26 @@ typedef enum WGPULogLevel { WGPULogLevel_Force32 = 0x7FFFFFFF } WGPULogLevel; -typedef enum WGPUInstanceBackend { - WGPUInstanceBackend_All = 0x00000000, - WGPUInstanceBackend_Vulkan = 1 << 0, - WGPUInstanceBackend_GL = 1 << 1, - WGPUInstanceBackend_Metal = 1 << 2, - WGPUInstanceBackend_DX12 = 1 << 3, - WGPUInstanceBackend_DX11 = 1 << 4, - WGPUInstanceBackend_BrowserWebGPU = 1 << 5, - WGPUInstanceBackend_Primary = WGPUInstanceBackend_Vulkan | WGPUInstanceBackend_Metal | - WGPUInstanceBackend_DX12 | - WGPUInstanceBackend_BrowserWebGPU, - WGPUInstanceBackend_Secondary = WGPUInstanceBackend_GL | WGPUInstanceBackend_DX11, - WGPUInstanceBackend_Force32 = 0x7FFFFFFF -} WGPUInstanceBackend; -typedef WGPUFlags WGPUInstanceBackendFlags; - -typedef enum WGPUInstanceFlag { - WGPUInstanceFlag_Default = 0x00000000, - WGPUInstanceFlag_Debug = 1 << 0, - WGPUInstanceFlag_Validation = 1 << 1, - WGPUInstanceFlag_DiscardHalLabels = 1 << 2, - WGPUInstanceFlag_Force32 = 0x7FFFFFFF -} WGPUInstanceFlag; -typedef WGPUFlags WGPUInstanceFlags; +typedef WGPUFlags WGPUInstanceBackend; +static const WGPUInstanceBackend WGPUInstanceBackend_All = 0x00000000; +static const WGPUInstanceBackend WGPUInstanceBackend_Vulkan = 1 << 0; +static const WGPUInstanceBackend WGPUInstanceBackend_GL = 1 << 1; +static const WGPUInstanceBackend WGPUInstanceBackend_Metal = 1 << 2; +static const WGPUInstanceBackend WGPUInstanceBackend_DX12 = 1 << 3; +static const WGPUInstanceBackend WGPUInstanceBackend_DX11 = 1 << 4; +static const WGPUInstanceBackend WGPUInstanceBackend_BrowserWebGPU = 1 << 5; +// Vulkan, Metal, DX12 and BrowserWebGPU +static const WGPUInstanceBackend WGPUInstanceBackend_Primary = (1 << 0) | (1 << 2) | (1 << 3) | (1 << 5); +// GL and DX11 +static const WGPUInstanceBackend WGPUInstanceBackend_Secondary = (1 << 1) | (1 << 4); +static const WGPUInstanceBackend WGPUInstanceBackend_Force32 = 0x7FFFFFFF; + +typedef WGPUFlags WGPUInstanceFlag; +static const WGPUInstanceFlag WGPUInstanceFlag_Default = 0x00000000; +static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0; +static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1; +static const WGPUInstanceFlag WGPUInstanceFlag_DiscardHalLabels = 1 << 2; +static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF; typedef enum WGPUDx12Compiler { WGPUDx12Compiler_Undefined = 0x00000000, @@ -122,36 +120,28 @@ typedef enum WGPUNativeQueryType { typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; - WGPUInstanceBackendFlags backends; - WGPUInstanceFlags flags; + WGPUInstanceBackend backends; + WGPUInstanceFlag flags; WGPUDx12Compiler dx12ShaderCompiler; WGPUGles3MinorVersion gles3MinorVersion; - const char * dxilPath; - const char * dxcPath; + WGPUStringView dxilPath; + WGPUStringView dxcPath; } WGPUInstanceExtras; typedef struct WGPUDeviceExtras { WGPUChainedStruct chain; - const char * tracePath; + WGPUStringView tracePath; } WGPUDeviceExtras; typedef struct WGPUNativeLimits { + /** This struct chain is used as mutable in some places and immutable in others. */ + WGPUChainedStructOut chain; uint32_t maxPushConstantSize; uint32_t maxNonSamplerBindings; } WGPUNativeLimits; -typedef struct WGPURequiredLimitsExtras { - WGPUChainedStruct chain; - WGPUNativeLimits limits; -} WGPURequiredLimitsExtras; - -typedef struct WGPUSupportedLimitsExtras { - WGPUChainedStructOut chain; - WGPUNativeLimits limits; -} WGPUSupportedLimitsExtras; - typedef struct WGPUPushConstantRange { - WGPUShaderStageFlags stages; + WGPUShaderStage stages; uint32_t start; uint32_t end; } WGPUPushConstantRange; @@ -164,29 +154,29 @@ typedef struct WGPUPipelineLayoutExtras { typedef uint64_t WGPUSubmissionIndex; -typedef struct WGPUWrappedSubmissionIndex { - WGPUQueue queue; - WGPUSubmissionIndex submissionIndex; -} WGPUWrappedSubmissionIndex; - typedef struct WGPUShaderDefine { - char const * name; - char const * value; + WGPUStringView name; + WGPUStringView value; } WGPUShaderDefine; typedef struct WGPUShaderModuleGLSLDescriptor { WGPUChainedStruct chain; WGPUShaderStage stage; - char const * code; + WGPUStringView code; uint32_t defineCount; WGPUShaderDefine * defines; } WGPUShaderModuleGLSLDescriptor; +typedef struct WGPUShaderModuleDescriptorSpirV { + WGPUStringView label; + uint32_t sourceSize; + uint32_t const * source; +} WGPUShaderModuleDescriptorSpirV; + typedef struct WGPURegistryReport { size_t numAllocated; size_t numKeptFromUser; size_t numReleasedFromUser; - size_t numError; size_t elementSize; } WGPURegistryReport; @@ -202,6 +192,7 @@ typedef struct WGPUHubReport { WGPURegistryReport renderBundles; WGPURegistryReport renderPipelines; WGPURegistryReport computePipelines; + WGPURegistryReport pipelineCaches; WGPURegistryReport querySets; WGPURegistryReport buffers; WGPURegistryReport textures; @@ -211,16 +202,12 @@ typedef struct WGPUHubReport { typedef struct WGPUGlobalReport { WGPURegistryReport surfaces; - WGPUBackendType backendType; - WGPUHubReport vulkan; - WGPUHubReport metal; - WGPUHubReport dx12; - WGPUHubReport gl; + WGPUHubReport hub; } WGPUGlobalReport; typedef struct WGPUInstanceEnumerateAdapterOptions { WGPUChainedStruct const * nextInChain; - WGPUInstanceBackendFlags backends; + WGPUInstanceBackend backends; } WGPUInstanceEnumerateAdapterOptions; typedef struct WGPUBindGroupEntryExtras { @@ -249,7 +236,7 @@ typedef struct WGPUSurfaceConfigurationExtras { uint32_t desiredMaximumFrameLatency; } WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; -typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); +typedef void (*WGPULogCallback)(WGPULogLevel level, WGPUStringView message, void * userdata); typedef enum WGPUNativeTextureFormat { // From Features::TEXTURE_FORMAT_16BIT_NORM @@ -273,7 +260,8 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex); +WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); @@ -281,7 +269,9 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); -void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuComputePassEncoderSetPushConstants(WGPUComputePassEncoder encoder, uint32_t offset, uint32_t sizeBytes, void const * data); +void wgpuRenderBundleEncoderSetPushConstants(WGPURenderBundleEncoder encoder, WGPUShaderStage stages, uint32_t offset, uint32_t sizeBytes, void const * data); void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); @@ -294,6 +284,9 @@ void wgpuComputePassEncoderEndPipelineStatisticsQuery(WGPUComputePassEncoder com void wgpuRenderPassEncoderBeginPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); void wgpuRenderPassEncoderEndPipelineStatisticsQuery(WGPURenderPassEncoder renderPassEncoder); +void wgpuComputePassEncoderWriteTimestamp(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); +void wgpuRenderPassEncoderWriteTimestamp(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint32_t queryIndex); + #ifdef __cplusplus } // extern "C" #endif