[Mesa-dev] [PATCH 1/6] i965: Consolidate certain miptree params to flags

Matt Turner mattst88 at gmail.com
Mon Jun 1 12:39:22 PDT 2015


On Fri, May 29, 2015 at 12:33 PM, Chad Versace <chad.versace at intel.com> wrote:
> On Fri 29 May 2015, Matt Turner wrote:
>> On Thu, May 28, 2015 at 10:21 AM, Ben Widawsky
>> > @@ -286,7 +284,7 @@ intel_miptree_create_layout(struct brw_context *brw,
>> >     mt->logical_height0 = height0;
>> >     mt->logical_depth0 = depth0;
>> >     mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_NO_MCS;
>> > -   mt->disable_aux_buffers = disable_aux_buffers;
>> > +   mt->disable_aux_buffers = !!(layout_flags & MIPTREE_LAYOUT_DISABLE_AUX);
>>
>> FWIW, I much prefer (x & y) != 0 to !!(x & y).
>
> Matt, in the C code you've encountered in the wild, do you feel that
> `(x & y) != 0` is more prevalent than `!!(x & y)`? I'm curious, because
> we should probably choose the idiom which is more recognizable.
>
> For the record, I slightly prefer !! because I've encountered it often
> in idiomatic Python, but it really doesn't matter to me. I suspect that
> != 0 may be the more common idiom in C.

My quick grepping convinces me that (x & y) != 0 is a lot more common
than !!(x & y) in mesa (outside of the freedreno driver).

I think the first is cleaner since there aren't any implicit
conversions. With !!, the operators aren't even doing the same thing:
the first ! is doing an implicit conversion from int to bool and
inverting, and the second is just inverting.


More information about the mesa-dev mailing list