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

Ilia Mirkin imirkin at alum.mit.edu
Sat Mar 19 17:07:40 UTC 2016


Normally samples == 0 is perfecly valid and means "not multisampling".
Why is it invalid here?

On Sat, Mar 19, 2016 at 2:41 AM, 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.
>
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.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..c507f22 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.
> +    *
> +    * N.B., 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.0
>
> _______________________________________________
> 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