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:

(PseudoCode)


VkCommandBuffer cmdSec = new SecondaryCommandBuffer;
int subPass = 0;
vkBeginCommandBuffer(cmdSec,COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE,renderPass,framebuffer,subPass);
	vkCmdBindPipeline(cmdSec,pipeline);
	foreach(mesh) {
		vkCmdBindVertexBuffers(cmdSec,...);
		vkCmdDraw(cmdSec);
	}
vkEndCommandBuffer(cmdSec);

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


VkCommandBuffer cmdPrim = new PrimaryCommandBuffer;
vkBeginRenderPass(cmdPrim,renderPass,framebuffer,VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
	vkCmdPushConstants(cmdPrim,...); // Push additional data required for rendering the meshes
	vkCmdExecuteCommands(cmdPrim,cmdSec);
vkEndRenderPass(cmdPrim);

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?