From 257143ad5f827fe48d521c8bfb49849310572e9e Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 20 Nov 2023 10:27:00 +0100 Subject: [PATCH] Cleanup classes namespace and repr (#427) * Rename base.py -> _classes.py * Tweak docs related to classes * Tweak classes repr * Fix/tweak docs * codegen * Fix tests * codegen --- codegen/README.md | 22 ++++---- codegen/__init__.py | 8 +-- codegen/apipatcher.py | 10 ++-- codegen/files.py | 2 +- docs/_templates/wgpu_class_layout.rst | 2 +- docs/conf.py | 4 +- docs/wgpu.rst | 6 ++- tests/test_api.py | 27 +++++----- tests/test_gui_base.py | 2 +- tests/test_wgpu_native_buffer.py | 2 + wgpu/__init__.py | 4 +- wgpu/{base.py => _classes.py} | 38 ++++++++++--- wgpu/_diagnostics.py | 2 +- wgpu/backends/__init__.py | 2 +- wgpu/backends/wgpu_native/_api.py | 78 +++++++++++++-------------- wgpu/backends/wgpu_native/_helpers.py | 4 +- wgpu/classes.py | 8 +++ wgpu/gui/_offscreen.py | 4 +- wgpu/resources/codegen_report.md | 4 +- 19 files changed, 134 insertions(+), 95 deletions(-) rename wgpu/{base.py => _classes.py} (98%) create mode 100644 wgpu/classes.py diff --git a/codegen/README.md b/codegen/README.md index 7928b425..fdeebb6d 100644 --- a/codegen/README.md +++ b/codegen/README.md @@ -40,7 +40,7 @@ but the parsers and generators are less important to fully cover by tests, becau ## What the codegen does in general * Help update the front API. - * Make changes to `base.py`. + * Make changes to `_classes.py`. * Generate `flags.py`, `enums.py`, and `structs.py`. * Help update the wgpu-native backend: * Make changes to `backends/wgpu_native/_api.py`. @@ -55,7 +55,7 @@ but the parsers and generators are less important to fully cover by tests, becau The WebGPU API is specified by `webgpu.idl` (in the resources directory). We parse this file with a custom parser (`idlparser.py`) to obtain a description of the interfaces, enums, and flags. -Note that while `base.py` defines the API (and corresponding docstrings), the implementation of the majority of methods occurs in the backends, so most methods simply `raise NotimplementedError()`. +Note that while `wgpu/_classes.py` defines the API (and corresponding docstrings), the implementation of the majority of methods occurs in the backends, so most methods simply `raise NotimplementedError()`. ### Changes with respect to JS @@ -75,7 +75,7 @@ Other changes include: * Generate `flags.py`, `enums.py`, and `structs.py`. -* Make changes to `base.py`. +* Make changes to `_classes.py`. * Add missing classes, methods and properties, along with a FIXME comment.. @@ -91,7 +91,7 @@ Other changes include: * Run `python codegen` to apply the automatic patches to the code. * It may be necessary to tweak the `idlparser.py` to adjust to new formatting. * Check the diff of `flags.py`, `enums.py`, `structs.py` for any changes that might need manual work. -* Go through all FIXME comments that were added in `base.py`: +* Go through all FIXME comments that were added in `_classes.py`: * Apply any necessary changes. * Remove the FIXME comment if no further action is needed, or turn into a TODO for later. * Note that all new classes/methods/properties (instead those marked as hidden) need a docstring. @@ -103,15 +103,15 @@ Other changes include: -## Updating the Rust backend (`rs.py`) +## Updating the wgpu-native backend ### Introduction -The backends are almost a copy of `base.py`: all methods in `base.py` that `raise NotImplementedError()` must be implemented. +The backends are almost a copy of `_classes.py`: all methods in `_classes.py` that `raise NotImplementedError()` must be implemented. -The `rs.py` backend calls into a dynamic library, which interface is specified by `webgpu.h` and `wgpu.h` (in the resources directory). We parse these files with a custom parser (`hparser.py`) to obtain a description of the interfaces, enums, flags, and structs. +The wgpu-native backend calls into a dynamic library, which interface is specified by `webgpu.h` and `wgpu.h` (in the resources directory). We parse these files with a custom parser (`hparser.py`) to obtain a description of the interfaces, enums, flags, and structs. -The majority of work in `rs.py` is the conversion of Python dicts to C structs, and then using them to call into the dynamic library. The codegen helps by validating the structs and API calls. +The majority of work in the wgpu-native backend is the conversion of Python dicts to C structs, and then using them to call into the dynamic library. The codegen helps by validating the structs and API calls. ### Tips @@ -129,7 +129,7 @@ The majority of work in `rs.py` is the conversion of Python dicts to C structs, * Generate mappings for enum field names to ints. * Detect and report missing flags and enum fields. -* Make changes to `backends/rs.py`. +* Make changes to `wgpu_native/_api.py`. * Validate and annotate function calls into the lib. * Validate and annotate struct creations (missing struct fields are filled in). * Ensure that each incoming struct is checked to catch invalid input. @@ -140,8 +140,8 @@ The majority of work in `rs.py` is the conversion of Python dicts to C structs, * Run `python codegen` to apply the automatic patches to the code. * It may be necessary to tweak the `hparser.py` to adjust to new formatting. * Diff the report for new differences to take into account. -* Diff `rs.py` to get an idea of what structs and functions have changed. -* Go through all FIXME comments that were added in `rs.py`: +* Diff `wgpu_native/_api.py` to get an idea of what structs and functions have changed. +* Go through all FIXME comments that were added in `_api.py`: * Apply any necessary changes. * Remove the FIXME comment if no further action is needed, or turn into a TODO for later. diff --git a/codegen/__init__.py b/codegen/__init__.py index 612b60e5..b2b7767a 100644 --- a/codegen/__init__.py +++ b/codegen/__init__.py @@ -37,12 +37,12 @@ def update_api(): apiwriter.write_structs() # Patch base API: IDL -> API - code1 = file_cache.read("base.py") - print("### Patching API for base.py") + code1 = file_cache.read("_classes.py") + print("### Patching API for _classes.py") code2 = apipatcher.patch_base_api(code1) - file_cache.write("base.py", code2) + file_cache.write("_classes.py", code2) - # Patch backend APIs: base.py -> API + # Patch backend APIs: _classes.py -> API for fname in ["backends/wgpu_native/_api.py"]: code1 = file_cache.read(fname) print(f"### Patching API for {fname}") diff --git a/codegen/apipatcher.py b/codegen/apipatcher.py index 94d1d219..a4cfdcc3 100644 --- a/codegen/apipatcher.py +++ b/codegen/apipatcher.py @@ -36,7 +36,7 @@ def patch_backend_api(code): """ # Obtain the base API definition - base_api_code = file_cache.read("base.py") + base_api_code = file_cache.read("_classes.py") # Patch! for patcher in [ @@ -386,7 +386,7 @@ def get_required_method_names(self, classname): class BaseApiPatcher(IdlPatcherMixin, AbstractApiPatcher): - """A patcher to patch the base API (in base.py), using IDL as input.""" + """A patcher to patch the base API (in _classes.py), using IDL as input.""" class IdlCommentInjector(IdlPatcherMixin, AbstractCommentInjector): @@ -409,7 +409,7 @@ def get_method_comment(self, classname, methodname): class BackendApiPatcher(AbstractApiPatcher): - """A patcher to patch a backend API (e.g. rs.py), using the base API as input.""" + """A patcher to patch a backend API, using the base API as input.""" def __init__(self, base_api_code): super().__init__() @@ -437,12 +437,12 @@ def get_class_def(self, classname): line, _ = self.classes[classname] if "):" not in line: - return line.replace(":", f"(base.{classname}):") + return line.replace(":", f"(classes.{classname}):") else: i = line.find("(") bases = line[i:].strip("():").replace(",", " ").split() bases = [b for b in bases if b.startswith("GPU")] - bases.insert(0, f"base.{classname}") + bases.insert(0, f"classes.{classname}") return line[:i] + "(" + ", ".join(bases) + "):" def get_method_def(self, classname, methodname): diff --git a/codegen/files.py b/codegen/files.py index cbdca2f2..0b7c4b65 100644 --- a/codegen/files.py +++ b/codegen/files.py @@ -23,7 +23,7 @@ class FileCache: """ _filenames_to_change = [ - "base.py", + "_classes.py", "flags.py", "enums.py", "structs.py", diff --git a/docs/_templates/wgpu_class_layout.rst b/docs/_templates/wgpu_class_layout.rst index a7da33da..24f62af5 100644 --- a/docs/_templates/wgpu_class_layout.rst +++ b/docs/_templates/wgpu_class_layout.rst @@ -1,4 +1,4 @@ -{{ fullname | escape | underline}} +{{ objname | escape | underline}} .. currentmodule:: {{ module }} diff --git a/docs/conf.py b/docs/conf.py index 093c1d96..1e403888 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,7 @@ with open(os.path.join(ROOT_DIR, "docs", "wgpu.rst"), "rb") as f: wgpu_text = f.read().decode() wgpu_lines = [line.strip() for line in wgpu_text.splitlines()] -for cls_name in wgpu.base.__all__: +for cls_name in wgpu.classes.__all__: assert ( f"~{cls_name}" in wgpu_lines ), f"Class '{cls_name}' not listed in class list in wgpu.rst" @@ -98,7 +98,7 @@ def resolve_crossrefs(text): # Tweak docstrings of classes and their methods -for module, hide_class_signature in [(wgpu.base, True), (wgpu.gui, False)]: +for module, hide_class_signature in [(wgpu.classes, True), (wgpu.gui, False)]: for cls_name in module.__all__: cls = getattr(module, cls_name) # Class docstring diff --git a/docs/wgpu.rst b/docs/wgpu.rst index 6fc10125..372f15e8 100644 --- a/docs/wgpu.rst +++ b/docs/wgpu.rst @@ -39,7 +39,7 @@ For example, methods that in WebGPU accept a descriptor/struct/dict, here accept the fields in that struct as keyword arguments. -.. autodata:: wgpu.base.apidiff +.. autodata:: wgpu._classes.apidiff :annotation: Differences of base API: @@ -176,6 +176,10 @@ List of flags, enums, and structs List of GPU classes ------------------- +.. automodule:: wgpu.classes + +.. currentmodule:: wgpu + .. autosummary:: :nosignatures: :toctree: generated diff --git a/tests/test_api.py b/tests/test_api.py index 20877870..313ce5b6 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -19,11 +19,15 @@ def test_basic_api(): assert wgpu.gpu.request_adapter assert wgpu.gpu.request_adapter_async - code1 = wgpu.base.GPU.request_adapter.__code__ - code2 = wgpu.base.GPU.request_adapter_async.__code__ + code1 = wgpu.GPU.request_adapter.__code__ + code2 = wgpu.GPU.request_adapter_async.__code__ nargs1 = code1.co_argcount + code1.co_kwonlyargcount assert code1.co_varnames[:nargs1] == code2.co_varnames + assert repr(wgpu.classes.GPU()).startswith( + "" - # IDL: attribute USVString label; @property def label(self): @@ -2060,10 +2057,37 @@ def count(self): def _seed_object_counts(): - for key, val in globals().items(): - if key.startswith("GPU") and not key.endswith(("Base", "Mixin")): - if hasattr(val, "_ot"): - object_tracker.counts[key] = 0 + m = globals() + for class_name in __all__: + cls = m[class_name] + if not class_name.endswith(("Base", "Mixin")): + if hasattr(cls, "_ot"): + object_tracker.counts[class_name] = 0 + + +def generic_repr(self): + try: + module_name = "wgpu" + if "backends." in self.__module__: + backend_name = self.__module__.split("backends")[-1].split(".")[1] + module_name = f"wgpu.backends.{backend_name}" + object_str = "object" + if isinstance(self, GPUObjectBase): + object_str = f"object '{self.label}'" + return ( + f"<{module_name}.{self.__class__.__name__} {object_str} at {hex(id(self))}>" + ) + except Exception: # easy fallback + return object.__repr__(self) + + +def _set_repr_methods(): + m = globals() + for class_name in __all__: + cls = m[class_name] + if len(cls.mro()) == 2: # class itself and object + cls.__repr__ = generic_repr _seed_object_counts() +_set_repr_methods() diff --git a/wgpu/_diagnostics.py b/wgpu/_diagnostics.py index ca55b261..e0e0c83d 100644 --- a/wgpu/_diagnostics.py +++ b/wgpu/_diagnostics.py @@ -486,7 +486,7 @@ def get_dict(self): class ObjectCountDiagnostics(Diagnostics): - """Provides object counts and resource consumption, used in base.py.""" + """Provides object counts and resource consumption, used in _classes.py.""" def __init__(self, name): super().__init__(name) diff --git a/wgpu/backends/__init__.py b/wgpu/backends/__init__.py index 86d03d0e..3e78dc0f 100644 --- a/wgpu/backends/__init__.py +++ b/wgpu/backends/__init__.py @@ -4,7 +4,7 @@ import sys -from ..base import GPU as _base_GPU # noqa +from ..classes import GPU as _base_GPU # noqa def _register_backend(gpu): diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index 6245b693..db1d77c5 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -22,7 +22,7 @@ from weakref import WeakKeyDictionary from typing import List, Dict, Union -from ... import base, flags, enums, structs +from ... import classes, flags, enums, structs from ..._coreutils import str_flag_to_int from ._ffi import ffi, lib @@ -43,7 +43,7 @@ # The API is prettu well defined -__all__ = base.__all__.copy() +__all__ = classes.__all__.copy() # %% Helper functions and objects @@ -175,7 +175,7 @@ def check_struct(struct_name, d): # %% The API -class GPU(base.GPU): +class GPU(classes.GPU): def request_adapter( self, *, power_preference=None, force_fallback_adapter=False, canvas=None ): @@ -349,7 +349,7 @@ async def request_adapter_async( gpu = GPU() -class GPUCanvasContext(base.GPUCanvasContext): +class GPUCanvasContext(classes.GPUCanvasContext): def __init__(self, canvas): super().__init__(canvas) self._device = None @@ -495,15 +495,15 @@ def _destroy(self): libf.wgpuSurfaceRelease(surface_id) -class GPUObjectBase(base.GPUObjectBase): +class GPUObjectBase(classes.GPUObjectBase): pass -class GPUAdapterInfo(base.GPUAdapterInfo): +class GPUAdapterInfo(classes.GPUAdapterInfo): pass -class GPUAdapter(base.GPUAdapter): +class GPUAdapter(classes.GPUAdapter): def request_device( self, *, @@ -694,7 +694,7 @@ def _destroy(self): libf.wgpuAdapterRelease(internal) -class GPUDevice(base.GPUDevice, GPUObjectBase): +class GPUDevice(classes.GPUDevice, GPUObjectBase): def __init__(self, label, internal, adapter, features, limits, queue): super().__init__(label, internal, adapter, features, limits, queue) @@ -1444,7 +1444,7 @@ def _destroy(self): # wgpuDeviceDestroy(internal) is also an option -class GPUBuffer(base.GPUBuffer, GPUObjectBase): +class GPUBuffer(classes.GPUBuffer, GPUObjectBase): def __init__(self, label, internal, device, size, usage, map_state): super().__init__(label, internal, device, size, usage, map_state) @@ -1643,7 +1643,7 @@ def _destroy(self): # releasing something are highly unlikely. -class GPUTexture(base.GPUTexture, GPUObjectBase): +class GPUTexture(classes.GPUTexture, GPUObjectBase): def create_view( self, *, @@ -1701,7 +1701,7 @@ def _destroy(self): self._device._poll() -class GPUTextureView(base.GPUTextureView, GPUObjectBase): +class GPUTextureView(classes.GPUTextureView, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1710,7 +1710,7 @@ def _destroy(self): self._device._poll() -class GPUSampler(base.GPUSampler, GPUObjectBase): +class GPUSampler(classes.GPUSampler, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1719,7 +1719,7 @@ def _destroy(self): self._device._poll() -class GPUBindGroupLayout(base.GPUBindGroupLayout, GPUObjectBase): +class GPUBindGroupLayout(classes.GPUBindGroupLayout, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1727,7 +1727,7 @@ def _destroy(self): libf.wgpuBindGroupLayoutRelease(internal) -class GPUBindGroup(base.GPUBindGroup, GPUObjectBase): +class GPUBindGroup(classes.GPUBindGroup, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1735,7 +1735,7 @@ def _destroy(self): libf.wgpuBindGroupRelease(internal) -class GPUPipelineLayout(base.GPUPipelineLayout, GPUObjectBase): +class GPUPipelineLayout(classes.GPUPipelineLayout, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1744,7 +1744,7 @@ def _destroy(self): self._device._poll() -class GPUShaderModule(base.GPUShaderModule, GPUObjectBase): +class GPUShaderModule(classes.GPUShaderModule, GPUObjectBase): def get_compilation_info(self): # Here's a little setup to implement this method. Unfortunately, # this is not yet implemented in wgpu-native. Another problem @@ -1783,11 +1783,11 @@ def _destroy(self): libf.wgpuShaderModuleRelease(internal) -class GPUPipelineBase(base.GPUPipelineBase): +class GPUPipelineBase(classes.GPUPipelineBase): pass -class GPUComputePipeline(base.GPUComputePipeline, GPUPipelineBase, GPUObjectBase): +class GPUComputePipeline(classes.GPUComputePipeline, GPUPipelineBase, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1796,7 +1796,7 @@ def _destroy(self): self._device._poll() -class GPURenderPipeline(base.GPURenderPipeline, GPUPipelineBase, GPUObjectBase): +class GPURenderPipeline(classes.GPURenderPipeline, GPUPipelineBase, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -1805,7 +1805,7 @@ def _destroy(self): self._device._poll() -class GPUCommandBuffer(base.GPUCommandBuffer, GPUObjectBase): +class GPUCommandBuffer(classes.GPUCommandBuffer, GPUObjectBase): def _destroy(self): # Since command buffers get destroyed when you submit them, we # must only release them if they've not been submitted, or we get @@ -1819,11 +1819,11 @@ def _destroy(self): libf.wgpuCommandBufferRelease(internal) -class GPUCommandsMixin(base.GPUCommandsMixin): +class GPUCommandsMixin(classes.GPUCommandsMixin): pass -class GPUBindingCommandsMixin(base.GPUBindingCommandsMixin): +class GPUBindingCommandsMixin(classes.GPUBindingCommandsMixin): def set_bind_group( self, index, @@ -1851,7 +1851,7 @@ def set_bind_group( ) -class GPUDebugCommandsMixin(base.GPUDebugCommandsMixin): +class GPUDebugCommandsMixin(classes.GPUDebugCommandsMixin): def push_debug_group(self, group_label): c_group_label = ffi.new("char []", group_label.encode()) color = 0 @@ -1895,7 +1895,7 @@ def insert_debug_marker(self, marker_label): ) -class GPURenderCommandsMixin(base.GPURenderCommandsMixin): +class GPURenderCommandsMixin(classes.GPURenderCommandsMixin): def set_pipeline(self, pipeline): pipeline_id = pipeline._internal # H: void f(WGPURenderPassEncoder renderPassEncoder, WGPURenderPipeline pipeline) @@ -1958,7 +1958,7 @@ def draw_indexed_indirect(self, indirect_buffer, indirect_offset): class GPUCommandEncoder( - base.GPUCommandEncoder, GPUCommandsMixin, GPUDebugCommandsMixin, GPUObjectBase + classes.GPUCommandEncoder, GPUCommandsMixin, GPUDebugCommandsMixin, GPUObjectBase ): def begin_compute_pass( self, *, label="", timestamp_writes: "structs.ComputePassTimestampWrites" = None @@ -2321,7 +2321,7 @@ def _destroy(self): class GPUComputePassEncoder( - base.GPUComputePassEncoder, + classes.GPUComputePassEncoder, GPUCommandsMixin, GPUDebugCommandsMixin, GPUBindingCommandsMixin, @@ -2361,7 +2361,7 @@ def _destroy(self): class GPURenderPassEncoder( - base.GPURenderPassEncoder, + classes.GPURenderPassEncoder, GPUCommandsMixin, GPUDebugCommandsMixin, GPUBindingCommandsMixin, @@ -2424,7 +2424,7 @@ def _destroy(self): class GPURenderBundleEncoder( - base.GPURenderBundleEncoder, + classes.GPURenderBundleEncoder, GPUCommandsMixin, GPUDebugCommandsMixin, GPUBindingCommandsMixin, @@ -2441,7 +2441,7 @@ def _destroy(self): libf.wgpuRenderBundleEncoderRelease(internal) -class GPUQueue(base.GPUQueue, GPUObjectBase): +class GPUQueue(classes.GPUQueue, GPUObjectBase): def submit(self, command_buffers): command_buffer_ids = [cb._internal for cb in command_buffers] c_command_buffers = ffi.new("WGPUCommandBuffer []", command_buffer_ids) @@ -2650,7 +2650,7 @@ def _destroy(self): libf.wgpuQueueRelease(internal) -class GPURenderBundle(base.GPURenderBundle, GPUObjectBase): +class GPURenderBundle(classes.GPURenderBundle, GPUObjectBase): def _destroy(self): if self._internal is not None and libf is not None: self._internal, internal = None, self._internal @@ -2658,7 +2658,7 @@ def _destroy(self): libf.wgpuRenderBundleRelease(internal) -class GPUQuerySet(base.GPUQuerySet, GPUObjectBase): +class GPUQuerySet(classes.GPUQuerySet, GPUObjectBase): pass def destroy(self): @@ -2671,35 +2671,35 @@ def destroy(self): # %% Subclasses that don't need anything else -class GPUCompilationMessage(base.GPUCompilationMessage): +class GPUCompilationMessage(classes.GPUCompilationMessage): pass -class GPUCompilationInfo(base.GPUCompilationInfo): +class GPUCompilationInfo(classes.GPUCompilationInfo): pass -class GPUDeviceLostInfo(base.GPUDeviceLostInfo): +class GPUDeviceLostInfo(classes.GPUDeviceLostInfo): pass -class GPUError(base.GPUError): +class GPUError(classes.GPUError): pass -class GPUOutOfMemoryError(base.GPUOutOfMemoryError, GPUError): +class GPUOutOfMemoryError(classes.GPUOutOfMemoryError, GPUError): pass -class GPUValidationError(base.GPUValidationError, GPUError): +class GPUValidationError(classes.GPUValidationError, GPUError): pass -class GPUPipelineError(base.GPUPipelineError): +class GPUPipelineError(classes.GPUPipelineError): pass -class GPUInternalError(base.GPUInternalError, GPUError): +class GPUInternalError(classes.GPUInternalError, GPUError): pass diff --git a/wgpu/backends/wgpu_native/_helpers.py b/wgpu/backends/wgpu_native/_helpers.py index 40eb8370..2492e2d9 100644 --- a/wgpu/backends/wgpu_native/_helpers.py +++ b/wgpu/backends/wgpu_native/_helpers.py @@ -1,4 +1,4 @@ -"""Utilities used in rs.py. +"""Utilities used in the wgpu-native backend. """ import os @@ -7,7 +7,7 @@ from ._ffi import ffi, lib from ..._diagnostics import Diagnostics -from ...base import ( +from ...classes import ( GPUError, GPUOutOfMemoryError, GPUValidationError, diff --git a/wgpu/classes.py b/wgpu/classes.py new file mode 100644 index 00000000..20190141 --- /dev/null +++ b/wgpu/classes.py @@ -0,0 +1,8 @@ +""" +The classes that make up the wgpu API. +These can be accessed via ``wgpu.classes``, +but are also available in the root wgpu namespace. +""" + +from ._classes import * # noqa: F401, F403 +from ._classes import __all__ # noqa: F401 diff --git a/wgpu/gui/_offscreen.py b/wgpu/gui/_offscreen.py index 68e2adcd..64f12965 100644 --- a/wgpu/gui/_offscreen.py +++ b/wgpu/gui/_offscreen.py @@ -1,4 +1,4 @@ -from .. import base, flags +from .. import classes, flags from ..gui.base import WgpuCanvasBase @@ -43,7 +43,7 @@ def get_preferred_format(self): return "rgba8unorm-srgb" -class GPUCanvasContext(base.GPUCanvasContext): +class GPUCanvasContext(classes.GPUCanvasContext): """Helper class for canvases that render to a texture.""" def __init__(self, canvas): diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index fdbb486c..3f0d40f9 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -8,7 +8,7 @@ * Wrote 5 flags to flags.py * Wrote 33 enums to enums.py * Wrote 59 structs to structs.py -### Patching API for base.py +### Patching API for _classes.py * Diffs for GPU: change get_preferred_canvas_format, change request_adapter, change request_adapter_async * Diffs for GPUCanvasContext: add get_preferred_format, add present * Diffs for GPUDevice: add adapter, add create_buffer_with_data, hide import_external_texture, hide lost, hide onuncapturederror, hide pop_error_scope, hide push_error_scope @@ -16,7 +16,7 @@ * Diffs for GPUTexture: add size * Diffs for GPUTextureView: add size, add texture * Diffs for GPUQueue: add read_buffer, add read_texture, hide copy_external_image_to_texture -* Validated 37 classes, 112 methods, 43 properties +* Validated 37 classes, 111 methods, 43 properties ### Patching API for backends/wgpu_native/_api.py * Validated 37 classes, 100 methods, 0 properties ## Validating backends/wgpu_native/_api.py