<div dir="ltr"><div>I agree using DRM_FORMAT_MOD_INVALID for implicit modifier is simplest.  Let's move the discussion to the other patch which does that.</div><div><br></div><div>On Fri, Apr 12, 2019 at 2:17 AM Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 11 Apr 2019 15:33:06 -0700<br>
Chia-I Wu <<a href="mailto:olvaffe@gmail.com" target="_blank">olvaffe@gmail.com</a>> wrote:<br>
<br>
> On Thu, Apr 11, 2019 at 7:12 AM Simon Ser <<a href="mailto:contact@emersion.fr" target="_blank">contact@emersion.fr</a>> wrote:<br>
> <br>
> > On Thursday, April 11, 2019 11:48 AM, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>><br>
> > wrote:  <br>
<br>
> > > At first read of your commit message, I got the feeling you want<br>
> > > formats to be advertised by both events: format event to declare a<br>
> > > format at all, plus modifier events to list any modifiers. That is also<br>
> > > what your proposed spec text reads, so I'd recommend clarifying that<br>
> > > implementations need to send only one of the two events per format. Or<br>
> > > both if the same format can be used with and without a modifier?  <br>
> >  <br>
> Your interpretation is correct: format events are for formats, and modifier<br>
> events are for modifiers.<br>
> <br>
> This is more intuitive comparing to Weston's.<br>
<br>
Hi,<br>
<br>
I disagree. Your design raises the question: what does it mean if there<br>
is a 'modifier' event with a format that was not in a 'format' event?<br>
<br>
If you want to forbid that, you need to write it down.<br></blockquote><div>It is written down. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
It also makes the 'format' event completely redundant if there is a<br>
'modifier' event for the same format. This is quite likely the reason<br>
why 'format' event was deprecated.<br>
<br>
If you insist on keeping the 'format' event, then it should be<br>
formulated like this:<br>
<br>
- send 'format' event for a format that is usable without an explicit<br>
  modifier<br>
<br>
- send 'modifier' event for a format that is usable with the given<br>
  explicit modifier<br>
<br>
- sending 'modifier' event does not directly imply that also 'format'<br>
  event must be sent, because the two have different meanings.<br>
<br>
However, for the reason mentioned below, that will make the format<br>
advertisement asymmetric with creating buffers.<br>
<br>
> > > If we have two events, one without and one with a modifier, should we<br>
> > > also then have two (well, four actually, for the immed variant)<br>
> > > requests to create a buffer: one without and one with a modifier? I<br>
> > > think it would be nice to have these consistent unless there is a<br>
> > > reason not to.<br>
> > ><br>
> > > I can find justification both ways, and whether we need to fix Weston<br>
> > > or Mutter is not that important to me. I might want to avoid the four<br>
> > > create requests case though.  <br>
> ><br>
> > I agree that either way, some compositors will need to be fixed, and that<br>
> > we<br>
> > shouldn't decide based on current implementations.  <br>
> <br>
> At the advertising phase, supported formats and modifiers are unambiguously<br>
> advertised.<br>
> <br>
> At the creation phase, you are right that it is hard to express the intent<br>
> to create a buffer with implicit modifier.  I think it is best to add a new<br>
> bit to flags, to express the intent unambiguously.<br>
<br>
A flag for "ignore argument m" does avoid the proliferation of<br>
requests, but it seems redundant. DRM_FORMAT_MOD_INVALID has a unique<br>
definition that cannot conflict with anything else, so we can as well<br>
use that. If one passes the flag to use implicit modifiers, then we<br>
should also require the modifier argument to be DRM_FORMAT_MOD_INVALID<br>
anyway for the same reason you want the flag: clarity.<br></blockquote><div>Yes.  Explicit, implicit, and invalid can all be separated for clarity, if we model after the kernel.</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">
<br>
> > > I'm not sure the versioning fully works out, if we have:<br>
> > > - version 1 and 2 have only 'format' event<br>
> > > - version 3 has 'modifier' event, with 'format' event not to be used<br>
> > > - version 4 wants to use both 'modifier' and 'format' events  <br>
> ><br>
> > Yeah, that would be a little bit annoying.  <br>
> <br>
> <br>
> > > Implementation would need to adhere to these, so Mutter would still<br>
> > > need fixing for clients that bind version 3. I don't think we should<br>
> > > retro-actively change the semantics of an existing version.  <br>
> ><br>
> > If the protocol isn't ambiguous, it would be dangerous to change semantics<br>
> > indeed.<br>
> >  <br>
> When it comes to implementations, my view is<br>
> <br>
>  v1/v2: `format' event<br>
>  v3: add `modifier' event and `format' event becomes optional (i.e.,<br>
> clients ignores it)<br>
>  v4: `format' should not be optional<br>
> <br>
> An implementation can support all versions by always sending `format'<br>
> events, and only send modifier events when version >= 3.  A client can pick<br>
> any version that suits it.<br>
<br>
One more detail: v3 'modifier' events for formats using the implicit<br>
modifier must be sent with DRM_FORMAT_MOD_INVALID. Otherwise a<br>
compositor has no way to advertise a format with the implicit modifier<br>
as clients will ignore the 'format' event.<br>
<br>
> > > I notice that currently the modifier is in<br>
> > > zwp_linux_buffer_params_v1.add request which makes the modifier<br>
> > > per-plane, but I seem to recall that in practise modifiers are nowadays<br>
> > > used only per-buffer, not per-plane, so the modifier argument should<br>
> > > move to the create and create_immed requests.  <br>
> ><br>
> > You're right, modifiers are now per-buffer and not per-plane.<br>
> >  <br>
> This diverges from what EGL and kernel do.  If we are sure it will be fine<br>
> down the road, I am fine with it.<br>
<br>
Don't both kernel and EGL implementations require all modifiers of<br>
planes to be equal? Was it not considered a mistake to have per-plane<br>
modifiers in both APIs?<br></blockquote><div>I don't have the answer.  But I will leave it out of this discussion.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
The current protocol extension was modelled after the existing DRM and<br>
EGL APIs. I'm not against keeping the interface matching the DRM API.<br>
<br>
> But it also makes implementations more complex to support both older and<br>
> new versions.  This was brought up above.  So I think it is also a concern?<br>
> <br>
> <br>
> >  <br>
> > > We also need to consider <a href="https://patchwork.freedesktop.org/patch/263061/" rel="noreferrer" target="_blank">https://patchwork.freedesktop.org/patch/263061/</a>  <br>
> > .  <br>
> > ><br>
> > > I would propose the following roadmap:<br>
> > ><br>
> > > 1. Do not un-deprecate format events; instead clarify the modifier on<br>
> > >    create and fix Mutter's behaviour.<br>
> > ><br>
> > > 2. Get <a href="https://patchwork.freedesktop.org/patch/263061/" rel="noreferrer" target="_blank">https://patchwork.freedesktop.org/patch/263061/</a> merged.<br>
> > ><br>
> > > 3. Stop using wl_drm completely when both server and client support the<br>
> > >    latest zwp_linux_dmabuf.<br>
> > ><br>
> > > 4. Do ABI-breaking cleanups, and bump the major or if we are sure<br>
> > >    enough then declare the extension stable.<br>
> > ><br>
> > > The reason why I would throw the 'format' event away as it is is that<br>
> > > then it will be consistent with the create requests: use<br>
> > > DRM_FORMAT_MOD_INVALID for "no modifier" in both events and requests. I  <br>
> <br>
> I think going the kernel way is also justified: DRM_FORMAT_MOD_INVALID is<br>
> invalid in both events and requests.  The `flags' parameter in requests<br>
> decides if the modifier is explicit or implicit.  We tried to use<br>
> DRM_FORMAT_MOD_INVALID wisely, in Mutter or in Weston.  But it led to<br>
> confusions.<br>
<br>
You cannot not send an argument in a request. 0 is valid modifier. This<br>
results in a request that has a flag "ignore argument m" but no special<br>
value to set m to when it needs to be ignored. People looking at the<br>
protocol exchange will see a valid modifier and be confused when it's<br>
not actually used.<br>
<br>
I don't see replacing the use of DRM_FORMAT_MOD_INVALID with a new<br>
variable 'bool use_modifier' making anything more clear in a<br>
compositor. You still need the same two paths, you just have one more<br>
variable to look at while the modifier variable will never indicate it<br>
should be ignored.<br>
<br>
> > would assume that the bandwidth savings would not be significant,  <br>
> > > considering everything is aiming to have explicit modifiers.<br>
> > ><br>
> > > How would that sound?  <br>
> ><br>
> > This makes a lot of sense to me. +1.<br>
> >  <br>
> I defended Mutter's behavior here, but I am on the fence.  To me, it boils<br>
> down to, should we use DRM_FORMAT_MOD_INVALID cleverly?  And this is what<br>
> kernel says about the modifier<br>
> <br>
> /*<br>
>  * Invalid Modifier<br>
>  *<br>
>  * This modifier can be used as a sentinel to terminate the format modifiers<br>
>  * list, or to initialize a variable with an invalid modifier. It might<br>
> also be<br>
>  * used to report an error back to userspace for certain APIs.<br>
>  */<br>
> #define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED)<br>
<br>
We're going to need it in any case, to store a not-a-modifier value in<br>
implementations.<br>
<br>
The question is, do you require client implementations to send a valid<br>
modifier with an ignore flag instead of an invalid modifier (with or<br>
without an ignore flag).<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
To me the simplest and most obvious solution is to use<br>
DRM_FORMAT_MOD_INVALID to signify "use implicit modifier", unless we<br>
have separate events and requests without an explicit modifier.<br>
<br>
The latter would look like this:<br>
- 'format' -> 'format_mod_implicit'<br>
- 'modifier' -> 'format_mod'<br>
- 'create' -> 'create_mod_implicit' + 'create_mod'<br>
- 'create_immed' -> 'create_immed_mod_implicit' + 'create_immed_mod'<br>
<br>
I would be the happiest if the implicit modifier would not need to be<br>
considered at all, meaning we would always have a valid explicit<br>
modifier.<br>
<br>
Is there use for implicit modifiers beyond pure legacy support?<br></blockquote><div>It is only for legacy support to me.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div></div>