# vkCmdFillMemoryKHR(3) Manual Page

## Name

vkCmdFillMemoryKHR - Fill a memory range with a fixed 4-byte bit pattern

Loading… please wait.

## C Specification

To fill a memory range with a fixed 4-byte bit pattern, call:

    // Provided by VK_KHR_device_address_commands
    void vkCmdFillMemoryKHR(
        VkCommandBuffer                             commandBuffer,
        const VkDeviceAddressRangeKHR*              pDstRange,
        VkAddressCommandFlagsKHR                    dstFlags,
        uint32_t                                    data);

## Parameters

- `commandBuffer` is the command buffer into which the command will be recorded.

- `pDstRange` is a pointer to the VkDeviceAddressRangeKHR selecting the memory range to be filled.

- `dstFlags` is a VkAddressCommandFlagsKHR value defining the copy flags for the destination address range.

- `data` is the 4-byte word written repeatedly to the destination range to fill `size` bytes of data.

## Description

Note | The bit pattern of `data` is determined by the host endianness. For example, an unsigned integer value of `1` will result in a different bit pattern on a little endian machine compared to a big endian machine.

Valid Usage

- VUID-vkCmdFillMemoryKHR-pDstRange-13097
  If the range specified by `pDstRange` is not bound completely to memory when accessed, `dstFlags` must not include VK_ADDRESS_COMMAND_FULLY_BOUND_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13098
  If the buffer from which the range specified by `pDstRange` was created with VK_BUFFER_CREATE_PROTECTED_BIT, and `protectedNoFault` is not supported, `dstFlags` must include VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13099
  If the buffer from which the range specified by `pDstRange` was created without VK_BUFFER_CREATE_PROTECTED_BIT, and `protectedNoFault` is not supported, `dstFlags` must not include VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR

- VUID-vkCmdFillMemoryKHR-dstFlags-13100
  `dstFlags` must not include both VK_ADDRESS_COMMAND_STORAGE_BUFFER_USAGE_BIT_KHR and VK_ADDRESS_COMMAND_UNKNOWN_STORAGE_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13122
  If any buffer, which is bound to a range of VkDeviceMemory that overlaps the range backing `pDstRange`, was created with VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, `dstFlags` must include VK_ADDRESS_COMMAND_STORAGE_BUFFER_USAGE_BIT_KHR or VK_ADDRESS_COMMAND_UNKNOWN_STORAGE_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13123
  If any buffer, which is bound to a range of VkDeviceMemory that overlaps the range backing `pDstRange`, was created without VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, `dstFlags` must not include VK_ADDRESS_COMMAND_STORAGE_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-dstFlags-13101
  `dstFlags` must not include both VK_ADDRESS_COMMAND_TRANSFORM_FEEDBACK_BUFFER_USAGE_BIT_KHR and VK_ADDRESS_COMMAND_UNKNOWN_TRANSFORM_FEEDBACK_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13124
  If any buffer, which is bound to a range of VkDeviceMemory that overlaps the range backing `pDstRange`, was created with VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT, `dstFlags` must include VK_ADDRESS_COMMAND_TRANSFORM_FEEDBACK_BUFFER_USAGE_BIT_KHR or VK_ADDRESS_COMMAND_UNKNOWN_TRANSFORM_FEEDBACK_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-pDstRange-13125
  If any buffer, which is bound to a range of VkDeviceMemory that overlaps the range backing `pDstRange`, was created without VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT, `dstFlags` must not include VK_ADDRESS_COMMAND_TRANSFORM_FEEDBACK_BUFFER_USAGE_BIT_KHR

- VUID-vkCmdFillMemoryKHR-dstRange-13000
  The buffer from which `dstRange` was queried must have been created with VK_BUFFER_USAGE_TRANSFER_DST_BIT usage flag

- VUID-vkCmdFillMemoryKHR-pDstRange-13001
  `pDstRange->address` must be a multiple of 4

- VUID-vkCmdFillMemoryKHR-pDstRange-13002
  `pDstRange->size` must be a multiple of 4

- VUID-vkCmdFillMemoryKHR-commandBuffer-13003
  If `commandBuffer` is an unprotected command buffer and `protectedNoFault` is not supported, `dstFlags` must not include VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR

- VUID-vkCmdFillMemoryKHR-commandBuffer-13004
  If `commandBuffer` is a protected command buffer and `protectedNoFault` is not supported, `dstFlags` must include VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR

Valid Usage (Implicit)

- VUID-vkCmdFillMemoryKHR-commandBuffer-parameter
  `commandBuffer` must be a valid VkCommandBuffer handle

- VUID-vkCmdFillMemoryKHR-pDstRange-parameter
  `pDstRange` must be a valid pointer to a valid VkDeviceAddressRangeKHR structure

- VUID-vkCmdFillMemoryKHR-dstFlags-parameter
  `dstFlags` must be a valid combination of VkAddressCommandFlagBitsKHR values

- VUID-vkCmdFillMemoryKHR-commandBuffer-recording
  `commandBuffer` must be in the recording state

- VUID-vkCmdFillMemoryKHR-commandBuffer-cmdpool
  The `VkCommandPool` that `commandBuffer` was allocated from must support VK_QUEUE_TRANSFER_BIT operations

- VUID-vkCmdFillMemoryKHR-renderpass
  This command must only be called outside of a render pass instance

- VUID-vkCmdFillMemoryKHR-suspended
  This command must not be called between suspended render pass instances

- VUID-vkCmdFillMemoryKHR-videocoding
  This command must only be called outside of a video coding scope

Host Synchronization

- Host access to `commandBuffer` must be externally synchronized

- Host access to the `VkCommandPool` that `commandBuffer` was allocated from must be externally synchronized

Command Properties

Command Buffer Levels | Render Pass Scope | Video Coding Scope | Supported Queue Types | Command Type
--- | --- | --- | --- | ---
Primary Secondary | Outside | Outside | VK_QUEUE_TRANSFER_BIT | Action

Conditional Rendering

vkCmdFillMemoryKHR is not affected by conditional rendering

## See Also

VK_KHR_device_address_commands, VkAddressCommandFlagsKHR, VkCommandBuffer, VkDeviceAddressRangeKHR

## Document Notes

For more information, see the Vulkan Specification.

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

## Copyright

Copyright 2014-2026 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0