Skip to content

Commit

Permalink
Update two comments (#395)
Browse files Browse the repository at this point in the history
* Change todo into comment in write_texture.

* address another todo
  • Loading branch information
almarklein authored Oct 24, 2023
1 parent 2de785c commit ce68b40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit ce68b40

Please sign in to comment.