[Mesa-dev] [PATCH 03/30] intel/isl: Add a helper for determining if a color is 0/1
--- src/intel/isl/isl.c | 19 +++ src/intel/isl/isl.h | 4 2 files changed, 23 insertions(+) diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c index 321850e..4eec2fd 100644 --- a/src/intel/isl/isl.c +++ b/src/intel/isl/isl.c @@ -267,6 +267,25 @@ isl_tiling_get_info(const struct isl_device *dev, return true; } +bool +isl_color_value_is_zero_one(union isl_color_value value, +enum isl_format format) +{ + if (isl_format_has_int_channel(format)) { + for (unsigned i = 0; i < 4; i++) { + if (value.u32[i] != 0 && value.u32[i] != 1) +return false; + } + } else { + for (unsigned i = 0; i < 4; i++) { + if (value.f32[i] != 0.0f && value.f32[i] != 1.0f) +return false; + } + } + + return true; +} + /** * @param[out] tiling is set only on success */ diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index acc9e77..b9d8fa8 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1370,6 +1370,10 @@ isl_extent4d(uint32_t width, uint32_t height, uint32_t depth, return e; } +bool isl_color_value_is_zero_one(union isl_color_value value, + enum isl_format format); + + #define isl_surf_init(dev, surf, ...) \ isl_surf_init_s((dev), (surf), \ &(struct isl_surf_init_info) { __VA_ARGS__ }); -- 2.5.0.400.gff86faf ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/30] intel/isl: Add a helper for determining if a color is 0/1
On Fri 26 May 2017, Jason Ekstrand wrote: > --- > src/intel/isl/isl.c | 19 +++ > src/intel/isl/isl.h | 4 > 2 files changed, 23 insertions(+) > > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c > index 321850e..4eec2fd 100644 > --- a/src/intel/isl/isl.c > +++ b/src/intel/isl/isl.c > @@ -267,6 +267,25 @@ isl_tiling_get_info(const struct isl_device *dev, > return true; > } > > +bool > +isl_color_value_is_zero_one(union isl_color_value value, > +enum isl_format format) > +{ > + if (isl_format_has_int_channel(format)) { > + for (unsigned i = 0; i < 4; i++) { This patch assumes the all four channels of isl_color_value are initialized, even if the isl_format has fewer than four channels. This smells like the seed of a hard-to-reproduce bug. Since it's not possible today to query the number of channels in an isl_format, please at least add a scary comment on the function about this. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/30] intel/isl: Add a helper for determining if a color is 0/1
On Fri, Jun 2, 2017 at 1:09 PM, Chad Versace wrote: > On Fri 26 May 2017, Jason Ekstrand wrote: > > --- > > src/intel/isl/isl.c | 19 +++ > > src/intel/isl/isl.h | 4 > > 2 files changed, 23 insertions(+) > > > > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c > > index 321850e..4eec2fd 100644 > > --- a/src/intel/isl/isl.c > > +++ b/src/intel/isl/isl.c > > @@ -267,6 +267,25 @@ isl_tiling_get_info(const struct isl_device *dev, > > return true; > > } > > > > +bool > > +isl_color_value_is_zero_one(union isl_color_value value, > > +enum isl_format format) > > +{ > > + if (isl_format_has_int_channel(format)) { > > + for (unsigned i = 0; i < 4; i++) { > > This patch assumes the all four channels of isl_color_value are > initialized, even if the isl_format has fewer than four channels. > This smells like the seed of a hard-to-reproduce bug. > > Since it's not possible today to query the number of channels in an > isl_format, please at least add a scary comment on the function about > this. > Yeah... Turns out this patch isn't actually needed for anything. I'll just drop it for now. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev