Function Prototype

vkCmdSetDiscardRectangleEXT

Set discard rectangles dynamically for a command buffer
primary / secondary
both
graphics
state

To dynamically set the discard rectangles, call:

void vkCmdSetDiscardRectangleEXT(
    VkCommandBuffer commandBuffer,
    uint32_t firstDiscardRectangle,
    uint32_t discardRectangleCount,
    const VkRect2D* pDiscardRectangles);
  • commandBuffer is the command buffer into which the command will be recorded.
  • firstDiscardRectangle is the index of the first discard rectangle whose state is updated by the command.
  • discardRectangleCount is the number of discard rectangles whose state are updated by the command.
  • pDiscardRectangles is a pointer to an array of VkRect2D structures specifying discard rectangles.

The discard rectangle taken from element i of pDiscardRectangles replace the current state for the discard rectangle at index firstDiscardRectangle + i, for i in [0, discardRectangleCount).

This command sets the discard rectangles for subsequent drawing commands when drawing using shader objects, or when the graphics pipeline is created with VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT set in VkPipelineDynamicStateCreateInfo::pDynamicStates. Otherwise, this state is specified by the VkPipelineDiscardRectangleStateCreateInfoEXT::pDiscardRectangles values used to create the currently active pipeline.

Valid Usage

VUID-vkCmdSetDiscardRectangleEXT-firstDiscardRectangle-00585

The sum of firstDiscardRectangle and discardRectangleCountmust be less than or equal to VkPhysicalDeviceDiscardRectanglePropertiesEXT::maxDiscardRectangles

VUID-vkCmdSetDiscardRectangleEXT-x-00587

The x and y member of offset in each VkRect2D element of pDiscardRectangles must be greater than or equal to 0

VUID-vkCmdSetDiscardRectangleEXT-offset-00588

Evaluation of (offset.x + extent.width) in each VkRect2D element of pDiscardRectangles must not cause a signed integer addition overflow

VUID-vkCmdSetDiscardRectangleEXT-offset-00589

Evaluation of (offset.y + extent.height) in each VkRect2D element of pDiscardRectangles must not cause a signed integer addition overflow

VUID-vkCmdSetDiscardRectangleEXT-viewportScissor2D-04788

If this command is recorded in a secondary command buffer with VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D enabled, then this function must not be called

Valid Usage (Implicit)

VUID-vkCmdSetDiscardRectangleEXT-pDiscardRectangles-parameter

pDiscardRectangles must be a valid pointer to an array of discardRectangleCount VkRect2D structures

VUID-vkCmdSetDiscardRectangleEXT-commandBuffer-cmdpool

The VkCommandPool that commandBuffer was allocated from must support graphics operations

VUID-vkCmdSetDiscardRectangleEXT-videocoding

This command must only be called outside of a video coding scope

VUID-vkCmdSetDiscardRectangleEXT-discardRectangleCount-arraylength

discardRectangleCount must be greater than 0

Host Synchronization

  • Host access to commandBuffer must be externally synchronized
  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized ::