Vulkan Dynamic Rendering: Skip Render Passes and Framebuffers
Use Vulkan 1.3 dynamic rendering to begin and end rendering directly in command buffers without VkRenderPass or VkFramebuffer.
01 Jun 2026, 16:12 UTC

Problem: render passes lock you into attachment layouts up front
Traditional Vulkan rendering requires a VkRenderPass and matching VkFramebuffer before you record any drawing commands. The render pass declares attachment formats, load and store operations, and subpass dependencies at pipeline creation time. If you want to change an attachment image or resolve target between draws, you usually need a new render pass, a new framebuffer, or both. That boilerplate makes deferred renderers, tiled post-processing, and multi-viewport workflows harder than they need to be.
Useful takeaway: declare attachments at draw time
If your target supports Vulkan 1.3 or the VK_KHR_dynamic_rendering extension, you can skip VkRenderPass and VkFramebuffer entirely for many workloads. Instead, call vkCmdBeginRendering with VkRenderingInfo, attach image views directly, draw, then call vkCmdEndRendering. Attachment formats are declared once at pipeline creation through VkPipelineRenderingCreateInfoKHR, while individual images and load/store operations are chosen per draw.
How dynamic rendering works
Dynamic rendering moves attachment description from render-pass creation time to command-buffer recording time. Three pieces are required:
VkPhysicalDeviceDynamicRenderingFeaturesKHRmust be enabled during logical device creation.VkPipelineRenderingCreateInfoKHRtells the pipeline which color, depth, and stencil formats it will render into.VkRenderingInfopassed tovkCmdBeginRenderingnames the actual image views, layouts, load operations, and store operations for this rendering instance.
Worked configuration: device, pipeline, and command buffer
The following C example shows the minimum declarations. Replace placeholders such as device, commandBuffer, colorImageView, and depthImageView with your own Vulkan handles. Run this code in your host application during device initialization and command-buffer recording; no special OS permissions are required beyond a working Vulkan context.
/* 1. Device creation: enable dynamic rendering */
VkPhysicalDeviceDynamicRenderingFeaturesKHR dynamicRenderingFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR,
.pNext = NULL,
.dynamicRendering = VK_TRUE,
};
VkDeviceCreateInfo deviceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.pNext = &dynamicRenderingFeatures, /* insert into pNext chain */
/* ... queueCreateInfoCount, pQueueCreateInfos, enabledExtensionCount, etc. */
};
VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, NULL, &device);
/* Check result == VK_SUCCESS. If VK_ERROR_EXTENSION_NOT_PRESENT, the
device does not support dynamic rendering through this path. */
/* 2. Pipeline creation: declare formats without a render pass */
VkPipelineRenderingCreateInfoKHR renderingCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR,
.pNext = NULL,
.viewMask = 0,
.colorAttachmentCount = 1,
.pColorAttachmentFormats = (VkFormat[]){ VK_FORMAT_B8G8R8A8_UNORM },
.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT,
.stencilAttachmentFormat = VK_FORMAT_UNDEFINED,
};
VkGraphicsPipelineCreateInfo pipelineInfo = {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
.pNext = &renderingCreateInfo,
/* ... stages, vertex input, rasterizer, multisample, etc. */
.renderPass = VK_NULL_HANDLE,
.subpass = 0,
};
/* 3. Command buffer: begin rendering with explicit attachments */
VkRenderingAttachmentInfoKHR colorAttachment = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,
.pNext = NULL,
.imageView = colorImageView, /* placeholder: your swapchain or offscreen view */
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
.resolveMode = VK_RESOLVE_MODE_NONE,
.resolveImageView = VK_NULL_HANDLE,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = { .color = { { 0.1f, 0.1f, 0.1f, 1.0f } } },
};
VkRenderingAttachmentInfoKHR depthAttachment = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,
.pNext = NULL,
.imageView = depthImageView, /* placeholder: your depth image view */
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
.resolveMode = VK_RESOLVE_MODE_NONE,
.resolveImageView = VK_NULL_HANDLE,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = { .depthStencil = { 1.0f, 0 } },
};
VkRenderingInfo renderingInfo = {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
.pNext = NULL,
.flags = 0, /* set VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT if needed */
.renderArea = { .offset = { 0, 0 }, .extent = { width, height } },
.layerCount = 1,
.viewMask = 0,
.colorAttachmentCount = 1,
.pColorAttachments = &colorAttachment,
.pDepthAttachment = &depthAttachment,
.pStencilAttachment = NULL,
};
vkCmdBeginRendering(commandBuffer, &renderingInfo);
/* record draw commands here */
vkCmdEndRendering(commandBuffer);
Expected checks: validation layers (VK_LAYER_KHRONOS_validation) should report no errors when vkCmdBeginRendering is called. If you see validation warnings about attachment formats, compare the formats in VkPipelineRenderingCreateInfoKHR against the image view formats in VkRenderingAttachmentInfo. They must match.
Risk: vkCmdBeginRendering does not fix a mismatched image layout for you. The image must already be in the layout named by imageLayout. Insert a pipeline barrier before vkCmdBeginRendering if the image was previously used as a transfer source, sampled texture, or in another layout.
Limits and common mistakes
- Depth and stencil resolve are separate. You cannot resolve depth and stencil through a single attachment info. Use
pDepthAttachmentfor depth resolve andpStencilAttachmentfor stencil resolve, each with its own resolve image view and resolve mode. - Sample counts must match. The color attachment sample count, pipeline rasterization samples, and resolve target sample count must agree. A mismatch produces validation errors and, on some drivers, undefined behavior.
- Secondary command buffers need an explicit flag. If you record rendering commands in secondary command buffers, set
VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BITinVkRenderingInfo::flags. Omitting it is a common cause of validation failures when executing secondary buffers inside a dynamic render instance. - Mobile tile-based GPUs may prefer render passes. Dynamic rendering removes object-creation overhead, but some tile-based drivers still optimize traditional render passes better for tile memory residency. Measure on target hardware before assuming dynamic rendering is faster.
- Validation layers do not catch everything. Cross-vendor testing is recommended because driver-specific misuse may pass validation on one implementation and fail on another.
Practical verification
- Confirm support: check
VkPhysicalDeviceProperties::apiVersion >= VK_API_VERSION_1_3, or callvkEnumerateDeviceExtensionPropertiesand look forVK_KHR_dynamic_rendering. - Enable the feature: include
VkPhysicalDeviceDynamicRenderingFeaturesKHRwithdynamicRendering = VK_TRUEin thepNextchain ofVkDeviceCreateInfo. - Run with validation layers enabled and inspect the debug callback output around
vkCmdBeginRenderingandvkCmdEndRendering. - Verify frame output: clear values should appear, depth testing should behave as expected, and resolve targets (if used) should contain the resolved image rather than garbage.
When to keep render passes
Dynamic rendering is not a replacement for every render pass. Keep VkRenderPass when you need subpass dependencies, automatic tile load/store semantics that the driver expresses only through render passes, or when targeting older Vulkan implementations without the extension.