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 for webgpu 0.15 #10

Merged
merged 1 commit into from
Jun 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ dependencies = [
"pynbody >=1.3.0",
"matplotlib >=3.6.0",
"pillow >=9.5.0", # 9.5.0 needed for Image.frombytes accepting memoryview
"wgpu == 0.13.0",
"wgpu ~= 0.15",
"jupyter_rfb >=0.4.1",
"tqdm >=4.62.0",
"opencv-python >=4.8.0",
17 changes: 16 additions & 1 deletion src/topsy/canvas/__init__.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,22 @@ def call_later(cls, delay, fn, *args):
# Note also that is_jupyter as implemented fails to distinguish correctly if we are
# running inside a kernel that isn't attached to a notebook. There doesn't seem to
# be any way to distinguish this, so we live with it for now.
from wgpu.gui.auto import is_jupyter

def is_jupyter():
"""Determine whether the user is executing in a Jupyter Notebook / Lab.

This has been pasted from an old version of wgpu.gui.auto.is_jupyter; the function was removed"""
from IPython import get_ipython
try:
ip = get_ipython()
if ip is None:
return False
if ip.has_trait("kernel"):
return True
else:
return False
except NameError:
return False


if is_jupyter():
2 changes: 1 addition & 1 deletion src/topsy/visualizer.py
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ def _setup_wgpu(self):
self.adapter: wgpu.GPUAdapter = wgpu.gpu.request_adapter(power_preference="high-performance")
if self.device is None:
type(self).device: wgpu.GPUDevice = self.adapter.request_device(
required_features=["TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES"])
required_features=["TextureAdapterSpecificFormatFeatures", "float32-filterable"])
self.context: wgpu.GPUCanvasContext = self.canvas.get_context()
self.canvas_format = self.context.get_preferred_format(self.adapter)
if self.canvas_format.endswith("-srgb"):