In the chapter "Vertex input description" you declared the vertex attribute as
layout(location = 0) in vec2 inPosition;
so to use it, you had to cast it to vec4, like this
gl_Position = vec4(inPosition, 0.0, 1.0);
Later in the chapter "Depth buffering" you had to change this to
All this does not make sense.
Vulkan specification says
If the format does not include G, B, or A components, then those are filled with (0,0,1) as needed (using either 1.0f or integer 1 based on the format) for attributes that are not 64-bit data types. The number of components in the vertex shader input variable need not exactly match the number of components in the format. If the vertex shader has fewer components, the extra components are discarded.
Therefore, if you declare a vertex attribute, like this
layout(location = 0) in vec4 inPosition;
you do not need to cast it to vec4, whatever the format.
So this cast here just adds an extra operation. And forces us to recompile the shader when changing the format of the vertices.
Yes, it is possible to rely on the implicit values, but I think this only adds confusion. Just like some of the other implicit behavior in Vulkan that I have made explicit in the tutorial, I won't change this.
In the chapter "Vertex input description" you declared the vertex attribute as
layout(location = 0) in vec2 inPosition;
so to use it, you had to cast it to vec4, like thisgl_Position = vec4(inPosition, 0.0, 1.0);
Later in the chapter "Depth buffering" you had to change this toAll this does not make sense. Vulkan specification says
Therefore, if you declare a vertex attribute, like this
layout(location = 0) in vec4 inPosition;
you do not need to cast it to vec4, whatever the format.So this cast here just adds an extra operation. And forces us to recompile the shader when changing the format of the vertices.