shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
MIT License
2.18k stars 187 forks source link

SPIR-V/Vulkan specialization constants are not generated in SPIRV when -allow-glsl is set #5463

Open andreasschultes opened 2 weeks ago

andreasschultes commented 2 weeks ago

SPIR-V/Vulkan specialization constants are not generated in SPIRV when -allow-glsl is set.

${SLANGC} ${SHADER_FILE} -target spirv -I${SOURCE_ROOT} ${SHADER_INCLUDE_DIRS} -DdebugPrintfEXT -depfile ${SPIRV}.d -o ${SPIRV}

generates the SpecId "OpDecorate %a SpecId 5"

${SLANGC} ${SHADER_FILE} -target spirv -allow-glsl -I${SOURCE_ROOT} ${SHADER_INCLUDE_DIRS} -DdebugPrintfEXT -depfile ${SPIRV}.d -o ${SPIRV}

uses the default values and the constants are optimised out

csyonghe commented 2 weeks ago

Can you share with us the shader code that canbe used to reproduce this issue?

andreasschultes commented 1 week ago

The test case for specialization constants reproduce this with the parameter -target spirv -allow-glsl -o test.spv https://github.com/shader-slang/slang/blob/master/tests/spirv/specialization-constant.slang