I'm new to WebGPU and am currently trying to get an existing engine running with it.
Our shaders are written in HLSL, though we are already used to convert them to SPIR-V for our Vulkan backend. So I thought I could just use that for testing. However, WebGPU doesn't like even my very simple shader:
cbuffer GlobalConstants : register(b2, space0)
{
float4x4 MVP;
};
struct VS_IN
{
float3 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
};
struct VS_OUT
{
float4 Position : SV_Position;
float2 TexCoord0 : TEXCOORD0;
};
VS_OUT main(VS_IN Input)
{
VS_OUT RetVal;
RetVal.Position = mul(MVP, float4(Input.Position, 1.0f));
RetVal.TexCoord0 = Input.TexCoord0;
return RetVal;
}
It complains about this line:
mul(MVP, float4(Input.Position, 1.0f));
WebGPU Validation: Error while parsing SPIR-V: error: WGSL does not support row-major matrices: can't translate member 0 of %6 = OpTypeStruct %13
I am using DXC to convert HLSL to SPIR-V. It is proven to work in Vulkan. And originally I wrote this shader in WGSL and uploaded my matrices the same way (same column-major data layout) as in our D3D / Vulkan port and it worked. So I am a bit surprised that it complains about row-major matrices.
Is there anything obvious that I am doing wrong? I assume that people have gotten way more complicated shaders to work with this workflow.
Thanks!
Jan.