Skip to content

Instantly share code, notes, and snippets.

@pablomayobre
Created July 9, 2018 17:28
Show Gist options
  • Save pablomayobre/3e73e5cb9403fcbbb287551426748ff3 to your computer and use it in GitHub Desktop.
Save pablomayobre/3e73e5cb9403fcbbb287551426748ff3 to your computer and use it in GitHub Desktop.
WYSS - What're Your System Specs? Gather all the specs from a system into a neat table
local wyss = {
--OS detected by LÖVE
os = love.system.getOS(),
--Current LÖVE version (>= 11.0)
love = table.concat({love.getVersion()}, '.', 1, 3),
--Lua version (in case it was changed)
lua = _VERSION,
processor = {
--Number of threads/processors
count = love.system.getProcessorCount(),
}
}
if jit then
--FFI trick to get the ammount of RAM in the system
local ffi = require "ffi"
ffi.cdef[[
int SDL_GetSystemRAM(void);
]]
local sdl = ffi.os == "Windows" and ffi.load("SDL") or ffi.C
local ok, value = pcall(sdl.SDL_GetSystemRAM)
if ok and tonumber(value) then
wyss.processor.memory = tonumber(value)
end
--Architecture of the CPU
wyss.processor.arch = jit.arch
--Available JIT compiler features
local features = {jit.status()}
wyss.jit = {
version = jit.version,
enabled = table.remove(features, 1),
features = features
}
--Double check for the OS string using LuaJIT's own information
wyss.os = string.format("%s (%s)", wyss.os, jit.os)
end
if love.graphics then
--Get renderer (GPU and driver) information
local name, version, vendor, gpu = love.graphics.getRendererInfo()
--Tables with supported features
local features, image, canvas, readable = {}, {}, {}, {}
for k, v in pairs(love.graphics.getSupported()) do
if v then table.insert(features, k) end
end
for k, v in pairs(love.graphics.getImageFormats()) do --luacheck: ignore
if v then table.insert(image, k) end
end
for k, v in pairs(love.graphics.getCanvasFormats()) do
if v then table.insert(canvas, k) end
end
for k, v in pairs(love.graphics.getCanvasFormats(true)) do
if v then table.insert(readable, k) end
end
wyss.renderer = {
info = {
driver = {name, version},
gpu = gpu,
vendor = vendor
},
supports = {
features = features,
image = image,
canvas = canvas,
readable = readable
},
--Renderer limits
limits = love.graphics.getSystemLimits()
}
end
return wyss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment