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.
-
uint32_t view_mask¶
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 beNULL
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 inall
. Ifall == 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 viaalloc_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
-
BITSET_DECLARE(dynamic, MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX)¶
-
struct vk_vertex_binding_state¶
-
struct vk_vertex_attribute_state¶
-
struct vk_vertex_input_state¶
-
struct vk_input_assembly_state¶
-
struct vk_tessellation_state¶
-
struct vk_viewport_state¶
Public Members
-
bool depth_clip_negative_one_to_one¶
VkPipelineViewportDepthClipControlCreateInfoEXT::negativeOneToOne
-
uint8_t viewport_count¶
VkPipelineViewportStateCreateInfo::viewportCount
MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_VIEWPORT_COUNT
-
uint8_t scissor_count¶
VkPipelineViewportStateCreateInfo::scissorCount
MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_SCISSOR_COUNT
-
VkViewport viewports[MESA_VK_MAX_VIEWPORTS]¶
VkPipelineViewportStateCreateInfo::pViewports
MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_VIEWPORTS
-
VkRect2D scissors[MESA_VK_MAX_SCISSORS]¶
VkPipelineViewportStateCreateInfo::pScissors
MESA_VK_DYNAMIC_GRAPHICS_STATE_VP_SCISSORS
-
bool depth_clip_negative_one_to_one¶
-
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
-
VkDiscardRectangleModeEXT mode¶
-
struct vk_rasterization_state¶
Public Members
-
bool rasterizer_discard_enable¶
VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable
This will be false if rasterizer discard is dynamic
MESA_VK_DYNAMIC_RS_RASTERIZER_DISCARD_ENABLE
-
bool depth_clamp_enable¶
VkPipelineRasterizationStateCreateInfo::depthClampEnable
MESA_VK_DYNAMIC_RS_DEPTH_CLAMP_ENABLE
-
enum vk_mesa_depth_clip_enable depth_clip_enable¶
VkPipelineRasterizationDepthClipStateCreateInfoEXT::depthClipEnable
MESA_VK_DYNAMIC_RS_DEPTH_CLIP_ENABLE
-
VkPolygonMode polygon_mode¶
VkPipelineRasterizationStateCreateInfo::polygonMode
MESA_VK_DYNAMIC_RS_POLYGON_MODE_ENABLEDEPTH_CLIP_ENABLE
-
VkCullModeFlags cull_mode¶
VkPipelineRasterizationStateCreateInfo::cullMode
MESA_VK_DYNAMIC_RS_CULL_MODE
-
VkFrontFace front_face¶
VkPipelineRasterizationStateCreateInfo::frontFace
MESA_VK_DYNAMIC_RS_FRONT_FACE
-
VkConservativeRasterizationModeEXT conservative_mode¶
VkPipelineRasterizationConservativeStateCreateInfoEXT::conservativeRasterizationMode
MESA_VK_DYNAMIC_RS_CONSERVATIVE_MODE
-
float extra_primitive_overestimation_size¶
VkPipelineRasterizationConservativeStateCreateInfoEXT::extraPrimitiveOverestimationSize
MESA_VK_DYNAMIC_RS_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE
-
VkRasterizationOrderAMD rasterization_order_amd¶
VkPipelineRasterizationStateRasterizationOrderAMD::rasterizationOrder
-
VkProvokingVertexModeEXT provoking_vertex¶
VkPipelineRasterizationProvokingVertexStateCreateInfoEXT::provokingVertexMode
MESA_VK_DYNAMIC_RS_PROVOKING_VERTEX
-
uint32_t rasterization_stream¶
VkPipelineRasterizationStateStreamCreateInfoEXT::rasterizationStream
MESA_VK_DYNAMIC_RS_RASTERIZATION_STREAM
-
bool enable¶
VkPipelineRasterizationStateCreateInfo::depthBiasEnable
MESA_VK_DYNAMIC_RS_DEPTH_BIAS_ENABLE
VkPipelineRasterizationLineStateCreateInfoEXT::stippledLineEnable
MESA_VK_DYNAMIC_RS_LINE_STIPPLE_ENABLE
-
float constant¶
VkPipelineRasterizationStateCreateInfo::depthBiasConstantFactor
MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
-
float clamp¶
VkPipelineRasterizationStateCreateInfo::depthBiasClamp
MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
-
float slope¶
VkPipelineRasterizationStateCreateInfo::depthBiasSlopeFactor
MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS
-
float width¶
VkPipelineRasterizationStateCreateInfo::lineWidth
MESA_VK_DYNAMIC_RS_LINE_WIDTH
-
VkLineRasterizationModeEXT mode¶
VkPipelineRasterizationLineStateCreateInfoEXT::lineRasterizationMode
Will be set to VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT if VkPipelineRasterizationLineStateCreateInfoEXT is not provided.
MESA_VK_DYNAMIC_RS_LINE_MODE
-
uint32_t factor¶
VkPipelineRasterizationLineStateCreateInfoEXT::lineStippleFactor
MESA_VK_DYNAMIC_RS_LINE_STIPPLE
-
uint16_t pattern¶
VkPipelineRasterizationLineStateCreateInfoEXT::lineStipplePattern
MESA_VK_DYNAMIC_RS_LINE_STIPPLE
-
bool rasterizer_discard_enable¶
-
struct vk_fragment_shading_rate_state¶
-
struct vk_sample_locations_state¶
-
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
This will be true if sample locations enable dynamic.
-
const struct vk_sample_locations_state *sample_locations¶
VkPipelineSampleLocationsStateCreateInfoEXT::sampleLocationsInfo
May be NULL for dynamic sample locations.
-
VkSampleCountFlagBits rasterization_samples¶
-
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
-
uint8_t fail¶
-
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
-
bool test_enable¶
-
struct vk_color_blend_state¶
Public Members
-
bool logic_op_enable¶
VkPipelineColorBlendStateCreateInfo::logicOpEnable
MESA_VK_DYNAMIC_CB_LOGIC_OP_ENABLE,
-
uint8_t logic_op¶
VkPipelineColorBlendStateCreateInfo::logicOp
MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_LOGIC_OP,
-
uint8_t color_write_enables¶
VkPipelineColorWriteCreateInfoEXT::pColorWriteEnables
Bitmask of color write enables, indexed by color attachment index.
MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_COLOR_WRITE_ENABLES,
-
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
MESA_VK_DYNAMIC_GRAPHICS_STATE_CB_BLEND_CONSTANTS,
-
bool logic_op_enable¶
-
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¶
-
bool depth_self_dependency¶
-
bool stencil_self_dependency¶
-
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
-
uint8_t color_attachment_samples[MESA_VK_MAX_COLOR_ATTACHMENTS]¶
VkAttachmentSampleCountInfoAMD::pColorAttachmentSamples
-
uint8_t depth_stencil_attachment_samples¶
VkAttachmentSampleCountInfoAMD::depthStencilAttachmentSamples
-
VkImageAspectFlags attachment_aspects¶
-
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_TS_DOMAIN_ORIGIN¶
-
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_VP_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE¶
-
enumerator MESA_VK_DYNAMIC_DR_RECTANGLES¶
-
enumerator MESA_VK_DYNAMIC_RS_RASTERIZER_DISCARD_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_RS_DEPTH_CLAMP_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_RS_DEPTH_CLIP_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_RS_POLYGON_MODE¶
-
enumerator MESA_VK_DYNAMIC_RS_CULL_MODE¶
-
enumerator MESA_VK_DYNAMIC_RS_FRONT_FACE¶
-
enumerator MESA_VK_DYNAMIC_RS_CONSERVATIVE_MODE¶
-
enumerator MESA_VK_DYNAMIC_RS_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE¶
-
enumerator MESA_VK_DYNAMIC_RS_RASTERIZATION_ORDER_AMD¶
-
enumerator MESA_VK_DYNAMIC_RS_PROVOKING_VERTEX¶
-
enumerator MESA_VK_DYNAMIC_RS_RASTERIZATION_STREAM¶
-
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_MODE¶
-
enumerator MESA_VK_DYNAMIC_RS_LINE_STIPPLE_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_RS_LINE_STIPPLE¶
-
enumerator MESA_VK_DYNAMIC_FSR¶
-
enumerator MESA_VK_DYNAMIC_MS_RASTERIZATION_SAMPLES¶
-
enumerator MESA_VK_DYNAMIC_MS_SAMPLE_MASK¶
-
enumerator MESA_VK_DYNAMIC_MS_ALPHA_TO_COVERAGE_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_MS_ALPHA_TO_ONE_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS_ENABLE¶
-
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_ENABLE¶
-
enumerator MESA_VK_DYNAMIC_CB_LOGIC_OP¶
-
enumerator MESA_VK_DYNAMIC_CB_COLOR_WRITE_ENABLES¶
-
enumerator MESA_VK_DYNAMIC_CB_BLEND_ENABLES¶
-
enumerator MESA_VK_DYNAMIC_CB_BLEND_EQUATIONS¶
-
enumerator MESA_VK_DYNAMIC_CB_WRITE_MASKS¶
-
enumerator MESA_VK_DYNAMIC_CB_BLEND_CONSTANTS¶
-
enumerator MESA_VK_DYNAMIC_GRAPHICS_STATE_ENUM_MAX¶
-
enumerator MESA_VK_DYNAMIC_VI¶
-
struct vk_dynamic_graphics_state¶
Struct representing all dynamic graphics state
Before invoking any core functions, the driver must properly populate initialize this struct:
Initialize using vk_default_dynamic_graphics_state, if desired
Set vi to a driver-allocated vk_vertex_input_state struct
Set ms.sample_locations to a driver-allocated vk_sample_locations_state 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
-
struct vk_input_assembly_state ia¶
Input assembly state
-
struct vk_tessellation_state ts¶
Tessellation state
-
struct vk_viewport_state vp¶
Viewport state
-
struct vk_dynamic_graphics_state::[anonymous] dr¶
Discard rectangles
MESA_VK_DYNAMIC_GRAPHICS_STATE_DR_RECTANGLES
-
struct vk_rasterization_state rs¶
Rasterization state
-
VkSampleCountFlagBits rasterization_samples¶
Rasterization samples
MESA_VK_DYNAMIC_MS_RASTERIZATION_SAMPLES
-
uint16_t sample_mask¶
Sample mask
MESA_VK_DYNAMIC_MS_SAMPLE_MASK
-
bool alpha_to_coverage_enable¶
Alpha to coverage enable
MESA_VK_DYNAMIC_MS_ALPHA_TO_CONVERAGE_ENABLE
-
bool alpha_to_one_enable¶
Alpha to one enable
MESA_VK_DYNAMIC_MS_ALPHA_TO_ONE_ENABLE
-
bool sample_locations_enable¶
Custom sample locations enable
MESA_VK_DYNAMIC_MS_SAMPLE_LOCATIONS_ENABLE
-
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_MS_SAMPLE_LOCATIONS
-
struct vk_dynamic_graphics_state::[anonymous] ms¶
Multisample state
-
struct vk_depth_stencil_state ds¶
Depth stencil state
-
struct vk_color_blend_state cb¶
Color blend state