[Mesa-dev] [PATCH 09/11] i965/eu: Refactor jump distance scaling to use a helper function.
Matt Turner
mattst88 at gmail.com
Sun Aug 10 01:47:31 PDT 2014
On Sat, Aug 9, 2014 at 2:28 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Different generations of hardware measure jump distances in different
> units. Previously, every function that needed to set a jump target open
> coded this scaling, or made a hardcoded assumption (i.e. just used 2).
>
> Most functions start with the number of instructions to jump, and scale
> up to the hardware-specific value. So, I made the function match that.
>
> Others start with a byte offset, and divide by a constant (8) to obtain
> the jump distance. This is actually 16 / 2 (the jump scale for Gen5-7).
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/mesa/drivers/dri/i965/brw_eu.h | 2 ++
> src/mesa/drivers/dri/i965/brw_eu_emit.c | 42 +++++++++++++++++---------
> src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 8 +++--
> 3 files changed, 35 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
> index 7efc028..fdf6e4c 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu.h
> +++ b/src/mesa/drivers/dri/i965/brw_eu.h
> @@ -316,6 +316,8 @@ void brw_shader_time_add(struct brw_compile *p,
> struct brw_reg payload,
> uint32_t surf_index);
>
> +unsigned brw_jump_scale(const struct brw_context *brw);
> +
> /* If/else/endif. Works by manipulating the execution flags on each
> * channel.
> */
> diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> index 665fc07..3d9c96a 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
> +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
> @@ -1170,6 +1170,27 @@ void brw_NOP(struct brw_compile *p)
> * Comparisons, if/else/endif
> */
>
> +/**
> + * Return the generation-specific jump distance scaling factor.
> + *
> + * Given the number of instructions to jump, we need to scale by
> + * some number to obtain the actual jump distance to program in an
> + * instruction.
> + */
> +unsigned
> +brw_jump_scale(const struct brw_context *brw)
> +{
> + /* Ironlake and later measure jump targets in 64-bit data chunks (in order
> + * (to support compaction), so each 128-bit instruction requires 2 chunks.
> + */
> + if (brw->gen >= 5)
> + return 2;
> +
> + /* Gen4 simply uses the number of 128-bit instructions. */
> + return 1;
> +}
I'd probably put the body of the function in brw_eu.h and let it be
inlined, since it's so simple.
More information about the mesa-dev
mailing list