[Mesa-dev] [PATCH 10/17] gallium/util: Ensure util_framebuffer_get_num_samples() is valid

Ilia Mirkin imirkin at alum.mit.edu
Fri Mar 25 03:20:09 UTC 2016


Instead of introducing buggy code in patch 6/17 and then fixing it up
here, you need to fold this with patch 6 so that it's all done at the
same time.

On Thu, Mar 24, 2016 at 8:11 PM, Edward O'Callaghan
<eocallaghan at alterapraxis.com> wrote:
> Upon context creation, internal driver structures are malloc()'ed
> and memset() to zero them. This results in a invalid number of
> samples 'by default'. Handle this in the simplest way to avoid
> elaborate and probably equally sub-optimial solutions.
>
> V2: Minor, use "NOTE:" instead of "N.B." in comment.
>
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
> ---
>  src/gallium/auxiliary/util/u_framebuffer.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c
> index 775f050..b020f27 100644
> --- a/src/gallium/auxiliary/util/u_framebuffer.c
> +++ b/src/gallium/auxiliary/util/u_framebuffer.c
> @@ -204,9 +204,15 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)
>      * In the case of ARB_framebuffer_no_attachment
>      * we obtain the number of samples directly from
>      * the framebuffer state.
> +    *
> +    * NOTE: fb->samples may wind up as zero due to memset()'s on internal
> +    *       driver structures on their initialization and so we take the
> +    *       MAX here to ensure we have a valid number of samples. However,
> +    *       if samples is legitimately not getting set somewhere
> +    *       multi-sampling will evidently break.
>      */
>     if (!(fb->nr_cbufs || fb->zsbuf))
> -      return fb->samples;
> +      return MAX2(fb->samples, 1);
>
>     for (i = 0; i < fb->nr_cbufs; i++) {
>        if (fb->cbufs[i]) {
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list