From 33f0170b031b12b50e6ac69f86fa43386c585c85 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 30 Jul 2018 12:58:27 +1000 Subject: [PATCH] shader: merge array types This just merges the sampler and image array types. Reviewed-by: Gurchetan Singh --- src/vrend_renderer.c | 2 +- src/vrend_shader.c | 12 ++++++------ src/vrend_shader.h | 11 +++-------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 4397f98..fc82ee1 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1150,7 +1150,7 @@ static void bind_image_locs(struct vrend_linked_shader_program *sprog, if (sprog->ss[id]->sel->sinfo.num_image_arrays) { int idx; for (i = 0; i < sprog->ss[id]->sel->sinfo.num_image_arrays; i++) { - struct vrend_image_array *img_array = &sprog->ss[id]->sel->sinfo.image_arrays[i]; + struct vrend_array *img_array = &sprog->ss[id]->sel->sinfo.image_arrays[i]; for (int j = 0; j < img_array->array_size; j++) { snprintf(name, 32, "%simg%d[%d]", prefix, img_array->first, j); sprog->img_locs[id][img_array->first + j] = glGetUniformLocation(sprog->id, name); diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 658a830..42ebe11 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -156,10 +156,10 @@ struct dump_ctx { struct vrend_shader_image images[32]; uint32_t images_used_mask; - struct vrend_image_array *image_arrays; + struct vrend_array *image_arrays; uint32_t num_image_arrays; - struct vrend_sampler_array *sampler_arrays; + struct vrend_array *sampler_arrays; uint32_t num_sampler_arrays; int num_consts; @@ -533,7 +533,7 @@ static int add_images(struct dump_ctx *ctx, int first, int last, if (ctx->info.indirect_files & (1 << TGSI_FILE_IMAGE)) { if (ctx->num_image_arrays) { - struct vrend_image_array *last_array = &ctx->image_arrays[ctx->num_image_arrays - 1]; + struct vrend_array *last_array = &ctx->image_arrays[ctx->num_image_arrays - 1]; /* * If this set of images is consecutive to the last array, * and has compatible return and decls, then increase the array size. @@ -548,7 +548,7 @@ static int add_images(struct dump_ctx *ctx, int first, int last, /* allocate a new image array for this range of images */ ctx->num_image_arrays++; - ctx->image_arrays = realloc(ctx->image_arrays, sizeof(struct vrend_image_array) * ctx->num_image_arrays); + ctx->image_arrays = realloc(ctx->image_arrays, sizeof(struct vrend_array) * ctx->num_image_arrays); if (!ctx->image_arrays) return -1; ctx->image_arrays[ctx->num_image_arrays - 1].first = first; @@ -561,7 +561,7 @@ static int add_sampler_array(struct dump_ctx *ctx, int first, int last) { int idx = ctx->num_sampler_arrays; ctx->num_sampler_arrays++; - ctx->sampler_arrays = realloc(ctx->sampler_arrays, sizeof(struct vrend_sampler_array) * ctx->num_sampler_arrays); + ctx->sampler_arrays = realloc(ctx->sampler_arrays, sizeof(struct vrend_array) * ctx->num_sampler_arrays); if (!ctx->sampler_arrays) return -1; @@ -609,7 +609,7 @@ static int add_samplers(struct dump_ctx *ctx, int first, int last, int sview_typ if (ctx->info.indirect_files & (1 << TGSI_FILE_SAMPLER)) { if (ctx->num_sampler_arrays) { - struct vrend_sampler_array *last_array = &ctx->sampler_arrays[ctx->num_sampler_arrays - 1]; + struct vrend_array *last_array = &ctx->sampler_arrays[ctx->num_sampler_arrays - 1]; if ((last_array->first + last_array->array_size == first) && ctx->samplers[last_array->first].tgsi_sampler_type == sview_type && ctx->samplers[last_array->first].tgsi_sampler_return == sview_rtype) { diff --git a/src/vrend_shader.h b/src/vrend_shader.h index 54e4ec6..04e92e6 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -36,12 +36,7 @@ struct vrend_interp_info { unsigned location; }; -struct vrend_sampler_array { - int first; - int array_size; -}; - -struct vrend_image_array { +struct vrend_array { int first; int array_size; }; @@ -73,10 +68,10 @@ struct vrend_shader_info { bool tes_point_mode; uint32_t attrib_input_mask; - struct vrend_sampler_array *sampler_arrays; + struct vrend_array *sampler_arrays; int num_sampler_arrays; - struct vrend_image_array *image_arrays; + struct vrend_array *image_arrays; int num_image_arrays; struct pipe_stream_output_info so_info;