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

Update two comments #395

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2565,11 +2565,19 @@ def write_texture(self, destination, data, data_layout, size):
raise ValueError("copy destination texture must be a texture, not a view")

m, address = get_memoryview_and_address(data)
# todo: could we not derive the size from the shape of m?

c_data = ffi.cast("uint8_t *", address)
data_length = m.nbytes

# We could allow size=None in this method, and derive the size from the data.
# Or compare size with the data size if it is given. However, the data
# could be a bit raw, being 1D and/or the shape expressed in bytes, so
# this gets a bit muddy. Also methods like copy_buffer_to_texture have the
# same size arg, so let's just leave it like this.
#
# data_size = list(reversed(m.shape)) + [1, 1, 1]
# data_size = data_size[:3]

size = _tuple_from_tuple_or_dict(
size, ("width", "height", "depth_or_array_layers")
)
Expand Down
3 changes: 2 additions & 1 deletion wgpu/gui/_offscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def get_preferred_format(self, adapter):

def get_current_texture(self):
self._create_new_texture_if_needed()
# todo: we return a view here, to align with the rs implementation, even though its wrong.
# Technically a texture view, even though WebGPU says it must be a texture.
# Anyway, this API will change in a next version anyway.
return self._texture_view

def present(self):
Expand Down
Loading