Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # vulkan-diag.sh — Vulkan / VA-API diagnostic tool for Fedora
- # Usage: bash vulkan-diag.sh
- set -euo pipefail
- RED='\033[0;31m'
- YEL='\033[0;33m'
- GRN='\033[0;32m'
- BLU='\033[0;34m'
- BOLD='\033[1m'
- RST='\033[0m'
- ok() { echo -e " ${GRN}[OK]${RST} $*"; }
- warn() { echo -e " ${YEL}[WARN]${RST} $*"; }
- err() { echo -e " ${RED}[ERROR]${RST} $*"; }
- info() { echo -e " ${BLU}[INFO]${RST} $*"; }
- hdr() { echo -e "\n${BOLD}$*${RST}"; echo " $(printf '─%.0s' {1..60})"; }
- # ── summary state ─────────────────────────────────────────────
- declare -A SUMMARY
- SUMMARY[gpu]="unknown"
- SUMMARY[vulkan]="not checked"
- SUMMARY[vkvideo]="not checked"
- SUMMARY[vaapi]="not checked"
- SUMMARY[pkgs]="not checked"
- SUMMARY[browser]="not checked"
- # ── helpers ───────────────────────────────────────────────────
- need_cmd() {
- if ! command -v "$1" &>/dev/null; then
- warn "'$1' not found. Install with: sudo dnf install $2"
- return 1
- fi
- return 0
- }
- # ──────────────────────────────────────────────────────────────
- echo -e "\n${BOLD}╔══════════════════════════════════════════════════╗${RST}"
- echo -e "${BOLD}║ Vulkan / VA-API diagnostic tool for Fedora ║${RST}"
- echo -e "${BOLD}╚══════════════════════════════════════════════════╝${RST}"
- # ── Step 0: detect GPU ───────────────────────────────────────
- hdr "Step 0 — Detecting GPU"
- GPU_INFO=$(lspci 2>/dev/null | grep -iE "vga|3d|display" || true)
- if [ -z "$GPU_INFO" ]; then
- warn "Could not detect GPU via lspci."
- else
- echo "$GPU_INFO" | while IFS= read -r line; do info "$line"; done
- fi
- HAS_INTEL=false
- HAS_AMD=false
- HAS_NVIDIA=false
- echo "$GPU_INFO" | grep -qi "intel" && HAS_INTEL=true
- echo "$GPU_INFO" | grep -qi "amd\|radeon\|advanced micro" && HAS_AMD=true
- echo "$GPU_INFO" | grep -qi "nvidia" && HAS_NVIDIA=true
- # Hybrid system detection (e.g. AMD iGPU + NVIDIA dGPU)
- HYBRID=false
- VENDOR_COUNT=0
- $HAS_INTEL && VENDOR_COUNT=$((VENDOR_COUNT+1))
- $HAS_AMD && VENDOR_COUNT=$((VENDOR_COUNT+1))
- $HAS_NVIDIA && VENDOR_COUNT=$((VENDOR_COUNT+1))
- [ "$VENDOR_COUNT" -gt 1 ] && HYBRID=true
- # Primary vendor = discrete GPU wins over integrated
- GPU_VENDOR="unknown"
- if $HAS_NVIDIA && $HYBRID; then
- GPU_VENDOR="nvidia-hybrid"
- elif $HAS_NVIDIA; then
- GPU_VENDOR="nvidia"
- elif $HAS_AMD; then
- GPU_VENDOR="amd"
- elif $HAS_INTEL; then
- GPU_VENDOR="intel"
- fi
- SUMMARY[gpu]="$GPU_VENDOR"
- if $HYBRID; then
- warn "Hybrid GPU system detected (multiple GPU vendors found)."
- $HAS_AMD && info "AMD integrated GPU present (Radeon/Vega)"
- $HAS_NVIDIA && info "NVIDIA discrete GPU present"
- $HAS_INTEL && info "Intel GPU present"
- info "Vulkan will load ICDs for all GPUs — llvmpipe may also appear as a software fallback, which is normal."
- info "The active GPU for rendering depends on your compositor / prime-run settings."
- fi
- case "$GPU_VENDOR" in
- intel) ok "Intel GPU detected — will use ANV_DEBUG flags for video extensions" ;;
- amd) ok "AMD GPU detected — will use Mesa RADV driver checks" ;;
- nvidia) warn "NVIDIA GPU detected — Vulkan video is still TBD on Fedora; VA-API via libva-nvidia-driver is recommended" ;;
- nvidia-hybrid) warn "NVIDIA + AMD/Intel hybrid detected — discrete GPU is NVIDIA. VA-API on the AMD iGPU is usually the most reliable path for video decode." ;;
- *) warn "GPU vendor unknown — running generic checks" ;;
- esac
- # ── Step 1: Vulkan basic check ────────────────────────────────
- hdr "Step 1 — Vulkan support"
- if ! need_cmd vulkaninfo "vulkan-tools"; then
- err "Install vulkan-tools and re-run: sudo dnf install vulkan-tools"
- SUMMARY[vulkan]="ERROR — vulkaninfo not installed"
- else
- VKFLAGS=""
- [ "$GPU_VENDOR" = "intel" ] && VKFLAGS="ANV_DEBUG=video-decode,video-encode"
- VK_OUT=$(env $VKFLAGS vulkaninfo --summary 2>&1 || true)
- HAS_REAL_GPU=false
- HAS_LLVMPIPE=false
- echo "$VK_OUT" | grep -qiE "radv|anv|nv_|nvidia" && HAS_REAL_GPU=true
- echo "$VK_OUT" | grep -qi "llvmpipe\|lavapipe" && HAS_LLVMPIPE=true
- if echo "$VK_OUT" | grep -qi "error\|cannot open"; then
- err "vulkaninfo returned an error — Vulkan is not initializing."
- info "Try: sudo dnf install mesa-vulkan-drivers"
- SUMMARY[vulkan]="ERROR — failed to initialize"
- elif $HAS_REAL_GPU; then
- ok "Vulkan is working on your real GPU."
- # print each detected driver
- echo "$VK_OUT" | grep -iE "driverName" | while IFS= read -r line; do
- drv=$(echo "$line" | awk -F'=' '{print $2}' | xargs)
- case "${drv,,}" in
- llvmpipe|lavapipe) info "driverName = $drv ${YEL}(software fallback — normal on hybrid systems, not your render GPU)${RST}" ;;
- *) info "driverName = $drv" ;;
- esac
- done
- if $HAS_LLVMPIPE && $HYBRID; then
- warn "llvmpipe is listed alongside your real GPU driver — this is normal on hybrid systems. It is a software fallback ICD and will not be used for rendering."
- fi
- SUMMARY[vulkan]="OK"
- elif $HAS_LLVMPIPE; then
- err "Only llvmpipe/Lavapipe (software renderer) detected — real GPU driver not loaded."
- info "Check mesa-vulkan-drivers is installed and your session is using the GPU."
- info "Try: sudo dnf install mesa-vulkan-drivers"
- SUMMARY[vulkan]="ERROR — software renderer only"
- else
- warn "Could not clearly identify GPU driver from vulkaninfo output."
- info "Check manually: vulkaninfo --summary | grep -iE 'GPU|driver'"
- SUMMARY[vulkan]="WARN — unclear"
- fi
- fi
- # ── Step 2: Vulkan video extensions ──────────────────────────
- hdr "Step 2 — Vulkan video extensions"
- if command -v vulkaninfo &>/dev/null; then
- VKFLAGS=""
- [ "$GPU_VENDOR" = "intel" ] && VKFLAGS="ANV_DEBUG=video-decode,video-encode"
- VK_VIDEO=$(env $VKFLAGS vulkaninfo 2>/dev/null | grep -i "video" || true)
- if echo "$VK_VIDEO" | grep -qi "VK_KHR_video_decode_queue\|VK_KHR_video_queue"; then
- ok "Vulkan video extensions found — VK_KHR_video_decode_queue detected."
- echo "$VK_VIDEO" | grep -iE "VK_KHR_video" | head -6 | while IFS= read -r line; do info " $line"; done
- SUMMARY[vkvideo]="OK"
- elif [ -n "$VK_VIDEO" ]; then
- warn "Some video-related output found but VK_KHR_video_decode_queue not detected."
- echo "$VK_VIDEO" | head -5 | while IFS= read -r line; do info " $line"; done
- info "Vulkan video may be partially supported — check the full extension list."
- SUMMARY[vkvideo]="WARN — partial"
- else
- if [ "$GPU_VENDOR" = "nvidia" ]; then
- warn "No Vulkan video extensions found. This is expected for NVIDIA on Fedora — use VA-API instead."
- else
- warn "No Vulkan video extensions found."
- info "For Intel: make sure you used ANV_DEBUG=video-decode,video-encode (this script does it automatically)."
- info "For AMD: install mesa-vulkan-drivers-freeworld from RPM Fusion."
- fi
- SUMMARY[vkvideo]="WARN — not available"
- fi
- else
- warn "vulkaninfo not available — skipping Vulkan video check."
- SUMMARY[vkvideo]="SKIPPED"
- fi
- # ── Step 3: VA-API ────────────────────────────────────────────
- hdr "Step 3 — VA-API"
- if ! need_cmd vainfo "libva-utils"; then
- SUMMARY[vaapi]="ERROR — vainfo not installed"
- else
- VAINFO=$(vainfo 2>&1 || true)
- if echo "$VAINFO" | grep -qi "failed\|cannot open\|error"; then
- err "VA-API initialization failed."
- case "$GPU_VENDOR" in
- intel) info "Install intel-media-driver: sudo dnf install intel-media-driver" ;;
- amd) info "Install mesa-va-drivers-freeworld: sudo dnf install mesa-va-drivers-freeworld" ;;
- nvidia) info "Install libva-nvidia-driver: sudo dnf install libva-nvidia-driver" ;;
- *) info "Check that the correct VA-API driver for your GPU is installed." ;;
- esac
- SUMMARY[vaapi]="ERROR — failed to initialize"
- elif echo "$VAINFO" | grep -qiE "VAEntrypointVLD|h264|hevc|vp9|h265|av1"; then
- ok "VA-API is working and exposes decode profiles."
- PROFILES=$(echo "$VAINFO" | grep -iE "VAProfile" | head -6 || true)
- echo "$PROFILES" | while IFS= read -r line; do info " $line"; done
- SUMMARY[vaapi]="OK"
- elif echo "$VAINFO" | grep -qi "driver"; then
- warn "VA-API driver loaded but no codec profiles detected."
- info "You may be missing freeworld codec packages."
- case "$GPU_VENDOR" in
- amd|intel) info "Try: sudo dnf install mesa-va-drivers-freeworld" ;;
- nvidia) info "Try: sudo dnf install libva-nvidia-driver" ;;
- esac
- SUMMARY[vaapi]="WARN — driver found but no codecs"
- else
- warn "VA-API output unclear — check manually with: vainfo"
- SUMMARY[vaapi]="WARN — unclear"
- fi
- fi
- # ── Step 4: Package check ─────────────────────────────────────
- hdr "Step 4 — Driver packages"
- PKG_OUT=$(rpm -qa 2>/dev/null | grep -E "mesa-vulkan|mesa-va|libva-nvidia|nvidia-vaapi|intel-media" || true)
- if [ -z "$PKG_OUT" ]; then
- err "No relevant driver packages found."
- case "$GPU_VENDOR" in
- intel) info "Install: sudo dnf install mesa-vulkan-drivers-freeworld intel-media-driver" ;;
- amd) info "Install: sudo dnf install mesa-vulkan-drivers-freeworld mesa-va-drivers-freeworld" ;;
- nvidia) info "Install: sudo dnf install libva-nvidia-driver" ;;
- *) info "Install mesa-vulkan-drivers-freeworld (AMD/Intel) or libva-nvidia-driver (NVIDIA)" ;;
- esac
- SUMMARY[pkgs]="ERROR — missing packages"
- else
- HAS_FREEWORLD=false
- echo "$PKG_OUT" | while IFS= read -r pkg; do info "$pkg"; done
- echo "$PKG_OUT" | grep -q "freeworld" && HAS_FREEWORLD=true
- if echo "$PKG_OUT" | grep -q "freeworld" || echo "$PKG_OUT" | grep -qE "libva-nvidia|intel-media"; then
- ok "Codec packages look good."
- SUMMARY[pkgs]="OK"
- else
- warn "Only standard mesa-vulkan-drivers found — missing freeworld variant."
- info "For H.264/H.265 support, install from RPM Fusion:"
- info " sudo dnf install mesa-vulkan-drivers-freeworld"
- SUMMARY[pkgs]="WARN — freeworld packages missing"
- fi
- fi
- # ── Step 5: Firefox env check ─────────────────────────────────
- hdr "Step 5 — Firefox VA-API environment"
- if command -v firefox &>/dev/null; then
- WAYLAND_VAL="${MOZ_ENABLE_WAYLAND:-}"
- SESSION="${XDG_SESSION_TYPE:-unknown}"
- info "Session type: $SESSION"
- if [ "$SESSION" = "wayland" ]; then
- if [ "$WAYLAND_VAL" = "1" ]; then
- ok "MOZ_ENABLE_WAYLAND=1 is set — Firefox will use Wayland and VA-API."
- else
- warn "MOZ_ENABLE_WAYLAND is not set (or not 1). Firefox may not use hardware decode on Wayland."
- info "Add to your shell profile: export MOZ_ENABLE_WAYLAND=1"
- fi
- else
- info "Not running Wayland — MOZ_ENABLE_WAYLAND not required."
- fi
- # check about:config equivalents via profile prefs
- FFPROF=$(find ~/.mozilla/firefox -name "prefs.js" 2>/dev/null | head -1 || true)
- if [ -n "$FFPROF" ]; then
- VAAPI_PREF=$(grep "media.ffmpeg.vaapi.enabled" "$FFPROF" 2>/dev/null || true)
- if echo "$VAAPI_PREF" | grep -q "true"; then
- ok "media.ffmpeg.vaapi.enabled = true in Firefox prefs."
- SUMMARY[browser]="OK"
- elif echo "$VAAPI_PREF" | grep -q "false"; then
- warn "media.ffmpeg.vaapi.enabled = false — hardware decode disabled in Firefox."
- info "Enable in about:config: media.ffmpeg.vaapi.enabled = true"
- SUMMARY[browser]="WARN — vaapi disabled in Firefox"
- else
- info "media.ffmpeg.vaapi.enabled not explicitly set (uses default)."
- info "To ensure hardware decode: set media.ffmpeg.vaapi.enabled = true in about:config"
- SUMMARY[browser]="INFO — pref not set"
- fi
- else
- info "No Firefox profile found — skipping prefs check."
- SUMMARY[browser]="SKIPPED"
- fi
- else
- info "Firefox not installed — skipping Firefox check."
- SUMMARY[browser]="SKIPPED"
- fi
- # ── Summary ───────────────────────────────────────────────────
- echo -e "\n${BOLD}╔══════════════════════════════════════════════════╗${RST}"
- echo -e "${BOLD}║ Summary ║${RST}"
- echo -e "${BOLD}╚══════════════════════════════════════════════════╝${RST}"
- print_summary_line() {
- local label="$1"
- local value="$2"
- case "$value" in
- OK*) echo -e " ${GRN}✔${RST} $(printf '%-18s' "$label") $value" ;;
- WARN*) echo -e " ${YEL}!${RST} $(printf '%-18s' "$label") $value" ;;
- ERROR*) echo -e " ${RED}✘${RST} $(printf '%-18s' "$label") $value" ;;
- SKIPPED*) echo -e " ${BLU}-${RST} $(printf '%-18s' "$label") $value" ;;
- *) echo -e " ${BLU}?${RST} $(printf '%-18s' "$label") $value" ;;
- esac
- }
- echo ""
- print_summary_line "GPU vendor" "${SUMMARY[gpu]}"
- print_summary_line "Vulkan" "${SUMMARY[vulkan]}"
- print_summary_line "Vulkan video" "${SUMMARY[vkvideo]}"
- print_summary_line "VA-API" "${SUMMARY[vaapi]}"
- print_summary_line "Packages" "${SUMMARY[pkgs]}"
- print_summary_line "Firefox" "${SUMMARY[browser]}"
- echo ""
- # ── install suggestions ───────────────────────────────────────
- NEEDS_RPMFUSION=false
- echo "$PKG_OUT" | grep -q "freeworld" || NEEDS_RPMFUSION=true
- if $NEEDS_RPMFUSION; then
- echo -e "${BOLD}RPM Fusion note:${RST}"
- info "Some packages above require RPM Fusion. Enable it with:"
- info " sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-\$(rpm -E %fedora).noarch.rpm"
- info " sudo dnf install https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-\$(rpm -E %fedora).noarch.rpm"
- echo ""
- fi
- echo -e "${BLU}For more info:${RST} https://fedoraproject.org/wiki/Hardware_Video_Acceleration"
- echo ""
Advertisement