LuPPC/src/lua/core/gpudetect.lua

49 lines
973 B
Lua
Raw Normal View History

2016-02-29 00:31:55 +11:00
local gpudetect = {}
local function tryText()
2016-08-18 06:40:11 +10:00
lprint("Trying text-mode gpu")
2016-02-29 00:31:55 +11:00
loadModule("textgpu")
local textgpuAddr, tgfail = modules.textgpu.start()
if not textgpuAddr then
lprint("Couldn't initialize text gpu: " .. tostring(tgfail))
return false
end
return true
end
local function tryFb()
2016-08-18 06:40:11 +10:00
lprint("Trying framebuffer-mode gpu")
2016-02-29 00:31:55 +11:00
if framebuffer.isReady() then
loadModule("fbgpu")
modules.fbgpu.start()
return true
end
return false
end
2016-03-03 04:48:12 +11:00
local function tryWindows()
loadModule("winapigpu")
return modules.winapigpu.start() and true or false
end
2016-02-29 00:31:55 +11:00
function gpudetect.run()
local s = false
if hasOpt("-t", "--text") then
s = tryText()
return
end
if hasOpt("-f", "--fb") or native.isinit() then
s = tryFb()
end
if not s then
lprint("Falling back to text gpu")
s = tryText()
end
2016-03-03 04:48:12 +11:00
if not s and winapigpu then
lprint("Falling back to windows gpu")
s = tryWindows()
end
2016-02-29 00:31:55 +11:00
end
return gpudetect