zink: make zink_gfx_pipeline_state::vertices_per_patch a bitfield

this is clamped to MAX_PATCH_VERTICES

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12586>
This commit is contained in:
Mike Blumenkrantz 2021-06-15 11:52:20 -04:00 committed by Marge Bot
parent 7b3dfea6c1
commit 4a5dfabb12
5 changed files with 7 additions and 6 deletions

View File

@ -1122,7 +1122,7 @@ void main()
struct zink_shader *
zink_shader_tcs_create(struct zink_context *ctx, struct zink_shader *vs)
{
unsigned vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch;
unsigned vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch + 1;
struct zink_shader *ret = CALLOC_STRUCT(zink_shader);
ret->programs = _mesa_pointer_set_create(NULL);
simple_mtx_init(&ret->lock, mtx_plain);

View File

@ -438,7 +438,8 @@ zink_draw_vbo(struct pipe_context *pctx,
ctx->buffer_rebind_counter = screen->buffer_rebind_counter;
zink_rebind_all_buffers(ctx);
}
if (ctx->gfx_pipeline_state.vertices_per_patch != ctx->gfx_pipeline_state.patch_vertices)
uint8_t vertices_per_patch = ctx->gfx_pipeline_state.patch_vertices ? ctx->gfx_pipeline_state.patch_vertices - 1 : 0;
if (ctx->gfx_pipeline_state.vertices_per_patch != vertices_per_patch)
ctx->gfx_pipeline_state.dirty = true;
bool drawid_broken = ctx->drawid_broken;
ctx->drawid_broken = false;
@ -448,7 +449,7 @@ zink_draw_vbo(struct pipe_context *pctx,
(HAS_MULTIDRAW && num_draws > 1 && !dinfo->increment_draw_id));
if (drawid_broken != ctx->drawid_broken)
ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_VERTEX);
ctx->gfx_pipeline_state.vertices_per_patch = ctx->gfx_pipeline_state.patch_vertices;
ctx->gfx_pipeline_state.vertices_per_patch = vertices_per_patch;
if (ctx->rast_state->base.point_quad_rasterization && mode_changed) {
if (ctx->gfx_prim_mode == PIPE_PRIM_POINTS || mode == PIPE_PRIM_POINTS)
ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_FRAGMENT);

View File

@ -239,7 +239,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
VkPipelineTessellationDomainOriginStateCreateInfo tdci = {0};
if (prog->shaders[PIPE_SHADER_TESS_CTRL] && prog->shaders[PIPE_SHADER_TESS_EVAL]) {
tci.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
tci.patchControlPoints = state->vertices_per_patch;
tci.patchControlPoints = state->vertices_per_patch + 1;
pci.pTessellationState = &tci;
tci.pNext = &tdci;
tdci.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;

View File

@ -40,8 +40,8 @@ struct zink_vertex_elements_state;
struct zink_gfx_pipeline_state {
uint32_t rast_state : ZINK_RAST_HW_STATE_SIZE; //zink_rasterizer_hw_state
uint32_t vertices_per_patch:5;
uint32_t rast_samples:7;
uint32_t vertices_per_patch;
uint32_t void_alpha_attachments:PIPE_MAX_COLOR_BUFS;
VkSampleMask sample_mask;

View File

@ -161,7 +161,7 @@ shader_key_tcs_gen(struct zink_context *ctx, struct zink_shader *zs,
struct zink_tcs_key *tcs_key = &key->key.tcs;
key->size = sizeof(struct zink_tcs_key);
tcs_key->vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch;
tcs_key->vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch + 1;
tcs_key->vs_outputs_written = shaders[PIPE_SHADER_VERTEX]->nir->info.outputs_written;
}