zink: do not warn about rare features until used

We currently cause the following scary warning to be printed on
start-up for *every* application regardless if that feature is being
used or not when run on top of ANV:

> WARNING: Some incorrect rendering might occur because the selected
> Vulkan device (Intel(R) UHD Graphics 620 (KBL GT2)) doesn't support
> base Zink requirements: line_rast_feats.stippledRectangularLines
> line_rast_feats.stippledSmoothLines

There's no need to scare the users about this, as most applications
don't care about these combinational features. So let's instead emit a
warning when these features are attempted (but failed) to be used
instead.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12587>
This commit is contained in:
Erik Faye-Lund 2021-08-27 10:05:52 +02:00 committed by Marge Bot
parent 28b3563a95
commit 64c558ab83
2 changed files with 25 additions and 15 deletions

View File

@ -1711,13 +1711,7 @@ check_base_requirements(struct zink_screen *screen)
screen->info.have_EXT_scalar_block_layout) ||
!screen->info.have_KHR_maintenance1 ||
!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) {
!screen->info.have_EXT_line_rasterization) {
fprintf(stderr, "WARNING: Some incorrect rendering "
"might occur because the selected Vulkan device (%s) doesn't support "
"base Zink requirements: ", screen->info.props.deviceName);
@ -1735,14 +1729,6 @@ check_base_requirements(struct zink_screen *screen)
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

@ -455,6 +455,18 @@ line_width(float width, float granularity, const float range[2])
return CLAMP(width, range[0], range[1]);
}
#define warn_line_feature(feat) \
do { \
static bool warned = false; \
if (!warned) { \
fprintf(stderr, "WARNING: Incorrect rendering will happen, " \
"because the Vulkan device doesn't support " \
"the %s feature of " \
"VK_EXT_line_rasterization\n", feat); \
warned = true; \
} \
} while (0)
static void *
zink_create_rasterizer_state(struct pipe_context *pctx,
const struct pipe_rasterizer_state *rs_state)
@ -498,13 +510,19 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
if (line_feats->stippledSmoothLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
else
warn_line_feature("stippledSmoothLines");
} else if (line_feats->stippledRectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
else
warn_line_feature("stippledRectangularLines");
} else if (line_feats->stippledBresenhamLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
else {
warn_line_feature("stippledBresenhamLines");
/* no suitable mode that supports line stippling */
state->base.line_stipple_factor = 0;
state->base.line_stipple_pattern = UINT16_MAX;
@ -517,12 +535,18 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
if (line_feats->smoothLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
else
warn_line_feature("smoothLines");
} else if (line_feats->rectangularLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT;
else
warn_line_feature("rectangularLines");
} else if (line_feats->bresenhamLines)
state->hw_state.line_mode =
VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
else
warn_line_feature("bresenhamLines");
}
state->base.line_stipple_factor = 0;
state->base.line_stipple_pattern = UINT16_MAX;