zink: fill in the right line-mode based on state

We need to fill in the right line-mode here based on the state to get
the correct rasterization; bresenham isn't always the right one.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11795>
This commit is contained in:
Erik Faye-Lund
2021-04-20 18:28:24 +02:00
committed by Marge Bot
parent f589159db9
commit c3b0f439a7
4 changed files with 56 additions and 2 deletions

View File

@@ -149,7 +149,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
if (screen->info.have_EXT_line_rasterization) {
rast_line_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT;
rast_line_state.pNext = rast_state.pNext;
rast_line_state.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
rast_line_state.lineRasterizationMode = state->rast_state->line_mode;
if (state->rast_state->line_stipple_pattern != UINT16_MAX) {
rast_line_state.stippledLineEnable = VK_TRUE;

View File

@@ -1706,7 +1706,14 @@ check_base_requirements(struct zink_screen *screen)
!(screen->info.feats12.scalarBlockLayout ||
screen->info.have_EXT_scalar_block_layout) ||
!screen->info.have_KHR_maintenance1 ||
!screen->info.have_EXT_custom_border_color) {
!screen->info.have_EXT_custom_border_color ||
!screen->info.have_EXT_line_rasterization ||
!screen->info.line_rast_feats.rectangularLines ||
!screen->info.line_rast_feats.bresenhamLines ||
!screen->info.line_rast_feats.smoothLines ||
!screen->info.line_rast_feats.stippledRectangularLines ||
!screen->info.line_rast_feats.stippledBresenhamLines ||
!screen->info.line_rast_feats.stippledSmoothLines) {
fprintf(stderr, "WARNING: Some incorrect rendering "
"might occur because the selected Vulkan device (%s) doesn't support "
"base Zink requirements: ", screen->info.props.deviceName);
@@ -1723,6 +1730,15 @@ check_base_requirements(struct zink_screen *screen)
printf("scalarBlockLayout OR EXT_scalar_block_layout ");
CHECK_OR_PRINT(have_KHR_maintenance1);
CHECK_OR_PRINT(have_EXT_custom_border_color);
CHECK_OR_PRINT(have_EXT_line_rasterization);
if (screen->info.have_EXT_line_rasterization) {
CHECK_OR_PRINT(line_rast_feats.rectangularLines);
CHECK_OR_PRINT(line_rast_feats.bresenhamLines);
CHECK_OR_PRINT(line_rast_feats.smoothLines);
CHECK_OR_PRINT(line_rast_feats.stippledRectangularLines);
CHECK_OR_PRINT(line_rast_feats.stippledBresenhamLines);
CHECK_OR_PRINT(line_rast_feats.stippledSmoothLines);
}
fprintf(stderr, "\n");
}
}

View File

@@ -459,10 +459,47 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
VK_FRONT_FACE_COUNTER_CLOCKWISE :
VK_FRONT_FACE_CLOCKWISE;
VkPhysicalDeviceLineRasterizationFeaturesEXT *line_feats =
&screen->info.line_rast_feats;
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
if (rs_state->line_stipple_enable) {
state->hw_state.line_stipple_factor = rs_state->line_stipple_factor;
state->hw_state.line_stipple_pattern = rs_state->line_stipple_pattern;
if (screen->info.have_EXT_line_rasterization) {
if (rs_state->multisample) {
if (line_feats->stippledRectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
} else if (rs_state->line_smooth) {
if (line_feats->stippledRectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
} else if (line_feats->stippledBresenhamLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
else {
/* no suitable mode that supports line stippling */
state->hw_state.line_stipple_factor = 0;
state->hw_state.line_stipple_pattern = UINT16_MAX;
}
}
} else {
if (screen->info.have_EXT_line_rasterization) {
if (rs_state->multisample) {
if (line_feats->rectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
} else if (rs_state->line_smooth) {
if (line_feats->rectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
} else if (line_feats->bresenhamLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
}
state->hw_state.line_stipple_factor = 0;
state->hw_state.line_stipple_pattern = UINT16_MAX;
}

View File

@@ -50,6 +50,7 @@ struct zink_rasterizer_hw_state {
VkPolygonMode polygon_mode;
VkCullModeFlags cull_mode;
VkProvokingVertexModeEXT pv_mode;
VkLineRasterizationModeEXT line_mode;
unsigned depth_clamp : 1;
unsigned rasterizer_discard : 1;
unsigned force_persample_interp : 1;