I am building a rendering in Vulkan using C++. I have been running into issues implementing subpasses in the renderer to split lighting into a separate subpass. The issue suggests a problem with dependencies where it is expecting a different image layout than the one transitioned to for the second pass. However, I believe the issue may be in the shaders where I may not be using the correct vertex shader for the second pass. Can you please look at the shaders and suggest new code for the lighting vertex shader if required? Here is the code for the shaders:

Geometry Vertex Shader:

#version 450

layout(binding = 0) buffer ModelBufferObject {
    mat4 models[];
} modelUBO;

layout(binding = 1) uniform ViewBufferObject {
    mat4 view;
} viewUBO;

layout(binding = 2) uniform ProjBufferObject {
    mat4 proj;
} projUBO;

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 3) in vec3 inNormal;

layout(location = 0) out vec3 fragPosition;
layout(location = 1) out vec3 fragNormal;
layout(location = 2) out vec3 fragColor;
layout(location = 3) out vec2 fragTexCoord;

void main() {
    mat4 model = modelUBO.models[gl_InstanceIndex]; // Use the model matrix for the current instance
    gl_Position = projUBO.proj * viewUBO.view * model * vec4(inPosition, 1.0);
    fragPosition = vec3(model * vec4(inPosition, 1.0));
    fragNormal = normalize(mat3(transpose(inverse(model))) * inNormal);
    fragColor = inColor;
    fragTexCoord = inTexCoord;
}

Geometry Fragment Shader:

#version 450

layout(location = 0) in vec3 fragPosition;
layout(location = 1) in vec3 fragNormal;
layout(location = 2) in vec3 fragColor;
layout(location = 3) in vec2 fragTexCoord;

layout(binding = 3) uniform sampler2D texSampler;

layout(location = 0) out vec4 gPosition;
layout(location = 1) out vec4 gNormal;
layout(location = 2) out vec4 gAlbedo;

void main() {
    gPosition = vec4(fragPosition, 1.0);
    gNormal = vec4(fragNormal, 1.0);
    gAlbedo = texture(texSampler, fragTexCoord) * vec4(fragColor, 1.0);
}

Lighting Vertex Shader:

#version 450

layout(binding = 0) buffer ModelBufferObject {
    mat4 models[];
} modelUBO;

layout(binding = 1) uniform ViewBufferObject {
    mat4 view;
} viewUBO;

layout(binding = 2) uniform ProjBufferObject {
    mat4 proj;
} projUBO;

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 3) in vec3 inNormal;

layout(location = 0) out vec3 fragPosition;
layout(location = 1) out vec3 fragNormal;
layout(location = 2) out vec3 fragColor;
layout(location = 3) out vec2 fragTexCoord;

void main() {
    mat4 model = modelUBO.models[gl_InstanceIndex]; // Use the model matrix for the current instance
    gl_Position = projUBO.proj * viewUBO.view * model * vec4(inPosition, 1.0);
    fragPosition = vec3(model * vec4(inPosition, 1.0));
    fragNormal = normalize(mat3(transpose(inverse(model))) * inNormal);
    fragColor = inColor;
    fragTexCoord = inTexCoord;
}

Lighting Fragment Shader:

#version 450

layout(location = 0) out vec4 outColor;

layout(binding = 3) uniform sampler2D gPosition;
layout(binding = 4) uniform sampler2D gNormal;
layout(binding = 5) uniform sampler2D gAlbedo;

layout(location = 0) in vec3 fragPosition;
layout(location = 1) in vec3 fragNormal;
layout(location = 2) in vec3 fragColor;
layout(location = 3) in vec2 fragTexCoord;

layout(set = 0, binding = 6) uniform Ambient_Data {
    vec3 color;
    float intensity;
} ambient;

layout(set = 0, binding = 7) uniform Directional_Data {
    vec3 position;
    vec3 color;
    float intensity;
} directional;

void main() {
    vec3 fragPosition = texture(gPosition, fragTexCoord).xyz;
    vec3 fragNormal = normalize(texture(gNormal, fragTexCoord).xyz);
    vec3 fragAlbedo = texture(gAlbedo, fragTexCoord).rgb;

    vec3 ambientLight = ambient.intensity * ambient.color;

    vec3 lightDir = normalize(directional.position - fragPosition);
    float diff = max(dot(fragNormal, lightDir), 0.0);
    vec3 diffuse = diff * directional.color;

    outColor = vec4((ambientLight + diffuse) * fragAlbedo, 1.0);
}