<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We can define accessor functions too (not ptrs), then the struct is opaque and you can do your own accessor implementation if aligning is not possible or desired.<br></blockquote><div><br></div><div>Accessor functions in libdrm sound good to me. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 12, 2018 at 11:44 AM, Rob Herring <span dir="ltr"><<a href="mailto:robh@kernel.org" target="_blank">robh@kernel.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Jan 12, 2018 at 2:29 AM, Tomasz Figa <<a href="mailto:tfiga@chromium.org">tfiga@chromium.org</a>> wrote:<br>
> Hi Rob,<br>
><br>
> On Fri, Jan 12, 2018 at 5:26 AM, Robert Foss <<a href="mailto:robert.foss@collabora.com">robert.foss@collabora.com</a>> wrote:<br>
>> Heya,<br>
>><br>
>><br>
>> On 12/22/17 1:09 PM, Tomasz Figa wrote:<br>
>>><br>
>>> On Fri, Dec 22, 2017 at 10:09 AM, Gurchetan Singh<br>
>>> <<a href="mailto:gurchetansingh@chromium.org">gurchetansingh@chromium.org</a>> wrote:<br>
>>>><br>
>>>> So the plan is for alloc_handle_t to not be sub-classed by the<br>
>>>> implementations, but have all necessary information that an<br>
>>>> implementation<br>
>>>> would need?<br>
>>>><br>
>>>> If so, how do we reconcile the implementation specific information that<br>
>>>> is<br>
>>>> often in the handle:<br>
>>>><br>
>>>><br>
>>>> <a href="https://github.com/intel/minigbm/blob/master/cros_gralloc/cros_gralloc_handle.h" rel="noreferrer" target="_blank">https://github.com/intel/<wbr>minigbm/blob/master/cros_<wbr>gralloc/cros_gralloc_handle.h</a><br>
>>>> [consumer_usage, producer_usage, yuv_color_range, is_updated etc.]<br>
>>>><br>
>>>><br>
>>>> <a href="https://chromium.googlesource.com/chromiumos/platform/minigbm/+/master/cros_gralloc/cros_gralloc_handle.h" rel="noreferrer" target="_blank">https://chromium.googlesource.<wbr>com/chromiumos/platform/<wbr>minigbm/+/master/cros_gralloc/<wbr>cros_gralloc_handle.h</a><br>
>>>> [use_flags, pixel_stride]<br>
>>>><br>
>>>> In our case, removing our minigbm specific use flags from the handle<br>
>>>> would<br>
>>>> add complexity to our (*registerBuffer) path.<br>
>>>><br>
>>>> On Thu, Dec 21, 2017 at 10:14 AM, Rob Herring <<a href="mailto:robh@kernel.org">robh@kernel.org</a>> wrote:<br>
>>>>><br>
>>>>><br>
>>>>> On Wed, Dec 13, 2017 at 5:02 PM, Gurchetan Singh<br>
>>>>> <<a href="mailto:gurchetansingh@chromium.org">gurchetansingh@chromium.org</a>> wrote:<br>
>>>>>><br>
>>>>>> Hi Robert,<br>
>>>>>><br>
>>>>>> Thanks for looking into this! We need to decide if we want:<br>
>>>>>><br>
>>>>>> (1) A common struct that implementations can subclass, i.e:<br>
>>>>>><br>
>>>>>> struct blah_gralloc_handle {<br>
>>>>>> alloc_handle_t alloc_handle;<br>
>>>>>> int x, y, z;<br>
>>>>>> ....<br>
>>>>>> }<br>
>>>>>><br>
>>>>>> (2) An accessor library that vendors can implement, i.e:<br>
>>>>>><br>
>>>>>> struct drmAndroidHandleInfo {<br>
>>>>>> uint32_t (*get_fourcc)(buffer_handle_t handle);<br>
>>>>>> uint32_t (*get_stride)(buffer_handle_t handle, uint32_t plane);<br>
>>>>>> uint32_t (*get_offsets)(buffer_handle_t handle, uint32_t plane);<br>
>>>>>> uint64_t (*get_modifier)(buffer_handle_<wbr>t handle);<br>
>>>>>> };<br>
>>>>>><br>
>>>>>> From my perspective as someone who has to maintain the minigbm gralloc<br>
>>>>>> implementation, (2) is preferable since:<br>
>>>>><br>
>>>>><br>
>>>>> Yeah, I'd prefer not to encourage 1 as the default.<br>
>>>>><br>
>><br>
>> So I had a look into implementing this,<br>
><br>
> Thanks!<br>
><br>
>> and using function pointers is<br>
>> problematic due to this struct being passed between processes which would<br>
>> prevent mesa calling a function assigned in gbm_gralloc for example.<br>
><br>
> Why would be this struct passed between processes?<br>
><br>
> The only data being exchanged between processes using gralloc is the<br>
> handle and it isn't actually exchanged directly, but the exporting<br>
> process will flatten it and send through Binder, while the importing<br>
> one will have it unflattened and then the gralloc implementation<br>
> called on it (the register buffer operation), which could update any<br>
> per-process data in the handle. (But still, why would we need to<br>
> include the function pointers there?)<br>
><br>
>><br>
>> It could be used to provide runtime support for multiple gralloc<br>
>> implementations, but that seems to about the only advantage to adding FPs.<br>
>><br>
>> Am I missing a good usecase for FPs? If not I think the added<br>
>> complexity/cruft is more problematic than good.<br>
>><br>
>> Any thoughts?<br>
>><br>
><br>
> I guess it might not be a big deal whether FPs or structs are used, as<br>
> long as they are not directly embedded in the handle, which we don't<br>
> want constraints on.<br>
<br>
</div></div>Why no constraints? Is converging on a common handle really that hard?<br>
It is mostly all the same data. Some of the differences are just<br>
because a particular implementation hasn't addressed some feature<br>
(e.g. planar formats). There's other things like the pid and data ptr<br>
in drm_gralloc and gbm_gralloc that really should be removed (it's<br>
just for tracking imports). If we have some fields that are unused by<br>
some implementations, that seems fine to me.<br>
<br>
We're really only talking about what is the interface to mesa and<br>
drm_hwc for handles (and mostly drm_hwc because mesa just needs the<br>
dma-buf fd(s)). Today it is simply accessing the raw handle. Moving<br>
that to libdrm doesn't change that and is no worse. It's at least<br>
better in that drm_gralloc and gbm_gralloc can share it. Making it<br>
work with cros_gralloc doesn't seem hard. We can define accessor<br>
functions too (not ptrs), then the struct is opaque and you can do<br>
your own accessor implementation if aligning is not possible or<br>
desired. Or you can do your own importer within drm_hwc too.<br>
<span class="HOEnZb"><font color="#888888"><br>
Rob<br>
</font></span></blockquote></div><br></div>