Processing RAWs for HDR displays in Darktable

Ok, here is a picture that I think shows the problem quite clearly.

First, the SDR JPEG (sRGB), just so everyone can get an idea of what the image looks like:

The scene itself has a high dynamic range, and I have kept the contrast linear (just applied some corrective modules). The sunshades, red tableclothes and part of the roofs are clipped in the SDR version.

The same picture in JXL format but still with sRGB (SDR) profile: SDR.jxl (1.6 MB)

And now various HDR versions in JXL format, that only vary by their profile and the amount of exposure compensation that is applied at the end of the pipeline:

I viewed all these images on the iPad (Photos app) and on the Mac, using both Photos and Adobe’s experimental viewer (“Gain Map Demo App”) on the latter. I kept the default “Apple XDR Display (P3-1600 nits)” profile on the Mac (this is important in order to get the right SDR brightness).

When using these apps and settings, the non-clipped part of the image is consistent between the SDR and PQ images, so I think I got the right exposure compensation for this profile. However, the blacks seem crushed and the contrast off in both HLG versions, regardless of the viewer.

So it seems to me that something is still wrong with the HLG export. But I have no idea if this is due to a bug in Darktable or to a fundamental limitation of HLG. Any insights would be highly appreciated!

Finally, the raw and sidecar files, in case you want to try to reproduce my results:
_DSC6846.NEF (30.8 MB)
_DSC6846.NEF.xmp (7.8 KB) (matches the PQ version)