[Mesa-dev] [PATCH] swr: Templetize std::max to work on windows
Kyriazis, George
george.kyriazis at intel.com
Tue Nov 29 19:59:00 UTC 2016
> -----Original Message-----
> From: ibmirkin at gmail.com [mailto:ibmirkin at gmail.com] On Behalf Of Ilia
> Mirkin
> Sent: Tuesday, November 29, 2016 1:54 PM
> To: Kyriazis, George <george.kyriazis at intel.com>
> Cc: mesa-dev at lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH] swr: Templetize std::max to work on
> windows
>
> How about just making 'layers' unsigned? (Hm, I wonder why this didn't
> trigger issues with gcc... maybe it should be +1u instead of +1?)
>
Could do that, too, but there are other places in our code that use templetized versions of std::max.
I guess gcc prioritizes implicit casts... +1u does not help, since the last_layer/first_layer fields are already unsigned. It's the int vs unsigned type mismatch that caused the issue.
George
> On Tue, Nov 29, 2016 at 2:46 PM, George Kyriazis
> <george.kyriazis at intel.com> wrote:
> > ---
> > src/gallium/drivers/swr/swr_clear.cpp | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/gallium/drivers/swr/swr_clear.cpp
> > b/src/gallium/drivers/swr/swr_clear.cpp
> > index f59179f..e752ee0 100644
> > --- a/src/gallium/drivers/swr/swr_clear.cpp
> > +++ b/src/gallium/drivers/swr/swr_clear.cpp
> > @@ -46,20 +46,20 @@ swr_clear(struct pipe_context *pipe,
> > for (unsigned i = 0; i < fb->nr_cbufs; ++i)
> > if (fb->cbufs[i] && (buffers & (PIPE_CLEAR_COLOR0 << i))) {
> > clearMask |= (SWR_ATTACHMENT_COLOR0_BIT << i);
> > - layers = std::max(layers, fb->cbufs[i]->u.tex.last_layer -
> > + layers = std::max<int>(layers,
> > + fb->cbufs[i]->u.tex.last_layer -
> > fb->cbufs[i]->u.tex.first_layer + 1);
> > }
> > }
> >
> > if (buffers & PIPE_CLEAR_DEPTH && fb->zsbuf) {
> > clearMask |= SWR_ATTACHMENT_DEPTH_BIT;
> > - layers = std::max(layers, fb->zsbuf->u.tex.last_layer -
> > + layers = std::max<int>(layers, fb->zsbuf->u.tex.last_layer -
> > fb->zsbuf->u.tex.first_layer + 1);
> > }
> >
> > if (buffers & PIPE_CLEAR_STENCIL && fb->zsbuf) {
> > clearMask |= SWR_ATTACHMENT_STENCIL_BIT;
> > - layers = std::max(layers, fb->zsbuf->u.tex.last_layer -
> > + layers = std::max<int>(layers, fb->zsbuf->u.tex.last_layer -
> > fb->zsbuf->u.tex.first_layer + 1);
> > }
> >
> > --
> > 2.7.4
> >
> > _______________________________________________
> > 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