Skip to content

Commit

Permalink
Merge pull request #10 from pynbody/wgpu-0.15
Browse files Browse the repository at this point in the history
Update for webgpu 0.15
  • Loading branch information
apontzen authored Jun 12, 2024
2 parents df179a9 + 3ed2d28 commit e6d8b46
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 16 additions & 1 deletion src/topsy/canvas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion src/topsy/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit e6d8b46

Please sign in to comment.