From 4663b0b1089fbbc92b5b3489cf04b38dcc716dfd Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 17 Feb 2021 17:37:52 +0100 Subject: [PATCH] vrend: make shader interpinfo a fixed size array Use a bitfield to declare vrend_interp_info and make it a fixed size array. One one hand this avoids all the hassles with allocating and freeing memory, and it will make it possible to shrink the size of the data that is passed from the sinfo to the shader key. Signed-off-by: Gert Wollny Reviewed-by: Rohan Garg --- src/vrend_renderer.c | 1 - src/vrend_shader.c | 18 ++---------------- src/vrend_shader.h | 10 +++++----- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 06856e1..019e4de 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1139,7 +1139,6 @@ static void vrend_destroy_shader_selector(struct vrend_shader_selector *sel) free(sel->sinfo.so_names[i]); free(sel->tmp_buf); free(sel->sinfo.so_names); - free(sel->sinfo.interpinfo); free(sel->sinfo.sampler_arrays); free(sel->sinfo.image_arrays); free(sel->tokens); diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 6ebdfe3..59f7dc5 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -6775,26 +6775,12 @@ static boolean fill_fragment_interpolants(const struct dump_ctx *ctx, struct vre static boolean fill_interpolants(const struct dump_ctx *ctx, struct vrend_shader_info *sinfo) { - boolean ret; - if (!ctx->num_interps) return true; if (ctx->prog_type == TGSI_PROCESSOR_VERTEX || ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) return true; - free(sinfo->interpinfo); - sinfo->interpinfo = calloc(ctx->num_interps, sizeof(struct vrend_interp_info)); - if (!sinfo->interpinfo) - return false; - - ret = fill_fragment_interpolants(ctx, sinfo); - if (ret == false) - goto out_fail; - - return true; - out_fail: - free(sinfo->interpinfo); - return false; + return fill_fragment_interpolants(ctx, sinfo); } static boolean analyze_instruction(struct tgsi_iterate_context *iter, @@ -7128,7 +7114,7 @@ static bool vrend_patch_vertex_shader_interpolants(MAYBE_UNUSED const struct vre if (!vs_info || !fs_info) return true; - if (!fs_info->interpinfo) + if (!fs_info->num_interps) return true; if (fs_info->has_sample_input) { diff --git a/src/vrend_shader.h b/src/vrend_shader.h index 6b8503b..5ca6249 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -54,10 +54,10 @@ enum gl_advanced_blend_mode /* need to store patching info for interpolation */ struct vrend_interp_info { - int semantic_name; - int semantic_index; - int interpolate; - unsigned location; + unsigned semantic_name : 6; + unsigned semantic_index : 16; + unsigned interpolate : 3; + unsigned location : 3; }; struct vrend_array { @@ -112,7 +112,7 @@ struct vrend_shader_info { struct pipe_stream_output_info so_info; - struct vrend_interp_info *interpinfo; + struct vrend_interp_info interpinfo[PIPE_MAX_SHADER_INPUTS]; char **so_names; uint64_t invariant_outputs; };