[Mesa-dev] [PATCH] i965: Don't use GCC extension for ?: with only two operands.

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Jun 24 01:11:47 PDT 2015


On Wednesday 24 June 2015 00:34:04 Kenneth Graunke wrote:
> From the "apparently I don't know C" files...GCC apparently supports:
> 
>     x ?: y
> 
> which is equivalent to
> 
>     x ? x : y
> 
> except that it doesn't cause side-effects to occur twice.  See:
> https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html#Conditionals
> 
> This was confusing and looked like a typo.  It doesn't really buy us
> anything, so just write the obvious code in normal C.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/intel_fbo.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c
> b/src/mesa/drivers/dri/i965/intel_fbo.c index 1b3a72f..d1f5770 100644
> --- a/src/mesa/drivers/dri/i965/intel_fbo.c
> +++ b/src/mesa/drivers/dri/i965/intel_fbo.c
> @@ -551,10 +551,12 @@ intel_renderbuffer_update_wrapper(struct brw_context
> *brw,
> 
>     irb->mt_layer = layer_multiplier * layer;
> 
> -   if (layered) {
> -      irb->layer_count = image->TexObject->NumLayers ?:
> mt->level[level].depth / layer_multiplier; -   } else {
> +   if (!layered) {
>        irb->layer_count = 1;
> +   } else if (image->TexObject->NumLayers > 0) {
> +      irb->layer_count = image->TexObject->NumLayers;
> +   } else {
> +      irb->layer_count = mt->level[level].depth / layer_multiplier;
>     }
> 
>     intel_miptree_reference(&irb->mt, mt);

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>

Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150624/3746d688/attachment-0001.sig>


More information about the mesa-dev mailing list