<div dir="ltr">I am working on a new version of this patch. I have one version which does away with all the bitfields, and uses<div>functions to update the index.</div><div>Another approach would be to change the union to a struct, and use a function to get the index.</div><div>Yet another approach would be to keep the contents of the union and the index in one struct, and use a function to</div><div>(re)calculate the index.</div><div><br></div><div>Which would you prefer?</div><div><br></div><div>Bas Vermeulen</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 20, 2018 at 6:33 PM, Gert Wollny <span dir="ltr"><<a href="mailto:gw.fossdev@gmail.com" target="_blank">gw.fossdev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Am Dienstag, den 20.03.2018, 15:33 +0100 schrieb Nicolai Hähnle:<br>
> Nice, did you actually get it to work entirely on a big endian<br>
> machine?<br>
><br>
</span>> Bit fields aren't super portable, [...]<br>
Indeed, the order of the bits in a bit field is compiler implementation<br>
dependent. To make sure that changing the compiler doesn't change the<br>
behaviour of the code I'd suggest that instead of using a bit field the<br>
index should be created by explicitly shifting the bits into the right<br>
positions.<br>
<br>
Best,<br>
Gert<br>
<div><div class="h5"><br>
> However, I<br>
> think we should use the PIPE_ARCH_LITTLE_ENDIAN define from<br>
> u_endian.h<br>
><br>
> Cheers,<br>
> Nicolai<br>
><br>
> On 20.03.2018 15:21, Bas Vermeulen wrote:<br>
> > Using mesa OpenCL failed on a big endian PowerPC machine because<br>
> > si_vgt_param_key is using bitfields and a 32 bit int for an<br>
> > index into an array.<br>
> ><br>
> > Fix si_vgt_param_key to work correctly on both little endian<br>
> > and big endian machines.<br>
> ><br>
> > Signed-off-by: Bas Vermeulen <<a href="mailto:bas@daedalean.ai">bas@daedalean.ai</a>><br>
> > ---<br>
> > src/gallium/drivers/radeonsi/<wbr>si_pipe.h | 13 +++++++++++++<br>
> > 1 file changed, 13 insertions(+)<br>
> ><br>
> > diff --git a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
> > b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
> > index 2053dcb9fc..32dbdf6e2c 100644<br>
> > --- a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
> > +++ b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
> > @@ -385,6 +385,7 @@ struct si_shader_ctx_state {<br>
> > */<br>
> > union si_vgt_param_key {<br>
> > struct {<br>
> > +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)<br>
> > unsigned prim:4;<br>
> > unsigned uses_instancing:1;<br>
> > unsigned<br>
> > multi_instances_smaller_than_<wbr>primgroup:1;<br>
> > @@ -395,6 +396,18 @@ union si_vgt_param_key {<br>
> > unsigned tess_uses_prim_id:1;<br>
> > unsigned uses_gs:1;<br>
> > unsigned _pad:32 - SI_NUM_VGT_PARAM_KEY_BITS;<br>
> > +#else /* __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */<br>
> > + unsigned _pad:32 - SI_NUM_VGT_PARAM_KEY_BITS;<br>
> > + unsigned uses_gs:1;<br>
> > + unsigned tess_uses_prim_id:1;<br>
> > + unsigned uses_tess:1;<br>
> > + unsigned line_stipple_enabled:1;<br>
> > + unsigned count_from_stream_output:1;<br>
> > + unsigned primitive_restart:1;<br>
> > + unsigned multi_instances_smaller_than_<wbr>primgroup:1;<br>
> > + unsigned uses_instancing:1;<br>
> > + unsigned prim:4;<br>
> > +#endif<br>
> > } u;<br>
> > uint32_t index;<br>
> > };<br>
> ><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div>