venus: Refactor vn_fix_graphics_pipeline_create_info
We currently do only a single fix. Prepare to do multiple independent fixes. Signed-off-by: Chad Versace <chadversary@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16284>
This commit is contained in:
@@ -241,6 +241,16 @@ vn_MergePipelineCaches(VkDevice device,
|
|||||||
|
|
||||||
/* pipeline commands */
|
/* pipeline commands */
|
||||||
|
|
||||||
|
struct vn_graphics_pipeline_create_info_fix {
|
||||||
|
/* Ignore the following:
|
||||||
|
* pViewportState
|
||||||
|
* pMultisampleState
|
||||||
|
* pDepthStencilState
|
||||||
|
* pColorBlendState
|
||||||
|
*/
|
||||||
|
bool ignore_raster_dedicated_states;
|
||||||
|
};
|
||||||
|
|
||||||
static const VkGraphicsPipelineCreateInfo *
|
static const VkGraphicsPipelineCreateInfo *
|
||||||
vn_fix_graphics_pipeline_create_info(
|
vn_fix_graphics_pipeline_create_info(
|
||||||
struct vn_device *dev,
|
struct vn_device *dev,
|
||||||
@@ -250,42 +260,67 @@ vn_fix_graphics_pipeline_create_info(
|
|||||||
VkGraphicsPipelineCreateInfo **out)
|
VkGraphicsPipelineCreateInfo **out)
|
||||||
{
|
{
|
||||||
VkGraphicsPipelineCreateInfo *infos = NULL;
|
VkGraphicsPipelineCreateInfo *infos = NULL;
|
||||||
bool has_ignored_state = false;
|
|
||||||
|
/* Defer allocation until we find a needed fix. */
|
||||||
|
struct vn_graphics_pipeline_create_info_fix *fixes = NULL;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < create_info_count; i++) {
|
for (uint32_t i = 0; i < create_info_count; i++) {
|
||||||
if (create_infos[i].pRasterizationState->rasterizerDiscardEnable ==
|
const VkGraphicsPipelineCreateInfo *info = &create_infos[i];
|
||||||
VK_FALSE)
|
struct vn_graphics_pipeline_create_info_fix fix = { 0 };
|
||||||
continue;
|
bool any_fix = false;
|
||||||
|
|
||||||
if (create_infos[i].pViewportState ||
|
/* FIXME: Conditions for ignoring pDepthStencilState and
|
||||||
create_infos[i].pMultisampleState ||
|
* pColorBlendState miss some cases that depend on the render pass. Make
|
||||||
create_infos[i].pDepthStencilState ||
|
* them agree with the VUIDs.
|
||||||
create_infos[i].pColorBlendState) {
|
*
|
||||||
has_ignored_state = true;
|
* TODO: Update conditions for VK_EXT_extended_dynamic_state2.
|
||||||
break;
|
*/
|
||||||
|
if (info->pRasterizationState->rasterizerDiscardEnable == VK_TRUE &&
|
||||||
|
(info->pViewportState || info->pMultisampleState ||
|
||||||
|
info->pDepthStencilState || info->pColorBlendState)) {
|
||||||
|
fix.ignore_raster_dedicated_states = true;
|
||||||
|
any_fix = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (any_fix) {
|
||||||
|
if (!fixes) {
|
||||||
|
fixes = vk_zalloc(alloc, create_info_count * sizeof(fixes[0]),
|
||||||
|
VN_DEFAULT_ALIGN,
|
||||||
|
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||||
|
if (!fixes)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixes[i] = fix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_ignored_state)
|
if (!fixes)
|
||||||
return create_infos;
|
return create_infos;
|
||||||
|
|
||||||
infos = vk_alloc(alloc, sizeof(*infos) * create_info_count,
|
infos = vk_alloc(alloc, sizeof(*infos) * create_info_count,
|
||||||
VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||||
if (!infos)
|
if (!infos) {
|
||||||
|
vk_free(alloc, fixes);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(infos, create_infos, sizeof(*infos) * create_info_count);
|
memcpy(infos, create_infos, sizeof(*infos) * create_info_count);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < create_info_count; i++) {
|
for (uint32_t i = 0; i < create_info_count; i++) {
|
||||||
if (infos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)
|
VkGraphicsPipelineCreateInfo *info = &infos[i];
|
||||||
continue;
|
struct vn_graphics_pipeline_create_info_fix fix = fixes[i];
|
||||||
|
|
||||||
infos[i].pViewportState = NULL;
|
if (fix.ignore_raster_dedicated_states) {
|
||||||
infos[i].pMultisampleState = NULL;
|
info->pViewportState = NULL;
|
||||||
infos[i].pDepthStencilState = NULL;
|
info->pMultisampleState = NULL;
|
||||||
infos[i].pColorBlendState = NULL;
|
info->pDepthStencilState = NULL;
|
||||||
|
info->pColorBlendState = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk_free(alloc, fixes);
|
||||||
|
|
||||||
*out = infos;
|
*out = infos;
|
||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user