From: Alejandro PiƱeiro Date: Sat, 25 Jul 2020 22:52:17 +0000 (+0200) Subject: v3d/compiler: add v3dv_prog_data_size helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd38ea77e80d1d8f10097c4484ecf5f370effd03;p=mesa.git v3d/compiler: add v3dv_prog_data_size helper Main use case is to help to implement Vulkan PipelineCache, as we are serializing/deserializing the prog_data too. Reviewed-by: Eric Anholt Part-of: --- diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index 154b059856b..0026dd2fef3 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -808,6 +808,7 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler, int program_id, int variant_id, uint32_t *final_assembly_size); +uint32_t v3d_prog_data_size(gl_shader_stage stage); void v3d_nir_to_vir(struct v3d_compile *c); void vir_compile_destroy(struct v3d_compile *c); diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index d7e9784a10a..d81931ec27b 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1146,6 +1146,23 @@ v3d_attempt_compile(struct v3d_compile *c) v3d_nir_to_vir(c); } +uint32_t +v3d_prog_data_size(gl_shader_stage stage) +{ + static const int prog_data_size[] = { + [MESA_SHADER_VERTEX] = sizeof(struct v3d_vs_prog_data), + [MESA_SHADER_GEOMETRY] = sizeof(struct v3d_gs_prog_data), + [MESA_SHADER_FRAGMENT] = sizeof(struct v3d_fs_prog_data), + [MESA_SHADER_COMPUTE] = sizeof(struct v3d_compute_prog_data), + }; + + assert(stage >= 0 && + stage < ARRAY_SIZE(prog_data_size) && + prog_data_size[stage]); + + return prog_data_size[stage]; +} + uint64_t *v3d_compile(const struct v3d_compiler *compiler, struct v3d_key *key, struct v3d_prog_data **out_prog_data, @@ -1189,18 +1206,7 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler, struct v3d_prog_data *prog_data; - static const int prog_data_size[] = { - [MESA_SHADER_VERTEX] = sizeof(struct v3d_vs_prog_data), - [MESA_SHADER_GEOMETRY] = sizeof(struct v3d_gs_prog_data), - [MESA_SHADER_FRAGMENT] = sizeof(struct v3d_fs_prog_data), - [MESA_SHADER_COMPUTE] = sizeof(struct v3d_compute_prog_data), - }; - - assert(c->s->info.stage >= 0 && - c->s->info.stage < ARRAY_SIZE(prog_data_size) && - prog_data_size[c->s->info.stage]); - - prog_data = rzalloc_size(NULL, prog_data_size[c->s->info.stage]); + prog_data = rzalloc_size(NULL, v3d_prog_data_size(c->s->info.stage)); v3d_set_prog_data(c, prog_data);