Skip to content
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
11 changes: 6 additions & 5 deletions wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ def create_view(
)
id = _lib.wgpu_texture_create_view(self._internal, struct)

return base.GPUTextureView(label, id, self._device, self)
return base.GPUTextureView(label, id, self._device, self, self.texture_size)

# wgpu.help('texturedestroy', dev=True)
def destroy(self):
Expand Down Expand Up @@ -1811,19 +1811,20 @@ def __enter__(self):
# Get the current texture view, and make sure it is presented when done
self._create_native_swap_chain_if_needed()
sc_output = _lib.wgpu_swap_chain_get_next_texture(self._internal)
if sc_output.status == _lib.WGPUSwapChainStatus_Good:
status, view_id = sc_output.status, sc_output.view_id
if status == _lib.WGPUSwapChainStatus_Good:
pass
elif sc_output.status == _lib.WGPUSwapChainStatus_Suboptimal: # no-cover
elif status == _lib.WGPUSwapChainStatus_Suboptimal: # no-cover
if not getattr(self, "_warned_swap_chain_suboptimal", False):
logger.warning(f"Swap chain status of {self} is suboptimal")
self._warned_swap_chain_suboptimal = True
else: # no-cover
status = sc_output.status
status_str = swap_chain_status_map.get(status, "")
raise RuntimeError(
f"Swap chain status is not good: {status_str} ({status})"
)
return base.GPUTextureView("swap_chain", sc_output.view_id, self._device, None)
size = self._surface_size[0], self._surface_size[1], 1
return base.GPUTextureView("swap_chain", view_id, self._device, None, size)

def __exit__(self, type, value, tb):
# Present the current texture
Expand Down
9 changes: 8 additions & 1 deletion wgpu/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,16 @@ class GPUTextureView(GPUObject):
Create a texture view using :func:`GPUTexture.create_view`.
"""

def __init__(self, label, internal, device, texture):
def __init__(self, label, internal, device, texture, size):
super().__init__(label, internal, device)
self._texture = texture
self._size = size

@property
def size(self):
""" The texture size (as a 3-tuple).
"""
return self._size

@property
def texture(self):
Expand Down