-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathlaunch_gui.sh
More file actions
executable file
·153 lines (136 loc) · 4.78 KB
/
launch_gui.sh
File metadata and controls
executable file
·153 lines (136 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Launcher script for svVascularize GUI with software rendering
# Add svVascularize to Python path
export PYTHONPATH="$(pwd):$PYTHONPATH"
# Function to find Mesa drivers
find_mesa_drivers() {
local candidates=()
# Check conda environment locations
if [ -n "$CONDA_PREFIX" ]; then
candidates+=(
"$CONDA_PREFIX/lib/dri"
"$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot/usr/lib64/dri"
"$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot/usr/lib/dri"
)
# Check base conda if in an environment
if [[ "$CONDA_PREFIX" == */envs/* ]]; then
BASE_PREFIX="${CONDA_PREFIX%/envs/*}"
candidates+=(
"$BASE_PREFIX/x86_64-conda-linux-gnu/sysroot/usr/lib64/dri"
)
fi
fi
# Check system locations (prioritize these as they exist)
candidates=(
"/usr/lib/x86_64-linux-gnu/dri"
"/usr/lib64/dri"
"/usr/lib/dri"
"${candidates[@]}"
)
# Find first existing directory
for dir in "${candidates[@]}"; do
if [ -d "$dir" ] && [ -f "$dir/swrast_dri.so" -o -f "$dir/llvmpipe_dri.so" ]; then
echo "$dir"
return 0
fi
done
return 1
}
# Parse command line arguments
USE_SYSTEM_GL=0
DEBUG_GL=0
for arg in "$@"; do
case $arg in
--system-gl)
USE_SYSTEM_GL=1
shift
;;
--debug-gl)
DEBUG_GL=1
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --system-gl Use system OpenGL instead of software rendering"
echo " --debug-gl Enable OpenGL debugging output"
echo " --help Show this help message"
echo ""
echo "Environment variables:"
echo " SVV_GUI_GL_MODE='system' Use system OpenGL (same as --system-gl)"
echo " SVV_GUI_SOFTWARE_DRIVER='swr' Use OpenSWR instead of llvmpipe"
echo " SVV_LIBGL_DRIVERS_PATH='/path' Override DRI drivers path"
exit 0
;;
esac
done
# Configure OpenGL settings
if [ "$USE_SYSTEM_GL" -eq 1 ]; then
export SVV_GUI_GL_MODE=system
echo "Using system OpenGL drivers"
else
# Configure software rendering
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER=llvmpipe
export MESA_GL_VERSION_OVERRIDE=3.3
export MESA_LOADER_DRIVER_OVERRIDE=llvmpipe
export QT_OPENGL=software
export SVV_GUI_GL_MODE=software
# Find and set Mesa drivers path
if [ -z "$SVV_LIBGL_DRIVERS_PATH" ]; then
DRI_PATH=$(find_mesa_drivers)
if [ $? -eq 0 ]; then
export LIBGL_DRIVERS_PATH="$DRI_PATH"
export SVV_LIBGL_DRIVERS_PATH="$DRI_PATH"
echo "Found Mesa drivers at: $DRI_PATH"
else
echo "Warning: Could not find Mesa DRI drivers. Trying system fallback..."
# Try installing mesa packages if needed
if command -v conda &> /dev/null && [ -n "$CONDA_PREFIX" ]; then
echo "Attempting to install Mesa drivers via conda..."
conda install -y -c conda-forge mesa-libgl-cos7-x86_64 mesa-dri-drivers-cos7-x86_64 2>/dev/null || true
# Try to find again after installation
DRI_PATH=$(find_mesa_drivers)
if [ $? -eq 0 ]; then
export LIBGL_DRIVERS_PATH="$DRI_PATH"
export SVV_LIBGL_DRIVERS_PATH="$DRI_PATH"
echo "Mesa drivers installed and found at: $DRI_PATH"
fi
fi
fi
else
export LIBGL_DRIVERS_PATH="$SVV_LIBGL_DRIVERS_PATH"
echo "Using user-specified Mesa drivers at: $SVV_LIBGL_DRIVERS_PATH"
fi
# Force XCB on Wayland systems
if [ -n "$WAYLAND_DISPLAY" ]; then
export QT_QPA_PLATFORM=xcb
fi
fi
# Enable debugging if requested
if [ "$DEBUG_GL" -eq 1 ]; then
export SVV_GUI_DEBUG_GL=1
export MESA_DEBUG=1
export LIBGL_DEBUG=verbose
fi
# Fix libffi conflicts for Mesa drivers
if [ -n "$CONDA_PREFIX" ]; then
# Look for libffi in conda environment
if [ -f "$CONDA_PREFIX/lib/libffi.so.7" ]; then
export LD_PRELOAD="$CONDA_PREFIX/lib/libffi.so.7:$LD_PRELOAD"
echo "Using libffi from conda: $CONDA_PREFIX/lib/libffi.so.7"
elif [ -f "$CONDA_PREFIX/lib/libffi.so.8" ]; then
export LD_PRELOAD="$CONDA_PREFIX/lib/libffi.so.8:$LD_PRELOAD"
echo "Using libffi from conda: $CONDA_PREFIX/lib/libffi.so.8"
fi
fi
# Launch the GUI (delegates to Python launcher which configures telemetry)
echo "Launching svVascularize GUI..."
python -c "
from svv.visualize.gui import launch_gui
launch_gui()
" || python -c "
from svv.visualize.gui import launch_gui
launch_gui()
"