Single time push constants and per frame push constants

In my vertex shader i have this push constant:

layout(push_constant) uniform Push {
    vec2 globalOffset;
    vec2 globalScale;
    int cols;
    int rows;
    float spacing;
} push;

I want to update globalOffset and globalScale quite often, but cols, rows and spacing only once at the beginning of the programm.

I just can’t get it to work, because i do not understand what components i need to do that.

Currently i have a workaround with

    if (statistics.totalDrawFrames == 0)
      setRuntimePushConstants(commandBuffer);

which is in my recordCommandBuffer() function and just contains one vkCmdPushConstants(...) call. It works, but it’s obviously bad to check every frame if it’s the very first frame.

What do i need to make a single time vkCmdPushConstants(...) work?

From the description of vkCmdPushConstants:

In other words if you are re-recording the cmd buffer each frame you also need to set the push constants each frame.

Okay, thanks. Then i will call push vkCmdPushConstants 1 time every frame and move all Data into a single PushConstant structure.

Note that push constants are intended for data that changes frequently, but the amount of data you can put there is pretty small. So if you’re using it for infrequently changing data, you’ll have less available for frequent changes.

Consider a UBO for stuff that is shared across many objects but doesn’t change every frame.

Yeah, though about an UBO, but it seems to be so much overhaed for 12 Bytes to push…