radv: add a new helper to determine if rasterization is enabled

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15764>
This commit is contained in:
Samuel Pitoiset
2022-04-06 10:48:22 +02:00
committed by Marge Bot
parent 3724e09609
commit c7ae87d7af

View File

@@ -101,11 +101,17 @@ radv_is_state_dynamic(const VkGraphicsPipelineCreateInfo *pCreateInfo, VkDynamic
return false; return false;
} }
static bool
radv_is_raster_enabled(const VkGraphicsPipelineCreateInfo *pCreateInfo)
{
return !pCreateInfo->pRasterizationState->rasterizerDiscardEnable ||
radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE);
}
static const VkPipelineMultisampleStateCreateInfo * static const VkPipelineMultisampleStateCreateInfo *
radv_pipeline_get_multisample_state(const VkGraphicsPipelineCreateInfo *pCreateInfo) radv_pipeline_get_multisample_state(const VkGraphicsPipelineCreateInfo *pCreateInfo)
{ {
if (!pCreateInfo->pRasterizationState->rasterizerDiscardEnable || if (radv_is_raster_enabled(pCreateInfo))
radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE))
return pCreateInfo->pMultisampleState; return pCreateInfo->pMultisampleState;
return NULL; return NULL;
} }
@@ -137,8 +143,7 @@ radv_pipeline_get_depth_stencil_state(const VkGraphicsPipelineCreateInfo *pCreat
{ {
bool has_ds_att = radv_pipeline_has_ds_attachments(pCreateInfo); bool has_ds_att = radv_pipeline_has_ds_attachments(pCreateInfo);
if ((!pCreateInfo->pRasterizationState->rasterizerDiscardEnable && has_ds_att) || if (radv_is_raster_enabled(pCreateInfo) && has_ds_att)
radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE))
return pCreateInfo->pDepthStencilState; return pCreateInfo->pDepthStencilState;
return NULL; return NULL;
} }
@@ -164,8 +169,7 @@ radv_pipeline_get_color_blend_state(const VkGraphicsPipelineCreateInfo *pCreateI
{ {
bool has_color_att = radv_pipeline_has_color_attachments(pCreateInfo); bool has_color_att = radv_pipeline_has_color_attachments(pCreateInfo);
if ((!pCreateInfo->pRasterizationState->rasterizerDiscardEnable && has_color_att) || if (radv_is_raster_enabled(pCreateInfo) && has_color_att)
radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE))
return pCreateInfo->pColorBlendState; return pCreateInfo->pColorBlendState;
return NULL; return NULL;
} }
@@ -1411,14 +1415,12 @@ radv_pipeline_needed_dynamic_state(const struct radv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *pCreateInfo) const VkGraphicsPipelineCreateInfo *pCreateInfo)
{ {
bool has_color_att = radv_pipeline_has_color_attachments(pCreateInfo); bool has_color_att = radv_pipeline_has_color_attachments(pCreateInfo);
bool has_static_rasterizer_discard = bool raster_enabled = radv_is_raster_enabled(pCreateInfo);
pCreateInfo->pRasterizationState->rasterizerDiscardEnable &&
!radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE);
uint64_t states = RADV_DYNAMIC_ALL; uint64_t states = RADV_DYNAMIC_ALL;
/* Disable dynamic states that are useless to mesh shading. */ /* Disable dynamic states that are useless to mesh shading. */
if (radv_pipeline_has_mesh(pipeline)) { if (radv_pipeline_has_mesh(pipeline)) {
if (has_static_rasterizer_discard) if (!raster_enabled)
return RADV_DYNAMIC_RASTERIZER_DISCARD_ENABLE; return RADV_DYNAMIC_RASTERIZER_DISCARD_ENABLE;
states &= ~(RADV_DYNAMIC_VERTEX_INPUT | RADV_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE | states &= ~(RADV_DYNAMIC_VERTEX_INPUT | RADV_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE |
@@ -1430,7 +1432,7 @@ radv_pipeline_needed_dynamic_state(const struct radv_pipeline *pipeline,
* except primitive topology, primitive restart enable, vertex * except primitive topology, primitive restart enable, vertex
* binding stride and rasterization discard itself. * binding stride and rasterization discard itself.
*/ */
if (has_static_rasterizer_discard) { if (!raster_enabled) {
return RADV_DYNAMIC_PRIMITIVE_TOPOLOGY | RADV_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE | return RADV_DYNAMIC_PRIMITIVE_TOPOLOGY | RADV_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE |
RADV_DYNAMIC_PRIMITIVE_RESTART_ENABLE | RADV_DYNAMIC_RASTERIZER_DISCARD_ENABLE | RADV_DYNAMIC_PRIMITIVE_RESTART_ENABLE | RADV_DYNAMIC_RASTERIZER_DISCARD_ENABLE |
RADV_DYNAMIC_VERTEX_INPUT; RADV_DYNAMIC_VERTEX_INPUT;
@@ -1874,8 +1876,7 @@ static void
radv_pipeline_init_viewport_state(struct radv_pipeline *pipeline, radv_pipeline_init_viewport_state(struct radv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *pCreateInfo) const VkGraphicsPipelineCreateInfo *pCreateInfo)
{ {
if (pCreateInfo->pRasterizationState->rasterizerDiscardEnable && if (!radv_is_raster_enabled(pCreateInfo))
!radv_is_state_dynamic(pCreateInfo, VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE))
return; return;
const VkPipelineViewportDepthClipControlCreateInfoEXT *depth_clip_control = const VkPipelineViewportDepthClipControlCreateInfoEXT *depth_clip_control =