[Mesa-dev] [PATCH 4/9] i965: Factor out oword block read and write message control calculation.

Kenneth Graunke kenneth at whitecape.org
Mon Dec 12 05:55:54 UTC 2016


On Sunday, December 11, 2016 5:44:03 PM PST Francisco Jerez wrote:
> Kenneth Graunke <kenneth at whitecape.org> writes:
> 
> > On Friday, December 9, 2016 11:03:27 AM PST Francisco Jerez wrote:
> >> We'll need roughly the same logic in other places and it would be
> >> annoying to duplicate it.  Instead factor it out into a function-like
> >> macro that takes the number of dwords per block (which will prove more
> >> convenient than taking the same value in owords or some other unit).
> >> ---
> >>  src/mesa/drivers/dri/i965/brw_defines.h |  6 ++++++
> >>  src/mesa/drivers/dri/i965/brw_eu_emit.c | 14 ++------------
> >>  2 files changed, 8 insertions(+), 12 deletions(-)
> >> 
> >> diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
> >> index cae8e9a..1c638a0 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_defines.h
> >> +++ b/src/mesa/drivers/dri/i965/brw_defines.h
> >> @@ -1669,6 +1669,12 @@ enum brw_message_target {
> >>  #define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS     2
> >>  #define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS     3
> >>  #define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS     4
> >> +#define BRW_DATAPORT_OWORD_BLOCK_DWORDS(n)              \
> >> +   ((n) == 4 ? BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW :    \
> >> +    (n) == 8 ? BRW_DATAPORT_OWORD_BLOCK_2_OWORDS :      \
> >> +    (n) == 16 ? BRW_DATAPORT_OWORD_BLOCK_4_OWORDS :     \
> >> +    (n) == 32 ? BRW_DATAPORT_OWORD_BLOCK_8_OWORDS :     \
> >> +    (abort(), ~0))
> >
> > How about:
> >
> > #define BRW_DATAPORT_OWORD_BLOCK_DWORDS(n) \
> >    (assert(n == 4 || n == 8 || n == 16 || n == 32), ffs(n) - 3)
> >
> 
> I don't think that would work for n > 4 due to the rather unfortunate
> hardware encoding, e.g. BRW_DATAPORT_OWORD_BLOCK_2_OWORDS is supposed to
> be encoded as 2 but your macro would give 1 as result. :|

Whoops.  I suppose you could do:

#define BRW_DATAPORT_OWORD_BLOCK_DWORDS(n) \
   ((n) == 4 ? 0 : (assert(n == 8 || n == 16 || n == 32), ffs(n) - 2))

but I'm not sure that's that much better...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161211/a350e2cf/attachment.sig>


More information about the mesa-dev mailing list