9b4defe202
Support flattening StorageOutput & StorageInput matrices and arrays. No longer move matrix & array inputs to separate buffer. Add separate SPIRFunction::fixup_statements_in & SPIRFunction::fixup_statements_out instead of just SPIRFunction::fixup_statements. Emit SPIRFunction::fixup_statements at beginning of functions. CompilerMSL track vars_needing_early_declaration. Pass global output variables as variables to functions that access them. Sort input structs by location, same as output structs. Emit struct declarations in order output, input, uniforms. Regenerate reference shaders to new formats defined by above.
42 lines
1.1 KiB
GLSL
42 lines
1.1 KiB
GLSL
#version 450
|
|
|
|
layout(binding = 0, std140) uniform UBO
|
|
{
|
|
mat4 projection;
|
|
mat4 model;
|
|
float lodBias;
|
|
} ubo;
|
|
|
|
layout(location = 0) in vec3 inPos;
|
|
layout(location = 1) in vec4 colors[3];
|
|
layout(location = 4) in vec3 inNormal;
|
|
layout(location = 5) in mat4 inViewMat;
|
|
layout(location = 0) out vec3 outPos;
|
|
layout(location = 1) out vec3 outNormal;
|
|
layout(location = 2) out mat4 outTransModel;
|
|
layout(location = 6) out float outLodBias;
|
|
layout(location = 7) out vec4 color;
|
|
|
|
void write_deeper_in_function()
|
|
{
|
|
outTransModel[1][1] = ubo.lodBias;
|
|
color = colors[2];
|
|
}
|
|
|
|
void write_in_function()
|
|
{
|
|
outTransModel[2] = vec4(inNormal, 1.0);
|
|
write_deeper_in_function();
|
|
}
|
|
|
|
void main()
|
|
{
|
|
gl_Position = (ubo.projection * ubo.model) * vec4(inPos, 1.0);
|
|
outPos = vec3((ubo.model * vec4(inPos, 1.0)).xyz);
|
|
outNormal = mat3(vec3(ubo.model[0].x, ubo.model[0].y, ubo.model[0].z), vec3(ubo.model[1].x, ubo.model[1].y, ubo.model[1].z), vec3(ubo.model[2].x, ubo.model[2].y, ubo.model[2].z)) * inNormal;
|
|
outLodBias = ubo.lodBias;
|
|
outTransModel = transpose(ubo.model) * inViewMat;
|
|
write_in_function();
|
|
}
|
|
|