Vulkan StorageBuffer versus VertexBuffer

317 Views Asked by At

I'm experimenting with Vulkan rendering, and noticed that we can render using StorageBuffer + gl_VertexIndex instead of VertexBuffer. I've seen this in Metal API tutorials. There are any benefits of using VertexBuffer except missing descriptor sets and ability to set custom vertex layout? In what scenarios can StorageBuffer be used instead of VertexBuffer?

#version 450 core

struct Vertex {
    vec3 position;
    vec3 normal;
    vec4 color;
    vec2 texcoord;
};

layout(binding = 0) readonly buffer VertexInput {
    Vertex[] vertices;
};

out gl_PerVertex {
    vec4 gl_Position;
};

layout(location = 0) out struct {
    vec4 color;
    vec2 texcoord;
} vs_out;

void main() {
    vs_out.color = vertices[gl_VertexIndex].color;
    vs_out.texcoord = vertices[gl_VertexIndex].texcoord;
    
    gl_Position = vec4(vertices[gl_VertexIndex].position, 1);
}
0

There are 0 best solutions below