Last active
November 30, 2021 15:02
-
-
Save aglitchman/167b7f15d01ebd584c3b9a5209adbe23 to your computer and use it in GitHub Desktop.
Editor script for Defold IDE. The script adds the menu items "Compile Fragment Shader" and "Compile Vertex Shader" for .fp/.vp files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Download and install Arm Mobile Studio from | |
-- https://developer.arm.com/tools-and-software/graphics-and-gaming/arm-mobile-studio/components/mali-offline-compiler | |
local M = {} | |
local function ends_with(str, ending) | |
return ending == "" or str:sub(-#ending) == ending | |
end | |
function M.get_commands() | |
return { | |
{ | |
label = "Compile Fragment Shader (Mali-G72)", | |
locations = {"Edit", "Assets"}, | |
query = {selection = {type = "resource", cardinality = "one"}}, | |
active = function(opts) | |
local path = editor.get(opts.selection, "path") | |
return ends_with(path, ".fp") | |
end, | |
run = function(opts) | |
local path = editor.get(opts.selection, "path") | |
path = path:sub(2) | |
return { | |
{action = "shell", command = {"cmd", "/C", "malioc.exe", "--core", "Mali-G72", "--fragment", path}} | |
} | |
end | |
}, { | |
label = "Compile Vertex Shader (Mali-G72)", | |
locations = {"Edit", "Assets"}, | |
query = {selection = {type = "resource", cardinality = "one"}}, | |
active = function(opts) | |
local path = editor.get(opts.selection, "path") | |
return ends_with(path, ".vp") | |
end, | |
run = function(opts) | |
local path = editor.get(opts.selection, "path") | |
path = path:sub(2) | |
return { | |
{action = "shell", command = {"cmd", "/C", "malioc.exe", "--core", "Mali-G72", "--vertex", path}} | |
} | |
end | |
}, { | |
label = "Compile Fragment Shader (Mali-T860)", | |
locations = {"Edit", "Assets"}, | |
query = {selection = {type = "resource", cardinality = "one"}}, | |
active = function(opts) | |
local path = editor.get(opts.selection, "path") | |
return ends_with(path, ".fp") | |
end, | |
run = function(opts) | |
local path = editor.get(opts.selection, "path") | |
path = path:sub(2) | |
return { | |
{action = "shell", command = {"cmd", "/C", "malioc.exe", "--core", "Mali-T860", "--fragment", path}} | |
} | |
end | |
}, { | |
label = "Compile Vertex Shader (Mali-T860)", | |
locations = {"Edit", "Assets"}, | |
query = {selection = {type = "resource", cardinality = "one"}}, | |
active = function(opts) | |
local path = editor.get(opts.selection, "path") | |
return ends_with(path, ".vp") | |
end, | |
run = function(opts) | |
local path = editor.get(opts.selection, "path") | |
path = path:sub(2) | |
return { | |
{action = "shell", command = {"cmd", "/C", "malioc.exe", "--core", "Mali-T860", "--vertex", path}} | |
} | |
end | |
} | |
} | |
end | |
return M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified version to work with stand alone legacy version of shader compiler
https://developer.arm.com/tools-and-software/graphics-and-gaming/mali-offline-compiler/downloads