[Mesa-dev] [PATCH 3/4] i965: Move add_exec_bo()

Daniel Vetter daniel at ffwll.ch
Fri Jul 7 10:19:55 UTC 2017


On Mon, Jun 19, 2017 at 11:06:49AM +0100, Chris Wilson wrote:
> To avoid a forward declaration in the next patch, move the definition of
> add_exec_bo() earlier.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Matt Turner <mattst88 at gmail.com>
> Cc: Jason Ekstrand <jason.ekstrand at intel.com>

Needs to be rebased when patch 2 is updated, but ack.
-Daniel

> ---
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c | 106 +++++++++++++-------------
>  1 file changed, 53 insertions(+), 53 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index 7129209c26..15aaf01e52 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -87,6 +87,59 @@ intel_batchbuffer_init(struct intel_batchbuffer *batch,
>     }
>  }
>  
> +#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
> +
> +static unsigned int
> +add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
> +{
> +   if (bo != batch->bo) {
> +      unsigned int index = READ_ONCE(bo->index);
> +
> +      if (index < batch->exec_count && batch->exec_bos[index] == bo)
> +         return index;
> +
> +      /* May have been shared between multiple active batches */
> +      for (index = 0; index < batch->exec_count; index++) {
> +         if (batch->exec_bos[index] == bo)
> +            return index;
> +      }
> +
> +      brw_bo_reference(bo);
> +   }
> +
> +   if (batch->exec_count == batch->exec_array_size) {
> +      batch->exec_array_size *= 2;
> +      batch->exec_bos =
> +         realloc(batch->exec_bos,
> +                 batch->exec_array_size * sizeof(batch->exec_bos[0]));
> +      batch->exec_objects =
> +         realloc(batch->exec_objects,
> +                 batch->exec_array_size * sizeof(batch->exec_objects[0]));
> +   }
> +
> +   struct drm_i915_gem_exec_object2 *validation_entry =
> +      &batch->exec_objects[batch->exec_count];
> +   validation_entry->handle = bo->gem_handle;
> +   if (bo == batch->bo) {
> +      validation_entry->relocation_count = batch->reloc_count;
> +      validation_entry->relocs_ptr = (uintptr_t) batch->relocs;
> +   } else {
> +      validation_entry->relocation_count = 0;
> +      validation_entry->relocs_ptr = 0;
> +   }
> +   validation_entry->alignment = bo->align;
> +   validation_entry->offset = bo->offset64;
> +   validation_entry->flags = bo->kflags;
> +   validation_entry->rsvd1 = 0;
> +   validation_entry->rsvd2 = 0;
> +
> +   bo->index = batch->exec_count;
> +   batch->exec_bos[batch->exec_count] = bo;
> +   batch->aperture_space += bo->size;
> +
> +   return batch->exec_count++;
> +}
> +
>  static void
>  intel_batchbuffer_reset(struct intel_batchbuffer *batch,
>                          struct brw_bufmgr *bufmgr,
> @@ -515,59 +568,6 @@ throttle(struct brw_context *brw)
>     }
>  }
>  
> -#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
> -
> -static unsigned int
> -add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
> -{
> -   if (bo != batch->bo) {
> -      unsigned int index = READ_ONCE(bo->index);
> -
> -      if (index < batch->exec_count && batch->exec_bos[index] == bo)
> -         return index;
> -
> -      /* May have been shared between multiple active batches */
> -      for (index = 0; index < batch->exec_count; index++) {
> -         if (batch->exec_bos[index] == bo)
> -            return index;
> -      }
> -
> -      brw_bo_reference(bo);
> -   }
> -
> -   if (batch->exec_count == batch->exec_array_size) {
> -      batch->exec_array_size *= 2;
> -      batch->exec_bos =
> -         realloc(batch->exec_bos,
> -                 batch->exec_array_size * sizeof(batch->exec_bos[0]));
> -      batch->exec_objects =
> -         realloc(batch->exec_objects,
> -                 batch->exec_array_size * sizeof(batch->exec_objects[0]));
> -   }
> -
> -   struct drm_i915_gem_exec_object2 *validation_entry =
> -      &batch->exec_objects[batch->exec_count];
> -   validation_entry->handle = bo->gem_handle;
> -   if (bo == batch->bo) {
> -      validation_entry->relocation_count = batch->reloc_count;
> -      validation_entry->relocs_ptr = (uintptr_t) batch->relocs;
> -   } else {
> -      validation_entry->relocation_count = 0;
> -      validation_entry->relocs_ptr = 0;
> -   }
> -   validation_entry->alignment = bo->align;
> -   validation_entry->offset = bo->offset64;
> -   validation_entry->flags = bo->kflags;
> -   validation_entry->rsvd1 = 0;
> -   validation_entry->rsvd2 = 0;
> -
> -   bo->index = batch->exec_count;
> -   batch->exec_bos[batch->exec_count] = bo;
> -   batch->aperture_space += bo->size;
> -
> -   return batch->exec_count++;
> -}
> -
>  static int
>  execbuffer(int fd,
>             struct intel_batchbuffer *batch,
> -- 
> 2.11.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the mesa-dev mailing list