[Nouveau] [PATCH 1/2] drm/nv50: align size of buffer object to the right boundaries.

Maarten Maathuis madman2003 at gmail.com
Sun Dec 27 13:36:02 PST 2009


To avoid any confusion, "make sure your buffers are large enough"
means you shouldn't go allocating very small depth/stencil buffers,
because that will waste space. Userspace should never have to worry
about the restrictions themselves.

Maarten.

On Sun, Dec 27, 2009 at 3:28 PM, Maarten Maathuis <madman2003 at gmail.com> wrote:
> On Sun, Dec 27, 2009 at 2:43 PM, Christoph Bumiller
> <e0425955 at student.tuwien.ac.at> wrote:
>> On 12/27/2009 12:41 PM, Maarten Maathuis wrote:
>>> - Depth and stencil buffers are supposed to be large enough in general.
>>>
>>> Signed-off-by: Maarten Maathuis <madman2003 at gmail.com>
>>> ---
>>>  drivers/gpu/drm/nouveau/nouveau_bo.c |    9 ++++-----
>>>  1 files changed, 4 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
>>> index e342a41..9fc4bd6 100644
>>> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
>>> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
>>> @@ -65,8 +65,9 @@ nouveau_bo_fixup_align(struct drm_device *dev,
>>>
>>>       /*
>>>        * Some of the tile_flags have a periodic structure of N*4096 bytes,
>>> -      * align to to that as well as the page size. Overallocate memory to
>>> -      * avoid corruption of other buffer objects.
>>> +      * align to to that as well as the page size. Align the size to the
>>> +      * appropriate boundaries. This does imply that sizes are rounded up
>>> +      * 3-7 pages, so make sure your "special" buffer sizes are large enough.
>>>        */
>> No - 16x16 depth textures or whatever crazy idea some app might have
>> won't be large enough.
>> Taking care of size in userspace and of alignment in kernel ... not nice
>> to split in my opinion.
>
> Userspace doesn't know all constraints, so the kernel has to do
> something. How to deal with these limitations is another question.
> Either we over allocate (and hide the overallocation from everyone),
> align the size, or we try to make the allocator smarter to group them
> together based on their tile flags.
>
>>>       if (dev_priv->card_type == NV_50) {
>>>               uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15;
>>> @@ -77,22 +78,20 @@ nouveau_bo_fixup_align(struct drm_device *dev,
>>>               case 0x2800:
>>>               case 0x4800:
>>>               case 0x7a00:
>>> -                     *size = roundup(*size, block_size);
>>>                       if (is_power_of_2(block_size)) {
>>> -                             *size += 3 * block_size;
>>>                               for (i = 1; i < 10; i++) {
>>>                                       *align = 12 * i * block_size;
>>>                                       if (!(*align % 65536))
>>>                                               break;
>>>                               }
>>>                       } else {
>>> -                             *size += 6 * block_size;
>>>                               for (i = 1; i < 10; i++) {
>>>                                       *align = 8 * i * block_size;
>>>                                       if (!(*align % 65536))
>>>                                               break;
>>>                               }
>>>                       }
>>> +                     *size = roundup(*size, *align);
>>>                       break;
>>>               default:
>>>                       break;
>>
>>
>


More information about the Nouveau mailing list