8-bit quantization when rendering F32 colours into RGBA16F surface

31 views
Skip to first unread message

Marc Pabst

unread,
Sep 25, 2025, 3:37:31 PM (2 days ago) Sep 25
to skia-discuss
Hi all, 

On iOS/Metal I wrap an RGBA16F MTLTexture into an SkSurface (ColorType::RGBAF16). Drawing solid colors (no images, no saveLayer) with BlendMode::Src and alpha 1.0 still lands on ~1/255 steps when inspecting in Xcode capture (not FP16’s ~1/1024).

Questions:
- Is there a known path on Metal where Ganesh packs solid colors to UNORM8 or renders via an RGBA8888 intermediate when using a wrapped render target?
- How can I force a fully float path for solids on Metal?

Thanks!

Michael Ludwig

unread,
Sep 25, 2025, 3:41:00 PM (2 days ago) Sep 25
to skia-discuss
Yes, in Ganesh, certain geometry renderers will use colors packed into UNORM8x4 vertex attributes to allow for disparate Skia draw calls to be batched into a smaller number of GPU draws. This decision is based on whether or not the color value returns true from `SkColor4f::fitsInBytes()` which is true when all channels fall in the range [0, 1].  This logic is intended to detect when color values were meant to carry wide gamut values that must store things outside of [0,1] to correctly represent the value in the current color space.  Unfortunately, the logic does not take into account whether or not the precision of the output surface would show that quantization.

In Graphite, colors are always kept in at least F16 until they are rendered, so this inconsistency should not arise.

Reply all
Reply to author
Forward
0 new messages