From 0587446258c721e47afd82df8aaf782703a6e4a8 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 6 Apr 2026 21:15:22 +0200 Subject: [PATCH 1/3] don't refault required positional args --- codegen/apipatcher.py | 8 +- codegen/idlparser.py | 31 +++-- wgpu/_classes.py | 187 ++++++++++++++++-------------- wgpu/backends/wgpu_native/_api.py | 157 +++++++++++++------------ 4 files changed, 205 insertions(+), 178 deletions(-) diff --git a/codegen/apipatcher.py b/codegen/apipatcher.py index 8bb973f5..f7c7b731 100644 --- a/codegen/apipatcher.py +++ b/codegen/apipatcher.py @@ -454,7 +454,7 @@ def get_method_def(self, classname, methodname) -> str: # Get arg names and types idl_line = functions[name_idl] args = idl_line.split("(", 1)[1].split(")", 1)[0].split(",") - args = [Attribute(arg) for arg in args if arg.strip()] + args = [Attribute(arg, struct=False) for arg in args if arg.strip()] return_type = idl_line.split()[0] if return_type.startswith("[NewObject]"): # [NewObject] can be skipped: https://webidl.spec.whatwg.org/#NewObject @@ -471,8 +471,10 @@ def get_method_def(self, classname, methodname) -> str: if len(args) == 1 and args[0].typename.endswith( ("Options", "Descriptor", "Configuration") ): + if not args[0].required: + args[0].typename = args[0].typename.removeprefix("optional ") assert args[0].typename.startswith("GPU") - des_is_optional = bool(args[0].default) + des_is_optional = bool(args[0].default) # part of the logic above? attributes = self.idl.structs[args[0].typename[3:]].values() py_args = [ self._arg_from_attribute(methodname, attr, des_is_optional) @@ -583,7 +585,7 @@ def get_method_comment(self, classname, methodname): idl_line = functions[name_idl] args = idl_line.split("(", 1)[1].split(")", 1)[0].split(",") - args = [Attribute(arg) for arg in args if arg.strip()] + args = [Attribute(arg, struct=False) for arg in args if arg.strip()] # If one arg that is a dict, flatten dict to kwargs if len(args) == 1 and args[0].typename.endswith( diff --git a/codegen/idlparser.py b/codegen/idlparser.py index dfbe6f00..94e9fac7 100644 --- a/codegen/idlparser.py +++ b/codegen/idlparser.py @@ -35,24 +35,33 @@ def get_idl_parser(*, allow_cache=True): class Attribute: """A little object to hold a function argument or struct field.""" - def __init__(self, line): + def __init__(self, line: str, struct:bool=True): self.line = line.strip().strip(",;").strip() default = None # None means 'no default' and "None" kinda means "auto". - required = False + required = False # as opposed to optional, https://webidl.spec.whatwg.org/#required-dictionary-member but struct members? + # function args can be optional https://webidl.spec.whatwg.org/#dfn-optional-argument and a required if not arg = self.line if "=" in arg: arg, default = arg.rsplit("=", 1) arg, default = arg.strip(), default.strip() arg_type, arg_name = arg.strip().rsplit(" ", 1) - if arg_type.startswith("required "): - required = True - arg_type = arg_type.split(" ", 1)[1] - # required args should not have a default - assert default is None - elif arg_type.startswith("optional "): - arg_type = arg_type.split(" ", 1)[1] - default = default or "None" + if struct: + # some struct members might be required + if arg_type.startswith("required "): + required = True + arg_type = arg_type.split(" ", 1)[1] + # required args should not have a default + assert default is None + else: + # some function args might be optional + if arg_type.startswith("optional "): + required = False + arg_type = arg_type.split(" ", 1)[1] + default = default or "None" + else: + # but otherwise they are reuired + required = True if default: if default in ["false", "true"]: @@ -66,7 +75,7 @@ def __init__(self, line): def __repr__(self): return f"" - def to_str(self): + def to_str(self) -> str: return self.line diff --git a/wgpu/_classes.py b/wgpu/_classes.py index c14555ce..1e143e44 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -1260,9 +1260,10 @@ def create_query_set( """Create a `GPUQuerySet` object.""" raise NotImplementedError() + # FIXME: was push_error_scope(self, filter: enums.ErrorFilterEnum | None = None) -> None: # IDL: undefined pushErrorScope(GPUErrorFilter filter); @apidiff.hide - def push_error_scope(self, filter: enums.ErrorFilterEnum | None = None) -> None: + def push_error_scope(self, filter: enums.ErrorFilterEnum) -> None: """Pushes a new GPU error scope onto the stack.""" raise NotImplementedError() @@ -1348,12 +1349,10 @@ def map_state(self) -> enums.BufferMapStateEnum: # but reading and writing data goes via method calls instead of via # an array-like object that exposes the shared memory. + # FIXME: was map_sync(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); def map_sync( - self, - mode: flags.MapModeFlags | None = None, - offset: int = 0, - size: int | None = None, + self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None ) -> None: """Sync version of `map_async()`. @@ -1362,12 +1361,10 @@ def map_sync( promise = self.map_async(mode=mode, offset=offset, size=size) return promise.sync_wait() + # FIXME: was map_async(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> GPUPromise[None]: # IDL: Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); def map_async( - self, - mode: flags.MapModeFlags | None = None, - offset: int = 0, - size: int | None = None, + self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None ) -> GPUPromise[None]: """Maps the given range of the GPUBuffer. @@ -1697,8 +1694,9 @@ def get_compilation_info_async(self) -> GPUPromise[GPUCompilationInfo]: class GPUPipelineBase: """A mixin class for render and compute pipelines.""" + # FIXME: was get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: # IDL: [NewObject] GPUBindGroupLayout getBindGroupLayout(unsigned long index); - def get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: + def get_bind_group_layout(self, index: int) -> GPUBindGroupLayout: """Get the bind group layout at the given index.""" raise NotImplementedError() @@ -1771,8 +1769,9 @@ def set_bind_group( class GPUDebugCommandsMixin: """Mixin for classes that support debug groups and markers.""" + # FIXME: was push_debug_group(self, group_label: str | None = None) -> None: # IDL: undefined pushDebugGroup(USVString groupLabel); - def push_debug_group(self, group_label: str | None = None) -> None: + def push_debug_group(self, group_label: str) -> None: """Push a named debug group into the command stream.""" raise NotImplementedError() @@ -1781,8 +1780,9 @@ def pop_debug_group(self) -> None: """Pop the active debug group.""" raise NotImplementedError() + # FIXME: was insert_debug_marker(self, marker_label: str | None = None) -> None: # IDL: undefined insertDebugMarker(USVString markerLabel); - def insert_debug_marker(self, marker_label: str | None = None) -> None: + def insert_debug_marker(self, marker_label: str) -> None: """Insert the given message into the debug message queue.""" raise NotImplementedError() @@ -1790,8 +1790,9 @@ def insert_debug_marker(self, marker_label: str | None = None) -> None: class GPURenderCommandsMixin: """Mixin for classes that provide rendering commands.""" + # FIXME: was set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: # IDL: undefined setPipeline(GPURenderPipeline pipeline); - def set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: + def set_pipeline(self, pipeline: GPURenderPipeline) -> None: """Set the pipeline for this render pass. Arguments: @@ -1799,11 +1800,12 @@ def set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: """ raise NotImplementedError() + # FIXME: was set_index_buffer(self, buffer: GPUBuffer | None = None, index_format: enums.IndexFormatEnum | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size); def set_index_buffer( self, - buffer: GPUBuffer | None = None, - index_format: enums.IndexFormatEnum | None = None, + buffer: GPUBuffer, + index_format: enums.IndexFormatEnum, offset: int = 0, size: int | None = None, ) -> None: @@ -1820,13 +1822,10 @@ def set_index_buffer( """ raise NotImplementedError() + # FIXME: was set_vertex_buffer(self, slot: int | None = None, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer? buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); def set_vertex_buffer( - self, - slot: int | None = None, - buffer: GPUBuffer | None = None, - offset: int = 0, - size: int | None = None, + self, slot: int, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: """Associate a vertex buffer with a bind slot. @@ -1841,10 +1840,11 @@ def set_vertex_buffer( """ raise NotImplementedError() + # FIXME: was draw(self, vertex_count: int | None = None, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0) -> None: # IDL: undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1, optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0); def draw( self, - vertex_count: int | None = None, + vertex_count: int, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0, @@ -1859,12 +1859,9 @@ def draw( """ raise NotImplementedError() + # FIXME: was draw_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); - def draw_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, - ) -> None: + def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> None: """Like `draw()`, but the function arguments are in a buffer. Arguments: @@ -1875,10 +1872,11 @@ def draw_indirect( """ raise NotImplementedError() + # FIXME: was draw_indexed(self, index_count: int | None = None, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, first_instance: int = 0) -> None: # IDL: undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1, optional GPUSize32 firstIndex = 0, optional GPUSignedOffset32 baseVertex = 0, optional GPUSize32 firstInstance = 0); def draw_indexed( self, - index_count: int | None = None, + index_count: int, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, @@ -1897,11 +1895,10 @@ def draw_indexed( """ raise NotImplementedError() + # FIXME: was draw_indexed_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); def draw_indexed_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, + self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: """ Like `draw_indexed()`, but the function arguments are in a buffer. @@ -1959,9 +1956,10 @@ def begin_render_pass( """ raise NotImplementedError() + # FIXME: was clear_buffer(self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined clearBuffer( GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); def clear_buffer( - self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None + self, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: """Set (part of) the given buffer to zeros. @@ -1974,13 +1972,14 @@ def clear_buffer( """ raise NotImplementedError() + # FIXME: was copy_buffer_to_buffer(self, source: GPUBuffer | None = None, source_offset: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None, size: int | None = None) -> None: # IDL: undefined copyBufferToBuffer( GPUBuffer source, GPUSize64 sourceOffset, GPUBuffer destination, GPUSize64 destinationOffset, optional GPUSize64 size); def copy_buffer_to_buffer( self, - source: GPUBuffer | None = None, - source_offset: int | None = None, - destination: GPUBuffer | None = None, - destination_offset: int | None = None, + source: GPUBuffer, + source_offset: int, + destination: GPUBuffer, + destination_offset: int, size: int | None = None, ) -> None: """Copy the contents of a buffer to another buffer. @@ -1996,12 +1995,13 @@ def copy_buffer_to_buffer( """ raise NotImplementedError() + # FIXME: was copy_buffer_to_texture(self, source: structs.TexelCopyBufferInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyBufferToTexture( GPUTexelCopyBufferInfo source, GPUTexelCopyTextureInfo destination, GPUExtent3D copySize); def copy_buffer_to_texture( self, - source: structs.TexelCopyBufferInfoStruct | None = None, - destination: structs.TexelCopyTextureInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyBufferInfoStruct, + destination: structs.TexelCopyTextureInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: """Copy the contents of a buffer to a texture (view). @@ -2014,12 +2014,13 @@ def copy_buffer_to_texture( """ raise NotImplementedError() + # FIXME: was copy_texture_to_buffer(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyBufferInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyTextureToBuffer( GPUTexelCopyTextureInfo source, GPUTexelCopyBufferInfo destination, GPUExtent3D copySize); def copy_texture_to_buffer( self, - source: structs.TexelCopyTextureInfoStruct | None = None, - destination: structs.TexelCopyBufferInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyTextureInfoStruct, + destination: structs.TexelCopyBufferInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: """Copy the contents of a texture (view) to a buffer. @@ -2032,12 +2033,13 @@ def copy_texture_to_buffer( """ raise NotImplementedError() + # FIXME: was copy_texture_to_texture(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyTextureToTexture( GPUTexelCopyTextureInfo source, GPUTexelCopyTextureInfo destination, GPUExtent3D copySize); def copy_texture_to_texture( self, - source: structs.TexelCopyTextureInfoStruct | None = None, - destination: structs.TexelCopyTextureInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyTextureInfoStruct, + destination: structs.TexelCopyTextureInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: """Copy the contents of a texture (view) to another texture (view). @@ -2057,14 +2059,15 @@ def finish(self, *, label: str = "") -> GPUCommandBuffer: """ raise NotImplementedError() + # FIXME: was resolve_query_set(self, query_set: GPUQuerySet | None = None, first_query: int | None = None, query_count: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None) -> None: # IDL: undefined resolveQuerySet( GPUQuerySet querySet, GPUSize32 firstQuery, GPUSize32 queryCount, GPUBuffer destination, GPUSize64 destinationOffset); def resolve_query_set( self, - query_set: GPUQuerySet | None = None, - first_query: int | None = None, - query_count: int | None = None, - destination: GPUBuffer | None = None, - destination_offset: int | None = None, + query_set: GPUQuerySet, + first_query: int, + query_count: int, + destination: GPUBuffer, + destination_offset: int, ) -> None: """ Resolves query results from a ``GPUQuerySet`` out into a range of a ``GPUBuffer``. @@ -2089,8 +2092,9 @@ class GPUComputePassEncoder( Create a compute pass encoder using `GPUCommandEncoder.begin_compute_pass()`. """ + # FIXME: was set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: # IDL: undefined setPipeline(GPUComputePipeline pipeline); - def set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: + def set_pipeline(self, pipeline: GPUComputePipeline) -> None: """Set the pipeline for this compute pass. Arguments: @@ -2098,10 +2102,11 @@ def set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: """ raise NotImplementedError() + # FIXME: was dispatch_workgroups(self, workgroup_count_x: int | None = None, workgroup_count_y: int = 1, workgroup_count_z: int = 1) -> None: # IDL: undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1); def dispatch_workgroups( self, - workgroup_count_x: int | None = None, + workgroup_count_x: int, workgroup_count_y: int = 1, workgroup_count_z: int = 1, ) -> None: @@ -2114,11 +2119,10 @@ def dispatch_workgroups( """ raise NotImplementedError() + # FIXME: was dispatch_workgroups_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); def dispatch_workgroups_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, + self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: """Like `dispatch_workgroups()`, but the function arguments are in a buffer. @@ -2146,15 +2150,16 @@ class GPURenderPassEncoder( Create a render pass encoder using `GPUCommandEncoder.begin_render_pass`. """ + # FIXME: was set_viewport(self, x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None, min_depth: float | None = None, max_depth: float | None = None) -> None: # IDL: undefined setViewport(float x, float y, float width, float height, float minDepth, float maxDepth); def set_viewport( self, - x: float | None = None, - y: float | None = None, - width: float | None = None, - height: float | None = None, - min_depth: float | None = None, - max_depth: float | None = None, + x: float, + y: float, + width: float, + height: float, + min_depth: float, + max_depth: float, ) -> None: """Set the viewport for this render pass. The whole scene is rendered to this sub-rectangle. @@ -2170,14 +2175,9 @@ def set_viewport( """ raise NotImplementedError() + # FIXME: was set_scissor_rect(self, x: int | None = None, y: int | None = None, width: int | None = None, height: int | None = None) -> None: # IDL: undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, GPUIntegerCoordinate width, GPUIntegerCoordinate height); - def set_scissor_rect( - self, - x: int | None = None, - y: int | None = None, - width: int | None = None, - height: int | None = None, - ) -> None: + def set_scissor_rect(self, x: int, y: int, width: int, height: int) -> None: """Set the scissor rectangle for this render pass. The scene is rendered as usual, but is only applied to this sub-rectangle. @@ -2189,10 +2189,10 @@ def set_scissor_rect( """ raise NotImplementedError() + # FIXME: was set_blend_constant(self, color: tuple[float, float, float, float] | structs.ColorStruct | None = None) -> None: # IDL: undefined setBlendConstant(GPUColor color); def set_blend_constant( - self, - color: tuple[float, float, float, float] | structs.ColorStruct | None = None, + self, color: tuple[float, float, float, float] | structs.ColorStruct ) -> None: """Set the blend color for the render pass. @@ -2201,8 +2201,9 @@ def set_blend_constant( """ raise NotImplementedError() + # FIXME: was set_stencil_reference(self, reference: int | None = None) -> None: # IDL: undefined setStencilReference(GPUStencilValue reference); - def set_stencil_reference(self, reference: int | None = None) -> None: + def set_stencil_reference(self, reference: int) -> None: """Set the reference stencil value for this render pass. Arguments: @@ -2210,8 +2211,9 @@ def set_stencil_reference(self, reference: int | None = None) -> None: """ raise NotImplementedError() + # FIXME: was execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: # IDL: undefined executeBundles(sequence bundles); - def execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: + def execute_bundles(self, bundles: Sequence[GPURenderBundle]) -> None: """Executes commands previously recorded into the render bundles as part of this render pass. @@ -2225,8 +2227,9 @@ def end(self) -> None: """Record the end of the render pass.""" raise NotImplementedError() + # FIXME: was begin_occlusion_query(self, query_index: int | None = None) -> None: # IDL: undefined beginOcclusionQuery(GPUSize32 queryIndex); - def begin_occlusion_query(self, query_index: int | None = None) -> None: + def begin_occlusion_query(self, query_index: int) -> None: """Begins an occlusion query. Arguments: @@ -2274,8 +2277,9 @@ class GPUQueue(GPUObjectBase): You can obtain a queue object via the :attr:`GPUDevice.queue` property. """ + # FIXME: was submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: # IDL: undefined submit(sequence commandBuffers); - def submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: + def submit(self, command_buffers: Sequence[GPUCommandBuffer]) -> None: """Submit a `GPUCommandBuffer` to the queue. Arguments: @@ -2283,12 +2287,13 @@ def submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> N """ raise NotImplementedError() + # FIXME: was write_buffer(self, buffer: GPUBuffer | None = None, buffer_offset: int | None = None, data: ArrayLike | None = None, data_offset: int = 0, size: int | None = None) -> None: # IDL: undefined writeBuffer( GPUBuffer buffer, GPUSize64 bufferOffset, AllowSharedBufferSource data, optional GPUSize64 dataOffset = 0, optional GPUSize64 size); def write_buffer( self, - buffer: GPUBuffer | None = None, - buffer_offset: int | None = None, - data: ArrayLike | None = None, + buffer: GPUBuffer, + buffer_offset: int, + data: ArrayLike, data_offset: int = 0, size: int | None = None, ) -> None: @@ -2335,13 +2340,14 @@ def read_buffer( """ raise NotImplementedError() + # FIXME: was write_texture(self, destination: structs.TexelCopyTextureInfoStruct | None = None, data: ArrayLike | None = None, data_layout: structs.TexelCopyBufferLayoutStruct | None = None, size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined writeTexture( GPUTexelCopyTextureInfo destination, AllowSharedBufferSource data, GPUTexelCopyBufferLayout dataLayout, GPUExtent3D size); def write_texture( self, - destination: structs.TexelCopyTextureInfoStruct | None = None, - data: ArrayLike | None = None, - data_layout: structs.TexelCopyBufferLayoutStruct | None = None, - size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + destination: structs.TexelCopyTextureInfoStruct, + data: ArrayLike, + data_layout: structs.TexelCopyBufferLayoutStruct, + size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: """Takes the data contents and schedules a write operation of these contents to the destination texture in the queue. A @@ -2384,13 +2390,14 @@ def read_texture( """ raise NotImplementedError() + # FIXME: was copy_external_image_to_texture(self, source: structs.CopyExternalImageSourceInfoStruct | None = None, destination: structs.CopyExternalImageDestInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyExternalImageToTexture( GPUCopyExternalImageSourceInfo source, GPUCopyExternalImageDestInfo destination, GPUExtent3D copySize); @apidiff.hide("Specific to browsers") def copy_external_image_to_texture( self, - source: structs.CopyExternalImageSourceInfoStruct | None = None, - destination: structs.CopyExternalImageDestInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.CopyExternalImageSourceInfoStruct, + destination: structs.CopyExternalImageDestInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: raise NotImplementedError() @@ -2450,26 +2457,27 @@ def message(self) -> str: class GPUOutOfMemoryError(GPUError, MemoryError): """An error raised when the GPU is out of memory.""" + # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); - def __init__(self, message: str | None = None): + def __init__(self, message: str): super().__init__(message or "GPU is out of memory.") class GPUValidationError(GPUError): """An error raised when the pipeline could not be validated.""" + # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); - def __init__(self, message: str | None = None): + def __init__(self, message: str): super().__init__(message) class GPUPipelineError(Exception): """An error raised when a pipeline could not be created.""" + # FIXME: was __init__(self, message: str = "", options: structs.PipelineErrorInitStruct | None = None): # IDL: constructor(optional DOMString message = "", GPUPipelineErrorInit options); - def __init__( - self, message: str = "", options: structs.PipelineErrorInitStruct | None = None - ): + def __init__(self, message: str, options: structs.PipelineErrorInitStruct): super().__init__(message or "") self._options = options @@ -2487,8 +2495,9 @@ class GPUInternalError(GPUError): reason even when all validation requirements have been satisfied. """ + # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); - def __init__(self, message: str | None = None): + def __init__(self, message: str): super().__init__(message) diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index 725c5f33..0cd2aa54 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -2527,11 +2527,9 @@ def _check_range(self, offset, size): raise ValueError("Mapped range must not extend beyond total buffer size.") return offset, size + # FIXME: was map_async(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> GPUPromise[None]: def map_async( - self, - mode: flags.MapModeFlags | None = None, - offset: int = 0, - size: int | None = None, + self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None ) -> GPUPromise[None]: sync_on_read = True @@ -2867,7 +2865,8 @@ def get_compilation_info_async(self) -> GPUPromise[GPUCompilationInfo]: class GPUPipelineBase(classes.GPUPipelineBase): - def get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: + # FIXME: was get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: + def get_bind_group_layout(self, index: int) -> GPUBindGroupLayout: # H: WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) # H: WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) function = type(self)._get_bind_group_layout_function @@ -3000,7 +2999,8 @@ 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 | None = None) -> None: + # FIXME: was push_debug_group(self, group_label: str | None = None) -> None: + def push_debug_group(self, group_label: str) -> None: c_group_label = to_c_string_view(group_label) # H: void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) # H: void wgpuComputePassEncoderPushDebugGroup(WGPUComputePassEncoder computePassEncoder, WGPUStringView groupLabel) @@ -3017,7 +3017,8 @@ def pop_debug_group(self) -> None: function = type(self)._pop_debug_group_function function(self._internal) - def insert_debug_marker(self, marker_label: str | None = None) -> None: + # FIXME: was insert_debug_marker(self, marker_label: str | None = None) -> None: + def insert_debug_marker(self, marker_label: str) -> None: c_marker_label = to_c_string_view(marker_label) # H: void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) # H: void wgpuComputePassEncoderInsertDebugMarker(WGPUComputePassEncoder computePassEncoder, WGPUStringView markerLabel) @@ -3039,7 +3040,8 @@ def _write_timestamp(self, query_set, query_index): class GPURenderCommandsMixin(classes.GPURenderCommandsMixin): - def set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: + # FIXME: was set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: + def set_pipeline(self, pipeline: GPURenderPipeline) -> None: self._maybe_keep_alive(pipeline) pipeline_id = pipeline._internal # H: void wgpuRenderPassEncoderSetPipeline(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) @@ -3047,10 +3049,11 @@ def set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: function = type(self)._set_pipeline_function function(self._internal, pipeline_id) + # FIXME: was set_index_buffer(self, buffer: GPUBuffer | None = None, index_format: enums.IndexFormatEnum | None = None, offset: int = 0, size: int | None = None) -> None: def set_index_buffer( self, - buffer: GPUBuffer | None = None, - index_format: enums.IndexFormatEnum | None = None, + buffer: GPUBuffer, + index_format: enums.IndexFormatEnum, offset: int = 0, size: int | None = None, ) -> None: @@ -3065,12 +3068,9 @@ def set_index_buffer( self._internal, buffer._internal, c_index_format, int(offset), int(size) ) + # FIXME: was set_vertex_buffer(self, slot: int | None = None, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: def set_vertex_buffer( - self, - slot: int | None = None, - buffer: GPUBuffer | None = None, - offset: int = 0, - size: int | None = None, + self, slot: int, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: self._maybe_keep_alive(buffer) if not size: @@ -3080,9 +3080,10 @@ def set_vertex_buffer( function = type(self)._set_vertex_buffer_function function(self._internal, int(slot), buffer._internal, int(offset), int(size)) + # FIXME: was draw(self, vertex_count: int | None = None, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0) -> None: def draw( self, - vertex_count: int | None = None, + vertex_count: int, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0, @@ -3094,11 +3095,8 @@ def draw( self._internal, vertex_count, instance_count, first_vertex, first_instance ) - def draw_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, - ) -> None: + # FIXME: was draw_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: + def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> None: # self._maybe_keep_alive(indirect_buffer) buffer_id = indirect_buffer._internal # H: void wgpuRenderPassEncoderDrawIndirect(WGPURenderPassEncoder renderPassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) @@ -3106,9 +3104,10 @@ def draw_indirect( function = type(self)._draw_indirect_function function(self._internal, buffer_id, int(indirect_offset)) + # FIXME: was draw_indexed(self, index_count: int | None = None, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, first_instance: int = 0) -> None: def draw_indexed( self, - index_count: int | None = None, + index_count: int, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, @@ -3126,10 +3125,9 @@ def draw_indexed( first_instance, ) + # FIXME: was draw_indexed_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: def draw_indexed_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, + self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: self._maybe_keep_alive(indirect_buffer) buffer_id = indirect_buffer._internal @@ -3341,8 +3339,9 @@ def _create_render_pass_stencil_attachment(self, ds_attachment): ) return c_depth_stencil_attachment + # FIXME: was clear_buffer(self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: def clear_buffer( - self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None + self, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: offset = int(offset) if offset % 4 != 0: # pragma: no cover @@ -3365,12 +3364,13 @@ def clear_buffer( self._internal, buffer._internal, offset, size ) + # FIXME: was copy_buffer_to_buffer(self, source: GPUBuffer | None = None, source_offset: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None, size: int | None = None) -> None: def copy_buffer_to_buffer( self, - source: GPUBuffer | None = None, - source_offset: int | None = None, - destination: GPUBuffer | None = None, - destination_offset: int | None = None, + source: GPUBuffer, + source_offset: int, + destination: GPUBuffer, + destination_offset: int, size: int | None = None, ) -> None: if source_offset % 4 != 0: # pragma: no cover @@ -3396,11 +3396,12 @@ def copy_buffer_to_buffer( int(size), ) + # FIXME: was copy_buffer_to_texture(self, source: structs.TexelCopyBufferInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_buffer_to_texture( self, - source: structs.TexelCopyBufferInfoStruct | None = None, - destination: structs.TexelCopyTextureInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyBufferInfoStruct, + destination: structs.TexelCopyTextureInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: check_struct("TexelCopyBufferInfo", source) check_struct("TexelCopyTextureInfo", destination) @@ -3462,11 +3463,12 @@ def copy_buffer_to_texture( c_copy_size, ) + # FIXME: was copy_texture_to_buffer(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyBufferInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_texture_to_buffer( self, - source: structs.TexelCopyTextureInfoStruct | None = None, - destination: structs.TexelCopyBufferInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyTextureInfoStruct, + destination: structs.TexelCopyBufferInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: check_struct("TexelCopyTextureInfo", source) check_struct("TexelCopyBufferInfo", destination) @@ -3528,11 +3530,12 @@ def copy_texture_to_buffer( c_copy_size, ) + # FIXME: was copy_texture_to_texture(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_texture_to_texture( self, - source: structs.TexelCopyTextureInfoStruct | None = None, - destination: structs.TexelCopyTextureInfoStruct | None = None, - copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + source: structs.TexelCopyTextureInfoStruct, + destination: structs.TexelCopyTextureInfoStruct, + copy_size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: check_struct("TexelCopyTextureInfo", source) check_struct("TexelCopyTextureInfo", destination) @@ -3605,13 +3608,14 @@ def finish(self, *, label: str = "") -> GPUCommandBuffer: return GPUCommandBuffer(label, id, self._device) + # FIXME: was resolve_query_set(self, query_set: GPUQuerySet | None = None, first_query: int | None = None, query_count: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None) -> None: def resolve_query_set( self, - query_set: GPUQuerySet | None = None, - first_query: int | None = None, - query_count: int | None = None, - destination: GPUBuffer | None = None, - destination_offset: int | None = None, + query_set: GPUQuerySet, + first_query: int, + query_count: int, + destination: GPUBuffer, + destination_offset: int, ) -> None: # H: void f(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset) libf.wgpuCommandEncoderResolveQuerySet( @@ -3646,14 +3650,16 @@ class GPUComputePassEncoder( # GPUObjectBaseMixin _release_function = libf.wgpuComputePassEncoderRelease - def set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: + # FIXME: was set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: + def set_pipeline(self, pipeline: GPUComputePipeline) -> None: pipeline_id = pipeline._internal # H: void f(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) libf.wgpuComputePassEncoderSetPipeline(self._internal, pipeline_id) + # FIXME: was dispatch_workgroups(self, workgroup_count_x: int | None = None, workgroup_count_y: int = 1, workgroup_count_z: int = 1) -> None: def dispatch_workgroups( self, - workgroup_count_x: int | None = None, + workgroup_count_x: int, workgroup_count_y: int = 1, workgroup_count_z: int = 1, ) -> None: @@ -3662,10 +3668,9 @@ def dispatch_workgroups( self._internal, workgroup_count_x, workgroup_count_y, workgroup_count_z ) + # FIXME: was dispatch_workgroups_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: def dispatch_workgroups_indirect( - self, - indirect_buffer: GPUBuffer | None = None, - indirect_offset: int | None = None, + self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: buffer_id = indirect_buffer._internal # H: void f(WGPUComputePassEncoder computePassEncoder, WGPUBuffer indirectBuffer, uint64_t indirectOffset) @@ -3713,14 +3718,15 @@ class GPURenderPassEncoder( # GPUObjectBaseMixin _release_function = libf.wgpuRenderPassEncoderRelease + # FIXME: was set_viewport(self, x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None, min_depth: float | None = None, max_depth: float | None = None) -> None: def set_viewport( self, - x: float | None = None, - y: float | None = None, - width: float | None = None, - height: float | None = None, - min_depth: float | None = None, - max_depth: float | None = None, + x: float, + y: float, + width: float, + height: float, + min_depth: float, + max_depth: float, ) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, float x, float y, float width, float height, float minDepth, float maxDepth) libf.wgpuRenderPassEncoderSetViewport( @@ -3733,21 +3739,16 @@ def set_viewport( float(max_depth), ) - def set_scissor_rect( - self, - x: int | None = None, - y: int | None = None, - width: int | None = None, - height: int | None = None, - ) -> None: + # FIXME: was set_scissor_rect(self, x: int | None = None, y: int | None = None, width: int | None = None, height: int | None = None) -> None: + def set_scissor_rect(self, x: int, y: int, width: int, height: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) libf.wgpuRenderPassEncoderSetScissorRect( self._internal, int(x), int(y), int(width), int(height) ) + # FIXME: was set_blend_constant(self, color: tuple[float, float, float, float] | structs.ColorStruct | None = None) -> None: def set_blend_constant( - self, - color: tuple[float, float, float, float] | structs.ColorStruct | None = None, + self, color: tuple[float, float, float, float] | structs.ColorStruct ) -> None: if isinstance(color, dict): check_struct("Color", color) @@ -3763,7 +3764,8 @@ def set_blend_constant( # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) libf.wgpuRenderPassEncoderSetBlendConstant(self._internal, c_color) - def set_stencil_reference(self, reference: int | None = None) -> None: + # FIXME: was set_stencil_reference(self, reference: int | None = None) -> None: + def set_stencil_reference(self, reference: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) libf.wgpuRenderPassEncoderSetStencilReference(self._internal, int(reference)) @@ -3771,7 +3773,8 @@ def end(self) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder) libf.wgpuRenderPassEncoderEnd(self._internal) - def execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: + # FIXME: was execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: + def execute_bundles(self, bundles: Sequence[GPURenderBundle]) -> None: bundle_ids = [bundle._internal for bundle in bundles] c_bundle_info = new_array("WGPURenderBundle[]", bundle_ids) # H: void f(WGPURenderPassEncoder renderPassEncoder, size_t bundleCount, WGPURenderBundle const * bundles) @@ -3779,7 +3782,8 @@ def execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> N self._internal, len(bundles), c_bundle_info ) - def begin_occlusion_query(self, query_index: int | None = None) -> None: + # FIXME: was begin_occlusion_query(self, query_index: int | None = None) -> None: + def begin_occlusion_query(self, query_index: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) libf.wgpuRenderPassEncoderBeginOcclusionQuery(self._internal, int(query_index)) @@ -3884,17 +3888,19 @@ class GPUQueue(classes.GPUQueue, GPUObjectBase): # GPUObjectBaseMixin _release_function = libf.wgpuQueueRelease - def submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: + # FIXME: was submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: + def submit(self, command_buffers: Sequence[GPUCommandBuffer]) -> None: command_buffer_ids = [cb._internal for cb in command_buffers] c_command_buffers = new_array("WGPUCommandBuffer[]", command_buffer_ids) # H: void f(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) libf.wgpuQueueSubmit(self._internal, len(command_buffer_ids), c_command_buffers) + # FIXME: was write_buffer(self, buffer: GPUBuffer | None = None, buffer_offset: int | None = None, data: ArrayLike | None = None, data_offset: int = 0, size: int | None = None) -> None: def write_buffer( self, - buffer: GPUBuffer | None = None, - buffer_offset: int | None = None, - data: ArrayLike | None = None, + buffer: GPUBuffer, + buffer_offset: int, + data: ArrayLike, data_offset: int = 0, size: int | None = None, ) -> None: @@ -3967,12 +3973,13 @@ def read_buffer( return data + # FIXME: was write_texture(self, destination: structs.TexelCopyTextureInfoStruct | None = None, data: ArrayLike | None = None, data_layout: structs.TexelCopyBufferLayoutStruct | None = None, size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def write_texture( self, - destination: structs.TexelCopyTextureInfoStruct | None = None, - data: ArrayLike | None = None, - data_layout: structs.TexelCopyBufferLayoutStruct | None = None, - size: tuple[int, int, int] | structs.Extent3DStruct | None = None, + destination: structs.TexelCopyTextureInfoStruct, + data: ArrayLike, + data_layout: structs.TexelCopyBufferLayoutStruct, + size: tuple[int, int, int] | structs.Extent3DStruct, ) -> None: # Note that the bytes_per_row restriction does not apply for # this function; wgpu-native deals with it. From e6ea6226879db45e03482f05fa76b71833dd8ae4 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 6 Apr 2026 21:17:01 +0200 Subject: [PATCH 2/3] cleanup fixme comments --- wgpu/_classes.py | 36 ------------------------------- wgpu/backends/wgpu_native/_api.py | 29 ------------------------- 2 files changed, 65 deletions(-) diff --git a/wgpu/_classes.py b/wgpu/_classes.py index 1e143e44..c1e6a502 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -1260,7 +1260,6 @@ def create_query_set( """Create a `GPUQuerySet` object.""" raise NotImplementedError() - # FIXME: was push_error_scope(self, filter: enums.ErrorFilterEnum | None = None) -> None: # IDL: undefined pushErrorScope(GPUErrorFilter filter); @apidiff.hide def push_error_scope(self, filter: enums.ErrorFilterEnum) -> None: @@ -1349,7 +1348,6 @@ def map_state(self) -> enums.BufferMapStateEnum: # but reading and writing data goes via method calls instead of via # an array-like object that exposes the shared memory. - # FIXME: was map_sync(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); def map_sync( self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None @@ -1361,7 +1359,6 @@ def map_sync( promise = self.map_async(mode=mode, offset=offset, size=size) return promise.sync_wait() - # FIXME: was map_async(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> GPUPromise[None]: # IDL: Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); def map_async( self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None @@ -1694,7 +1691,6 @@ def get_compilation_info_async(self) -> GPUPromise[GPUCompilationInfo]: class GPUPipelineBase: """A mixin class for render and compute pipelines.""" - # FIXME: was get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: # IDL: [NewObject] GPUBindGroupLayout getBindGroupLayout(unsigned long index); def get_bind_group_layout(self, index: int) -> GPUBindGroupLayout: """Get the bind group layout at the given index.""" @@ -1769,7 +1765,6 @@ def set_bind_group( class GPUDebugCommandsMixin: """Mixin for classes that support debug groups and markers.""" - # FIXME: was push_debug_group(self, group_label: str | None = None) -> None: # IDL: undefined pushDebugGroup(USVString groupLabel); def push_debug_group(self, group_label: str) -> None: """Push a named debug group into the command stream.""" @@ -1780,7 +1775,6 @@ def pop_debug_group(self) -> None: """Pop the active debug group.""" raise NotImplementedError() - # FIXME: was insert_debug_marker(self, marker_label: str | None = None) -> None: # IDL: undefined insertDebugMarker(USVString markerLabel); def insert_debug_marker(self, marker_label: str) -> None: """Insert the given message into the debug message queue.""" @@ -1790,7 +1784,6 @@ def insert_debug_marker(self, marker_label: str) -> None: class GPURenderCommandsMixin: """Mixin for classes that provide rendering commands.""" - # FIXME: was set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: # IDL: undefined setPipeline(GPURenderPipeline pipeline); def set_pipeline(self, pipeline: GPURenderPipeline) -> None: """Set the pipeline for this render pass. @@ -1800,7 +1793,6 @@ def set_pipeline(self, pipeline: GPURenderPipeline) -> None: """ raise NotImplementedError() - # FIXME: was set_index_buffer(self, buffer: GPUBuffer | None = None, index_format: enums.IndexFormatEnum | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size); def set_index_buffer( self, @@ -1822,7 +1814,6 @@ def set_index_buffer( """ raise NotImplementedError() - # FIXME: was set_vertex_buffer(self, slot: int | None = None, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer? buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); def set_vertex_buffer( self, slot: int, buffer: GPUBuffer, offset: int = 0, size: int | None = None @@ -1840,7 +1831,6 @@ def set_vertex_buffer( """ raise NotImplementedError() - # FIXME: was draw(self, vertex_count: int | None = None, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0) -> None: # IDL: undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1, optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0); def draw( self, @@ -1859,7 +1849,6 @@ def draw( """ raise NotImplementedError() - # FIXME: was draw_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> None: """Like `draw()`, but the function arguments are in a buffer. @@ -1872,7 +1861,6 @@ def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> Non """ raise NotImplementedError() - # FIXME: was draw_indexed(self, index_count: int | None = None, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, first_instance: int = 0) -> None: # IDL: undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1, optional GPUSize32 firstIndex = 0, optional GPUSignedOffset32 baseVertex = 0, optional GPUSize32 firstInstance = 0); def draw_indexed( self, @@ -1895,7 +1883,6 @@ def draw_indexed( """ raise NotImplementedError() - # FIXME: was draw_indexed_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); def draw_indexed_indirect( self, indirect_buffer: GPUBuffer, indirect_offset: int @@ -1956,7 +1943,6 @@ def begin_render_pass( """ raise NotImplementedError() - # FIXME: was clear_buffer(self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: # IDL: undefined clearBuffer( GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); def clear_buffer( self, buffer: GPUBuffer, offset: int = 0, size: int | None = None @@ -1972,7 +1958,6 @@ def clear_buffer( """ raise NotImplementedError() - # FIXME: was copy_buffer_to_buffer(self, source: GPUBuffer | None = None, source_offset: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None, size: int | None = None) -> None: # IDL: undefined copyBufferToBuffer( GPUBuffer source, GPUSize64 sourceOffset, GPUBuffer destination, GPUSize64 destinationOffset, optional GPUSize64 size); def copy_buffer_to_buffer( self, @@ -1995,7 +1980,6 @@ def copy_buffer_to_buffer( """ raise NotImplementedError() - # FIXME: was copy_buffer_to_texture(self, source: structs.TexelCopyBufferInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyBufferToTexture( GPUTexelCopyBufferInfo source, GPUTexelCopyTextureInfo destination, GPUExtent3D copySize); def copy_buffer_to_texture( self, @@ -2014,7 +1998,6 @@ def copy_buffer_to_texture( """ raise NotImplementedError() - # FIXME: was copy_texture_to_buffer(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyBufferInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyTextureToBuffer( GPUTexelCopyTextureInfo source, GPUTexelCopyBufferInfo destination, GPUExtent3D copySize); def copy_texture_to_buffer( self, @@ -2033,7 +2016,6 @@ def copy_texture_to_buffer( """ raise NotImplementedError() - # FIXME: was copy_texture_to_texture(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyTextureToTexture( GPUTexelCopyTextureInfo source, GPUTexelCopyTextureInfo destination, GPUExtent3D copySize); def copy_texture_to_texture( self, @@ -2059,7 +2041,6 @@ def finish(self, *, label: str = "") -> GPUCommandBuffer: """ raise NotImplementedError() - # FIXME: was resolve_query_set(self, query_set: GPUQuerySet | None = None, first_query: int | None = None, query_count: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None) -> None: # IDL: undefined resolveQuerySet( GPUQuerySet querySet, GPUSize32 firstQuery, GPUSize32 queryCount, GPUBuffer destination, GPUSize64 destinationOffset); def resolve_query_set( self, @@ -2092,7 +2073,6 @@ class GPUComputePassEncoder( Create a compute pass encoder using `GPUCommandEncoder.begin_compute_pass()`. """ - # FIXME: was set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: # IDL: undefined setPipeline(GPUComputePipeline pipeline); def set_pipeline(self, pipeline: GPUComputePipeline) -> None: """Set the pipeline for this compute pass. @@ -2102,7 +2082,6 @@ def set_pipeline(self, pipeline: GPUComputePipeline) -> None: """ raise NotImplementedError() - # FIXME: was dispatch_workgroups(self, workgroup_count_x: int | None = None, workgroup_count_y: int = 1, workgroup_count_z: int = 1) -> None: # IDL: undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1); def dispatch_workgroups( self, @@ -2119,7 +2098,6 @@ def dispatch_workgroups( """ raise NotImplementedError() - # FIXME: was dispatch_workgroups_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: # IDL: undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); def dispatch_workgroups_indirect( self, indirect_buffer: GPUBuffer, indirect_offset: int @@ -2150,7 +2128,6 @@ class GPURenderPassEncoder( Create a render pass encoder using `GPUCommandEncoder.begin_render_pass`. """ - # FIXME: was set_viewport(self, x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None, min_depth: float | None = None, max_depth: float | None = None) -> None: # IDL: undefined setViewport(float x, float y, float width, float height, float minDepth, float maxDepth); def set_viewport( self, @@ -2175,7 +2152,6 @@ def set_viewport( """ raise NotImplementedError() - # FIXME: was set_scissor_rect(self, x: int | None = None, y: int | None = None, width: int | None = None, height: int | None = None) -> None: # IDL: undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, GPUIntegerCoordinate width, GPUIntegerCoordinate height); def set_scissor_rect(self, x: int, y: int, width: int, height: int) -> None: """Set the scissor rectangle for this render pass. The scene @@ -2189,7 +2165,6 @@ def set_scissor_rect(self, x: int, y: int, width: int, height: int) -> None: """ raise NotImplementedError() - # FIXME: was set_blend_constant(self, color: tuple[float, float, float, float] | structs.ColorStruct | None = None) -> None: # IDL: undefined setBlendConstant(GPUColor color); def set_blend_constant( self, color: tuple[float, float, float, float] | structs.ColorStruct @@ -2201,7 +2176,6 @@ def set_blend_constant( """ raise NotImplementedError() - # FIXME: was set_stencil_reference(self, reference: int | None = None) -> None: # IDL: undefined setStencilReference(GPUStencilValue reference); def set_stencil_reference(self, reference: int) -> None: """Set the reference stencil value for this render pass. @@ -2211,7 +2185,6 @@ def set_stencil_reference(self, reference: int) -> None: """ raise NotImplementedError() - # FIXME: was execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: # IDL: undefined executeBundles(sequence bundles); def execute_bundles(self, bundles: Sequence[GPURenderBundle]) -> None: """Executes commands previously recorded into the render bundles @@ -2227,7 +2200,6 @@ def end(self) -> None: """Record the end of the render pass.""" raise NotImplementedError() - # FIXME: was begin_occlusion_query(self, query_index: int | None = None) -> None: # IDL: undefined beginOcclusionQuery(GPUSize32 queryIndex); def begin_occlusion_query(self, query_index: int) -> None: """Begins an occlusion query. @@ -2277,7 +2249,6 @@ class GPUQueue(GPUObjectBase): You can obtain a queue object via the :attr:`GPUDevice.queue` property. """ - # FIXME: was submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: # IDL: undefined submit(sequence commandBuffers); def submit(self, command_buffers: Sequence[GPUCommandBuffer]) -> None: """Submit a `GPUCommandBuffer` to the queue. @@ -2287,7 +2258,6 @@ def submit(self, command_buffers: Sequence[GPUCommandBuffer]) -> None: """ raise NotImplementedError() - # FIXME: was write_buffer(self, buffer: GPUBuffer | None = None, buffer_offset: int | None = None, data: ArrayLike | None = None, data_offset: int = 0, size: int | None = None) -> None: # IDL: undefined writeBuffer( GPUBuffer buffer, GPUSize64 bufferOffset, AllowSharedBufferSource data, optional GPUSize64 dataOffset = 0, optional GPUSize64 size); def write_buffer( self, @@ -2340,7 +2310,6 @@ def read_buffer( """ raise NotImplementedError() - # FIXME: was write_texture(self, destination: structs.TexelCopyTextureInfoStruct | None = None, data: ArrayLike | None = None, data_layout: structs.TexelCopyBufferLayoutStruct | None = None, size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined writeTexture( GPUTexelCopyTextureInfo destination, AllowSharedBufferSource data, GPUTexelCopyBufferLayout dataLayout, GPUExtent3D size); def write_texture( self, @@ -2390,7 +2359,6 @@ def read_texture( """ raise NotImplementedError() - # FIXME: was copy_external_image_to_texture(self, source: structs.CopyExternalImageSourceInfoStruct | None = None, destination: structs.CopyExternalImageDestInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: # IDL: undefined copyExternalImageToTexture( GPUCopyExternalImageSourceInfo source, GPUCopyExternalImageDestInfo destination, GPUExtent3D copySize); @apidiff.hide("Specific to browsers") def copy_external_image_to_texture( @@ -2457,7 +2425,6 @@ def message(self) -> str: class GPUOutOfMemoryError(GPUError, MemoryError): """An error raised when the GPU is out of memory.""" - # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); def __init__(self, message: str): super().__init__(message or "GPU is out of memory.") @@ -2466,7 +2433,6 @@ def __init__(self, message: str): class GPUValidationError(GPUError): """An error raised when the pipeline could not be validated.""" - # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); def __init__(self, message: str): super().__init__(message) @@ -2475,7 +2441,6 @@ def __init__(self, message: str): class GPUPipelineError(Exception): """An error raised when a pipeline could not be created.""" - # FIXME: was __init__(self, message: str = "", options: structs.PipelineErrorInitStruct | None = None): # IDL: constructor(optional DOMString message = "", GPUPipelineErrorInit options); def __init__(self, message: str, options: structs.PipelineErrorInitStruct): super().__init__(message or "") @@ -2495,7 +2460,6 @@ class GPUInternalError(GPUError): reason even when all validation requirements have been satisfied. """ - # FIXME: was __init__(self, message: str | None = None): # IDL: constructor(DOMString message); def __init__(self, message: str): super().__init__(message) diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index 0cd2aa54..c96ff973 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -2527,7 +2527,6 @@ def _check_range(self, offset, size): raise ValueError("Mapped range must not extend beyond total buffer size.") return offset, size - # FIXME: was map_async(self, mode: flags.MapModeFlags | None = None, offset: int = 0, size: int | None = None) -> GPUPromise[None]: def map_async( self, mode: flags.MapModeFlags, offset: int = 0, size: int | None = None ) -> GPUPromise[None]: @@ -2865,7 +2864,6 @@ def get_compilation_info_async(self) -> GPUPromise[GPUCompilationInfo]: class GPUPipelineBase(classes.GPUPipelineBase): - # FIXME: was get_bind_group_layout(self, index: int | None = None) -> GPUBindGroupLayout: def get_bind_group_layout(self, index: int) -> GPUBindGroupLayout: # H: WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex) # H: WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex) @@ -2999,7 +2997,6 @@ 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 - # FIXME: was push_debug_group(self, group_label: str | None = None) -> None: def push_debug_group(self, group_label: str) -> None: c_group_label = to_c_string_view(group_label) # H: void wgpuCommandEncoderPushDebugGroup(WGPUCommandEncoder commandEncoder, WGPUStringView groupLabel) @@ -3017,7 +3014,6 @@ def pop_debug_group(self) -> None: function = type(self)._pop_debug_group_function function(self._internal) - # FIXME: was insert_debug_marker(self, marker_label: str | None = None) -> None: def insert_debug_marker(self, marker_label: str) -> None: c_marker_label = to_c_string_view(marker_label) # H: void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, WGPUStringView markerLabel) @@ -3040,7 +3036,6 @@ def _write_timestamp(self, query_set, query_index): class GPURenderCommandsMixin(classes.GPURenderCommandsMixin): - # FIXME: was set_pipeline(self, pipeline: GPURenderPipeline | None = None) -> None: def set_pipeline(self, pipeline: GPURenderPipeline) -> None: self._maybe_keep_alive(pipeline) pipeline_id = pipeline._internal @@ -3049,7 +3044,6 @@ def set_pipeline(self, pipeline: GPURenderPipeline) -> None: function = type(self)._set_pipeline_function function(self._internal, pipeline_id) - # FIXME: was set_index_buffer(self, buffer: GPUBuffer | None = None, index_format: enums.IndexFormatEnum | None = None, offset: int = 0, size: int | None = None) -> None: def set_index_buffer( self, buffer: GPUBuffer, @@ -3068,7 +3062,6 @@ def set_index_buffer( self._internal, buffer._internal, c_index_format, int(offset), int(size) ) - # FIXME: was set_vertex_buffer(self, slot: int | None = None, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: def set_vertex_buffer( self, slot: int, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: @@ -3080,7 +3073,6 @@ def set_vertex_buffer( function = type(self)._set_vertex_buffer_function function(self._internal, int(slot), buffer._internal, int(offset), int(size)) - # FIXME: was draw(self, vertex_count: int | None = None, instance_count: int = 1, first_vertex: int = 0, first_instance: int = 0) -> None: def draw( self, vertex_count: int, @@ -3095,7 +3087,6 @@ def draw( self._internal, vertex_count, instance_count, first_vertex, first_instance ) - # FIXME: was draw_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> None: # self._maybe_keep_alive(indirect_buffer) buffer_id = indirect_buffer._internal @@ -3104,7 +3095,6 @@ def draw_indirect(self, indirect_buffer: GPUBuffer, indirect_offset: int) -> Non function = type(self)._draw_indirect_function function(self._internal, buffer_id, int(indirect_offset)) - # FIXME: was draw_indexed(self, index_count: int | None = None, instance_count: int = 1, first_index: int = 0, base_vertex: int = 0, first_instance: int = 0) -> None: def draw_indexed( self, index_count: int, @@ -3125,7 +3115,6 @@ def draw_indexed( first_instance, ) - # FIXME: was draw_indexed_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: def draw_indexed_indirect( self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: @@ -3339,7 +3328,6 @@ def _create_render_pass_stencil_attachment(self, ds_attachment): ) return c_depth_stencil_attachment - # FIXME: was clear_buffer(self, buffer: GPUBuffer | None = None, offset: int = 0, size: int | None = None) -> None: def clear_buffer( self, buffer: GPUBuffer, offset: int = 0, size: int | None = None ) -> None: @@ -3364,7 +3352,6 @@ def clear_buffer( self._internal, buffer._internal, offset, size ) - # FIXME: was copy_buffer_to_buffer(self, source: GPUBuffer | None = None, source_offset: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None, size: int | None = None) -> None: def copy_buffer_to_buffer( self, source: GPUBuffer, @@ -3396,7 +3383,6 @@ def copy_buffer_to_buffer( int(size), ) - # FIXME: was copy_buffer_to_texture(self, source: structs.TexelCopyBufferInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_buffer_to_texture( self, source: structs.TexelCopyBufferInfoStruct, @@ -3463,7 +3449,6 @@ def copy_buffer_to_texture( c_copy_size, ) - # FIXME: was copy_texture_to_buffer(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyBufferInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_texture_to_buffer( self, source: structs.TexelCopyTextureInfoStruct, @@ -3530,7 +3515,6 @@ def copy_texture_to_buffer( c_copy_size, ) - # FIXME: was copy_texture_to_texture(self, source: structs.TexelCopyTextureInfoStruct | None = None, destination: structs.TexelCopyTextureInfoStruct | None = None, copy_size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def copy_texture_to_texture( self, source: structs.TexelCopyTextureInfoStruct, @@ -3608,7 +3592,6 @@ def finish(self, *, label: str = "") -> GPUCommandBuffer: return GPUCommandBuffer(label, id, self._device) - # FIXME: was resolve_query_set(self, query_set: GPUQuerySet | None = None, first_query: int | None = None, query_count: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None) -> None: def resolve_query_set( self, query_set: GPUQuerySet, @@ -3650,13 +3633,11 @@ class GPUComputePassEncoder( # GPUObjectBaseMixin _release_function = libf.wgpuComputePassEncoderRelease - # FIXME: was set_pipeline(self, pipeline: GPUComputePipeline | None = None) -> None: def set_pipeline(self, pipeline: GPUComputePipeline) -> None: pipeline_id = pipeline._internal # H: void f(WGPUComputePassEncoder computePassEncoder, WGPUComputePipeline pipeline) libf.wgpuComputePassEncoderSetPipeline(self._internal, pipeline_id) - # FIXME: was dispatch_workgroups(self, workgroup_count_x: int | None = None, workgroup_count_y: int = 1, workgroup_count_z: int = 1) -> None: def dispatch_workgroups( self, workgroup_count_x: int, @@ -3668,7 +3649,6 @@ def dispatch_workgroups( self._internal, workgroup_count_x, workgroup_count_y, workgroup_count_z ) - # FIXME: was dispatch_workgroups_indirect(self, indirect_buffer: GPUBuffer | None = None, indirect_offset: int | None = None) -> None: def dispatch_workgroups_indirect( self, indirect_buffer: GPUBuffer, indirect_offset: int ) -> None: @@ -3718,7 +3698,6 @@ class GPURenderPassEncoder( # GPUObjectBaseMixin _release_function = libf.wgpuRenderPassEncoderRelease - # FIXME: was set_viewport(self, x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None, min_depth: float | None = None, max_depth: float | None = None) -> None: def set_viewport( self, x: float, @@ -3739,14 +3718,12 @@ def set_viewport( float(max_depth), ) - # FIXME: was set_scissor_rect(self, x: int | None = None, y: int | None = None, width: int | None = None, height: int | None = None) -> None: def set_scissor_rect(self, x: int, y: int, width: int, height: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t x, uint32_t y, uint32_t width, uint32_t height) libf.wgpuRenderPassEncoderSetScissorRect( self._internal, int(x), int(y), int(width), int(height) ) - # FIXME: was set_blend_constant(self, color: tuple[float, float, float, float] | structs.ColorStruct | None = None) -> None: def set_blend_constant( self, color: tuple[float, float, float, float] | structs.ColorStruct ) -> None: @@ -3764,7 +3741,6 @@ def set_blend_constant( # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPUColor const * color) libf.wgpuRenderPassEncoderSetBlendConstant(self._internal, c_color) - # FIXME: was set_stencil_reference(self, reference: int | None = None) -> None: def set_stencil_reference(self, reference: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t reference) libf.wgpuRenderPassEncoderSetStencilReference(self._internal, int(reference)) @@ -3773,7 +3749,6 @@ def end(self) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder) libf.wgpuRenderPassEncoderEnd(self._internal) - # FIXME: was execute_bundles(self, bundles: Sequence[GPURenderBundle] | None = None) -> None: def execute_bundles(self, bundles: Sequence[GPURenderBundle]) -> None: bundle_ids = [bundle._internal for bundle in bundles] c_bundle_info = new_array("WGPURenderBundle[]", bundle_ids) @@ -3782,7 +3757,6 @@ def execute_bundles(self, bundles: Sequence[GPURenderBundle]) -> None: self._internal, len(bundles), c_bundle_info ) - # FIXME: was begin_occlusion_query(self, query_index: int | None = None) -> None: def begin_occlusion_query(self, query_index: int) -> None: # H: void f(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex) libf.wgpuRenderPassEncoderBeginOcclusionQuery(self._internal, int(query_index)) @@ -3888,14 +3862,12 @@ class GPUQueue(classes.GPUQueue, GPUObjectBase): # GPUObjectBaseMixin _release_function = libf.wgpuQueueRelease - # FIXME: was submit(self, command_buffers: Sequence[GPUCommandBuffer] | None = None) -> None: def submit(self, command_buffers: Sequence[GPUCommandBuffer]) -> None: command_buffer_ids = [cb._internal for cb in command_buffers] c_command_buffers = new_array("WGPUCommandBuffer[]", command_buffer_ids) # H: void f(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands) libf.wgpuQueueSubmit(self._internal, len(command_buffer_ids), c_command_buffers) - # FIXME: was write_buffer(self, buffer: GPUBuffer | None = None, buffer_offset: int | None = None, data: ArrayLike | None = None, data_offset: int = 0, size: int | None = None) -> None: def write_buffer( self, buffer: GPUBuffer, @@ -3973,7 +3945,6 @@ def read_buffer( return data - # FIXME: was write_texture(self, destination: structs.TexelCopyTextureInfoStruct | None = None, data: ArrayLike | None = None, data_layout: structs.TexelCopyBufferLayoutStruct | None = None, size: tuple[int, int, int] | structs.Extent3DStruct | None = None) -> None: def write_texture( self, destination: structs.TexelCopyTextureInfoStruct, From c015e9cfd5fc88f2832f0dfb91963c3155134a01 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 6 Apr 2026 21:20:12 +0200 Subject: [PATCH 3/3] ruff format --- codegen/apipatcher.py | 2 +- codegen/idlparser.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen/apipatcher.py b/codegen/apipatcher.py index f7c7b731..7958082a 100644 --- a/codegen/apipatcher.py +++ b/codegen/apipatcher.py @@ -474,7 +474,7 @@ def get_method_def(self, classname, methodname) -> str: if not args[0].required: args[0].typename = args[0].typename.removeprefix("optional ") assert args[0].typename.startswith("GPU") - des_is_optional = bool(args[0].default) # part of the logic above? + des_is_optional = bool(args[0].default) # part of the logic above? attributes = self.idl.structs[args[0].typename[3:]].values() py_args = [ self._arg_from_attribute(methodname, attr, des_is_optional) diff --git a/codegen/idlparser.py b/codegen/idlparser.py index 94e9fac7..5fb608ef 100644 --- a/codegen/idlparser.py +++ b/codegen/idlparser.py @@ -35,11 +35,11 @@ def get_idl_parser(*, allow_cache=True): class Attribute: """A little object to hold a function argument or struct field.""" - def __init__(self, line: str, struct:bool=True): + def __init__(self, line: str, struct: bool = True): self.line = line.strip().strip(",;").strip() default = None # None means 'no default' and "None" kinda means "auto". - required = False # as opposed to optional, https://webidl.spec.whatwg.org/#required-dictionary-member but struct members? + required = False # as opposed to optional, https://webidl.spec.whatwg.org/#required-dictionary-member but struct members? # function args can be optional https://webidl.spec.whatwg.org/#dfn-optional-argument and a required if not arg = self.line if "=" in arg: