I'm testing out DXC to compile HLSL files into SPIR-V, but have run into an issue on a seemingly simple shader. The shader compiles and runs fine using glslangValidator with the -D flag (HLSL input), but when trying to compile it with DXC, I get the following error message:
QuoteVKMessage: SPIR-V module not valid: Codesize must be a multiple of 4 but is 7333. The Vulkan spec states: If pCode points to SPIR-V code, codeSize must be a multiple of 4
Is there a flag or option I've missed to force DXC to output a multiple-of-4 result? With this requirement, I would have assumed it would have done that by default, but that obviously isn't the case.
Below are the two commands I'm trying to get to act the same. As stated, the first command produces the expected result and everything runs fine. The dxc line gives the issue. (And I run these separately - they're posted together below for quick reading, but they do not run sequentially and overwrite each other in practice).
C:/VulkanSDK/1.1.106.0/Bin/glslangValidator.exe -e main -V -D Basic_PushConstant_HLSL.frag -o basic_push_constant_ps.spv
C:/"Program Files (x86)"/"Windows Kits"/10/bin/10.0.17763.0/x64/dxc.exe /Zi /spirv /fspv-target-env=vulkan1.1 /E"main" /Od /Fo"basic_push_constant_ps.spv" /T"ps_6_0" /nologo Basic_PushConstant_HLSL.frag
The shader is below. Nothing fancy, just drawing colored quads on the screen.
[[vk::push_constant]]
cbuffer PConsts : register(b2)
{
[[vk::offset(8)]]
float cb_push;
};
struct PixelIn
{
float4 posH : SV_Position;
float3 color : COLOR;
float2 texcoord : TEXCOORD;
};
float4 main(PixelIn pIn) : SV_Target0
{
float3 color = pIn.color * saturate(cb_push + 0.2f);
return float4(color, 1.0f);
}
Thanks!