[Mesa-dev] [PATCH v2 1/5] radeon/video: don't use sub-allocated buffers

Nicolai Hähnle nhaehnle at gmail.com
Fri Sep 30 10:45:10 UTC 2016


Well, it depends on both the size and the type. Sub-allocation can be 
used up to 16KB with the current setting, but the override is clearly 
the right solution here :)

Cheers,
Nicolai

On 30.09.2016 12:24, Christian König wrote:
> Oh, so you use the allocation type instead of the size to determine if a
> buffer can be sub-allocated or not?
>
> I wasn't expecting that, in this case even the DPB would have ended up
> in the sub-allocator and that would clearly blow up immediately.
>
> Good that we stumbled over this.
>
> Regards,
> Christian.
>
> Am 30.09.2016 um 11:54 schrieb Nicolai Hähnle:
>> I should add that textures are already never sub-allocated, so with
>> this patch all the buffers used with UVD and VCE should be covered.
>>
>> Nicolai
>>
>> On 30.09.2016 11:52, Nicolai Hähnle wrote:
>>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>>
>>> Cc: Christian König <christian.koenig at amd.com>
>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97976
>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97969
>>> ---
>>>  src/gallium/drivers/radeon/r600_buffer_common.c | 3 +++
>>>  src/gallium/drivers/radeon/radeon_video.c       | 8 +++++++-
>>>  2 files changed, 10 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c
>>> b/src/gallium/drivers/radeon/r600_buffer_common.c
>>> index 9414920..4e1af92 100644
>>> --- a/src/gallium/drivers/radeon/r600_buffer_common.c
>>> +++ b/src/gallium/drivers/radeon/r600_buffer_common.c
>>> @@ -524,20 +524,23 @@ r600_alloc_buffer_struct(struct pipe_screen
>>> *screen,
>>>
>>>  struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
>>>                       const struct pipe_resource *templ,
>>>                       unsigned alignment)
>>>  {
>>>      struct r600_common_screen *rscreen = (struct
>>> r600_common_screen*)screen;
>>>      struct r600_resource *rbuffer = r600_alloc_buffer_struct(screen,
>>> templ);
>>>
>>>      r600_init_resource_fields(rscreen, rbuffer, templ->width0,
>>> alignment);
>>>
>>> +    if (templ->bind & PIPE_BIND_SHARED)
>>> +        rbuffer->flags |= RADEON_FLAG_HANDLE;
>>> +
>>>      if (!r600_alloc_resource(rscreen, rbuffer)) {
>>>          FREE(rbuffer);
>>>          return NULL;
>>>      }
>>>      return &rbuffer->b.b;
>>>  }
>>>
>>>  struct pipe_resource *r600_aligned_buffer_create(struct pipe_screen
>>> *screen,
>>>                           unsigned bind,
>>>                           unsigned usage,
>>> diff --git a/src/gallium/drivers/radeon/radeon_video.c
>>> b/src/gallium/drivers/radeon/radeon_video.c
>>> index d7c5a16..de8e11c 100644
>>> --- a/src/gallium/drivers/radeon/radeon_video.c
>>> +++ b/src/gallium/drivers/radeon/radeon_video.c
>>> @@ -59,22 +59,28 @@ unsigned rvid_alloc_stream_handle()
>>>      stream_handle ^= ++counter;
>>>      return stream_handle;
>>>  }
>>>
>>>  /* create a buffer in the winsys */
>>>  bool rvid_create_buffer(struct pipe_screen *screen, struct
>>> rvid_buffer *buffer,
>>>              unsigned size, unsigned usage)
>>>  {
>>>      memset(buffer, 0, sizeof(*buffer));
>>>      buffer->usage = usage;
>>> +
>>> +    /* Hardware buffer placement restrictions require the kernel to be
>>> +     * able to move buffers around individually, so request a
>>> +     * non-sub-allocated buffer.
>>> +     */
>>>      buffer->res = (struct r600_resource *)
>>> -        pipe_buffer_create(screen, PIPE_BIND_CUSTOM, usage, size);
>>> +        pipe_buffer_create(screen, PIPE_BIND_CUSTOM | PIPE_BIND_SHARED,
>>> +                   usage, size);
>>>
>>>      return buffer->res != NULL;
>>>  }
>>>
>>>  /* destroy a buffer */
>>>  void rvid_destroy_buffer(struct rvid_buffer *buffer)
>>>  {
>>>      r600_resource_reference(&buffer->res, NULL);
>>>  }
>>>
>>>
>


More information about the mesa-dev mailing list