Graphics state

The Mesa Vulkan runtime provides helpers for managing the numerous pieces of graphics state associated with a VkPipeline or set dynamically on a command buffer. No such helpers are provided for compute or ray-tracing because they have little or no state besides the shaders themselves.

Pipeline state

All (possibly dynamic) Vulkan graphics pipeline state is encapsulated into a single vk_graphics_pipeline_state structure which contains pointers to sub-structures for each of the different state categories. Unlike VkGraphicsPipelineCreateInfo, the pointers in vk_graphics_pipeline_state are guaranteed to be either be NULL or point to valid and properly populated memory.

When creating a pipeline, the vk_graphics_pipeline_state_fill() function can be used to gather all of the state from the core structures as well as various pNext chains into a single state structure. Whenever an extension struct is missing, a reasonable default value is provided whenever possible.

vk_graphics_pipeline_state_fill() automatically handles both the render pass and dynamic rendering. For drivers which use vk_render_pass, the vk_render_pass_state structure will be populated as if for dynamic rendering, regardless of which path is used. Drivers which use their own render pass structure should parse the render pass, if available, and pass a vk_subpass_info into vk_graphics_pipeline_state_fill() with the relevant information from the specified subpass. If a render pass is available, vk_render_pass_state will be populated with the VkRenderPass handle and subpass index as well as the information from the vk_render_pass_state. If dynamic rendering is used or the driver does not provide a vk_subpass_info structure, vk_render_pass_state structure will be populated for dynamic rendering, including color, depth, and stencil attachment formats.

struct vk_subpass_info

Struct for extra information that we need from the subpass.

This struct need only be provided if the driver has its own render pass implementation. If the driver uses the common render pass implementation, we can get this information ourselves.

Public Members

uint32_t view_mask

VkSubpassDescription2::viewMask

VkImageAspectFlags attachment_aspects

Aspects of all attachments used as color or depth/stencil attachments in the subpass. Input and resolve attachments should not be considered when computing the attachments aspect mask. This is used to determine whether or not depth/stencil and color blend state are required for a pipeline.

The usual flow for creating a full graphics pipeline (not library) looks like this:

struct vk_graphics_pipeline_state state = { };
struct vk_graphics_pipeline_all_state all;
vk_graphics_pipeline_state_fill(&device->vk, &state, pCreateInfo,
                                NULL, &all, NULL, 0, NULL);

/* Emit stuff using the state in `state` */

The vk_graphics_pipeline_all_state structure exists to allow the state to sit on the stack instead of requiring a heap allocation. This is useful if you intend to use the state right away and don’t need to store it. For pipeline libraries, it’s likely more useful to use the dynamically allocated version and store the dynamically allocated memory in the library pipeline.

/* Assuming we have a vk_graphics_pipeline_state in pipeline */
memset(&pipeline->state, 0, sizeof(pipeline->state));

for (uint32_t i = 0; i < lib_info->libraryCount; i++) {
   VK_FROM_HANDLE(drv_graphics_pipeline_library, lib, lib_info->pLibraries[i]);
   vk_graphics_pipeline_state_merge(&pipeline->state, &lib->state);
}

/* This assumes you have a void **state_mem in pipeline */
result = vk_graphics_pipeline_state_fill(&device->vk, &pipeline->state,
                                         pCreateInfo, NULL, NULL, pAllocator,
                                         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT,
                                         &pipeline->state_mem);
if (result != VK_SUCCESS)
   return result;

State from dependent libraries can be merged together using vk_graphics_pipeline_state_merge(). vk_graphics_pipeline_state_fill() will then only attempt to populate missing fields. You can also merge dependent pipeline libraries together but store the final state on the stack for immediate consumption:

struct vk_graphics_pipeline_state state = { };

for (uint32_t i = 0; i < lib_info->libraryCount; i++) {
   VK_FROM_HANDLE(drv_graphics_pipeline_library, lib, lib_info->pLibraries[i]);
   vk_graphics_pipeline_state_merge(&state, &lib->state);
}

struct vk_graphics_pipeline_all_state all;
vk_graphics_pipeline_state_fill(&device->vk, &state, pCreateInfo,
                                NULL, &all, NULL, 0, NULL);
VkResult vk_graphics_pipeline_state_fill(const struct vk_device *device, struct vk_graphics_pipeline_state *state, const VkGraphicsPipelineCreateInfo *info, const struct vk_subpass_info *sp_info, struct vk_graphics_pipeline_all_state *all, const VkAllocationCallbacks *alloc, VkSystemAllocationScope scope, void **alloc_ptr_out)

Populate a vk_graphics_pipeline_state from VkGraphicsPipelineCreateInfo

This function crawls the provided VkGraphicsPipelineCreateInfo and uses it to populate the vk_graphics_pipeline_state. Upon returning from this function, all pointers in state will either be NULL or point to a valid sub-state structure. Whenever an extension struct is missing, a reasonable default value is provided whenever possible. Some states may be left NULL if the state does not exist (such as when rasterizer discard is enabled) or if all of the corresponding states are dynamic.

This function assumes that the vk_graphics_pipeline_state is already valid (i.e., all pointers are NULL or point to valid states). Any states already present are assumed to be identical to how we would populate them from VkGraphicsPipelineCreateInfo.

This function can operate in one of two modes with respect to how the memory for states is allocated. If a vk_graphics_pipeline_all_state struct is provided, any newly populated states will point to the relevant field in all. If all == NULL, it attempts to dynamically allocate any newly required states using the provided allocator and scope. The pointer to this new blob of memory is returned via alloc_ptr_out and must eventually be freed by the driver.

Parameters
  • device[in] The Vulkan device

  • state[out] The graphics pipeline state to populate

  • info[in] The pCreateInfo from vkCreateGraphicsPipelines

  • sp_info[in] Subpass info if the driver implements render passes itself. This should be NULL for drivers that use the common render pass infrastructure built on top of dynamic rendering.

  • all[in] The vk_graphics_pipeline_all_state to use to back any newly needed states. If NULL, newly needed states will be dynamically allocated instead.

  • alloc[in] Allocation callbacks for dynamically allocating new state memory.

  • scope[in] Allocation scope for dynamically allocating new state memory.

  • alloc_ptr_out[out] Will be populated with a pointer to any newly allocated state. The driver is responsible for freeing this pointer.

void vk_graphics_pipeline_state_merge(struct vk_graphics_pipeline_state *dst, const struct vk_graphics_pipeline_state *src)

Merge one vk_graphics_pipeline_state into another

Both the destination and source states are assumed to be valid (i.e., all pointers are NULL or point to valid states). Any states which exist in both are expected to be identical and the state already in dst is used. The only exception here is render pass state which may be only partially defined in which case the fully defined one (if any) is used.

Parameters
  • dst[out] The destination state. When the function returns, this will be the union of the original dst and src.

  • src[in] The source state

Dynamic state

All dynamic states in Vulkan, regardless of which API version or extension introduced them, are represented by the mesa_vk_dynamic_graphics_state enum. This corresponds to the VkDynamicState enum in the Vulkan API only it’s compact (has no holes due to extension namespacing) and a bit better organized. Each enumerant is named with the name of the state group to which the dynamic state belongs as well as the name of the dynamic state itself. The fact that it’s compact allows us to use to index bitsets.

void vk_get_dynamic_graphics_states(BITSET_WORD *dynamic, const VkPipelineDynamicStateCreateInfo *info)

Populate a bitset with dynamic states

This function maps a VkPipelineDynamicStateCreateInfo to a bitset indexed by mesa_vk_dynamic_graphics_state enumerants.

Parameters
  • dynamic[out] Bitset to populate

  • info[in] VkPipelineDynamicStateCreateInfo or NULL

We also provide a vk_dynamic_graphics_state structure which contains all the dynamic graphics states, regardless of which API version or extension introduced them. This structure can be populated from a vk_graphics_pipeline_state via vk_dynamic_graphics_state_init().

void vk_dynamic_graphics_state_init(struct vk_dynamic_graphics_state *dyn)

Initialize a vk_dynamic_graphics_state with defaults

Parameters

dyn[out] Dynamic graphics state to initizlie

void vk_dynamic_graphics_state_copy(struct vk_dynamic_graphics_state *dst, const struct vk_dynamic_graphics_state *src)

Copies all set state from src to dst

Both src and dst are assumed to be properly initialized dynamic state structs. Anything not set in src, as indicated by src->set, is ignored and those bits of dst are left untouched.

Parameters
  • dst[out] Copy destination

  • src[in] Copy source

There is also a vk_dynamic_graphics_state embedded in vk_command_buffer. Should you choose to use them, we provide common implementations for all vkCmdSet*() functions. Two additional functions are provided for the driver to call in CmdBindPipeline() and CmdBindVertexBuffers2():

void vk_cmd_set_dynamic_graphics_state(struct vk_command_buffer *cmd, const struct vk_dynamic_graphics_state *src)

Set all of the state in src on a command buffer

Anything not set, as indicated by src->set, is ignored and those states in the command buffer are left untouched.

Parameters
  • cmd[inout] Command buffer to update

  • src[in] State to set

void vk_cmd_set_vertex_binding_strides(struct vk_command_buffer *cmd, uint32_t first_binding, uint32_t binding_count, const VkDeviceSize *strides)

Set vertex binding strides on a command buffer

This is the dynamic state part of vkCmdBindVertexBuffers2().

Parameters
  • cmd[inout] Command buffer to update

  • first_binding[in] First binding to update

  • binding_count[in] Number of bindings to update

  • strides[in] binding_count many stride values to set

To use the dynamic state framework, you will need the following in your pipeline structure:

struct drv_graphics_pipeline {
   ....
   struct vk_vertex_input_state vi_state;
   struct vk_sample_locations_state sl_state;
   struct vk_dynamic_graphics_state dynamic;
   ...
};

Then, in your pipeline create function,

memset(&pipeline->dynamic, 0, sizeof(pipeline->dynamic));
pipeline->dynamic->vi = &pipeline->vi_state;
pipeline->dynamic->ms.sample_locations = &pipeline->sl_state;
vk_dynamic_graphics_state_init(&pipeline->dynamic, &state);

In your implementation of vkCmdBindPipeline(),

vk_cmd_set_dynamic_graphics_state(&cmd->vk, &pipeline->dynamic_state);

And, finally, at vkCmdDraw*() time, the code to emit dynamic state into your hardware command buffer will look something like this:

static void
emit_dynamic_state(struct drv_cmd_buffer *cmd)
{
   struct vk_dynamic_graphics_state *dyn = &cmd->vk.dynamic_graphics_state;

   if (!vk_dynamic_graphics_state_any_dirty(dyn))
      return;

   if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_VIEWPORTS) |
       BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_VIEWPORT_COUNT)) {
      /* Re-emit viewports */
   }

   if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_SCISSORS) |
       BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_SCISSOR_COUNT)) {
      /* Re-emit scissors */
   }

   /* etc... */

   vk_dynamic_graphics_state_clear_dirty(dyn);
}

Any states used by the currently bound pipeline and attachments are always valid in vk_command_buffer::dynamic_graphics_state so you can always use a state even if it isn’t dirty on this particular draw.

static inline void vk_dynamic_graphics_state_dirty_all(struct vk_dynamic_graphics_state *d)

Mark all states in the given vk_dynamic_graphics_state dirty

Parameters

d[out] Dynamic graphics state struct

static inline void vk_dynamic_graphics_state_clear_dirty(struct vk_dynamic_graphics_state *d)

Mark all states in the given vk_dynamic_graphics_state not dirty

Parameters

d[out] Dynamic graphics state struct

static inline bool vk_dynamic_graphics_state_any_dirty(const struct vk_dynamic_graphics_state *d)

Test if any states in the given vk_dynamic_graphics_state are dirty

Parameters

d[in] Dynamic graphics state struct to test

Returns

true if any state is dirty

Depth stencil state optimization

void vk_optimize_depth_stencil_state(struct vk_depth_stencil_state *ds, VkImageAspectFlags ds_aspects, bool consider_write_mask)

Optimize a depth/stencil state

The way depth and stencil testing is specified, there are many case where, regardless of depth/stencil writes being enabled, nothing actually gets written due to some other bit of state being set. In the presence of discards, it’s fairly easy to get into cases where early depth/stencil testing is disabled on some hardware, leading to a fairly big performance hit. This function attempts to optimize the depth stencil state and disable writes and sometimes even testing whenever possible.

Parameters
  • ds[inout] The depth stencil state to optimize

  • ds_aspects[in] Which image aspects are present in the render pass.

  • consider_write_mask[in] If true, the write mask will be taken into account when optimizing. If false, it will be ignored.

Reference

struct vk_graphics_pipeline_state

Public Functions

BITSET_DECLARE(dynamic, MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX)

Bitset of which states are dynamic

Public Members

const struct vk_vertex_input_state *vi

Vertex input state

const struct vk_input_assembly_state *ia

Input assembly state

const struct vk_tessellation_state *ts

Tessellation state

const struct vk_viewport_state *vp

Viewport state

const struct vk_discard_rectangles_state *dr

Discard Rectangles state

const struct vk_rasterization_state *rs

Rasterization state

const struct vk_fragment_shading_rate_state *fsr

Fragment shading rate state

const struct vk_multisample_state *ms

Multiesample state

const struct vk_depth_stencil_state *ds

Depth stencil state

const struct vk_color_blend_state *cb

Color blend state

const struct vk_render_pass_state *rp

Render pass state

struct vk_vertex_binding_state

Public Members

uint16_t stride

VkVertexInputBindingDescription::stride

uint16_t input_rate

VkVertexInputBindingDescription::inputRate

uint32_t divisor

VkVertexInputBindingDivisorDescriptionEXT::divisor or 1

struct vk_vertex_attribute_state

Public Members

uint32_t binding

VkVertexInputAttributeDescription::binding

VkFormat format

VkVertexInputAttributeDescription::format

uint32_t offset

VkVertexInputAttributeDescription::offset

struct vk_vertex_input_state

Public Members

uint32_t bindings_valid

Bitset of which bindings are valid, indexed by binding

uint32_t attributes_valid

Bitset of which attributes are valid, indexed by location

struct vk_input_assembly_state

Public Members

uint8_t primitive_topology

VkPipelineInputAssemblyStateCreateInfo::topology

MESA_VK_DYNAMIC_GRAPHICS_STATE_IA_PRIMITIVE_TOPOLOGY

bool primitive_restart_enable

VkPipelineInputAssemblyStateCreateInfo::primitiveRestartEnable

MESA_VK_DYNAMIC_GRAPHICS_STATE_IA_PRIMITIVE_RESTART_ENABLE

struct vk_tessellation_state

Public Members

uint8_t patch_control_points

VkPipelineTessellationStateCreateInfo::patchControlPoints

uint8_t domain_origin

VkPipelineTessellationDomainOriginStateCreateInfo::domainOrigin

struct vk_viewport_state

Public Members

bool negative_one_to_one

VkPipelineViewportDepthClipControlCreateInfoEXT::negativeOneToOne

uint8_t viewport_count

VkPipelineViewportStateCreateInfo::viewportCount

uint8_t scissor_count

VkPipelineViewportStateCreateInfo::scissorCount

VkRect2D scissors[MESA_VK_MAX_SCISSORS]

VkPipelineViewportStateCreateInfo::pViewports

VkViewport viewports[MESA_VK_MAX_VIEWPORTS]

VkPipelineViewportStateCreateInfo::pScissors

struct vk_discard_rectangles_state

Public Members

VkDiscardRectangleModeEXT mode

VkPipelineDiscardRectangleStateCreateInfoEXT::discardRectangleMode

uint32_t rectangle_count

VkPipelineDiscardRectangleStateCreateInfoEXT::discardRectangleCount

VkRect2D rectangles[MESA_VK_MAX_DISCARD_RECTANGLES]

VkPipelineDiscardRectangleStateCreateInfoEXT::pDiscardRectangles

struct vk_rasterization_state

Public Members

bool rasterizer_discard_enable

VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable

This will be false if rasterizer discard is dynamic

bool depth_clamp_enable

VkPipelineRasterizationStateCreateInfo::depthClampEnable

bool depth_clip_enable

VkPipelineRasterizationDepthClipStateCreateInfoEXT::depthClipEnable

VkPolygonMode polygon_mode

VkPipelineRasterizationStateCreateInfo::polygonMode

VkCullModeFlags cull_mode

VkPipelineRasterizationStateCreateInfo::cullMode

VkFrontFace front_face

VkPipelineRasterizationStateCreateInfo::frontFace

VkConservativeRasterizationModeEXT conservative_mode

VkPipelineRasterizationConservativeStateCreateInfoEXT::conservativeRasterizationMode

VkRasterizationOrderAMD rasterization_order_amd

VkPipelineRasterizationStateRasterizationOrderAMD::rasterizationOrder

VkProvokingVertexModeEXT provoking_vertex

VkPipelineRasterizationProvokingVertexStateCreateInfoEXT::provokingVertexMode

uint32_t rasterization_stream

VkPipelineRasterizationStateStreamCreateInfoEXT::rasterizationStream

bool enable

VkPipelineRasterizationStateCreateInfo::depthBiasEnable

VkPipelineRasterizationLineStateCreateInfoEXT::stippledLineEnable

float constant

VkPipelineRasterizationStateCreateInfo::depthBiasConstantFactor

float clamp

VkPipelineRasterizationStateCreateInfo::depthBiasClamp

float slope

VkPipelineRasterizationStateCreateInfo::depthBiasSlopeFactor

float width

VkPipelineRasterizationStateCreateInfo::lineWidth

VkLineRasterizationModeEXT mode

VkPipelineRasterizationLineStateCreateInfoEXT::lineRasterizationMode

Will be set to VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT if VkPipelineRasterizationLineStateCreateInfoEXT is not provided.

uint32_t factor

VkPipelineRasterizationLineStateCreateInfoEXT::lineStippleFactor

uint16_t pattern

VkPipelineRasterizationLineStateCreateInfoEXT::lineStipplePattern

struct vk_fragment_shading_rate_state

Public Members

VkExtent2D fragment_size

VkPipelineFragmentShadingRateStateCreateInfoKHR::fragmentSize

MESA_VK_DYNAMIC_GRAPHICS_STATE_FSR

VkFragmentShadingRateCombinerOpKHR combiner_ops[2]

VkPipelineFragmentShadingRateStateCreateInfoKHR::combinerOps

MESA_VK_DYNAMIC_GRAPHICS_STATE_FSR

struct vk_sample_locations_state

Public Members

VkSampleCountFlagBits per_pixel

VkSampleLocationsInfoEXT::sampleLocationsPerPixel

VkExtent2D grid_size

VkSampleLocationsInfoEXT::sampleLocationGridSize

VkSampleLocationEXT locations[MESA_VK_MAX_SAMPLE_LOCATIONS]

VkSampleLocationsInfoEXT::sampleLocations

struct vk_multisample_state

Public Members

VkSampleCountFlagBits rasterization_samples

VkPipelineMultisampleStateCreateInfo::rasterizationSamples

bool sample_shading_enable

VkPipelineMultisampleStateCreateInfo::sampleShadingEnable

float min_sample_shading

VkPipelineMultisampleStateCreateInfo::minSampleShading

uint16_t sample_mask

VkPipelineMultisampleStateCreateInfo::pSampleMask

bool alpha_to_coverage_enable

VkPipelineMultisampleStateCreateInfo::alphaToCoverageEnable

bool alpha_to_one_enable

VkPipelineMultisampleStateCreateInfo::alphaToOneEnable

bool sample_locations_enable

VkPipelineSampleLocationsStateCreateInfoEXT::sampleLocationsEnable

const struct vk_sample_locations_state *sample_locations

VkPipelineSampleLocationsStateCreateInfoEXT::sampleLocationsInfo

May be NULL for dynamic sample locations.

struct vk_stencil_test_face_state

Represents the stencil test state for a face

Public Members

uint8_t fail

VkStencilOpState::failOp

uint8_t pass

VkStencilOpState::passOp

uint8_t depth_fail

VkStencilOpState::depthFailOp

uint8_t compare

VkStencilOpState::compareOp

uint8_t compare_mask

VkStencilOpState::compareMask

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_STENCIL_COMPARE_MASK

uint8_t write_mask

VkStencilOpState::writeMask

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_STENCIL_WRITE_MASK

uint8_t reference

VkStencilOpState::reference

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_STENCIL_REFERENCE

struct vk_depth_stencil_state

Public Members

bool test_enable

VkPipelineDepthStencilStateCreateInfo::depthTestEnable

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_DEPTH_TEST_ENABLE

VkPipelineDepthStencilStateCreateInfo::stencilTestEnable

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_STENCIL_TEST_ENABLE

bool write_enable

VkPipelineDepthStencilStateCreateInfo::depthWriteEnable

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_DEPTH_WRITE_ENABLE

Whether or not stencil is should be written

This does not map directly to any particular Vulkan API state and is initialized to true. If independent stencil disable ever becomes a thing, it will use this state. vk_optimize_depth_stencil_state() may set this to false if it can prove that the stencil test will never alter the stencil value.

VkCompareOp compare_op

VkPipelineDepthStencilStateCreateInfo::depthCompareOp

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_DEPTH_COMPARE_OP

bool enable

VkPipelineDepthStencilStateCreateInfo::depthBoundsTestEnable

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_DEPTH_BOUNDS_TEST_ENABLE

float min

VkPipelineDepthStencilStateCreateInfo::min/maxDepthBounds

MESA_VK_DYNAMIC_GRAPHICS_STATE_DS_DEPTH_BOUNDS_TEST_BOUNDS

struct vk_stencil_test_face_state front

VkPipelineDepthStencilStateCreateInfo::front

struct vk_stencil_test_face_state back

VkPipelineDepthStencilStateCreateInfo::back

struct vk_color_blend_state

Public Members

bool logic_op_enable

VkPipelineColorBlendStateCreateInfo::logicOpEnable

uint8_t logic_op

VkPipelineColorBlendStateCreateInfo::logicOp

uint8_t color_write_enables

VkPipelineColorWriteCreateInfoEXT::pColorWriteEnables

uint8_t attachment_count

VkPipelineColorBlendStateCreateInfo::attachmentCount

struct vk_color_blend_attachment_state attachments[MESA_VK_MAX_COLOR_ATTACHMENTS]

VkPipelineColorBlendStateCreateInfo::pAttachments

float blend_constants[4]

VkPipelineColorBlendStateCreateInfo::blendConstants

struct vk_render_pass_state

Public Members

VkImageAspectFlags attachment_aspects

Set of image aspects bound as color/depth/stencil attachments

Set to VK_IMAGE_ASPECT_METADATA_BIT to indicate that attachment info is invalid.

VkRenderPass render_pass

VkGraphicsPipelineCreateInfo::renderPass

uint32_t subpass

VkGraphicsPipelineCreateInfo::subpass

uint32_t view_mask

VkPipelineRenderingCreateInfo::viewMask

uint8_t color_self_dependencies

VkRenderingSelfDependencyInfoMESA::colorSelfDependencies

bool depth_self_dependency

VkRenderingSelfDependencyInfoMESA::depthSelfDependency

bool stencil_self_dependency

VkRenderingSelfDependencyInfoMESA::stencilSelfDependency

uint8_t color_attachment_count

VkPipelineRenderingCreateInfo::colorAttachmentCount

VkFormat color_attachment_formats[MESA_VK_MAX_COLOR_ATTACHMENTS]

VkPipelineRenderingCreateInfo::pColorAttachmentFormats

VkFormat depth_attachment_format

VkPipelineRenderingCreateInfo::depthAttachmentFormat

VkFormat stencil_attachment_format

VkPipelineRenderingCreateInfo::stencilAttachmentFormat

enum mesa_vk_dynamic_graphics_state

Enumeration of all Vulkan dynamic graphics states

Enumerants are named with both the abreviation of the state group to which the state belongs as well as the name of the state itself. These are intended to pretty closely match the VkDynamicState enum but may not match perfectly all the time.

Values:

enumerator MESA_VK_DYNAMIC_VI
enumerator MESA_VK_DYNAMIC_VI_BINDING_STRIDES
enumerator MESA_VK_DYNAMIC_IA_PRIMITIVE_TOPOLOGY
enumerator MESA_VK_DYNAMIC_IA_PRIMITIVE_RESTART_ENABLE
enumerator MESA_VK_DYNAMIC_TS_PATCH_CONTROL_POINTS
enumerator MESA_VK_DYNAMIC_VP_VIEWPORT_COUNT
enumerator MESA_VK_DYNAMIC_VP_VIEWPORTS
enumerator MESA_VK_DYNAMIC_VP_SCISSOR_COUNT
enumerator MESA_VK_DYNAMIC_VP_SCISSORS
enumerator MESA_VK_DYNAMIC_DR_RECTANGLES
enumerator MESA_VK_DYNAMIC_RS_RASTERIZER_DISCARD_ENABLE
enumerator MESA_VK_DYNAMIC_RS_CULL_MODE
enumerator MESA_VK_DYNAMIC_RS_FRONT_FACE
enumerator MESA_VK_DYNAMIC_RS_DEPTH_BIAS_ENABLE
enumerator MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
enumerator MESA_VK_DYNAMIC_RS_LINE_WIDTH
enumerator MESA_VK_DYNAMIC_RS_LINE_STIPPLE
enumerator MESA_VK_DYNAMIC_FSR
enumerator MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS
enumerator MESA_VK_DYNAMIC_DS_DEPTH_TEST_ENABLE
enumerator MESA_VK_DYNAMIC_DS_DEPTH_WRITE_ENABLE
enumerator MESA_VK_DYNAMIC_DS_DEPTH_COMPARE_OP
enumerator MESA_VK_DYNAMIC_DS_DEPTH_BOUNDS_TEST_ENABLE
enumerator MESA_VK_DYNAMIC_DS_DEPTH_BOUNDS_TEST_BOUNDS
enumerator MESA_VK_DYNAMIC_DS_STENCIL_TEST_ENABLE
enumerator MESA_VK_DYNAMIC_DS_STENCIL_OP
enumerator MESA_VK_DYNAMIC_DS_STENCIL_COMPARE_MASK
enumerator MESA_VK_DYNAMIC_DS_STENCIL_WRITE_MASK
enumerator MESA_VK_DYNAMIC_DS_STENCIL_REFERENCE
enumerator MESA_VK_DYNAMIC_CB_LOGIC_OP
enumerator MESA_VK_DYNAMIC_CB_COLOR_WRITE_ENABLES
enumerator MESA_VK_DYNAMIC_CB_BLEND_CONSTANTS
enumerator MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX
struct vk_dynamic_graphics_state

Struct representing all dynamic graphics state

Before invoking any core functions, the driver must properly populate initialize this struct:

Public Functions

BITSET_DECLARE(set, MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX)

For pipelines, which bits of dynamic state are set

BITSET_DECLARE(dirty, MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX)

For command buffers, which bits of dynamic state have changed

Public Members

struct vk_vertex_input_state *vi

Vertex input state

Must be provided by the driver if VK_EXT_vertex_input_dynamic_state is supported.

MESA_VK_DYNAMIC_GRAPHICS_STATE_VI

uint16_t vi_binding_strides[MESA_VK_MAX_VERTEX_BINDINGS]

Vertex binding strides

MESA_VK_DYNAMIC_GRAPHICS_STATE_VI_BINDING_STRIDES

uint32_t viewport_count

Viewport count

MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_VIEWPORT_COUNT

VkViewport viewports[MESA_VK_MAX_VIEWPORTS]

Viewports

MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_VIEWPORTS

uint32_t scissor_count

Scissor count

MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_SCISSOR_COUNT

VkRect2D scissors[MESA_VK_MAX_SCISSORS]

Scissor rects

MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_SCISSORS

struct vk_dynamic_graphics_state::[anonymous] vp

Viewport state

struct vk_dynamic_graphics_state::[anonymous] dr

Discard rectangles

MESA_VK_DYNAMIC_GRAPHICS_STATE_DR_RECTANGLES

bool rasterizer_discard_enable

Rasterizer discard

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_RASTERIZER_DISCARD_ENABLE

VkCullModeFlags cull_mode

Cull mode

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_CULL_MODE

VkFrontFace front_face

Front face

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_FRONT_FACE

bool enable

Depth bias enable

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_DEPTH_BIAS_ENABLE

float constant

Depth bias constant factor

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_DEPTH_BIAS_FACTORS

float clamp

Depth bias clamp

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_DEPTH_BIAS_FACTORS

float slope

Depth bias slope

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_DEPTH_BIAS_FACTORS

float width

Line width

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_LINE_WIDTH

struct vk_dynamic_graphics_state::[anonymous]::[anonymous]::[anonymous] stipple

Line stipple

MESA_VK_DYNAMIC_GRAPHICS_STATE_RS_LINE_STIPPLE

struct vk_dynamic_graphics_state::[anonymous] rs

Rasterization state

struct vk_sample_locations_state *sample_locations

Sample locations

Must be provided by the driver if VK_EXT_sample_locations is supported.

MESA_VK_DYNAMIC_GRAPHICS_STATE_MS_SAMPLE_LOCATIONS

struct vk_dynamic_graphics_state::[anonymous] ms

Multisample state

VkLogicOp logic_op

Integer color logic op

MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_LOGIC_OP,

uint32_t color_write_enables

Color write enables

Bitmask of color write enables, indexed by color attachment index.

MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_COLOR_WRITE_ENABLES,

float blend_constants[4]

Blend constants

MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_BLEND_CONSTANTS,

struct vk_dynamic_graphics_state::[anonymous] cb

Color blend state