potential fix for shaders

This commit is contained in:
bryanthaboi
2026-08-24 12:10:15 -04:00
parent 7d5856f93b
commit 6503e982db
2 changed files with 14 additions and 3 deletions
+13 -3
View File
@@ -371,9 +371,13 @@ end
-- `es`: true for GLSL ES 1.00 (mobile), false for GLSL 1.20 (desktop). Only -- `es`: true for GLSL ES 1.00 (mobile), false for GLSL 1.20 (desktop). Only
-- ever called from ShaderFX.convert(). -- ever called from ShaderFX.convert().
function ShaderFX.translate(fullPath, es) function ShaderFX.translate(fullPath, es)
local ffi = require("ffi") local okFfi, ffi = pcall(require, "ffi")
local ok, l = pcall(ensureLib) if not okFfi or type(ffi) ~= "table" then
return nil, "this build has no ffi, so presets cannot be converted here"
end
local ok, l, lerr = pcall(ensureLib)
if not ok then return nil, "ffi.load failed: " .. tostring(l) end if not ok then return nil, "ffi.load failed: " .. tostring(l) end
if not l then return nil, tostring(lerr or libError or "librashader bridge not available") end
local ptr = l.librashader_translate_preset(fullPath, es and 1 or 0) local ptr = l.librashader_translate_preset(fullPath, es and 1 or 0)
if ptr == nil then return nil, "librashader_translate_preset returned NULL" end if ptr == nil then return nil, "librashader_translate_preset returned NULL" end
local json = ffi.string(ptr) local json = ffi.string(ptr)
@@ -780,7 +784,7 @@ end
-- Translates `entry` via the bridge and writes ShaderFX.artifactPath(entry). -- Translates `entry` via the bridge and writes ShaderFX.artifactPath(entry).
-- Sets entry.converted on success; an existing artifact survives a failure. -- Sets entry.converted on success; an existing artifact survives a failure.
function ShaderFX.convert(entry, es) local function doConvert(entry, es)
ShaderSourcePatches.apply(entry) ShaderSourcePatches.apply(entry)
local preset, err = ShaderFX.translate(entry.fullPath, es == nil and defaultEs() or es) local preset, err = ShaderFX.translate(entry.fullPath, es == nil and defaultEs() or es)
if not preset then return false, err end if not preset then return false, err end
@@ -797,6 +801,12 @@ function ShaderFX.convert(entry, es)
return true return true
end end
function ShaderFX.convert(entry, es)
local ok, res, err = pcall(doConvert, entry, es)
if not ok then return false, tostring(res) end
return res, err
end
-- Two independent slots. "shaderfx" stays main's option key, so existing -- Two independent slots. "shaderfx" stays main's option key, so existing
-- saves keep meaning what they already meant. -- saves keep meaning what they already meant.
ShaderFX.SLOTS = { "main", "secondary" } ShaderFX.SLOTS = { "main", "secondary" }
+1
View File
@@ -119,6 +119,7 @@ function ShaderFXScreen.new(game, slot)
item.entry.name, tostring(err)) item.entry.name, tostring(err))
end end
applyRowState(item) applyRowState(item)
if not ok then item.right = Strings("FAILED") end
return return
end end