45
45
46
46
def _notebook_print_banner ():
47
47
from ipywidgets import Image
48
- from IPython .display import display
48
+ from IPython .display import display , HTML
49
49
50
50
logo_path = Path (__file__ ).parent .parent .joinpath (
51
51
"assets" , "fastplotlib_face_logo.png"
@@ -54,40 +54,69 @@ def _notebook_print_banner():
54
54
with open (logo_path , "rb" ) as f :
55
55
logo_data = f .read ()
56
56
57
+ # get small logo image
57
58
image = Image (value = logo_data , format = "png" , width = 300 , height = 55 )
58
59
59
- display (image )
60
-
61
- # print logo and adapter info
60
+ # get adapters and info
62
61
adapters = [a for a in wgpu .gpu .enumerate_adapters ()]
63
62
adapters_info = [a .info for a in adapters ]
64
63
65
64
default_adapter_info = wgpu .gpu .request_adapter ().info
66
65
default_ix = adapters_info .index (default_adapter_info )
67
66
68
- if len (adapters ) > 0 :
69
- print ("Available devices:" )
67
+ if len (adapters ) < 1 :
68
+ return
69
+
70
+ # start HTML table
71
+ table_str = (
72
+ "<b>Available devices:</b>"
73
+ "<table>"
74
+ "<tr>"
75
+ "<th>Valid</th>"
76
+ "<th>Device</th>"
77
+ "<th>Type</th>"
78
+ "<th>Backend</th>"
79
+ "<th>Driver</th>"
80
+ "</tr>"
81
+ )
70
82
83
+ # parse each adapter that WGPU found
71
84
for ix , adapter in enumerate (adapters_info ):
72
85
atype = adapter ["adapter_type" ]
73
86
backend = adapter ["backend_type" ]
74
87
driver = adapter ["description" ]
75
88
device = adapter ["device" ]
76
89
77
- if atype == "DiscreteGPU" and backend != "OpenGL" :
78
- charactor = chr (0x2705 )
79
- elif atype == "IntegratedGPU" and backend != "OpenGL" :
80
- charactor = chr (0x0001FBC4 )
90
+ if atype in ("DiscreteGPU" , "IntegratedGPU" ) and backend != "OpenGL" :
91
+ charactor = chr (0x2705 ) # green checkmark
92
+ tooltip = "This adapter can be used with fastplotlib"
93
+ elif backend == "OpenGL" :
94
+ charactor = chr (0x0000274C ) # red x
95
+ tooltip = "This adapter cannot be used with fastplotlib"
96
+ elif device .startswith ("llvmpipe" ) or atype == "CPU" :
97
+ charactor = f"{ chr (0x00002757 )} limited" # red !
98
+ tooltip = "CPU rendering support is limited and mainly for testing purposes"
81
99
else :
82
- charactor = chr (0x2757 )
100
+ charactor = f"{ chr (0x00002757 )} unknown" # red !
101
+ tooltip = "Unknown adapter type and backend"
83
102
84
103
if ix == default_ix :
85
104
default = " (default) "
86
105
else :
87
- default = " "
106
+ default = ""
88
107
89
- output_str = f"{ charactor } { default } | { device } | { atype } | { backend } | { driver } "
90
- print (output_str )
108
+ # add row to HTML table
109
+ table_str += f'<tr title="{ tooltip } ">'
110
+ # add each element to this row
111
+ for s in [f"{ charactor } { default } " , device , atype , backend , driver ]:
112
+ table_str += f"<td>{ s } </td>"
113
+ table_str += "</tr>"
114
+
115
+ table_str += "</table>"
116
+
117
+ # display logo and adapters table
118
+ display (image )
119
+ display (HTML (table_str ))
91
120
92
121
93
122
if GUI_BACKEND == "jupyter" :
0 commit comments