Skip to content

English

English

Appearance

GLSL/HLSL to SPIR-V

We can use utils.glsl2spv rules to compile GLSL/HLSL shaders to SPIR-V.

GLSL to SPIR-V

EXPLORER
src
main.c
test.glsl
xmake.lua
Lua xmake.lua
12345678910
add_rules("mode.debug", "mode.release")

add_requires("glslang", {configs = {binaryonly = true}})

target("test")
 set_kind("binary")
 add_rules("utils.glsl2spv", {bin2c = true})
 add_files("src/*.c")
 add_files("src/*.glsl")
 add_packages("glslang")

HLSL to SPIR-V

We can also use utils.hlsl2spv rule to compile HLSL to SPIR-V.

EXPLORER
src
main.c
test.hlsl
xmake.lua
Lua xmake.lua
12345678910
add_rules("mode.debug", "mode.release")

add_requires("directxshadercompiler", {configs = {binaryonly = true}})

target("test")
 set_kind("binary")
 add_rules("utils.hlsl2spv", {bin2c = true})
 add_files("src/*.c")
 add_files("src/*.hlsl")
 add_packages("directxshadercompiler")

Bin2obj Mode

By default, the rule may use bin2c to embed the SPV data. We can switch to bin2obj mode for better performance with large shaders:

EXPLORER
src
main.c
test.glsl
xmake.lua
Lua xmake.lua
12345678910
add_rules("mode.debug", "mode.release")

add_requires("glslang", {configs = {binaryonly = true}})

target("test")
 set_kind("binary")
 add_rules("utils.glsl2spv", {bin2obj = true})
 add_files("src/*.c")
 add_files("src/*.glsl")
 add_packages("glslang")

AltStyle によって変換されたページ (->オリジナル) /