mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 04:58:05 +02:00
anv/pipeline: Rework dynamic state handling
Aparently, we had the dynamic state array in the pipeline backwards. Instead of enabling the bits in the pipeline, it disables them and marks them as "dynamic".
This commit is contained in:
parent
8ed23654c9
commit
368e703a01
3 changed files with 113 additions and 81 deletions
|
|
@ -240,6 +240,11 @@ anv_device_init_meta_clear_state(struct anv_device *device)
|
|||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
|
||||
.primitiveRestartEnable = false,
|
||||
},
|
||||
.pViewportState = &(VkPipelineViewportStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.viewportCount = 1,
|
||||
.scissorCount = 1,
|
||||
},
|
||||
.pRasterState = &(VkPipelineRasterStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO,
|
||||
.depthClipEnable = true,
|
||||
|
|
@ -272,6 +277,21 @@ anv_device_init_meta_clear_state(struct anv_device *device)
|
|||
VK_CHANNEL_R_BIT | VK_CHANNEL_G_BIT | VK_CHANNEL_B_BIT },
|
||||
}
|
||||
},
|
||||
.pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.dynamicStateCount = 9,
|
||||
.pDynamicStates = (VkDynamicState[]) {
|
||||
VK_DYNAMIC_STATE_VIEWPORT,
|
||||
VK_DYNAMIC_STATE_SCISSOR,
|
||||
VK_DYNAMIC_STATE_LINE_WIDTH,
|
||||
VK_DYNAMIC_STATE_DEPTH_BIAS,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
|
||||
VK_DYNAMIC_STATE_DEPTH_BOUNDS,
|
||||
VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
|
||||
VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
|
||||
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
|
||||
},
|
||||
},
|
||||
.flags = 0,
|
||||
},
|
||||
&(struct anv_graphics_pipeline_create_info) {
|
||||
|
|
@ -634,6 +654,11 @@ anv_device_init_meta_blit_state(struct anv_device *device)
|
|||
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
|
||||
.primitiveRestartEnable = false,
|
||||
},
|
||||
.pViewportState = &(VkPipelineViewportStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.viewportCount = 1,
|
||||
.scissorCount = 1,
|
||||
},
|
||||
.pRasterState = &(VkPipelineRasterStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO,
|
||||
.depthClipEnable = true,
|
||||
|
|
@ -650,6 +675,21 @@ anv_device_init_meta_blit_state(struct anv_device *device)
|
|||
VK_CHANNEL_R_BIT | VK_CHANNEL_G_BIT | VK_CHANNEL_B_BIT },
|
||||
}
|
||||
},
|
||||
.pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.dynamicStateCount = 9,
|
||||
.pDynamicStates = (VkDynamicState[]) {
|
||||
VK_DYNAMIC_STATE_VIEWPORT,
|
||||
VK_DYNAMIC_STATE_SCISSOR,
|
||||
VK_DYNAMIC_STATE_LINE_WIDTH,
|
||||
VK_DYNAMIC_STATE_DEPTH_BIAS,
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
|
||||
VK_DYNAMIC_STATE_DEPTH_BOUNDS,
|
||||
VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
|
||||
VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
|
||||
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
|
||||
},
|
||||
},
|
||||
.flags = 0,
|
||||
.layout = device->meta_state.blit.pipeline_layout,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -181,92 +181,83 @@ static void
|
|||
anv_pipeline_init_dynamic_state(struct anv_pipeline *pipeline,
|
||||
const VkGraphicsPipelineCreateInfo *pCreateInfo)
|
||||
{
|
||||
pipeline->dynamic_state_mask = 0;
|
||||
uint32_t states = ANV_DYNAMIC_STATE_DIRTY_MASK;
|
||||
|
||||
if (pCreateInfo->pDynamicState == NULL)
|
||||
return;
|
||||
if (pCreateInfo->pDynamicState) {
|
||||
/* Remove all of the states that are marked as dynamic */
|
||||
uint32_t count = pCreateInfo->pDynamicState->dynamicStateCount;
|
||||
for (uint32_t s = 0; s < count; s++)
|
||||
states &= ~(1 << pCreateInfo->pDynamicState->pDynamicStates[s]);
|
||||
}
|
||||
|
||||
uint32_t count = pCreateInfo->pDynamicState->dynamicStateCount;
|
||||
struct anv_dynamic_state *dynamic = &pipeline->dynamic_state;
|
||||
|
||||
for (uint32_t s = 0; s < count; s++) {
|
||||
VkDynamicState state = pCreateInfo->pDynamicState->pDynamicStates[s];
|
||||
|
||||
assert(state < 32);
|
||||
pipeline->dynamic_state_mask |= (1u << state);
|
||||
|
||||
switch (state) {
|
||||
case VK_DYNAMIC_STATE_VIEWPORT:
|
||||
assert(pCreateInfo->pViewportState);
|
||||
dynamic->viewport.count = pCreateInfo->pViewportState->viewportCount;
|
||||
typed_memcpy(dynamic->viewport.viewports,
|
||||
pCreateInfo->pViewportState->pViewports,
|
||||
pCreateInfo->pViewportState->viewportCount);
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_SCISSOR:
|
||||
assert(pCreateInfo->pViewportState);
|
||||
dynamic->scissor.count = pCreateInfo->pViewportState->scissorCount;
|
||||
typed_memcpy(dynamic->scissor.scissors,
|
||||
pCreateInfo->pViewportState->pScissors,
|
||||
pCreateInfo->pViewportState->scissorCount);
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_LINE_WIDTH:
|
||||
assert(pCreateInfo->pRasterState);
|
||||
dynamic->line_width = pCreateInfo->pRasterState->lineWidth;
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_DEPTH_BIAS:
|
||||
assert(pCreateInfo->pRasterState);
|
||||
dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias;
|
||||
dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp;
|
||||
dynamic->depth_bias.slope_scaled =
|
||||
pCreateInfo->pRasterState->slopeScaledDepthBias;
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_BLEND_CONSTANTS:
|
||||
assert(pCreateInfo->pColorBlendState);
|
||||
typed_memcpy(dynamic->blend_constants,
|
||||
pCreateInfo->pColorBlendState->blendConst, 4);
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_DEPTH_BOUNDS:
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->depth_bounds.min =
|
||||
pCreateInfo->pDepthStencilState->minDepthBounds;
|
||||
dynamic->depth_bounds.max =
|
||||
pCreateInfo->pDepthStencilState->maxDepthBounds;
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK:
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_compare_mask.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilCompareMask;
|
||||
dynamic->stencil_compare_mask.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilCompareMask;
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK:
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_write_mask.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilWriteMask;
|
||||
dynamic->stencil_write_mask.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilWriteMask;
|
||||
break;
|
||||
|
||||
case VK_DYNAMIC_STATE_STENCIL_REFERENCE:
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_reference.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilReference;
|
||||
dynamic->stencil_reference.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilReference;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"Invalid dynamic state");
|
||||
}
|
||||
dynamic->viewport.count = pCreateInfo->pViewportState->viewportCount;
|
||||
if (states & (1 << VK_DYNAMIC_STATE_VIEWPORT)) {
|
||||
typed_memcpy(dynamic->viewport.viewports,
|
||||
pCreateInfo->pViewportState->pViewports,
|
||||
pCreateInfo->pViewportState->viewportCount);
|
||||
}
|
||||
|
||||
dynamic->scissor.count = pCreateInfo->pViewportState->scissorCount;
|
||||
if (states & (1 << VK_DYNAMIC_STATE_SCISSOR)) {
|
||||
typed_memcpy(dynamic->scissor.scissors,
|
||||
pCreateInfo->pViewportState->pScissors,
|
||||
pCreateInfo->pViewportState->scissorCount);
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_LINE_WIDTH)) {
|
||||
assert(pCreateInfo->pRasterState);
|
||||
dynamic->line_width = pCreateInfo->pRasterState->lineWidth;
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BIAS)) {
|
||||
assert(pCreateInfo->pRasterState);
|
||||
dynamic->depth_bias.bias = pCreateInfo->pRasterState->depthBias;
|
||||
dynamic->depth_bias.clamp = pCreateInfo->pRasterState->depthBiasClamp;
|
||||
dynamic->depth_bias.slope_scaled =
|
||||
pCreateInfo->pRasterState->slopeScaledDepthBias;
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS)) {
|
||||
assert(pCreateInfo->pColorBlendState);
|
||||
typed_memcpy(dynamic->blend_constants,
|
||||
pCreateInfo->pColorBlendState->blendConst, 4);
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS)) {
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->depth_bounds.min =
|
||||
pCreateInfo->pDepthStencilState->minDepthBounds;
|
||||
dynamic->depth_bounds.max =
|
||||
pCreateInfo->pDepthStencilState->maxDepthBounds;
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK)) {
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_compare_mask.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilCompareMask;
|
||||
dynamic->stencil_compare_mask.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilCompareMask;
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK)) {
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_write_mask.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilWriteMask;
|
||||
dynamic->stencil_write_mask.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilWriteMask;
|
||||
}
|
||||
|
||||
if (states & (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE)) {
|
||||
assert(pCreateInfo->pDepthStencilState);
|
||||
dynamic->stencil_reference.front =
|
||||
pCreateInfo->pDepthStencilState->front.stencilReference;
|
||||
dynamic->stencil_reference.back =
|
||||
pCreateInfo->pDepthStencilState->back.stencilReference;
|
||||
}
|
||||
|
||||
pipeline->dynamic_state_mask = states;
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
|
|||
|
|
@ -794,6 +794,7 @@ struct anv_buffer {
|
|||
#define ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY (1 << 6)
|
||||
#define ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY (1 << 7)
|
||||
#define ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY (1 << 8)
|
||||
#define ANV_DYNAMIC_STATE_DIRTY_MASK ((1 << 9) - 1)
|
||||
#define ANV_CMD_BUFFER_PIPELINE_DIRTY (1 << 9)
|
||||
#define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 10)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue