[Mesa-dev] [PATCH 2/3] glsl_to_tgsi: don't use a static array size for st_translate::arrays
Emil Velikov
emil.l.velikov at gmail.com
Tue May 26 13:15:51 PDT 2015
On 26/05/15 14:04, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 792771e..57b80a32 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -57,11 +57,6 @@
> (1 << PROGRAM_CONSTANT) | \
> (1 << PROGRAM_UNIFORM))
>
> -/**
> - * Maximum number of arrays
> - */
> -#define MAX_ARRAYS 256
> -
> #define MAX_GLSL_TEXTURE_OFFSET 4
>
> class st_src_reg;
> @@ -4372,7 +4367,8 @@ struct st_translate {
> unsigned temps_size;
> struct ureg_dst *temps;
>
> - struct ureg_dst arrays[MAX_ARRAYS];
> + struct ureg_dst *arrays;
> + unsigned num_temp_arrays;
> struct ureg_src *constants;
> int num_constants;
> struct ureg_src *immediates;
> @@ -4540,7 +4536,7 @@ dst_register(struct st_translate *t,
> case PROGRAM_ARRAY:
> array = index >> 16;
>
> - assert(array < ARRAY_SIZE(t->arrays));
> + assert(array < t->num_temp_arrays);
>
> if (ureg_dst_is_undef(t->arrays[array]))
> t->arrays[array] = ureg_DECL_array_temporary(
> @@ -4748,7 +4744,7 @@ translate_tex_offset(struct st_translate *t,
> array = in_offset->index >> 16;
>
> assert(array >= 0);
> - assert(array < (int) ARRAY_SIZE(t->arrays));
> + assert(array < (int)t->num_temp_arrays);
>
> dst = t->arrays[array];
> offset.File = dst.File;
> @@ -5148,6 +5144,10 @@ st_translate_program(
> t->inputMapping = inputMapping;
> t->outputMapping = outputMapping;
> t->ureg = ureg;
> + t->num_temp_arrays = program->next_array;
> + if (t->num_temp_arrays)
> + t->arrays = (struct ureg_dst*)
> + CALLOC(1, sizeof(t->arrays[0]) * t->num_temp_arrays);
Most cases in this file use the non wrapper functions - calloc + free.
Perhaps change the above to calloc() to match with the free() below ?
>
> /*
> * Declare input attributes.
> @@ -5383,6 +5383,7 @@ st_translate_program(
>
> out:
> if (t) {
> + free(t->arrays);
> free(t->temps);
> free(t->insn);
> free(t->labels);
>
Cheers
Emil
More information about the mesa-dev
mailing list