Re: [Mesa-dev] [PATCH] anv/formats: Fix build on gcc-4 and earlier

2016-10-03 Thread Ville Syrjälä
On Fri, Sep 30, 2016 at 04:11:51PM -0700, Jason Ekstrand wrote:
> I remember the first tone you fixed this but when I was going the
> ISL_SWIZZLE stuff,

Wasn't me, or at least I can't recall doing anything of the sort :)

> I couldn't find it in the git log so I went ahead and
> pushed the change. Thanks for fixing it again.
> 
> Reviewed-by: Jason Ekstrand 

Thanks. Pushed.

> 
> On Sep 30, 2016 1:00 PM,  wrote:
> 
> > From: Ville Syrjälä 
> >
> > gcc-4 and earlier don't allow compound literals where a constant
> > is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
> > when populating the anv_formats[] array. There are a few ways around
> > it: First one would be -std=c89/gnu89, but the rest of the code
> > depends on c99 so it's not really an option. The second option
> > would be to upgrade to gcc-5+ where the compiler behaviour was relaxed
> > a bit [1]. And the third option is just to avoid using compound
> > literals. I chose the last option since it keeps gcc-4 and earlier
> > working.
> >
> > [1] https://gcc.gnu.org/gcc-5/porting_to.html
> >
> > Cc: Jason Ekstrand 
> > Cc: Topi Pohjolainen 
> > Fixes: 7ddb21708c80 ("intel/isl: Add an isl_swizzle structure and use it
> > for isl_view swizzles")
> > Signed-off-by: Ville Syrjälä 
> > ---
> >  src/intel/vulkan/anv_formats.c | 23 +++
> >  1 file changed, 19 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> > formats.c
> > index 7341d725cd0a..f6915540fb3d 100644
> > --- a/src/intel/vulkan/anv_formats.c
> > +++ b/src/intel/vulkan/anv_formats.c
> > @@ -24,9 +24,24 @@
> >  #include "anv_private.h"
> >  #include "vk_format_info.h"
> >
> > -#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
> > -#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
> > -#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
> > +/*
> > + * gcc-4 and earlier don't allow compound literals where a constant
> > + * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
> > + * here. -std=c89/gnu89 would allow it, but we depend on c99 features
> > + * so using -std=c89/gnu89 is not an option. Starting from gcc-5
> > + * compound literals can also be considered constant in -std=c99/gnu99
> > + * mode.
> > + */
> > +#define _ISL_SWIZZLE(r, g, b, a) { \
> > +  ISL_CHANNEL_SELECT_##r, \
> > +  ISL_CHANNEL_SELECT_##g, \
> > +  ISL_CHANNEL_SELECT_##b, \
> > +  ISL_CHANNEL_SELECT_##a, \
> > +}
> > +
> > +#define RGBA _ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
> > +#define BGRA _ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
> > +#define RGB1 _ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
> >
> >  #define swiz_fmt(__vk_fmt, __hw_fmt, __swizzle) \
> > [__vk_fmt] = { \
> > @@ -276,7 +291,7 @@ anv_get_format(const struct gen_device_info *devinfo,
> > VkFormat vk_format,
> >   format.isl_format = rgbx;
> >} else {
> >   format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
> > - format.swizzle = RGB1;
> > + format.swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
> >}
> > }
> >
> > --
> > 2.7.4
> >
> >

-- 
Ville Syrjälä
Intel OTC
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] anv/formats: Fix build on gcc-4 and earlier

2016-09-30 Thread Jason Ekstrand
I remember the first tone you fixed this but when I was going the
ISL_SWIZZLE stuff, I couldn't find it in the git log so I went ahead and
pushed the change. Thanks for fixing it again.

Reviewed-by: Jason Ekstrand 

On Sep 30, 2016 1:00 PM,  wrote:

> From: Ville Syrjälä 
>
> gcc-4 and earlier don't allow compound literals where a constant
> is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
> when populating the anv_formats[] array. There are a few ways around
> it: First one would be -std=c89/gnu89, but the rest of the code
> depends on c99 so it's not really an option. The second option
> would be to upgrade to gcc-5+ where the compiler behaviour was relaxed
> a bit [1]. And the third option is just to avoid using compound
> literals. I chose the last option since it keeps gcc-4 and earlier
> working.
>
> [1] https://gcc.gnu.org/gcc-5/porting_to.html
>
> Cc: Jason Ekstrand 
> Cc: Topi Pohjolainen 
> Fixes: 7ddb21708c80 ("intel/isl: Add an isl_swizzle structure and use it
> for isl_view swizzles")
> Signed-off-by: Ville Syrjälä 
> ---
>  src/intel/vulkan/anv_formats.c | 23 +++
>  1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> formats.c
> index 7341d725cd0a..f6915540fb3d 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -24,9 +24,24 @@
>  #include "anv_private.h"
>  #include "vk_format_info.h"
>
> -#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
> -#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
> -#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
> +/*
> + * gcc-4 and earlier don't allow compound literals where a constant
> + * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
> + * here. -std=c89/gnu89 would allow it, but we depend on c99 features
> + * so using -std=c89/gnu89 is not an option. Starting from gcc-5
> + * compound literals can also be considered constant in -std=c99/gnu99
> + * mode.
> + */
> +#define _ISL_SWIZZLE(r, g, b, a) { \
> +  ISL_CHANNEL_SELECT_##r, \
> +  ISL_CHANNEL_SELECT_##g, \
> +  ISL_CHANNEL_SELECT_##b, \
> +  ISL_CHANNEL_SELECT_##a, \
> +}
> +
> +#define RGBA _ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
> +#define BGRA _ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
> +#define RGB1 _ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
>
>  #define swiz_fmt(__vk_fmt, __hw_fmt, __swizzle) \
> [__vk_fmt] = { \
> @@ -276,7 +291,7 @@ anv_get_format(const struct gen_device_info *devinfo,
> VkFormat vk_format,
>   format.isl_format = rgbx;
>} else {
>   format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
> - format.swizzle = RGB1;
> + format.swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
>}
> }
>
> --
> 2.7.4
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] anv/formats: Fix build on gcc-4 and earlier

2016-09-30 Thread ville . syrjala
From: Ville Syrjälä 

gcc-4 and earlier don't allow compound literals where a constant
is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
when populating the anv_formats[] array. There are a few ways around
it: First one would be -std=c89/gnu89, but the rest of the code
depends on c99 so it's not really an option. The second option
would be to upgrade to gcc-5+ where the compiler behaviour was relaxed
a bit [1]. And the third option is just to avoid using compound
literals. I chose the last option since it keeps gcc-4 and earlier
working.

[1] https://gcc.gnu.org/gcc-5/porting_to.html

Cc: Jason Ekstrand 
Cc: Topi Pohjolainen 
Fixes: 7ddb21708c80 ("intel/isl: Add an isl_swizzle structure and use it for 
isl_view swizzles")
Signed-off-by: Ville Syrjälä 
---
 src/intel/vulkan/anv_formats.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 7341d725cd0a..f6915540fb3d 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -24,9 +24,24 @@
 #include "anv_private.h"
 #include "vk_format_info.h"
 
-#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
-#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
-#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
+/*
+ * gcc-4 and earlier don't allow compound literals where a constant
+ * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
+ * here. -std=c89/gnu89 would allow it, but we depend on c99 features
+ * so using -std=c89/gnu89 is not an option. Starting from gcc-5
+ * compound literals can also be considered constant in -std=c99/gnu99
+ * mode.
+ */
+#define _ISL_SWIZZLE(r, g, b, a) { \
+  ISL_CHANNEL_SELECT_##r, \
+  ISL_CHANNEL_SELECT_##g, \
+  ISL_CHANNEL_SELECT_##b, \
+  ISL_CHANNEL_SELECT_##a, \
+}
+
+#define RGBA _ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
+#define BGRA _ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
+#define RGB1 _ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
 
 #define swiz_fmt(__vk_fmt, __hw_fmt, __swizzle) \
[__vk_fmt] = { \
@@ -276,7 +291,7 @@ anv_get_format(const struct gen_device_info *devinfo, 
VkFormat vk_format,
  format.isl_format = rgbx;
   } else {
  format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
- format.swizzle = RGB1;
+ format.swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
   }
}
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev