diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2021-05-11 12:21:10 -0400 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-06-16 04:25:00 +0000 |
commit | f6108c2d64ac0ced0d61eba6f173b4b46d40e539 (patch) | |
tree | 0540f63ad63dc33664d5498d66c8441fa0f2b913 | |
parent | ee24c719eeaa711ce1e981cf9e1fb84434d2462d (diff) |
zink: remove return types from program update functions during draw
also remove some null checks; these add overhead and the app is going to
explode anyway if they fail
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11406>
-rw-r--r-- | src/gallium/drivers/zink/zink_draw.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 43f35f99497..7c857a51f4c 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -161,8 +161,8 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx) ctx->vertex_buffers_dirty = false; } -static struct zink_compute_program * -get_compute_program(struct zink_context *ctx) +static void +update_compute_program(struct zink_context *ctx) { unsigned bits = 1 << PIPE_SHADER_COMPUTE; ctx->dirty_shader_stages |= ctx->inlinable_uniforms_dirty_mask & @@ -185,13 +185,10 @@ get_compute_program(struct zink_context *ctx) ctx->dirty_shader_stages &= bits; ctx->inlinable_uniforms_dirty_mask &= bits; } - - assert(ctx->curr_compute); - return ctx->curr_compute; } -static struct zink_gfx_program * -get_gfx_program(struct zink_context *ctx) +static void +update_gfx_program(struct zink_context *ctx) { if (ctx->last_vertex_stage_dirty) { if (ctx->gfx_stages[PIPE_SHADER_GEOMETRY]) @@ -225,9 +222,6 @@ get_gfx_program(struct zink_context *ctx) ctx->dirty_shader_stages &= ~bits; ctx->inlinable_uniforms_dirty_mask &= ~bits; } - - assert(ctx->curr_program); - return ctx->curr_program; } static bool @@ -451,9 +445,7 @@ zink_draw_vbo(struct pipe_context *pctx, ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_FRAGMENT); } ctx->gfx_prim_mode = dinfo->mode; - struct zink_gfx_program *gfx_program = get_gfx_program(ctx); - if (!gfx_program) - return; + update_gfx_program(ctx); if (ctx->gfx_pipeline_state.primitive_restart != !!dinfo->primitive_restart) ctx->gfx_pipeline_state.dirty = true; @@ -525,7 +517,7 @@ zink_draw_vbo(struct pipe_context *pctx, } } - if (zink_program_has_descriptors(&gfx_program->base)) + if (zink_program_has_descriptors(&ctx->curr_program->base)) screen->descriptors_update(ctx, false); if (ctx->descriptor_refs_dirty[0]) @@ -534,7 +526,7 @@ zink_draw_vbo(struct pipe_context *pctx, struct zink_batch *batch = zink_batch_rp(ctx); VkPipeline prev_pipeline = ctx->gfx_pipeline_state.pipeline; - VkPipeline pipeline = zink_get_gfx_pipeline(ctx, gfx_program, + VkPipeline pipeline = zink_get_gfx_pipeline(ctx, ctx->curr_program, &ctx->gfx_pipeline_state, dinfo->mode); bool pipeline_changed = prev_pipeline != pipeline || ctx->pipeline_changed[0]; @@ -662,12 +654,12 @@ zink_draw_vbo(struct pipe_context *pctx, if (BITSET_TEST(ctx->gfx_stages[PIPE_SHADER_VERTEX]->nir->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX)) { unsigned draw_mode_is_indexed = dinfo->index_size > 0; - vkCmdPushConstants(batch->state->cmdbuf, gfx_program->base.layout, VK_SHADER_STAGE_VERTEX_BIT, + vkCmdPushConstants(batch->state->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_VERTEX_BIT, offsetof(struct zink_gfx_push_constant, draw_mode_is_indexed), sizeof(unsigned), &draw_mode_is_indexed); } - if (gfx_program->shaders[PIPE_SHADER_TESS_CTRL] && gfx_program->shaders[PIPE_SHADER_TESS_CTRL]->is_generated) - vkCmdPushConstants(batch->state->cmdbuf, gfx_program->base.layout, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, + if (ctx->curr_program->shaders[PIPE_SHADER_TESS_CTRL] && ctx->curr_program->shaders[PIPE_SHADER_TESS_CTRL]->is_generated) + vkCmdPushConstants(batch->state->cmdbuf, ctx->curr_program->base.layout, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, offsetof(struct zink_gfx_push_constant, default_inner_level), sizeof(float) * 6, &ctx->tess_levels[0]); @@ -793,16 +785,14 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) update_barriers(ctx, true); - struct zink_compute_program *comp_program = get_compute_program(ctx); - if (!comp_program) - return; + update_compute_program(ctx); - zink_program_update_compute_pipeline_state(ctx, comp_program, info->block); + zink_program_update_compute_pipeline_state(ctx, ctx->curr_compute, info->block); VkPipeline prev_pipeline = ctx->compute_pipeline_state.pipeline; - VkPipeline pipeline = zink_get_compute_pipeline(screen, comp_program, + VkPipeline pipeline = zink_get_compute_pipeline(screen, ctx->curr_compute, &ctx->compute_pipeline_state); - if (zink_program_has_descriptors(&comp_program->base)) + if (zink_program_has_descriptors(&ctx->curr_compute->base)) screen->descriptors_update(ctx, true); if (ctx->descriptor_refs_dirty[1]) @@ -812,8 +802,8 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) vkCmdBindPipeline(batch->state->cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline); ctx->pipeline_changed[1] = false; - if (BITSET_TEST(comp_program->shader->nir->info.system_values_read, SYSTEM_VALUE_WORK_DIM)) - vkCmdPushConstants(batch->state->cmdbuf, comp_program->base.layout, VK_SHADER_STAGE_COMPUTE_BIT, + if (BITSET_TEST(ctx->curr_compute->shader->nir->info.system_values_read, SYSTEM_VALUE_WORK_DIM)) + vkCmdPushConstants(batch->state->cmdbuf, ctx->curr_compute->base.layout, VK_SHADER_STAGE_COMPUTE_BIT, offsetof(struct zink_cs_push_constant, work_dim), sizeof(uint32_t), &info->work_dim); |