On Wed, Mar 22, 2017 at 2:02 PM, Chad Versace <chadvers...@chromium.org> wrote:
> On Wed 22 Mar 2017, Jason Ekstrand wrote: > > Wow... This is an impressive quantity of infastructure just to get the > > number of bits in a field... > > In the initial patch, I hand-wrote macros and functions. And I made > mistakes. That's when I decided to eliminate the mistakes with > generation. That's why we have the genxml, after all. > > > On Tue, Mar 21, 2017 at 4:02 PM, Chad Versace <chadvers...@chromium.org> > > wrote: > > > > > + REGEX = re.compile('^#define (?P<token_name>GEN(?P<gen>[0- > > > 9]+)_(?P<token_basename>\w*Surface(Q?)Pitch)_bits).*$') > > > > > > > Can we please not use XML to generate a header and then use regex to > parse > > the header? Let's just use XML for both. > > > > I hate to ask for a rewrite, but you should have seen that coming... > > Argh... yes, I knew it was coming. Yes, I knew I shouldn't have. But it > was SOOOO easy. > > Now that I've had time to ponder my sin, I no longer want to maintain > a giant pile of Python "just to get the number of bits in a field". Let > me propose an alternative: Keep the Python changes to gen_pack_header.py > that emits the GEN_*Pitch_bits macros, but hand-write the genX_bits.h > headers. I think that's good compromise. What do you think? > Seems reasonable. You can even do a #define like so: #define GENX_BITS_DECLARE_LOOKUP(field) \ static inline uint32_t \ field##_bits(const struct gen_device_info *devinfo) \ { \ switch (devinfo->gen) { case 4: return devinfo->is_g4x ? GEN4_##field##_bits : GEN45_##field##_bits; case 5: return GEN5_##field##_bits; case 6: return GEN6_##field##_bits; case 7: return devinfo->is_haswell ? GEN75_##field##_bits : GEN7_##field##_bits; case 8: return GEN8_##field##_bits; case 9: return GEN9_##field##_bits; } } GENX_BITS_DECLARE_LOOKUP(RENDER_SURFACE_STATE_SurfacePitch) Unfortunately, this won't be able to deal with field renames but I think the right way to deal with that is to just fix the XML. Also, I didn't think you actually could include all of the genX_pack headers at the same time due to name conflicts. Is this not true?
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev