How create big buffer in Vulkan vertex shader ?

I need create big buffer(data 30 megabytes) for vertex shader.
In HLSL Buffer<float4> positions : register(t0);
Which analog in Vulkan vertex shader ?

On CPU i create simple vertex buffer on 30 megabytes and binding to shader layout. Then use in Vulkan vertex shader.

Depends on what you actually going to do with that buffer, but I’d go with a storage buffer object. They can be much bigger than ubos and accessed within the shaders.

Say you want to only upload data once to that storage buffer object for accessing it only on the device (inside shaders), you :

  • Create a staging buffer (usage VK_BUFFER_USAGE_TRANSFER_SRC_BIT) with host visibility (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
  • Copy your data
  • Create the storage buffer object (usage VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT) with VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
  • Copy your staging buffer from host to the GPU
  • Destroy staging buffer

But how buffer look in shader ? How to describe big buffer in Vulkan vertex shader ?
Please show me example how to describe big buffer in vertex shader.

It looks to me like you’re talking about vertex attributes. These are just input variables to the vertex shader. You don’t need to annotate them with “buffer” or whatever; they’re just in variables in a vertex shader, which have a location layout attached.

It’s your input description stuff that decides what buffers and formats are assigned to which input locations.

For example i know how look in Vulkan vertex shader UBO:
layout (binding = 0) uniform UBO
{
mat4 projectionMatrix;
mat4 viewMatrix;
mat4 modelMatrix;
} ubo;
But how look big buffer ? Just simple show me. Thats all.

You need to tell us what you want to do with that buffer. If it’s just about vertices, then do what Alfonse said, just use vertex attributes. If it’s more of a common buffer for doing some computational stuff, use a shader storage buffer object.

I want use for animation. I have many poses for animation, like run\dead\attack\jump etc.
And this all animation matrices 30 megabytes.
In Directx 11 i do in HLSL Buffer<float4> positions : register(t0); for describe big buffer.
Then from CPU i binding big buffer my animation matrices to Buffer<float4> positions : register(t0);
And use in vertex shader all my animation poses. And not storage in RAM memory. Only GPU memory.

It is right ?
layout (std430, binding=0) buffer some_block {
vec4 some[];
};

Yes, if you’re using a shader storage buffer that should be the right way of accessing it.

I want use for animation. I have many poses for animation, like run\dead\attack\jump etc.
And this all animation matrices 30 megabytes.

Vertex animation? In this millennium? And 30MB worth of data at that?

There are almost certainly more efficient (and effective) ways of animating figures.

I show example.
One model 30 MB, but i have 20 models.
All animations 480 MB.
Buffer in vertex shader can be used for mesh morphing, or for instance(for 20 000 grass )