Hi,

On Friday, 2 November 2018 06:22:13 CET Dave Airlie wrote:
> On Tue, 23 Oct 2018 at 10:57, Eric Anholt <e...@anholt.net> wrote:
> >
> > Eric Engestrom <eric.engest...@intel.com> writes:
> >
> > > Fixes errors thrown by GCC's Undefined Behaviour sanitizer (ubsan) every
> > > time this macro is used.
> 
> This seems to be causing problems for me here on gcc8 (8.0.1 and
> 8.2.1) in Fedora 28.
> 
> ./bin/texelFetch fs usampler2DMS 2
> 
> is failing here with:
> Failed to compile fragment shader: 0:6(1): error: invalid input layout
> qualifier used
> 
> gcc is probably broken, but we might want to revert his from the tree
> and upcoming release until we can figure it out.

I have been experiencing something similar on fedora 28.

The observation is that gcc-8.2.1-3 works correct and gcc-8.2.1-4 does
show this problem. So for myself I have been nailing down the rpm version
of the gcc packet not to update. That helps as first aid but is not exactly 
nice.

There is now also a reduced source that does not require a full mesa compile
to ease a bug report. The file is attached here. You need -O2 to make it fail.

Before filing a bug report at gcc I wanted to verify that we are not doing 
anything
wrong like with aliasing for example. Which is the reason the bug is not filed 
yet.

Now, I don't find time to put more work into that at the weekend and
probably also not next week. So if anybody of you wants accelerate the process,
double checks that we don't do something wrong and hand that over to gcc
I would not mind!

There is also an observation that the new gcc rpm includes the fix for gcc
bug 87137 that actually turns out to be a bitfield layouting problem.
If fedora wants to experiment with a fedora only fix its probably a good
starting point to check if omitting the corresponding patch for bug 87137
does actually help on linux. Well that is pure speculation from my side.

... so far the dump from my side on that problem.

best

Mathias
#include <iostream>

#include <cstring>

#define BITSET_WORD unsigned int
#define BITSET_WORDBITS (sizeof (BITSET_WORD) * 8)
#define BITSET_WORDS(bits) (((bits) + BITSET_WORDBITS - 1) / BITSET_WORDBITS)
#define BITSET_EQUAL(x, y) (std::memcmp( (x), (y), sizeof (x) ) == 0)

#define DECLARE_BITSET_T(T, N) struct T {                       \
                                                                \
      T &                                                       \
      operator=(int x)                                          \
      {                                                         \
         const T c = {{ (BITSET_WORD)x }};                      \
         return *this = c;                                      \
      }                                                         \
                                                                \
      friend bool                                               \
      operator==(const T &b, const T &c)                        \
      {                                                         \
         return BITSET_EQUAL(b.words, c.words);                 \
      }                                                         \
                                                                \
      friend bool                                               \
      operator!=(const T &b, const T &c)                        \
      {                                                         \
         return !(b == c);                                      \
      }                                                         \
                                                                \
      friend bool                                               \
      operator==(const T &b, int x)                             \
      {                                                         \
         const T c = {{ (BITSET_WORD)x }};                      \
         return b == c;                                         \
      }                                                         \
                                                                \
      friend bool                                               \
      operator!=(const T &b, int x)                             \
      {                                                         \
         return !(b == x);                                      \
      }                                                         \
                                                                \
      friend T                                                  \
      operator~(const T &b)                                     \
      {                                                         \
         T c;                                                   \
         for (unsigned i = 0; i < BITSET_WORDS(N); i++)         \
            c.words[i] = ~b.words[i];                           \
         return c;                                              \
      }                                                         \
                                                                \
      T &                                                       \
      operator&=(const T &b)                                    \
      {                                                         \
         for (unsigned i = 0; i < BITSET_WORDS(N); i++)         \
            words[i] &= b.words[i];                             \
         return *this;                                          \
      }                                                         \
                                                                \
      friend T                                                  \
      operator&(const T &b, const T &c)                         \
      {                                                         \
         T d = b;                                               \
         d &= c;                                                \
         return d;                                              \
      }                                                         \
                                                                \
      BITSET_WORD words[BITSET_WORDS(N)];                       \
   }


struct ast_type_qualifier {
   DECLARE_BITSET_T(bitset_t, 4);

   union flags {
      struct {
         unsigned in:1;
         unsigned out:1;
         unsigned flat:1;
         unsigned non_coherent:1;
      }
      q;

      bitset_t i;
   } flags;

   void blah();
};

void
ast_type_qualifier::blah()
{
  ast_type_qualifier input_layout_mask;
  input_layout_mask.flags.i = 0;
  input_layout_mask.flags.q.flat = 1;
  input_layout_mask.flags.q.in = 1;
  input_layout_mask.flags.q.out = 1;
  input_layout_mask.flags.q.non_coherent = 1;

  if (this->flags.q.in &&
      (this->flags.i & ~input_layout_mask.flags.i) != 0) {
    std::cout << "fail" << std::endl;
    exit(EXIT_FAILURE);
  }
}

int
main()
{
  ast_type_qualifier a;
  a.flags.i = 0;
  a.flags.q.out = 1;
  a.flags.q.in = 1;

  a.blah();

  return 0;
}
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to