feat(wezterm): properly detect and handle vulkan support

This commit is contained in:
Price Hiller 2023-05-03 16:09:27 -05:00
parent 88e6a93abd
commit ead312f29a
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
2 changed files with 29 additions and 1 deletions

View File

@ -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

View File

@ -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