From ead312f29a6020acaa5227f5bdc405939cdd2803 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 3 May 2023 16:09:27 -0500 Subject: [PATCH] feat(wezterm): properly detect and handle vulkan support --- dots/.config/wezterm/config/gpu.lua | 24 ++++++++++++++++++++++++ dots/.config/wezterm/wezterm.lua | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 dots/.config/wezterm/config/gpu.lua diff --git a/dots/.config/wezterm/config/gpu.lua b/dots/.config/wezterm/config/gpu.lua new file mode 100644 index 00000000..d2bb6569 --- /dev/null +++ b/dots/.config/wezterm/config/gpu.lua @@ -0,0 +1,24 @@ +-- We have to provide a good gpu for wezterm to use gpu acceleration. We ideally want to use a vullkan front end, but if +-- we are unable to locate a card that supports Vulkan we fall back to OpenGL +local config = {} +local wezterm = require("wezterm") +local wlib = require("wlib") + +local found_valid_gpu = false +wezterm.log_info(wlib.Table.dump(wezterm.gui.enumerate_gpus())) +for _, gpu in ipairs(wezterm.gui.enumerate_gpus()) do + if gpu.backend == "Vulkan" then + wezterm.log_info("Found Usable Vulkan GPU\n Device Name -> " .. gpu.name .."\n Device Type -> " .. gpu.device_type) + config.webgpu_preferred_adapter = gpu + config.front_end = "WebGpu" + found_valid_gpu = true + break + end +end + +if not found_valid_gpu then + wezterm.log_warn("Unable to locate a Vulkan-supported GPU, falling back to OpenGL") + config.front_end = "OpenGL" +end + +return config diff --git a/dots/.config/wezterm/wezterm.lua b/dots/.config/wezterm/wezterm.lua index cc9325ed..5b16b411 100644 --- a/dots/.config/wezterm/wezterm.lua +++ b/dots/.config/wezterm/wezterm.lua @@ -10,6 +10,7 @@ local tabbar = require("config.tabbar") local rendering = require("config.rendering") local keybinds = require("config.keybinds") local misc = require("config.misc") +local gpu = require("config.gpu") -- NOTE: Pull in the OS specific config, this is passed last to the mergeable -- NOTE: as the last item to be merged (last item passed) overrides all others @@ -23,5 +24,8 @@ if not found then os_config = {} end -local config = wlib.Table.merge(events, fonts, theme, tabbar, misc, rendering, keybinds, os_config) + +local config = wlib.Table.merge(gpu, events, fonts, theme, tabbar, misc, rendering, keybinds, os_config) + + return config