<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"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">So I had a look into implementing this, and using function pointers is problematic due to this struct being passed between processes which would prevent mesa calling a function assigned in gbm_gralloc for example.</span></blockquote><div><br></div><div>Which function? In theory, anything with a dependency on libdrm and a gralloc handle should be able use the FPs.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">It could be used to provide runtime support for multiple gralloc implementations, but that seems to about the only advantage to adding FPs.</span></blockquote><div><br></div><div>Yes, that's the main benefit. The other two options are:</div><div><br></div><div>(a) standardize the handle. I'm still not sure how we're going to reconcile the implementation specific differences that I pointed out in my last message.</div><div>(b) subclass the handles. If I'm reading everyone's comments correctly, no one is in favor of this b/c of alignment/padding issues.</div><div>(c) Standard struct in libdrm + a perform call in gralloc. However, the issue with that is (*perform) is removed in gralloc1 and HIDL gralloc (/hardware/interfaces/graphics/mapper/2.0/IMapper.hal and hardware/interfaces/graphics/allocator/2.0/IAllocator.hal in AOSP). </div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 11, 2018 at 12:26 PM, Robert Foss <span dir="ltr"><<a href="mailto:robert.foss@collabora.com" target="_blank">robert.foss@collabora.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Heya,<div><div class="gmail-m_2247219931219668624gmail-h5"><br>
<br>
On 12/22/17 1:09 PM, Tomasz Figa wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On Fri, Dec 22, 2017 at 10:09 AM, Gurchetan Singh<br>
<<a href="mailto:gurchetansingh@chromium.org" target="_blank">gurchetansingh@chromium.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So the plan is for alloc_handle_t to not be sub-classed by the<br>
implementations, but have all necessary information that an implementation<br>
would need?<br>
<br>
If so, how do we reconcile the implementation specific information that is<br>
often in the handle:<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/minig<wbr>bm/blob/master/cros_gralloc/cr<wbr>os_gralloc_handle.h</a><br>
[consumer_usage, producer_usage, yuv_color_range, is_updated etc.]<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/minigb<wbr>m/+/master/cros_gralloc/cros_g<wbr>ralloc_handle.h</a><br>
[use_flags, pixel_stride]<br>
<br>
In our case, removing our minigbm specific use flags from the handle 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" target="_blank">robh@kernel.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
On Wed, Dec 13, 2017 at 5:02 PM, Gurchetan Singh<br>
<<a href="mailto:gurchetansingh@chromium.org" target="_blank">gurchetansingh@chromium.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
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>
</blockquote>
<br>
Yeah, I'd prefer not to encourage 1 as the default.<br>
<br>
</blockquote></blockquote></blockquote>
<br></div></div>
So I had a look into implementing this, and using function pointers is problematic due to this struct being passed between processes which would prevent mesa calling a function assigned in gbm_gralloc for example.<br>
<br>
It could be used to provide runtime support for multiple gralloc 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 complexity/cruft is more problematic than good.<br>
<br>
Any thoughts?<br>
<br>
<br>
Rob.<div class="gmail-m_2247219931219668624gmail-HOEnZb"><div class="gmail-m_2247219931219668624gmail-h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
a) We really don't have a need for fields like data_owner, void *data,<br>
etc.<br>
</blockquote>
<br>
We should be able to get rid of this. It's just for tracking imports.<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also, minigbm puts per plane fds, strides, offsets into the handle.<br>
Separating the information for the first plane (for the alloc_handle_t)<br>
and<br>
then rest of the planes would be annoying.<br>
</blockquote>
<br>
The plan is to add those to alloc_handle_t.<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
b) we can avoid the struct within a struct that happens when we<br>
subclass,<br>
since alignment/padding issues often pop up during<br>
serialization/de-serialization<wbr>. Using __attribute__((aligned(xx))) is<br>
less<br>
portable than maintaining a POD struct.<br>
</blockquote>
<br>
Yes. Even just between 32 and 64 bit it's problematic.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
c) IMO creating the handle should be left to the gralloc implementation.<br>
Having accessor functions clearly defines what we need from libdrm -- to<br>
make up for shortcomings of the gralloc API for DRM/KMS use cases.<br>
<br>
</blockquote></blockquote></blockquote>
<br>
I think there might be also d). Define a standard struct in libdrm<br>
headers and add a custom call to gralloc that would fill in such<br>
struct for given buffer. This would keep the libdrm handle independent<br>
of gralloc's internal handle.<br>
<br>
P.S. Top-posting is bad.<br>
<br>
Best regards,<br>
Tomasz<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
On Wed, Dec 13, 2017 at 9:30 AM, Robert Foss <<a href="mailto:robert.foss@collabora.com" target="_blank">robert.foss@collabora.com</a>><br>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
This series moves {gbm,drm,cros}_gralloc_handle_<wbr>t struct to libdrm,<br>
since at least 4 implementations exist, and share a lot of contents.<br>
The idea is to keep the common stuff defined in one place, and libdrm<br>
is the common codebase to all of these platforms.<br>
<br>
Additionally, having this struct defined in libdrm will make it<br>
easier for mesa and grallocs to communicate.<br>
<br>
Curretly missing is:<br>
- Planar formats<br>
- Get/Set functions<br>
<br>
<br>
Planar formats<br>
--------------<br>
Support for planar formats is needed, but has not been added<br>
yet, mostly since this was not already implemented in {gbm,drm}_gralloc<br>
and the fact the having at least initial backwards compatability would<br>
be nice. Anonymous unions can of course be used later on to provide<br>
backwards compatability if so desired.<br>
<br>
<br>
Get/Set functions<br>
-----------------<br>
During the previous discussion[1] one suggestion was to add accessor<br>
functions. In this RFC I've only provided a alloc_handle_create()<br>
function.<br>
<br>
The Get/Set functions have not been added yet, I was hoping for some<br>
conclusive arguments for them being adeded.<br>
<br>
Lastly it was suggested by Rob Herring that having a fourcc<->android<br>
pixel format conversion function would be useful.<br>
<br>
<br>
[1]<br>
<br>
<a href="https://lists.freedesktop.org/archives/mesa-dev/2017-November/178199.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>archives/mesa-dev/2017-Novembe<wbr>r/178199.html</a><br>
<br>
Robert Foss (5):<br>
android: Move gralloc handle struct to libdrm<br>
android: Add version variable to alloc_handle_t<br>
android: Mark alloc_handle_t magic variable as const<br>
android: Remove member name from alloc_handle_t<br>
android: Change alloc_handle_t format from Android format to fourcc<br>
<br>
Android.mk | 8 +++-<br>
Makefile.sources | 3 ++<br>
android/alloc_handle.h | 87<br>
++++++++++++++++++++++++++++++<wbr>++++++++++++++<br>
android/gralloc_drm_handle.h | 1 +<br>
4 files changed, 97 insertions(+), 2 deletions(-)<br>
create mode 100644 android/alloc_handle.h<br>
create mode 120000 android/gralloc_drm_handle.h<br>
<br>
--<br>
2.14.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote>
<br>
<br>
</blockquote></blockquote>
<br>
<br>
</blockquote></blockquote>
</div></div></blockquote></div><br></div></div>