Bind dynamic data in primary command buffer for use in secondary command buffer?

I have a bunch of meshes that don’t ever change, which I all need to render in one swoop. However, I also need to pass some additional data via PushConstants to the pipeline which changes every frame.
So I’ve set up a primary and a secondary command buffer. The secondary command buffer records the rendering calls for the meshes:


VkCommandBuffer cmdSec = new SecondaryCommandBuffer;
int subPass = 0;
	foreach(mesh) {

The primary command buffer starts the actual render pass and executes the secondary command buffer:

VkCommandBuffer cmdPrim = new PrimaryCommandBuffer;
	vkCmdPushConstants(cmdPrim,...); // Push additional data required for rendering the meshes

The problem is the ‘vkCmdPushConstants’-call. Since I don’t know the data beforehand, I can’t record it into the secondary command buffer. However, the specs say:

So calling vkCmdPushConstants as in the code above is invalid as well.
I could use a descriptor set instead of push constants in this specific case to avoid the problem altogether, but I was wondering if there was another solution.

Is it possible to pass data dynamically to a render pass inside a secondary command buffer?

Is it possible to pass data dynamically to a render pass inside a secondary command buffer?

No. And not just for the reasons you cite.

When building a command buffer, that command buffer begins with all pipeline rendering state undefined. The only exceptions to this rule is what is defined in VkCommandBufferInheritanceInfo. Those are the only state which can be inherited by a secondary command buffer.

And push-constant state is not on that list.

If you want to pass some data to a static command buffer like this, you must use actual memory. That is, you must change the values of some UBO/SSBO/whatever that the program in the secondary buffer read and respond to. And of course, you will need to double-buffer this memory, which means you need to double-buffer your static command buffers too.

I’m assuming I need to double-buffer to prevent the memory from being written to, while a previous frame still reads from it, correct?
Wouldn’t I need a tripple-buffer when using mailbox present mode?