Commit bd38ea77 authored by Alejandro Piñeiro's avatar Alejandro Piñeiro

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's avatarEric Anholt <eric@anholt.net>
Part-of: <!6078>
parent a880f97d
Pipeline #192404 waiting for manual action with stages
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment