mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 07:23:35 +00:00
working on WebGPU command lists
This commit is contained in:
@@ -25,7 +25,7 @@ void DebugCallBack(PulseDebugMessageSeverity severity, const char* message)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_WEBGPU, PULSE_SHADER_FORMAT_SPIRV_BIT, PULSE_HIGH_DEBUG);
|
||||
PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_WEBGPU, PULSE_SHADER_FORMAT_WGSL_BIT, PULSE_HIGH_DEBUG);
|
||||
CHECK_PULSE_HANDLE_RETVAL(backend, 1);
|
||||
PulseSetDebugCallback(backend, DebugCallBack);
|
||||
PulseDevice device = PulseCreateDevice(backend, NULL, 0);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
[nzsl_version("1.0")]
|
||||
module;
|
||||
|
||||
struct Input
|
||||
{
|
||||
[builtin(global_invocation_indices)] indices: vec3[u32]
|
||||
}
|
||||
|
||||
[entry(compute)]
|
||||
[workgroup(32, 32, 1)]
|
||||
fn main(input: Input)
|
||||
{
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
3,2,35,7,0,0,1,0,39,0,0,0,16,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,14,0,
|
||||
3,0,0,0,0,0,1,0,0,0,15,0,6,0,5,0,0,0,12,0,0,0,109,97,105,110,0,0,0,0,
|
||||
6,0,0,0,16,0,6,0,12,0,0,0,17,0,0,0,32,0,0,0,32,0,0,0,1,0,0,0,3,0,
|
||||
3,0,9,0,0,0,100,0,0,0,5,0,4,0,10,0,0,0,73,110,112,117,116,0,0,0,6,0,5,0,
|
||||
10,0,0,0,0,0,0,0,105,110,100,105,99,101,115,0,5,0,9,0,6,0,0,0,103,108,111,98,97,108,
|
||||
95,105,110,118,111,99,97,116,105,111,110,95,105,110,100,105,99,101,115,0,0,0,5,0,4,0,12,0,0,0,
|
||||
109,97,105,110,0,0,0,0,71,0,4,0,6,0,0,0,11,0,0,0,28,0,0,0,72,0,5,0,10,0,
|
||||
0,0,0,0,0,0,35,0,0,0,0,0,0,0,19,0,2,0,1,0,0,0,33,0,3,0,2,0,0,0,
|
||||
1,0,0,0,21,0,4,0,3,0,0,0,32,0,0,0,0,0,0,0,23,0,4,0,4,0,0,0,3,0,
|
||||
0,0,3,0,0,0,32,0,4,0,5,0,0,0,1,0,0,0,4,0,0,0,21,0,4,0,7,0,0,0,
|
||||
32,0,0,0,1,0,0,0,43,0,4,0,7,0,0,0,8,0,0,0,0,0,0,0,32,0,4,0,9,0,
|
||||
0,0,7,0,0,0,4,0,0,0,30,0,3,0,10,0,0,0,4,0,0,0,32,0,4,0,11,0,0,0,
|
||||
7,0,0,0,10,0,0,0,59,0,4,0,5,0,0,0,6,0,0,0,1,0,0,0,54,0,5,0,1,0,
|
||||
0,0,12,0,0,0,0,0,0,0,2,0,0,0,248,0,2,0,13,0,0,0,59,0,4,0,11,0,0,0,
|
||||
14,0,0,0,7,0,0,0,65,0,5,0,9,0,0,0,15,0,0,0,14,0,0,0,8,0,0,0,63,0,
|
||||
3,0,15,0,0,0,6,0,0,0,253,0,1,0,56,0,1,0
|
||||
4
Examples/WebGPU/shader.wgsl
git.filemode.normal_file
4
Examples/WebGPU/shader.wgsl
git.filemode.normal_file
@@ -0,0 +1,4 @@
|
||||
@compute @workgroup_size(32, 32, 1)
|
||||
fn main(@builtin(global_invocation_id) grid: vec3u)
|
||||
{
|
||||
}
|
||||
@@ -1,99 +1,7 @@
|
||||
add_repositories("nazara-engine-repo https://github.com/NazaraEngine/xmake-repo")
|
||||
|
||||
add_requires("nzsl >=2023.12.31", { configs = { shared = false, nzslc = true } })
|
||||
|
||||
if is_cross() then
|
||||
add_requires("nzsl~host", { kind = "binary", host = true })
|
||||
end
|
||||
|
||||
-- Yoinked from NZSL xmake repo
|
||||
rule("find_nzsl")
|
||||
on_config(function(target)
|
||||
import("core.project.project")
|
||||
import("core.tool.toolchain")
|
||||
import("lib.detect.find_tool")
|
||||
|
||||
local envs
|
||||
if is_plat("windows") then
|
||||
local msvc = target:toolchain("msvc")
|
||||
if msvc and msvc:check() then
|
||||
envs = msvc:runenvs()
|
||||
end
|
||||
elseif is_plat("mingw") then
|
||||
local mingw = target:toolchain("mingw")
|
||||
if mingw and mingw:check() then
|
||||
envs = mingw:runenvs()
|
||||
end
|
||||
end
|
||||
target:data_set("nzsl_envs", envs)
|
||||
|
||||
local nzsl = project.required_package("nzsl~host") or project.required_package("nzsl")
|
||||
local nzsldir
|
||||
if nzsl then
|
||||
nzsldir = path.join(nzsl:installdir(), "bin")
|
||||
local osenvs = os.getenvs()
|
||||
envs = envs or {}
|
||||
for env, values in pairs(nzsl:get("envs")) do
|
||||
local flatval = path.joinenv(values)
|
||||
local oldenv = envs[env] or osenvs[env]
|
||||
if not oldenv or oldenv == "" then
|
||||
envs[env] = flatval
|
||||
elseif not oldenv:startswith(flatval) then
|
||||
envs[env] = flatval .. path.envsep() .. oldenv
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local nzsla = find_tool("nzsla", { version = true, paths = nzsldir, envs = envs })
|
||||
local nzslc = find_tool("nzslc", { version = true, paths = nzsldir, envs = envs })
|
||||
|
||||
target:data_set("nzsla", nzsla)
|
||||
target:data_set("nzslc", nzslc)
|
||||
target:data_set("nzsl_runenv", envs)
|
||||
end)
|
||||
rule_end()
|
||||
|
||||
rule("compile_shaders")
|
||||
set_extensions(".nzsl")
|
||||
add_deps("find_nzsl")
|
||||
|
||||
before_buildcmd_file(function(target, batchcmds, shaderfile, opt)
|
||||
local outputdir = target:data("nzsl_includedirs")
|
||||
local nzslc = target:data("nzslc")
|
||||
local runenvs = target:data("nzsl_runenv")
|
||||
assert(nzslc, "nzslc not found! please install nzsl package with nzslc enabled")
|
||||
|
||||
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.shader %s", shaderfile)
|
||||
local argv = { "--compile=spv-header", "--optimize" }
|
||||
if outputdir then
|
||||
batchcmds:mkdir(outputdir)
|
||||
table.insert(argv, "--output=" .. outputdir)
|
||||
end
|
||||
|
||||
local kind = target:data("plugin.project.kind") or ""
|
||||
if kind:match("vs") then
|
||||
table.insert(argv, "--log-format=vs")
|
||||
end
|
||||
|
||||
table.insert(argv, shaderfile)
|
||||
|
||||
batchcmds:vrunv(nzslc.program, argv, { curdir = ".", envs = runenvs })
|
||||
|
||||
local outputfile = path.join(outputdir or path.directory(shaderfile), path.basename(shaderfile) .. ".spv.h")
|
||||
|
||||
batchcmds:add_depfiles(shaderfile)
|
||||
batchcmds:add_depvalues(nzslc.version)
|
||||
batchcmds:set_depmtime(os.mtime(outputfile))
|
||||
batchcmds:set_depcache(target:dependfile(outputfile))
|
||||
end)
|
||||
rule_end()
|
||||
|
||||
target("WebGPUExample")
|
||||
add_deps("pulse_gpu")
|
||||
if is_plat("linux") then
|
||||
set_extension(".x86_64")
|
||||
end
|
||||
add_rules("compile_shaders")
|
||||
add_files("*.c")
|
||||
add_files("*.nzsl")
|
||||
target_end()
|
||||
|
||||
Reference in New Issue
Block a user