zink: implement VK_EXT_provoking_vertex

this only needs to be set if the mode is LAST, otherwise the normal
pipeline state can be used and this one can be omitted

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10458>
This commit is contained in:
Mike Blumenkrantz 2021-04-20 17:04:02 -04:00 committed by Marge Bot
parent 78232665db
commit bee38fba1b
3 changed files with 18 additions and 0 deletions

View File

@ -114,6 +114,15 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
rast_state.depthBiasSlopeFactor = 0.0;
rast_state.lineWidth = 1.0f;
VkPipelineRasterizationProvokingVertexStateCreateInfoEXT pv_state;
pv_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT;
pv_state.provokingVertexMode = state->rast_state->pv_mode;
if (screen->info.have_EXT_provoking_vertex &&
state->rast_state->pv_mode == VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT) {
pv_state.pNext = rast_state.pNext;
rast_state.pNext = &pv_state;
}
VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {};
depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
depth_stencil_state.depthTestEnable = state->depth_stencil_alpha_state->depth_test;

View File

@ -438,6 +438,7 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
state->hw_state.depth_clamp = rs_state->depth_clip_near == 0;
state->hw_state.rasterizer_discard = rs_state->rasterizer_discard;
state->hw_state.force_persample_interp = rs_state->force_persample_interp;
state->hw_state.pv_mode = rs_state->flatshade_first ? VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT : VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
assert(rs_state->fill_front <= PIPE_POLYGON_MODE_POINT);
if (rs_state->fill_back != rs_state->fill_front)
@ -467,12 +468,19 @@ static void
zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
{
struct zink_context *ctx = zink_context(pctx);
struct zink_screen *screen = zink_screen(pctx->screen);
bool clip_halfz = ctx->rast_state ? ctx->rast_state->base.clip_halfz : false;
bool point_quad_rasterization = ctx->rast_state ? ctx->rast_state->base.point_quad_rasterization : false;
ctx->rast_state = cso;
if (ctx->rast_state) {
if (ctx->gfx_pipeline_state.rast_state != &ctx->rast_state->hw_state) {
if (screen->info.have_EXT_provoking_vertex &&
(!ctx->gfx_pipeline_state.rast_state ||
ctx->gfx_pipeline_state.rast_state->pv_mode != ctx->rast_state->hw_state.pv_mode) &&
/* without this prop, change in pv mode requires new rp */
!screen->info.pv_props.provokingVertexModePerPipeline)
zink_batch_no_rp(ctx);
ctx->gfx_pipeline_state.rast_state = &ctx->rast_state->hw_state;
ctx->gfx_pipeline_state.dirty = true;
}

View File

@ -49,6 +49,7 @@ struct zink_rasterizer_hw_state {
VkFrontFace front_face;
VkPolygonMode polygon_mode;
VkCullModeFlags cull_mode;
VkProvokingVertexModeEXT pv_mode;
bool force_persample_interp;
};