[Mesa-dev] [PATCH 10/21] winsys/amdgpu: extract amdgpu_do_add_real_buffer

Marek Olšák maraeo at gmail.com
Fri Feb 10 22:07:30 UTC 2017


Assuming you address other people's comments, the first 10 are:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek


On Wed, Feb 8, 2017 at 1:42 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> We will use it for delayed adding of sparse buffers' backing buffers.
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> index 9d5b0bd..7d16ca2 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> @@ -315,15 +315,10 @@ int amdgpu_lookup_buffer(struct amdgpu_cs_context *cs, struct amdgpu_winsys_bo *
>  }
>
>  static int
> -amdgpu_lookup_or_add_real_buffer(struct amdgpu_cs *acs, struct amdgpu_winsys_bo *bo)
> +amdgpu_do_add_real_buffer(struct amdgpu_cs_context *cs, struct amdgpu_winsys_bo *bo)
>  {
> -   struct amdgpu_cs_context *cs = acs->csc;
>     struct amdgpu_cs_buffer *buffer;
> -   unsigned hash;
> -   int idx = amdgpu_lookup_buffer(cs, bo);
> -
> -   if (idx >= 0)
> -      return idx;
> +   int idx;
>
>     /* New buffer, check if the backing array is large enough. */
>     if (cs->num_real_buffers >= cs->max_real_buffers) {
> @@ -338,7 +333,7 @@ amdgpu_lookup_or_add_real_buffer(struct amdgpu_cs *acs, struct amdgpu_winsys_bo
>        new_flags = MALLOC(new_max * sizeof(*new_flags));
>
>        if (!new_buffers || !new_handles || !new_flags) {
> -         fprintf(stderr, "amdgpu_lookup_or_add_buffer: allocation failed\n");
> +         fprintf(stderr, "amdgpu_do_add_buffer: allocation failed\n");
>           FREE(new_buffers);
>           FREE(new_handles);
>           FREE(new_flags);
> @@ -369,6 +364,21 @@ amdgpu_lookup_or_add_real_buffer(struct amdgpu_cs *acs, struct amdgpu_winsys_bo
>     p_atomic_inc(&bo->num_cs_references);
>     cs->num_real_buffers++;
>
> +   return idx;
> +}
> +
> +static int
> +amdgpu_lookup_or_add_real_buffer(struct amdgpu_cs *acs, struct amdgpu_winsys_bo *bo)
> +{
> +   struct amdgpu_cs_context *cs = acs->csc;
> +   unsigned hash;
> +   int idx = amdgpu_lookup_buffer(cs, bo);
> +
> +   if (idx >= 0)
> +      return idx;
> +
> +   idx = amdgpu_do_add_real_buffer(cs, bo);
> +
>     hash = bo->unique_id & (ARRAY_SIZE(cs->buffer_indices_hashlist)-1);
>     cs->buffer_indices_hashlist[hash] = idx;
>
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list