Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer mapping API #377

Merged
merged 13 commits into from
Oct 17, 2023
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ Changed:
* Update to wgpu-native 0.17.2.1. No changes are needed in downstream code.


### [v0.11.0] - t.b.d.

We have revised the buffer mapping API, making it more similar to the
WebGPU spec, and providing more flexible and performant ways to set
buffer data.

Added:

* The `GPUBuffer` has new methods `map()`, `map_async()`, `unmap()`. These have been
part of the WebGPU spec for a long time, but we had an alternative API, until now.
* The `GPUBuffer` has new methods `read_mapped()` and `write_mapped()`. These are not
present in the WebGPU spec; they are the Pythonic alternative to `getMappedRange()`.

Changed:

* Can create a buffer that is initially mapped: `device.create_buffer(..., mapped_at_creation=True)` is enabled again.

Removed:

* The `GPUBuffer` methods `map_read()`and `map_write()` are deprecated, in favor of `map()`, `unmap()`, `read_mapped()` and `write_mapped()`.

For the record, these are not changed:

* The convenient `device.create_buffer_with_data()` (not part of the WebGPU spec) is also available.
* The `GPUQueue.read_buffer()` and `GPUQueue.write_buffer()` methods are unchanged.


### [v0.10.0] - 09-10-2023

In this release the API is aligned with the latest webgpu.idl, and
Expand Down
4 changes: 4 additions & 0 deletions codegen/apipatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def get_method_def(self, classname, methodname):
name_idl = self.name2idl(methodname)
if methodname.endswith("_async") and name_idl not in functions:
name_idl = self.name2idl(methodname.replace("_async", ""))
elif name_idl not in functions and name_idl + "Async" in functions:
name_idl += "Async"
idl_line = functions[name_idl]

# Construct preamble
Expand Down Expand Up @@ -369,6 +371,8 @@ def method_is_known(self, classname, methodname):
name_idl = self.name2idl(methodname)
if "_async" in methodname and name_idl not in functions:
name_idl = self.name2idl(methodname.replace("_async", ""))
elif name_idl not in functions and name_idl + "Async" in functions:
name_idl += "Async"
return name_idl if name_idl in functions else None

def get_class_names(self):
Expand Down
Loading
Loading