dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Pekka Paalanen <ppaalanen@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "Sebastian Wick" <sebastian.wick@redhat.com>,
	"Pekka Paalanen" <pekka.paalanen@collabora.com>,
	"xaver.hugl@gmail.com" <xaver.hugl@gmail.com>,
	"DRI Development" <dri-devel@lists.freedesktop.org>,
	wayland-devel <wayland-devel@lists.freedesktop.org>,
	"Melissa Wen" <mwen@igalia.com>,
	"Michel Dänzer" <mdaenzer@redhat.com>,
	"Jonas Ådahl" <jadahl@redhat.com>,
	"Victoria Brekenfeld" <victoria@system76.com>,
	"Aleix Pol" <aleixpol@kde.org>,
	"Uma Shankar" <uma.shankar@intel.com>,
	"Joshua Ashton" <joshua@froggi.es>
Subject: Re: [RFC] Plane color pipeline KMS uAPI
Date: Mon, 8 May 2023 11:24:23 +0300	[thread overview]
Message-ID: <20230508112423.688549cf@eldfell> (raw)
In-Reply-To: <ZFVeTcUOOpRrXtvI@phenom.ffwll.local>

[-- Attachment #1: Type: text/plain, Size: 9645 bytes --]

On Fri, 5 May 2023 21:51:41 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Fri, May 05, 2023 at 05:57:37PM +0200, Sebastian Wick wrote:
> > On Fri, May 5, 2023 at 5:28 PM Daniel Vetter <daniel@ffwll.ch> wrote:  
> > >
> > > On Thu, May 04, 2023 at 03:22:59PM +0000, Simon Ser wrote:  
> > > > Hi all,
> > > >
> > > > The goal of this RFC is to expose a generic KMS uAPI to configure the color
> > > > pipeline before blending, ie. after a pixel is tapped from a plane's
> > > > framebuffer and before it's blended with other planes. With this new uAPI we
> > > > aim to reduce the battery life impact of color management and HDR on mobile
> > > > devices, to improve performance and to decrease latency by skipping
> > > > composition on the 3D engine. This proposal is the result of discussions at
> > > > the Red Hat HDR hackfest [1] which took place a few days ago. Engineers
> > > > familiar with the AMD, Intel and NVIDIA hardware have participated in the
> > > > discussion.
> > > >
> > > > This proposal takes a prescriptive approach instead of a descriptive approach.
> > > > Drivers describe the available hardware blocks in terms of low-level
> > > > mathematical operations, then user-space configures each block. We decided
> > > > against a descriptive approach where user-space would provide a high-level
> > > > description of the colorspace and other parameters: we want to give more
> > > > control and flexibility to user-space, e.g. to be able to replicate exactly the
> > > > color pipeline with shaders and switch between shaders and KMS pipelines
> > > > seamlessly, and to avoid forcing user-space into a particular color management
> > > > policy.  
> > >
> > > Ack on the prescriptive approach, but generic imo. Descriptive pretty much
> > > means you need the shaders at the same api level for fallback purposes,
> > > and we're not going to have that ever in kms. That would need something
> > > like hwc in userspace to work.  
> > 
> > Which would be nice to have but that would be forcing a specific color
> > pipeline on everyone and we explicitly want to avoid that. There are
> > just too many trade-offs to consider.
> >   
> > > And not generic in it's ultimate consquence would mean we just do a blob
> > > for a crtc with all the vendor register stuff like adf (android display
> > > framework) does, because I really don't see a point in trying a
> > > generic-looking-but-not vendor uapi with each color op/stage split out.
> > >
> > > So from very far and pure gut feeling, this seems like a good middle
> > > ground in the uapi design space we have here.  
> > 
> > Good to hear!
> >   
> > > > We've decided against mirroring the existing CRTC properties
> > > > DEGAMMA_LUT/CTM/GAMMA_LUT onto KMS planes. Indeed, the color management
> > > > pipeline can significantly differ between vendors and this approach cannot
> > > > accurately abstract all hardware. In particular, the availability, ordering and
> > > > capabilities of hardware blocks is different on each display engine. So, we've
> > > > decided to go for a highly detailed hardware capability discovery.
> > > >
> > > > This new uAPI should not be in conflict with existing standard KMS properties,
> > > > since there are none which control the pre-blending color pipeline at the
> > > > moment. It does conflict with any vendor-specific properties like
> > > > NV_INPUT_COLORSPACE or the patches on the mailing list adding AMD-specific
> > > > properties. Drivers will need to either reject atomic commits configuring both
> > > > uAPIs, or alternatively we could add a DRM client cap which hides the vendor
> > > > properties and shows the new generic properties when enabled.
> > > >
> > > > To use this uAPI, first user-space needs to discover hardware capabilities via
> > > > KMS objects and properties, then user-space can configure the hardware via an
> > > > atomic commit. This works similarly to the existing KMS uAPI, e.g. planes.
> > > >
> > > > Our proposal introduces a new "color_pipeline" plane property, and a new KMS
> > > > object type, "COLOROP" (short for color operation). The "color_pipeline" plane
> > > > property is an enum, each enum entry represents a color pipeline supported by
> > > > the hardware. The special zero entry indicates that the pipeline is in
> > > > "bypass"/"no-op" mode. For instance, the following plane properties describe a
> > > > primary plane with 2 supported pipelines but currently configured in bypass
> > > > mode:
> > > >
> > > >     Plane 10
> > > >     ├─ "type": immutable enum {Overlay, Primary, Cursor} = Primary
> > > >     ├─ …
> > > >     └─ "color_pipeline": enum {0, 42, 52} = 0  
> > >
> > > A bit confused, why is this an enum, and not just an immutable prop that
> > > points at the first element? You already can disable elements with the
> > > bypass thing, also bypassing by changing the pointers to the next node in
> > > the graph seems a bit confusing and redundant.  
> > 
> > We want to allow multiple pipelines to exist and a plane can choose
> > the pipeline by selecting the first element of the pipeline. The enum
> > here lists all the possible pipelines that can be attached to the
> > surface.  
> 
> Ah in that case I guess we do need the flexibility of explicitly
> enumerated object property right away I guess. The example looked a bit
> like just bypass would do the trick.

Setting individual pipeline elements to bypass is not flexible enough,
because it does not allow re-ordering the pipeline elements.

OTOH, hardware does not allow arbitrary re-ordering of elements,
therefore all the "next" links in the pipeline elements are immutable.

Presumably when some re-ordering in hardware is possible, the number of
order-variants is small (given we can also bypass individual elements),
so all variants are explicitly enumerated at the plane property.

This way there are no traps like "you cannot enable all elements at the
same time" that a single standard pipeline would end up with. All
elements for all enumerated pipelines are always usable simultaneously,
I believe.

"Re-ordering" may not even be an accurate description of hardware. Some
hardware elements could be mutually exclusive, whether they implement
the same or a different operation.

> > > > The non-zero entries describe color pipelines as a linked list of COLOROP KMS
> > > > objects. The entry value is an object ID pointing to the head of the linked
> > > > list (the first operation in the color pipeline).
> > > >
> > > > The new COLOROP objects also expose a number of KMS properties. Each has a
> > > > type, a reference to the next COLOROP object in the linked list, and other
> > > > type-specific properties. Here is an example for a 1D LUT operation:  
> > >
> > > Ok no comments from me on the actual color operations and semantics of all
> > > that, because I have simply nothing to bring to that except confusion :-)
> > >
> > > Some higher level thoughts instead:
> > >
> > > - I really like that we just go with graph nodes here. I think that was
> > >   bound to happen sooner or later with kms (we almost got there with
> > >   writeback, and with hindsight maybe should have).
> > >
> > > - Since there's other use-cases for graph nodes (maybe scaler modes, or
> > >   histogram samplers for adaptive backglight, or blending that goes beyond
> > >   the stacked alpha blending we have now) it think we should make this all
> > >   fairly generic:
> > >   * Add a new graph node kms object type.
> > >   * Add a class type so that userspace knows which graph nodes it must
> > >     understand for a feature (like "ColorOp" on planes here), and which it
> > >     can ignore (like perhaps a scaler node to control the interpolation)
> > >   * Probably need to adjust the object property type. Currently that
> > >     accept any object of a given type (crtc, fb, blob are the major ones).
> > >     I think for these graph nodes we want an explicit enumeration of the
> > >     possible next objects. In kms thus far we've done that with the
> > >     separate possible_* mask properties, but they're cumbersome.
> > >   * It sounds like for now we only have immutable next pointers, so that
> > >     would simplify the first iteration, but should probably anticipate all
> > >     this.  
> > 
> > Just to be clear: right now we don't expect any pipeline to be a graph
> > but only linked lists. It probably doesn't hurt to generalize this to
> > graphs but that's not what we want to do here (for now).  
> 
> Oh a list is still a graph :-) Also my idea isn't to model a graph data
> structure, but just the graph nodes, and a bit of scaffolding to handle
> the links/pointers. Whether you only build a list of a graph out of that
> is kinda irrelevant.
> 
> Plus with the multiple pipelines you can already have a non-list in the
> starting point already.

No, there is no need for a graph. It literally is just multiple
single-linked lists at the UAPI level, and userspace picks one for the
plane.

If you change the immutable "next element" properties to mutable, then
I think the UAPI collapses. It becomes far too hard to know what even
could work, and probing for success/failure like with KMS in general is
simply infeasible.

Let's leave the more wild scenarios for the second total rewrite of the
KMS color API (assuming this is the start of the first). Otherwise we
get nowhere. That's what Wayland protocol design work has taught us.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-05-08  8:33 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04 15:22 [RFC] Plane color pipeline KMS uAPI Simon Ser
2023-05-04 21:10 ` Harry Wentland
2023-05-05 11:41 ` Pekka Paalanen
2023-05-05 13:30   ` Joshua Ashton
2023-05-05 14:16     ` Pekka Paalanen
2023-05-05 17:01       ` Joshua Ashton
2023-05-09 11:23     ` Melissa Wen
2023-05-09 11:47       ` Pekka Paalanen
2023-05-09 17:01         ` Melissa Wen
2023-05-11 21:21     ` Simon Ser
2023-05-05 15:28 ` Daniel Vetter
2023-05-05 15:57   ` Sebastian Wick
2023-05-05 19:51     ` Daniel Vetter
2023-05-08  8:24       ` Pekka Paalanen [this message]
2023-05-08  9:00         ` Daniel Vetter
2023-05-05 16:06   ` Simon Ser
2023-05-05 19:53     ` Daniel Vetter
2023-05-08  8:58       ` Simon Ser
2023-05-08  9:18         ` Daniel Vetter
2023-05-08 18:10           ` Harry Wentland
     [not found]         ` <20230508185409.07501f40@n2pa>
2023-05-09  8:17           ` Pekka Paalanen
2023-05-05 20:40 ` Dave Airlie
2023-05-05 22:20   ` Sebastian Wick
2023-05-07 23:14     ` Dave Airlie
2023-05-08  9:37       ` Pekka Paalanen
2023-05-08 10:03       ` Jonas Ådahl
2023-05-09 14:31       ` Harry Wentland
2023-05-09 19:53         ` Dave Airlie
2023-05-09 20:22           ` Simon Ser
2023-05-10  7:59             ` Jonas Ådahl
2023-05-10  8:59               ` Pekka Paalanen
2023-05-11  9:51               ` Karol Herbst
2023-05-11 16:56                 ` Joshua Ashton
2023-05-11 18:56                   ` Jonas Ådahl
2023-05-11 19:29                   ` Simon Ser
2023-05-12  7:24                     ` Pekka Paalanen
2023-05-10  8:48             ` Pekka Paalanen
     [not found]   ` <20230505160435.6e3ffa4a@n2pa>
2023-05-08  8:49     ` Pekka Paalanen
2023-05-09  8:04 ` Pekka Paalanen
     [not found] ` <4341dac6-ada1-2a75-1c22-086d96408a85@quicinc.com>
2023-06-09 15:52   ` Christopher Braga
2023-06-09 16:30     ` Simon Ser
2023-06-09 23:11       ` Christopher Braga
2023-06-12  9:21         ` Pekka Paalanen
2023-06-12 16:56           ` Christopher Braga
2023-06-13  8:23             ` Pekka Paalanen
2023-06-13 16:29               ` Christopher Braga
2023-06-14  9:00                 ` Pekka Paalanen
2023-06-15 21:44                   ` Christopher Braga
2023-06-16  7:59                     ` Pekka Paalanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230508112423.688549cf@eldfell \
    --to=ppaalanen@gmail.com \
    --cc=aleixpol@kde.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jadahl@redhat.com \
    --cc=joshua@froggi.es \
    --cc=mdaenzer@redhat.com \
    --cc=mwen@igalia.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=sebastian.wick@redhat.com \
    --cc=uma.shankar@intel.com \
    --cc=victoria@system76.com \
    --cc=wayland-devel@lists.freedesktop.org \
    --cc=xaver.hugl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).