diff --git a/reference/shaders-hlsl/vert/matrix-attribute.vert b/reference/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 00000000..abe8ca9e --- /dev/null +++ b/reference/shaders-hlsl/vert/matrix-attribute.vert @@ -0,0 +1,35 @@ +static float4 gl_Position; +static float4x4 m; +static float3 pos; + +struct SPIRV_Cross_Input +{ + float4 m_0 : TEXCOORD0; + float4 m_1 : TEXCOORD1; + float4 m_2 : TEXCOORD2; + float4 m_3 : TEXCOORD3; + float3 pos : TEXCOORD4; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(float4(pos, 1.0f), m); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + m[0] = stage_input.m_0; + m[1] = stage_input.m_1; + m[2] = stage_input.m_2; + m[3] = stage_input.m_3; + pos = stage_input.pos; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/shaders-hlsl/vert/matrix-attribute.vert b/shaders-hlsl/vert/matrix-attribute.vert new file mode 100644 index 00000000..14c03847 --- /dev/null +++ b/shaders-hlsl/vert/matrix-attribute.vert @@ -0,0 +1,9 @@ +#version 310 es + +in vec3 pos; +in mat4 m; + +void main() +{ + gl_Position = m * vec4(pos, 1.0); +} diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp index 2320f937..97e0b446 100644 --- a/spirv_hlsl.cpp +++ b/spirv_hlsl.cpp @@ -861,7 +861,7 @@ void CompilerHLSL::emit_hlsl_entry_point() { // Unroll matrices. for (uint32_t col = 0; col < mtype.columns; col++) - statement(name, "[", col, "] = stage_input.", name, "_0;"); + statement(name, "[", col, "] = stage_input.", name, "_", col, ";"); } else {