[Mesa-dev] [PATCH 19/23] i965/fs: Use next_insn_offset rather than nr_insn.

Kenneth Graunke kenneth at whitecape.org
Thu May 22 15:58:50 PDT 2014


On 05/19/2014 11:55 AM, Matt Turner wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_fs_generator.cpp  | 4 ++--
>  src/mesa/drivers/dri/i965/gen8_fs_generator.cpp | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> index 872b5a4..914fb29 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> @@ -1843,12 +1843,12 @@ fs_generator::generate_assembly(exec_list *simd8_instructions,
>  
>     if (simd16_instructions) {
>        /* align to 64 byte boundary. */
> -      while ((p->nr_insn * sizeof(struct brw_instruction)) % 64) {
> +      while (p->next_insn_offset % 64) {
>           brw_NOP(p);
>        }

So, I wondered how this worked (before and after your change).  In
theory, we could have an odd number of compacted instructions, giving us
a next_insn_offset of (64*n + 2).  Emitting uncompacted NOPs adds 4
bytes each time, which would never get us to a multiple of 64.

Apparently, this doesn't happen because sendc cannot be compacted and
must be aligned on a 128-bit/4-byte boundary.  So, it works.

Someday we should probably just do:
   p->next_insn_offset = ALIGN(p->next_insn_offset, 64);
and memset to 0 between the two programs.

In the meantime, this seems better than the existing code.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>  
>        /* Save off the start of this SIMD16 program */
> -      prog_data->prog_offset_16 = p->nr_insn * sizeof(struct brw_instruction);
> +      prog_data->prog_offset_16 = p->next_insn_offset;
>  
>        brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
>  
> diff --git a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
> index 9011bff..272f668 100644
> --- a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp
> @@ -1330,11 +1330,11 @@ gen8_fs_generator::generate_assembly(exec_list *simd8_instructions,
>  
>     if (simd16_instructions) {
>        /* Align to a 64-byte boundary. */
> -      while ((nr_inst * sizeof(gen8_instruction)) % 64)
> +      while (next_inst_offset % 64)
>           NOP();
>  
>        /* Save off the start of this SIMD16 program */
> -      prog_data->prog_offset_16 = nr_inst * sizeof(gen8_instruction);
> +      prog_data->prog_offset_16 = next_inst_offset;
>  
>        struct annotation *annotation;
>        int num_annotations;
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140522/46f75c26/attachment.sig>


More information about the mesa-dev mailing list