<div dir="ltr">The gralloc stride returned from alloc isn't required to be the actual stride of the buffer, it only needs to be the stride of the staging buffer when locked, though I suppose that does mean that it is intended to be invariant across the life of the buffer.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 2, 2016 at 12:05 PM, Rob Clark <span dir="ltr"><<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is for the non-zero-copy case.. for example pixels live in gl<br>
texture in host (vmwgfx/virtgl), or in vram for discrete gpu perhaps<br>
(or some tiled format, etc).<br>
<br>
Since in those cases, you have to copy part of the buffer, as<br>
specified by the bounding box, to and/or from staging buffer (based on<br>
read/write flags).. You'd prefer that the pitch of the returned ptr<br>
was not required to match the pitch of the original buffer.<br>
<br>
BR,<br>
-R<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, May 2, 2016 at 2:16 PM, Dan Stoza <<a href="mailto:stoza@google.com">stoza@google.com</a>> wrote:<br>
> Would it be possible for someone to elaborate a bit on the limitation<br>
> gralloc is imposing? Is it a mismatch between reported stride and the actual<br>
> stride of the buffer?<br>
><br>
> On Mon, May 2, 2016 at 11:07 AM, Greg Hackmann <<a href="mailto:ghackmann@google.com">ghackmann@google.com</a>> wrote:<br>
>><br>
>> On 05/01/2016 11:58 PM, Daniel Vetter wrote:<br>
>>><br>
>>> Adding Greg Hackmann from the Android side. Greg, please add anyone<br>
>>> else who might be relevant.<br>
>>><br>
>>> On Sat, Apr 30, 2016 at 2:54 PM, Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br>
>>>><br>
>>>> On Sat, Apr 30, 2016 at 8:26 AM, Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br>
>>>>><br>
>>>>> On Sat, Apr 30, 2016 at 1:55 PM, Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br>
>>>>>><br>
>>>>>> On Sat, Apr 30, 2016 at 5:39 AM, Michel Dänzer <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>><br>
>>>>>> wrote:<br>
>>>>>>><br>
>>>>>>> On <a href="tel:26.04.2016%2003" value="+12604201603">26.04.2016 03</a>:51, Rob Herring wrote:<br>
>>>>>>>><br>
>>>>>>>> On Mon, Apr 25, 2016 at 9:25 AM, Emil Velikov<br>
>>>>>>>> <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>> wrote:<br>
>>>>>>>>><br>
>>>>>>>>> On 25 April 2016 at 13:46, Daniel Stone <<a href="mailto:daniel@fooishbar.org">daniel@fooishbar.org</a>><br>
>>>>>>>>> wrote:<br>
>>>>>>>>>><br>
>>>>>>>>>> On 23 April 2016 at 03:08, Rob Herring <<a href="mailto:robh@kernel.org">robh@kernel.org</a>> wrote:<br>
>>>>>>>>>>><br>
>>>>>>>>>>> On Fri, Apr 22, 2016 at 6:32 PM, Emil Velikov<br>
>>>>>>>>>>> <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>> wrote:<br>
>>>>>>>>>>>><br>
>>>>>>>>>>>> Can we take a look at the GBM gralloc as well. One thing that<br>
>>>>>>>>>>>> worries<br>
>>>>>>>>>>>> me is that (most likely) you are requesting/creating a bo<br>
>>>>>>>>>>>> without<br>
>>>>>>>>>>>> GBM_BO_USE_WRITE whist using MAP + CPU write UNMAP. If you do<br>
>>>>>>>>>>>> set the<br>
>>>>>>>>>>>> USE_WRITE flag, you're getting a dumb buffer, which I'm not sure<br>
>>>>>>>>>>>> how<br>
>>>>>>>>>>>> well is going to work.<br>
>>>>>>>>>>><br>
>>>>>>>>>>><br>
>>>>>>>>>>> I'm not using GBM_BO_USE_WRITE and that is not a condition for<br>
>>>>>>>>>>> mapping<br>
>>>>>>>>>>> given that flag is tied to cursors (according to comments) and<br>
>>>>>>>>>>> gives<br>
>>>>>>>>>>> dumb buffers. Also of note, if gralloc flags are set for r/w<br>
>>>>>>>>>>> often,<br>
>>>>>>>>>>> then I request a linear buffer. Here's the gralloc side:<br>
>>>>>>>>>><br>
>>>>>>>>>><br>
>>>>>>>>>> Right, I wouldn't take GBM_BO_USE_WRITE to have much of an effect<br>
>>>>>>>>>> on<br>
>>>>>>>>>> mappings, as it pessimises allocation like you say.<br>
>>>>>>>>>><br>
>>>>>>>>> Ftr, I'm not objecting as to how things are done. Just saying that<br>
>>>>>>>>> things should be blindly obvious as one reads the documentation<br>
>>>>>>>>> alone.<br>
>>>>>>>>> I'm assuming that most people involved are "tainted" (the know to a<br>
>>>>>>>>> level how things are implemented) thus things are clearer for them.<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> I'm not sure what to document here other than the use flags have no<br>
>>>>>>>> impact or restrictions on mapping. If that's not true, then that is<br>
>>>>>>>> a<br>
>>>>>>>> limitation within the gallium drivers of which I have little<br>
>>>>>>>> knowledge<br>
>>>>>>>> about and need someone tainted to spell out. I suppose documenting<br>
>>>>>>>> that buffers with frequent cpu access should use a linear buffer<br>
>>>>>>>> would<br>
>>>>>>>> be universally true?<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> It's actually stricter than that with the radeonsi driver: It sets<br>
>>>>>>> the<br>
>>>>>>> RADEON_GEM_NO_CPU_ACCESS/AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag when<br>
>>>>>>> allocating non-linear buffers, signalling to the kernel driver that<br>
>>>>>>> CPU<br>
>>>>>>> access to the buffer doesn't need to work. At least the amdgpu kernel<br>
>>>>>>> driver actually enforces this and returns an error if userspace tries<br>
>>>>>>> mapping such a buffer.<br>
>>>>>>><br>
>>>>>><br>
>>>>>> *But*, the cpu access is going via pipe_transfer so it could work<br>
>>>>>> exactly the same way as (for example) glReadPixels() (ie. copies to<br>
>>>>>> and/or from a staging bo, rather than direct mmap access to the<br>
>>>>>> original bo).<br>
>>>>>><br>
>>>>>> (The one slight problem is that android/gralloc doesn't know how to<br>
>>>>>> deal when pitch of the staging buffer returned differers from the<br>
>>>>>> pitch of the actual buffer.. but that kinda somehow needs to be fixed<br>
>>>>>> in android. Maybe for the time being we need a<br>
>>>>>> PIPE_TRANSFER_GRALLOC_HACK type flag to tell drivers to allocate an<br>
>>>>>> unnecessarily large staging bo to preserve the pitch.)<br>
>>>>><br>
>>>>><br>
>>>>> Well, you can transfer_map the whole layer, but that's not enough to<br>
>>>>> get the original pitch, because tiled textures can be aligned to 8x8,<br>
>>>>> but linear textures can be aligned to 64x1.<br>
>>>><br>
>>>><br>
>>>> At any rate, this is a limitation of gralloc API (which we don't<br>
>>>> control), rather than proposed gbm interface. Maybe it is better to<br>
>>>> push google to fix gralloc rather than trying to work-around it.<br>
>>><br>
>>><br>
>>> Any chance we could fix that part of gralloc? For most UMA/SoC gpus<br>
>>> you just map the underlying buffer (and then flush), but even on some<br>
>>> SoC gpus and definitely on anything discrete you want staging buffers.<br>
>>> And those shouldn't need to be oversized like that ...<br>
>>><br>
>>> Thanks, Daniel<br>
>>><br>
>><br>
>> Adding Dan Stoza from our graphics team.<br>
><br>
><br>
</div></div></blockquote></div><br></div>