[Mesa-dev] [PATCH] i965: Fix context initialization after 2f896627175384fd5
Matt Turner
mattst88 at gmail.com
Mon Nov 4 17:55:23 PST 2013
On Mon, Nov 4, 2013 at 3:50 PM, Eric Anholt <eric at anholt.net> wrote:
> You can't return stack-initialized values and expect anything good to
> happen.
> ---
> src/mesa/drivers/dri/i965/brw_context.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 13569ad..95b602f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -275,12 +275,15 @@ brw_init_driver_functions(struct brw_context *brw,
> static const int*
> brw_supported_msaa_modes(const struct brw_context *brw)
> {
> + static const int gen7_samples[] = {8, 4, 0};
> + static const int gen6_samples[] = {4, 0};
> + static const int gen4_samples[] = {0};
> if (brw->gen >= 7) {
> - return (int[]){8, 4, 0};
> + return gen7_samples;
> } else if (brw->gen == 6) {
> - return (int[]){4, 0};
> + return gen6_samples;
> } else {
> - return (int[]){0};
> + return gen4_samples;
> }
> }
>
> --
> 1.8.4.rc3
Trivial, but you could do this with half the static data by returning
pointers to elements [1] and [2] of gen7_samples for the gen6 and
gen4/5 cases.
In any case
Reviewed-by: Matt Turner <mattst88 at gmail.com>
More information about the mesa-dev
mailing list