Skip to contentSkip to conversation

drm/amd/display: Change dither policy for 10 bpc output back to dithering

PATCH In review Mario Kleiner 6 participants 20 messages Mar 21 – Apr 3 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Change dither policy for 10 bpc output back to dithering

Commit d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round") degraded display of 12 bpc color precision output to 10 bpc sinks by switching 10 bpc output from dithering to "truncate to 10 bpc".

I don't find the argumentation in that commit convincing, but the consequences highly unfortunate, especially for applications that require effective > 10 bpc precision output of > 10 bpc framebuffers.

The argument wasn't something strong like "there are hardware design defects or limitations which require us to work around broken dithering to 10 bpc", or "there are some special use cases which do require truncation to 10 bpc", but essentially "at some point in the past we used truncation in Polaris/Vega times and it looks like it got inadvertently changed for Navi, so let's do that again". I couldn't find evidence for that in the git commit logs for this. The commit message also acknowledges that using dithering "...makes some sense for FP16... ...but not for ARGB2101010 surfaces..."

The problem with this is that it makes fp16 surfaces, and especially rgba16 fixed point surfaces, less useful. These are now well supported by Mesa 25.3 and later via OpenGL + EGL, Vulkan/WSI, and by OSS AMDVLK Vulkan/WSI/display, and also by GNOME 50 mutter under Wayland, and they used to provide more than 10 bpc effective precision at the output.

Even for 8 or 10 bpc surfaces, the color pipeline behind the framebuffer, e.g., gamma tables, CTM, can be used for color correction and will benefit from an effective > 10 bpc output precision via dithering, retaining some precision that would get lost on the way through the pipeline, e.g., due to non-linear gamma functions.

Scientific apps rely on this for > 10 bpc display precision. Truncating to 10 bpc, instead of dithering the pipeline internal 12 bpc precision down to 10 bpc, causes a serious loss of precision. This also creates the undesirable and slightly absurd situation that using a cheap monitor with only 8 bpc input and display panel will yield roughly 12 bpc precision via dithering from 12 -> 8 bpc, whereas investment into a more expensive monitor with 10 bpc input and native 10 bpc display will only yield 10 bpc, even if a fp16 or rgb16 framebuffer and/or a properly set up color pipeline (gamma tables, CTM's etc. with more than 10 bpc out precision) would allow effective 12 bpc precision output.

Therefore this patch proposes reverting that commit and going back to dithering down to 10 bpc, consistent with the behaviour for 6 bpc or 8 bpc output.

Successfully tested on AMD Polaris DCE 11.2 and Raven Ridge DCN 1.0 with a native 10 bpc capable monitor, outputting a RGBA16 unorm framebuffer and measuring resulting color precision with a photometer. No apparent visual artifacts or problems were observed, and effective precision was measured to be 12 bpc again, as expected.

Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round")
Cc Aric Cyr <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Krunoslav Kovac <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +1 -1
index c9fbb64d706a..29db5404c4a0 100644
@@ -5056,7 +5056,7 @@ void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
 			option = DITHER_OPTION_SPATIAL8;
 			break;
 		case COLOR_DEPTH_101010:
-			option = DITHER_OPTION_TRUN10;
+			option = DITHER_OPTION_SPATIAL10;
 			break;
 		default:
 			option = DITHER_OPTION_DISABLE;
Signature · 1 line
2.43.0
#1 lore raw

+ Harry, Alex

Quoted 82 lines · Mario Kleiner

Commit d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round") degraded display of 12 bpc color precision output to 10 bpc sinks by switching 10 bpc output from dithering to "truncate to 10 bpc".

I don't find the argumentation in that commit convincing, but the consequences highly unfortunate, especially for applications that require effective > 10 bpc precision output of > 10 bpc framebuffers.

The argument wasn't something strong like "there are hardware design defects or limitations which require us to work around broken dithering to 10 bpc", or "there are some special use cases which do require truncation to 10 bpc", but essentially "at some point in the past we used truncation in Polaris/Vega times and it looks like it got inadvertently changed for Navi, so let's do that again". I couldn't find evidence for that in the git commit logs for this. The commit message also acknowledges that using dithering "...makes some sense for FP16... ...but not for ARGB2101010 surfaces..."

The problem with this is that it makes fp16 surfaces, and especially rgba16 fixed point surfaces, less useful. These are now well supported by Mesa 25.3 and later via OpenGL + EGL, Vulkan/WSI, and by OSS AMDVLK Vulkan/WSI/display, and also by GNOME 50 mutter under Wayland, and they used to provide more than 10 bpc effective precision at the output.

Even for 8 or 10 bpc surfaces, the color pipeline behind the framebuffer, e.g., gamma tables, CTM, can be used for color correction and will benefit from an effective > 10 bpc output precision via dithering, retaining some precision that would get lost on the way through the pipeline, e.g., due to non-linear gamma functions.

Scientific apps rely on this for > 10 bpc display precision. Truncating to 10 bpc, instead of dithering the pipeline internal 12 bpc precision down to 10 bpc, causes a serious loss of precision. This also creates the undesirable and slightly absurd situation that using a cheap monitor with only 8 bpc input and display panel will yield roughly 12 bpc precision via dithering from 12 -> 8 bpc, whereas investment into a more expensive monitor with 10 bpc input and native 10 bpc display will only yield 10 bpc, even if a fp16 or rgb16 framebuffer and/or a properly set up color pipeline (gamma tables, CTM's etc. with more than 10 bpc out precision) would allow effective 12 bpc precision output.

Therefore this patch proposes reverting that commit and going back to dithering down to 10 bpc, consistent with the behaviour for 6 bpc or 8 bpc output.

Successfully tested on AMD Polaris DCE 11.2 and Raven Ridge DCN 1.0 with a native 10 bpc capable monitor, outputting a RGBA16 unorm framebuffer and measuring resulting color precision with a photometer. No apparent visual artifacts or problems were observed, and effective precision was measured to be 12 bpc again, as expected.

Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round")
Cc Aric Cyr <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Krunoslav Kovac <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +1 -2
index c9fbb64d706a..29db5404c4a0 100644
@@ -5056,7 +5056,7 @@ void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
                        option = DITHER_OPTION_SPATIAL8;
                        break;
                case COLOR_DEPTH_101010:
-                       option = DITHER_OPTION_TRUN10;
+                       option = DITHER_OPTION_SPATIAL10;
                        break;
                default:
                        option = DITHER_OPTION_DISABLE;
--

2.43.0

A message that is not in the archive (sent off-list or not yet received): DM4PR12MB521342239D4CF694B4A68E0AE64AA@DM4PR12MB5213.namprd12.prod.outlook.com

#3 lore raw

Hi Krunoslav,

(dropped Rodrigo from the mail thread, as he seems no longer with AMD's display team, and stable kernel for the moment).

Quoted 19 lines · Krunoslav

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Mario,

I'm not on that mailing list, not sure how to reply, so I'll start by replying directly here.

Thanks for the reply.

There is a reason for the change that is alluded in the commit, but perhaps I should've been clearer.
If you have an ARGB2101010 surface and monitor is 10bpc, one of the HW design goals is that we can output this in a bit-perfect way, i.e., for every surface pixel value K=0..1023, monitor will receive K at its end. It's also one of the things some customers have checked for and complained about historically. This is very hard to see visually or even with a colorimeter but is readily apparent with a HW capture card.

Quoted 10 lines

Our HW can accomplish this 10-bit perfect requirement if set up correctly, however, it can only do so if we use rounding, not dithering. For example, say you have a 10-bit code 200, our pipeline precision and error accumulation may result with 200.15, which in 12bpc before dithering would be 801 and the nature of the spatial dithering is that now and then RNG result will push that to 201 output, it's just the way it works. Rounding is several times less sensitive to this, and without this randomness component, we can verify we're always accurate enough at 10bpc level.

Ok, that makes a lot more sense. I can understand that. My own software and users have the same critical requirement for some use cases, of being able to pass through ARGB8888 surfaces to 8 bpc video sinks. They connect special neuroscience display equipment that parses special binary control information out of false-color coded framebuffer images, or implements very high color precision display up to 16 bpc per color channel on top of 8 bpc framebuffers and some shader magic. Luckily, using a standard 8 bpc framebuffer under the native X-Server, a 8 bpc DVI-D or DP video sink, and loading a specifically crafted gamma table achieved this for our case, despite the spatial dithering-down-to-8bpc being active. DC has some special detection function (__is_lut_linear() in amdgpu_dm_color.c) that detects if a user provided gamma lut is essentially meant to be a linear identity mapping lut, and if so, enables lut bypass or identity mapping iirc, and that does the trick well enough for us atm. At least under OpenGL + Xorg on modern DCN display engines. For older DCE engines, my software does its own low-level MMIO register programming to get rid of unwanted dithering, or to enforce the dithering it needs, but this has become impractical/infeasible for DCN.

I haven't tested this yet under Wayland, as the Wayland eco system is not ready for the more demanding use cases, and we still have to cling to the native X-Server for possibly quite a while longer.

Do you know what use cases those customers have for 10 bpc identity passthrough? I wonder if they are very similar to my use cases for 8 bpc identity passthrough.

The rounding mode poses a problem for some of my users though, the research labs that can't afford or use highly specialized display equipment for the price of an upper class car, and possibly not even the price of "conventional" high end display monitors ("reference monitors", "broadcast monitors" as used in movie and tv/streaming post-production etc.) with true 12 bpc input and processing. Or situations where video bandwidth limits enforce an only 10 bpc output even for 12 bpc capable sinks. Those can be fine with 10 bpc + gpu dithering.

Quoted 6 lines

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

This workaround, that you also propose, would be the least bad of all bad solutions.

One goal of the current patch was to be easy to backport, and also to still make it into drm-fixes before Linux 7. Linux 7.0 will be the standard distribution kernel for the upcoming Ubuntu 26.04-LTS, and therefore important for my users.

I think what would really be needed in the long term is a drm connector property to control dithering. Some kms drivers had this in the olden days, many years ago. I don't think a guess-o-matic will always guess right, given that having > 10 bpc precision via dithering will be also beneficial on 8 or 10 bpc framebuffers + gamma tables for most use cases.

Thanks,
mario

Quoted 102 lines

Thanks,
Kruno

-----Original Message-----
From: Mario Kleiner <[email protected]>
Sent: Saturday, March 21, 2026 1:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Cyr, Aric <[email protected]>; Koo, Anthony < [email protected]>; Rodrigo Siqueira <[email protected]>; Kovac, Krunoslav <[email protected]>; Deucher, Alexander < [email protected]>
Subject: [PATCH] drm/amd/display: Change dither policy for 10 bpc output back to dithering

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Commit d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round") degraded display of 12 bpc color precision output to 10 bpc sinks by switching 10 bpc output from dithering to "truncate to 10 bpc".

I don't find the argumentation in that commit convincing, but the consequences highly unfortunate, especially for applications that require effective > 10 bpc precision output of > 10 bpc framebuffers.

The argument wasn't something strong like "there are hardware design defects or limitations which require us to work around broken dithering to 10 bpc", or "there are some special use cases which do require truncation to 10 bpc", but essentially "at some point in the past we used truncation in Polaris/Vega times and it looks like it got inadvertently changed for Navi, so let's do that again". I couldn't find evidence for that in the git commit logs for this. The commit message also acknowledges that using dithering "...makes some sense for FP16...
...but not for ARGB2101010 surfaces..."

The problem with this is that it makes fp16 surfaces, and especially rgba16 fixed point surfaces, less useful. These are now well supported by Mesa 25.3 and later via OpenGL + EGL, Vulkan/WSI, and by OSS AMDVLK Vulkan/WSI/display, and also by GNOME 50 mutter under Wayland, and they used to provide more than 10 bpc effective precision at the output.

Even for 8 or 10 bpc surfaces, the color pipeline behind the framebuffer, e.g., gamma tables, CTM, can be used for color correction and will benefit from an effective > 10 bpc output precision via dithering, retaining some precision that would get lost on the way through the pipeline, e.g., due to non-linear gamma functions.

Scientific apps rely on this for > 10 bpc display precision. Truncating to 10 bpc, instead of dithering the pipeline internal 12 bpc precision down to 10 bpc, causes a serious loss of precision. This also creates the undesirable and slightly absurd situation that using a cheap monitor with only 8 bpc input and display panel will yield roughly 12 bpc precision via dithering from 12 -> 8 bpc, whereas investment into a more expensive monitor with 10 bpc input and native 10 bpc display will only yield 10 bpc, even if a fp16 or rgb16 framebuffer and/or a properly set up color pipeline (gamma tables, CTM's etc. with more than 10 bpc out
precision) would allow effective 12 bpc precision output.

Therefore this patch proposes reverting that commit and going back to dithering down to 10 bpc, consistent with the behaviour for 6 bpc or 8 bpc output.

Successfully tested on AMD Polaris DCE 11.2 and Raven Ridge DCN 1.0 with a native 10 bpc capable monitor, outputting a RGBA16 unorm framebuffer and measuring resulting color precision with a photometer. No apparent visual artifacts or problems were observed, and effective precision was measured to be 12 bpc again, as expected.

Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to

round")

Cc Aric Cyr <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Krunoslav Kovac <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +1 -1
index c9fbb64d706a..29db5404c4a0 100644
@@ -5056,7 +5056,7 @@ void
 resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
                        option = DITHER_OPTION_SPATIAL8;
                        break;
                case COLOR_DEPTH_101010:
-                       option = DITHER_OPTION_TRUN10;
+                       option = DITHER_OPTION_SPATIAL10;
                        break;
                default:
                        option = DITHER_OPTION_DISABLE;

--
2.43.0

maintainer
#4 lore raw

PATCH 1/1 drm/amd/display: Dither when plane bpc is higher than output bpc

We don't want to dither when a 10bpc buffer is output on a 10bpc connection as we'd get off-by-one errors. But we do want to dither if we have planes with a higher bit depth.

In order to solve this, look at all planes, and pick TRUN dither when input bit depth doesn't exceed output bit depth, otherwise pick SPATIAL.

Cc Kovac, Krunoslav <[email protected]>
Cc Hung, Alex <[email protected]>
Cc Deucher, Alexander <[email protected]>

---

Mario, Kruno,

this patch looks at planes and picks dither based on the max bit depth of all planes on the stream. Would this work for both of you?

I've only made sure my Rembrandt system boots with this but haven't been able to confirm that the correct dither mode is selected.

Harry

 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +-
 .../drm/amd/display/dc/core/dc_hw_sequencer.c |   3 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 110 +++++++++++++++++-
 drivers/gpu/drm/amd/display/dc/inc/resource.h |   3 +-
 .../display/dc/link/accessories/link_dp_cts.c |   3 +-
 .../dc/resource/dce110/dce110_resource.c      |   3 +-
 .../dc/resource/dcn10/dcn10_resource.c        |   3 +-
 .../dc/resource/dcn20/dcn20_resource.c        |   3 +-
 8 files changed, 122 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -2
index 8b21816cf7c8..56d6f9d2fcca 100644
@@ -788,7 +788,7 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream,
 	stream->dither_option = option;
 
 	memset(&params, 0, sizeof(params));
-	resource_build_bit_depth_reduction_params(stream, &params);
+	resource_build_bit_depth_reduction_params(stream, &params, stream->ctx->dc);
 	stream->bit_depth_params = params;
 
 	if (pipes->plane_res.xfm &&
@@ -3841,7 +3841,8 @@ static void commit_planes_do_stream_update(struct dc *dc,
 			if (stream_update->dither_option) {
 				struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
 				resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-									&pipe_ctx->stream->bit_depth_params);
+									&pipe_ctx->stream->bit_depth_params,
+									pipe_ctx->stream->ctx->dc);
 				pipe_ctx->stream_res.opp->funcs->opp_program_fmt(pipe_ctx->stream_res.opp,
 						&stream->bit_depth_params,
 						&stream->clamping);
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 5b3695e72e19..a042b31b57ba 100644
@@ -2485,7 +2485,8 @@ void hwss_opp_program_bit_depth_reduction(union block_sequence_params *params)
 	if (use_default_params)
 		memset(&bit_depth_params, 0, sizeof(bit_depth_params));
 	else
-		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &bit_depth_params);
+		resource_build_bit_depth_reduction_params(pipe_ctx->stream,
+			&bit_depth_params, pipe_ctx->stream->ctx->dc);
 
 	if (opp->funcs->opp_program_bit_depth_reduction)
 		opp->funcs->opp_program_bit_depth_reduction(opp, &bit_depth_params);
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +107 -3

132 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/inc/resource.h +2 -1
index cecd3282a29f..2d040e735521 100644
@@ -591,7 +591,8 @@ bool pipe_need_reprogram(
 		struct pipe_ctx *pipe_ctx);
 
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-		struct bit_depth_reduction_params *fmt_bit_depth);
+		struct bit_depth_reduction_params *fmt_bit_depth,
+		const struct dc *dc);
 
 void update_audio_usage(
 		struct resource_context *res_ctx,
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -1
index 693d852b1c40..377e02095867 100644
@@ -543,7 +543,8 @@ static void set_crtc_test_pattern(struct dc_link *link,
 	case DP_TEST_PATTERN_VIDEO_MODE:
 	{
 		/* restore bitdepth reduction */
-		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params);
+		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params,
+			pipe_ctx->stream->ctx->dc);
 		pipe_ctx->stream->bit_depth_params = params;
 		if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) {
 			opp->funcs->opp_program_bit_depth_reduction(opp, &params);
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c +2 -1
index 7c09825cd9bd..6433f48e9158 100644
@@ -928,7 +928,8 @@ void dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 		&pipe_ctx->stream_res.pix_clk_params,
 		&pipe_ctx->pll_settings);
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-			&pipe_ctx->stream->bit_depth_params);
+			&pipe_ctx->stream->bit_depth_params,
+			pipe_ctx->stream->ctx->dc);
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c +2 -1
index 9c1a57a1f989..6cd16b64baae 100644
@@ -1042,7 +1042,8 @@ static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-					&pipe_ctx->stream->bit_depth_params);
+					&pipe_ctx->stream->bit_depth_params,
+					pipe_ctx->stream->ctx->dc);
 	build_clamping_params(pipe_ctx->stream);
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c +2 -1
index b28e877fb99d..f2786bfc87c1 100644
@@ -1302,7 +1302,8 @@ static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-					&pipe_ctx->stream->bit_depth_params);
+					&pipe_ctx->stream->bit_depth_params,
+					pipe_ctx->stream->ctx->dc);
 	build_clamping_params(pipe_ctx->stream);
 
 	return DC_OK;
Signature · 1 line
2.53.0
maintainer
#5 lore raw

Re: [PATCH] drm/amd/display: Dither when plane bpc is higher than output bpc

Quoted 8 lines · Harry Wentland

We don't want to dither when a 10bpc buffer is output on a 10bpc connection as we'd get off-by-one errors. But we do want to dither if we have planes with a higher bit depth.

In order to solve this, look at all planes, and pick TRUN dither when input bit depth doesn't exceed output bit depth, otherwise pick SPATIAL.

Forgot to add, for completeness:

Assisted-by Claude:claude-sonnet-4.6

Harry

Quoted 273 lines
Cc Kovac, Krunoslav <[email protected]>
Cc Hung, Alex <[email protected]>
Cc Deucher, Alexander <[email protected]>

---

Mario, Kruno,

this patch looks at planes and picks dither based on the max bit depth of all planes on the stream. Would this work for both of you?

I've only made sure my Rembrandt system boots with this but haven't been able to confirm that the correct dither mode is selected.

Harry

 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +-
 .../drm/amd/display/dc/core/dc_hw_sequencer.c |   3 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 110 +++++++++++++++++-
 drivers/gpu/drm/amd/display/dc/inc/resource.h |   3 +-
 .../display/dc/link/accessories/link_dp_cts.c |   3 +-
 .../dc/resource/dce110/dce110_resource.c      |   3 +-
 .../dc/resource/dcn10/dcn10_resource.c        |   3 +-
 .../dc/resource/dcn20/dcn20_resource.c        |   3 +-
 8 files changed, 122 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -2
index 8b21816cf7c8..56d6f9d2fcca 100644
@@ -788,7 +788,7 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream,
 	stream->dither_option = option;
 
 	memset(&params, 0, sizeof(params));
-	resource_build_bit_depth_reduction_params(stream, &params);
+	resource_build_bit_depth_reduction_params(stream, &params, stream->ctx->dc);
 	stream->bit_depth_params = params;
 
 	if (pipes->plane_res.xfm &&
@@ -3841,7 +3841,8 @@ static void commit_planes_do_stream_update(struct dc *dc,
 			if (stream_update->dither_option) {
 				struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
 				resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-									&pipe_ctx->stream->bit_depth_params);
+									&pipe_ctx->stream->bit_depth_params,
+									pipe_ctx->stream->ctx->dc);
 				pipe_ctx->stream_res.opp->funcs->opp_program_fmt(pipe_ctx->stream_res.opp,
 						&stream->bit_depth_params,
 						&stream->clamping);
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 5b3695e72e19..a042b31b57ba 100644
@@ -2485,7 +2485,8 @@ void hwss_opp_program_bit_depth_reduction(union block_sequence_params *params)
 	if (use_default_params)
 		memset(&bit_depth_params, 0, sizeof(bit_depth_params));
 	else
-		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &bit_depth_params);
+		resource_build_bit_depth_reduction_params(pipe_ctx->stream,
+			&bit_depth_params, pipe_ctx->stream->ctx->dc);
 
 	if (opp->funcs->opp_program_bit_depth_reduction)
 		opp->funcs->opp_program_bit_depth_reduction(opp, &bit_depth_params);
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +107 -3
index 8271b12c1a66..10b7e14ef66f 100644
@@ -5037,25 +5037,129 @@ bool pipe_need_reprogram(
 	return false;
 }
 
+/**
+ * get_bit_depth_from_surface_pixel_format - Get effective bit depth from surface format
+ * @format: Surface pixel format
+ *
+ * Returns the effective bit depth per channel for the given surface format.
+ * This is used to determine if input precision is higher than output precision
+ * for dithering decisions.
+ *
+ * Return: Bits per channel (6, 8, 10, 12, or 16)
+ */
+static unsigned int get_bit_depth_from_surface_pixel_format(enum surface_pixel_format format)
+{
+	switch (format) {
+	case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
+		return 8;
+	case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+		return 5; /* 5 bits per channel */
+	case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+		return 6;
+	case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+	case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+		return 8;
+	case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+	case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+	case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+		return 10;
+	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+	case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+		return 16; /* 16-bit fixed point */
+	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
+	case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+		return 16; /* FP16 has higher effective precision */
+	case SURFACE_PIXEL_FORMAT_GRPH_RGBE:
+	case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
+		return 8; /* 8-bit mantissa per channel */
+	default:
+		return 8;
+	}
+}
+
+/**
+ * get_max_input_bpc_for_stream - Get maximum input plane bit depth for a stream
+ * @dc: DC context
+ * @stream: The stream to check
+ *
+ * Iterate through all pipes in the current DC state to find planes attached
+ * to this stream, and return the maximum bit depth across all those planes.
+ * This is used to determine if spatial dithering (for higher precision inputs
+ * like FP16/RGBA16) or rounding (for bit-accurate matching precision like
+ * RGB10->10bpc) should be used.
+ *
+ * Returns: Maximum bits per channel across all planes for this stream,
+ *          or 0 if no planes found or no current state.
+ */
+static unsigned int get_max_input_bpc_for_stream(const struct dc *dc,
+						 struct dc_stream_state *stream)
+{
+	unsigned int max_bpc = 0;
+	int i;
+
+	if (!dc || !dc->current_state || !stream)
+		return 0;
+
+	/* Iterate through all pipes to find planes for this stream */
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+		unsigned int plane_bpc;
+
+		if (!pipe->plane_state || pipe->stream != stream)
+			continue;
+
+		plane_bpc = get_bit_depth_from_surface_pixel_format(
+				pipe->plane_state->format);
+
+		if (plane_bpc > max_bpc)
+			max_bpc = plane_bpc;
+	}
+
+	return max_bpc;
+}
+
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-		struct bit_depth_reduction_params *fmt_bit_depth)
+		struct bit_depth_reduction_params *fmt_bit_depth,
+		const struct dc *dc)
 {
 	enum dc_dither_option option = stream->dither_option;
 	enum dc_pixel_encoding pixel_encoding =
 			stream->timing.pixel_encoding;
+	unsigned int max_plane_bpp;
 
 	memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
 
+	/* Get max input bpc from planes attached to this stream */
+	max_plane_bpp = get_max_input_bpc_for_stream(dc, stream);
+
 	if (option == DITHER_OPTION_DEFAULT) {
 		switch (stream->timing.display_color_depth) {
 		case COLOR_DEPTH_666:
 			option = DITHER_OPTION_SPATIAL6;
 			break;
 		case COLOR_DEPTH_888:
-			option = DITHER_OPTION_SPATIAL8;
+			/* Use spatial dithering if we don't know plane bpp (0) or
+			 * if plane precision > output precision, otherwise use
+			 * rounding/truncation for bit accuracy.
+			 */
+			if (max_plane_bpp == 0 || max_plane_bpp > 8)
+				option = DITHER_OPTION_SPATIAL8;
+			else
+				option = DITHER_OPTION_TRUN8;
 			break;
 		case COLOR_DEPTH_101010:
-			option = DITHER_OPTION_TRUN10;
+			/* Use spatial dithering if we don't know plane bpp (0) or
+			 * if plane precision > output precision, otherwise use
+			 * rounding for bit accuracy.
+			 */
+			if (max_plane_bpp == 0 || max_plane_bpp > 10)
+				option = DITHER_OPTION_SPATIAL10;
+			else
+				option = DITHER_OPTION_TRUN10;
 			break;
 		default:
 			option = DITHER_OPTION_DISABLE;
drivers/gpu/drm/amd/display/dc/inc/resource.h +2 -1
index cecd3282a29f..2d040e735521 100644
@@ -591,7 +591,8 @@ bool pipe_need_reprogram(
 		struct pipe_ctx *pipe_ctx);
 
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-		struct bit_depth_reduction_params *fmt_bit_depth);
+		struct bit_depth_reduction_params *fmt_bit_depth,
+		const struct dc *dc);
 
 void update_audio_usage(
 		struct resource_context *res_ctx,
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -1
index 693d852b1c40..377e02095867 100644
@@ -543,7 +543,8 @@ static void set_crtc_test_pattern(struct dc_link *link,
 	case DP_TEST_PATTERN_VIDEO_MODE:
 	{
 		/* restore bitdepth reduction */
-		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params);
+		resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params,
+			pipe_ctx->stream->ctx->dc);
 		pipe_ctx->stream->bit_depth_params = params;
 		if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) {
 			opp->funcs->opp_program_bit_depth_reduction(opp, &params);
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c +2 -1
index 7c09825cd9bd..6433f48e9158 100644
@@ -928,7 +928,8 @@ void dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 		&pipe_ctx->stream_res.pix_clk_params,
 		&pipe_ctx->pll_settings);
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-			&pipe_ctx->stream->bit_depth_params);
+			&pipe_ctx->stream->bit_depth_params,
+			pipe_ctx->stream->ctx->dc);
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c +2 -1
index 9c1a57a1f989..6cd16b64baae 100644
@@ -1042,7 +1042,8 @@ static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-					&pipe_ctx->stream->bit_depth_params);
+					&pipe_ctx->stream->bit_depth_params,
+					pipe_ctx->stream->ctx->dc);
 	build_clamping_params(pipe_ctx->stream);
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c +2 -1
index b28e877fb99d..f2786bfc87c1 100644
@@ -1302,7 +1302,8 @@ static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 	pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
 	resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-					&pipe_ctx->stream->bit_depth_params);
+					&pipe_ctx->stream->bit_depth_params,
+					pipe_ctx->stream->ctx->dc);
 	build_clamping_params(pipe_ctx->stream);
 
 	return DC_OK;
#6 lore raw

RE: [PATCH] drm/amd/display: Dither when plane bpc is higher than output bpc

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Mario,

(Sorry if my mail client strips Message-ID)

The cleanest solution would be to use dc_stream_set_dither_option and pass dither setting from amdgpu level, sort of the long-term solution Mario mentioned before. And default can be left as-is.

Aside from that, I think Harry's approach is an ok alternative - in FP16+ARGB10 it's fine to use dithering, dedicated plane is not guaranteed anyway. That would probably leave just the full-screen ARGB10 case using rounding.

Harry, for YCbCr surfaces we might want to do dithering too, even for 10 bpc surfaces, there's upsampling, matrix conversion (even if output YCbCr), I don't think bit-perfect means much here

Thanks.
Kruno

-----Original Message-----
From: Wentland, Harry <[email protected]>
Sent: Tuesday, March 24, 2026 17:14
To: [email protected]
Cc: Kovac, Krunoslav <[email protected]>; Hung, Alex <[email protected]>; Deucher, Alexander <[email protected]>; Mario Kleiner <[email protected]>
Subject: Re: [PATCH] drm/amd/display: Dither when plane bpc is higher than output bpc

Quoted 8 lines · Harry Wentland

We don't want to dither when a 10bpc buffer is output on a 10bpc connection as we'd get off-by-one errors. But we do want to dither if we have planes with a higher bit depth.

In order to solve this, look at all planes, and pick TRUN dither when input bit depth doesn't exceed output bit depth, otherwise pick SPATIAL.

Forgot to add, for completeness:

Assisted-by Claude:claude-sonnet-4.6

Harry

Quoted 292 lines
Cc Kovac, Krunoslav <[email protected]>
Cc Hung, Alex <[email protected]>
Cc Deucher, Alexander <[email protected]>

---

Mario, Kruno,

this patch looks at planes and picks dither based on the max bit depth of all planes on the stream. Would this work for both of you?

I've only made sure my Rembrandt system boots with this but haven't been able to confirm that the correct dither mode is selected.

Harry

 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +-
 .../drm/amd/display/dc/core/dc_hw_sequencer.c |   3 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 110 +++++++++++++++++-
 drivers/gpu/drm/amd/display/dc/inc/resource.h |   3 +-
 .../display/dc/link/accessories/link_dp_cts.c |   3 +-
 .../dc/resource/dce110/dce110_resource.c      |   3 +-
 .../dc/resource/dcn10/dcn10_resource.c        |   3 +-
 .../dc/resource/dcn20/dcn20_resource.c        |   3 +-
 8 files changed, 122 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +4 -2
index 8b21816cf7c8..56d6f9d2fcca 100644
@@ -788,7 +788,7 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream,
      stream->dither_option = option;
 
      memset(&params, 0, sizeof(params));
-     resource_build_bit_depth_reduction_params(stream, &params);
+     resource_build_bit_depth_reduction_params(stream, &params,
+stream->ctx->dc);
      stream->bit_depth_params = params;
 
      if (pipes->plane_res.xfm &&
@@ -3841,7 +3841,8 @@ static void commit_planes_do_stream_update(struct dc *dc,
                      if (stream_update->dither_option) {
                              struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
                              resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                                                     &pipe_ctx->stream->bit_depth_params);
+                                                                     &pipe_ctx->stream->bit_depth_params,
+                                                                     pipe_ctx->stream->ctx->dc);
                              pipe_ctx->stream_res.opp->funcs->opp_program_fmt(pipe_ctx->stream_res.opp,
                                              &stream->bit_depth_params,
                                              &stream->clamping);
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 5b3695e72e19..a042b31b57ba 100644
@@ -2485,7 +2485,8 @@ void hwss_opp_program_bit_depth_reduction(union block_sequence_params *params)
      if (use_default_params)
              memset(&bit_depth_params, 0, sizeof(bit_depth_params));
      else
-             resource_build_bit_depth_reduction_params(pipe_ctx->stream, &bit_depth_params);
+             resource_build_bit_depth_reduction_params(pipe_ctx->stream,
+                     &bit_depth_params, pipe_ctx->stream->ctx->dc);
 
      if (opp->funcs->opp_program_bit_depth_reduction)
              opp->funcs->opp_program_bit_depth_reduction(opp,

&bit_depth_params); diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 8271b12c1a66..10b7e14ef66f 100644

drivers/gpu/drm/amd/display/dc/core/dc_resource.c +111 -3
@@ -5037,25 +5037,129 @@ bool pipe_need_reprogram(
      return false;
 }
 
+/**
+ * get_bit_depth_from_surface_pixel_format - Get effective bit depth
+from surface format
+ * @format: Surface pixel format
+ *
+ * Returns the effective bit depth per channel for the given surface format.
+ * This is used to determine if input precision is higher than output
+precision
+ * for dithering decisions.
+ *
+ * Return: Bits per channel (6, 8, 10, 12, or 16)  */ static unsigned
+int get_bit_depth_from_surface_pixel_format(enum surface_pixel_format
+format) {
+     switch (format) {
+     case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
+             return 8;
+     case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+             return 5; /* 5 bits per channel */
+     case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+             return 6;
+     case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+     case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+     case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+     case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+             return 8;
+     case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+     case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+     case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+     case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+     case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+             return 10;
+     case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+     case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+             return 16; /* 16-bit fixed point */
+     case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
+     case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+             return 16; /* FP16 has higher effective precision */
+     case SURFACE_PIXEL_FORMAT_GRPH_RGBE:
+     case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
+             return 8; /* 8-bit mantissa per channel */
+     default:
+             return 8;
+     }
+}
+
+/**
+ * get_max_input_bpc_for_stream - Get maximum input plane bit depth
+for a stream
+ * @dc: DC context
+ * @stream: The stream to check
+ *
+ * Iterate through all pipes in the current DC state to find planes
+attached
+ * to this stream, and return the maximum bit depth across all those planes.
+ * This is used to determine if spatial dithering (for higher
+precision inputs
+ * like FP16/RGBA16) or rounding (for bit-accurate matching precision
+like
+ * RGB10->10bpc) should be used.
+ *
+ * Returns: Maximum bits per channel across all planes for this stream,
+ *          or 0 if no planes found or no current state.
+ */
+static unsigned int get_max_input_bpc_for_stream(const struct dc *dc,
+                                              struct dc_stream_state *stream) {
+     unsigned int max_bpc = 0;
+     int i;
+
+     if (!dc || !dc->current_state || !stream)
+             return 0;
+
+     /* Iterate through all pipes to find planes for this stream */
+     for (i = 0; i < MAX_PIPES; i++) {
+             struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+             unsigned int plane_bpc;
+
+             if (!pipe->plane_state || pipe->stream != stream)
+                     continue;
+
+             plane_bpc = get_bit_depth_from_surface_pixel_format(
+                             pipe->plane_state->format);
+
+             if (plane_bpc > max_bpc)
+                     max_bpc = plane_bpc;
+     }
+
+     return max_bpc;
+}
+
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-             struct bit_depth_reduction_params *fmt_bit_depth)
+             struct bit_depth_reduction_params *fmt_bit_depth,
+             const struct dc *dc)
 {
      enum dc_dither_option option = stream->dither_option;
      enum dc_pixel_encoding pixel_encoding =
                      stream->timing.pixel_encoding;
+     unsigned int max_plane_bpp;
 
      memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
 
+     /* Get max input bpc from planes attached to this stream */
+     max_plane_bpp = get_max_input_bpc_for_stream(dc, stream);
+
      if (option == DITHER_OPTION_DEFAULT) {
              switch (stream->timing.display_color_depth) {
              case COLOR_DEPTH_666:
                      option = DITHER_OPTION_SPATIAL6;
                      break;
              case COLOR_DEPTH_888:
-                     option = DITHER_OPTION_SPATIAL8;
+                     /* Use spatial dithering if we don't know plane bpp (0) or
+                      * if plane precision > output precision, otherwise use
+                      * rounding/truncation for bit accuracy.
+                      */
+                     if (max_plane_bpp == 0 || max_plane_bpp > 8)
+                             option = DITHER_OPTION_SPATIAL8;
+                     else
+                             option = DITHER_OPTION_TRUN8;
                      break;
              case COLOR_DEPTH_101010:
-                     option = DITHER_OPTION_TRUN10;
+                     /* Use spatial dithering if we don't know plane bpp (0) or
+                      * if plane precision > output precision, otherwise use
+                      * rounding for bit accuracy.
+                      */
+                     if (max_plane_bpp == 0 || max_plane_bpp > 10)
+                             option = DITHER_OPTION_SPATIAL10;
+                     else
+                             option = DITHER_OPTION_TRUN10;
                      break;
              default:
                      option = DITHER_OPTION_DISABLE;
drivers/gpu/drm/amd/display/dc/inc/resource.h +2 -1
index cecd3282a29f..2d040e735521 100644
@@ -591,7 +591,8 @@ bool pipe_need_reprogram(
              struct pipe_ctx *pipe_ctx);
 
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-             struct bit_depth_reduction_params *fmt_bit_depth);
+             struct bit_depth_reduction_params *fmt_bit_depth,
+             const struct dc *dc);
 
 void update_audio_usage(
              struct resource_context *res_ctx,

diff --git a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c index 693d852b1c40..377e02095867 100644

drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -2
@@ -543,7 +543,8 @@ static void set_crtc_test_pattern(struct dc_link *link,
      case DP_TEST_PATTERN_VIDEO_MODE:
      {
              /* restore bitdepth reduction */
-             resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params);
+             resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params,
+                     pipe_ctx->stream->ctx->dc);
              pipe_ctx->stream->bit_depth_params = params;
              if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) {
                      opp->funcs->opp_program_bit_depth_reduction(opp, &params); diff
--git

a/drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c index 7c09825cd9bd..6433f48e9158 100644

drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c +2 -1
@@ -928,7 +928,8 @@ void dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
              &pipe_ctx->stream_res.pix_clk_params,
              &pipe_ctx->pll_settings);
      resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                     &pipe_ctx->stream->bit_depth_params);
+                     &pipe_ctx->stream->bit_depth_params,
+                     pipe_ctx->stream->ctx->dc);
      pipe_ctx->stream->clamping.pixel_encoding =
 pipe_ctx->stream->timing.pixel_encoding;
 }

diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c index 9c1a57a1f989..6cd16b64baae 100644

drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c +2 -1
@@ -1042,7 +1042,8 @@ static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
      pipe_ctx->stream->clamping.pixel_encoding =
 pipe_ctx->stream->timing.pixel_encoding;
 
      resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                     &pipe_ctx->stream->bit_depth_params);
+                                     &pipe_ctx->stream->bit_depth_params,
+                                     pipe_ctx->stream->ctx->dc);
      build_clamping_params(pipe_ctx->stream);
 }

diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c index b28e877fb99d..f2786bfc87c1 100644

drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c +2 -1
@@ -1302,7 +1302,8 @@ static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
      pipe_ctx->stream->clamping.pixel_encoding =
 pipe_ctx->stream->timing.pixel_encoding;
 
      resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                     &pipe_ctx->stream->bit_depth_params);
+                                     &pipe_ctx->stream->bit_depth_params,
+                                     pipe_ctx->stream->ctx->dc);
      build_clamping_params(pipe_ctx->stream);
 
      return DC_OK;
#7 lore raw

Re: [PATCH] drm/amd/display: Dither when plane bpc is higher than output bpc

In reply to Harry Wentland

Hi Harry,

Thanks for taking a stab at this!

I agree that your patch would be a good solution. And my review suggested the code looked correct, but unfortunately in my testing on my laptop with Polaris11 for the 8 bpc input fb + 8 bpc output on the eDP panel of my laptop, the machine disagreed. It always gives me dithering for my XRGB8888 aka 8 bpc input fb to my 8 bpc COLOR_DEPTH_888 output. I'm visiting my parents atm., and therefore don't have access to the 10 bpc DP monitor for output 10 bpc testing, but at least the 8 bpc laptop panel is no success.

Reason is that max_plane_bpp = get_max_input_bpc_for_stream(dc, stream); is reported as 0, so it hits the if (max_plane_bpp == 0 || ...) condition and triggers DITHER_OPTION_SPATIAL8 when it should choose the else branch with DITHER_OPTION_TRUN8.

Reason for get_max_input_bpc_for_stream() reporting 0 is that for the only active pipe (with index i == 0) in dc->current_state->res_ctx.pipe_ctx[i], the pipe->stream != stream condition is true, so the whole maximum finding logic gets skipped. Added debug statements showed that pipe->stream from res_ctx never matches the stream pointer passed into resource_build_bit_depth_reduction_params(). So something is amiss there.

dc->current_state->res_ctx.pipe_ctx[0]->stream matches what the passed in stream was during early amdgpu driver init during boot, but during later bootup, login and session, the passed in stream pointer changes multiple times but never matches pipe->stream.

Apart from that, style-wise it would probably make sense to rename max_plane_bpp into max_plane_bpc for consistency?

And ideally we'd add...

Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round")

I hope getting this into drm-fixes for upcoming Linux 7.0 would still be possible, as that will be the standard distribution kernel for upcoming Ubuntu 26.04-LTS, Fedora 44 and other spring 2026 distribution updates, which will also ship with enhanced Mesa 26.0 and GNOME mutter 50, both improved to make good use of 16 bpc framebuffers on AMD hw.

Thanks
-mario

Quoted 285 lines · Harry Wentland

We don't want to dither when a 10bpc buffer is output on a 10bpc connection as we'd get off-by-one errors. But we do want to dither if we have planes with a higher bit depth.

In order to solve this, look at all planes, and pick TRUN dither when input bit depth doesn't exceed output bit depth, otherwise pick SPATIAL.

Cc Kovac, Krunoslav <[email protected]>
Cc Hung, Alex <[email protected]>
Cc Deucher, Alexander <[email protected]>

---

Mario, Kruno,

this patch looks at planes and picks dither based on the max bit depth of all planes on the stream. Would this work for both of you?

I've only made sure my Rembrandt system boots with this but haven't been able to confirm that the correct dither mode is selected.

Harry

 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +-
 .../drm/amd/display/dc/core/dc_hw_sequencer.c |   3 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 110 +++++++++++++++++-
 drivers/gpu/drm/amd/display/dc/inc/resource.h |   3 +-
 .../display/dc/link/accessories/link_dp_cts.c |   3 +-
 .../dc/resource/dce110/dce110_resource.c      |   3 +-
 .../dc/resource/dcn10/dcn10_resource.c        |   3 +-
 .../dc/resource/dcn20/dcn20_resource.c        |   3 +-
 8 files changed, 122 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -2
index 8b21816cf7c8..56d6f9d2fcca 100644
@@ -788,7 +788,7 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream,
        stream->dither_option = option;
 
        memset(&params, 0, sizeof(params));
-       resource_build_bit_depth_reduction_params(stream, &params);
+       resource_build_bit_depth_reduction_params(stream, &params, stream->ctx->dc);
        stream->bit_depth_params = params;
 
        if (pipes->plane_res.xfm &&
@@ -3841,7 +3841,8 @@ static void commit_planes_do_stream_update(struct dc *dc,
                        if (stream_update->dither_option) {
                                struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
                                resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                                                       &pipe_ctx->stream->bit_depth_params);
+                                                                       &pipe_ctx->stream->bit_depth_params,
+                                                                       pipe_ctx->stream->ctx->dc);
                                pipe_ctx->stream_res.opp->funcs->opp_program_fmt(pipe_ctx->stream_res.opp,
                                                &stream->bit_depth_params,
                                                &stream->clamping);
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 5b3695e72e19..a042b31b57ba 100644
@@ -2485,7 +2485,8 @@ void hwss_opp_program_bit_depth_reduction(union block_sequence_params *params)
        if (use_default_params)
                memset(&bit_depth_params, 0, sizeof(bit_depth_params));
        else
-               resource_build_bit_depth_reduction_params(pipe_ctx->stream, &bit_depth_params);
+               resource_build_bit_depth_reduction_params(pipe_ctx->stream,
+                       &bit_depth_params, pipe_ctx->stream->ctx->dc);
 
        if (opp->funcs->opp_program_bit_depth_reduction)
                opp->funcs->opp_program_bit_depth_reduction(opp, &bit_depth_params);
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +107 -3
index 8271b12c1a66..10b7e14ef66f 100644
@@ -5037,25 +5037,129 @@ bool pipe_need_reprogram(
        return false;
 }
 
+/**
+ * get_bit_depth_from_surface_pixel_format - Get effective bit depth from surface format
+ * @format: Surface pixel format
+ *
+ * Returns the effective bit depth per channel for the given surface format.
+ * This is used to determine if input precision is higher than output precision
+ * for dithering decisions.
+ *
+ * Return: Bits per channel (6, 8, 10, 12, or 16)
+ */
+static unsigned int get_bit_depth_from_surface_pixel_format(enum surface_pixel_format format)
+{
+       switch (format) {
+       case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
+               return 8;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+               return 5; /* 5 bits per channel */
+       case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+               return 6;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+               return 8;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+               return 10;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+               return 16; /* 16-bit fixed point */
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+               return 16; /* FP16 has higher effective precision */
+       case SURFACE_PIXEL_FORMAT_GRPH_RGBE:
+       case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
+               return 8; /* 8-bit mantissa per channel */
+       default:
+               return 8;
+       }
+}
+
+/**
+ * get_max_input_bpc_for_stream - Get maximum input plane bit depth for a stream
+ * @dc: DC context
+ * @stream: The stream to check
+ *
+ * Iterate through all pipes in the current DC state to find planes attached
+ * to this stream, and return the maximum bit depth across all those planes.
+ * This is used to determine if spatial dithering (for higher precision inputs
+ * like FP16/RGBA16) or rounding (for bit-accurate matching precision like
+ * RGB10->10bpc) should be used.
+ *
+ * Returns: Maximum bits per channel across all planes for this stream,
+ *          or 0 if no planes found or no current state.
+ */
+static unsigned int get_max_input_bpc_for_stream(const struct dc *dc,
+                                                struct dc_stream_state *stream)
+{
+       unsigned int max_bpc = 0;
+       int i;
+
+       if (!dc || !dc->current_state || !stream)
+               return 0;
+
+       /* Iterate through all pipes to find planes for this stream */
+       for (i = 0; i < MAX_PIPES; i++) {
+               struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+               unsigned int plane_bpc;
+
+               if (!pipe->plane_state || pipe->stream != stream)
+                       continue;
+
+               plane_bpc = get_bit_depth_from_surface_pixel_format(
+                               pipe->plane_state->format);
+
+               if (plane_bpc > max_bpc)
+                       max_bpc = plane_bpc;
+       }
+
+       return max_bpc;
+}
+
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-               struct bit_depth_reduction_params *fmt_bit_depth)
+               struct bit_depth_reduction_params *fmt_bit_depth,
+               const struct dc *dc)
 {
        enum dc_dither_option option = stream->dither_option;
        enum dc_pixel_encoding pixel_encoding =
                        stream->timing.pixel_encoding;
+       unsigned int max_plane_bpp;
 
        memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
 
+       /* Get max input bpc from planes attached to this stream */
+       max_plane_bpp = get_max_input_bpc_for_stream(dc, stream);
+
        if (option == DITHER_OPTION_DEFAULT) {
                switch (stream->timing.display_color_depth) {
                case COLOR_DEPTH_666:
                        option = DITHER_OPTION_SPATIAL6;
                        break;
                case COLOR_DEPTH_888:
-                       option = DITHER_OPTION_SPATIAL8;
+                       /* Use spatial dithering if we don't know plane bpp (0) or
+                        * if plane precision > output precision, otherwise use
+                        * rounding/truncation for bit accuracy.
+                        */
+                       if (max_plane_bpp == 0 || max_plane_bpp > 8)
+                               option = DITHER_OPTION_SPATIAL8;
+                       else
+                               option = DITHER_OPTION_TRUN8;
                        break;
                case COLOR_DEPTH_101010:
-                       option = DITHER_OPTION_TRUN10;
+                       /* Use spatial dithering if we don't know plane bpp (0) or
+                        * if plane precision > output precision, otherwise use
+                        * rounding for bit accuracy.
+                        */
+                       if (max_plane_bpp == 0 || max_plane_bpp > 10)
+                               option = DITHER_OPTION_SPATIAL10;
+                       else
+                               option = DITHER_OPTION_TRUN10;
                        break;
                default:
                        option = DITHER_OPTION_DISABLE;
drivers/gpu/drm/amd/display/dc/inc/resource.h +2 -1
index cecd3282a29f..2d040e735521 100644
@@ -591,7 +591,8 @@ bool pipe_need_reprogram(
                struct pipe_ctx *pipe_ctx);
 
 void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
-               struct bit_depth_reduction_params *fmt_bit_depth);
+               struct bit_depth_reduction_params *fmt_bit_depth,
+               const struct dc *dc);
 
 void update_audio_usage(
                struct resource_context *res_ctx,
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -1
index 693d852b1c40..377e02095867 100644
@@ -543,7 +543,8 @@ static void set_crtc_test_pattern(struct dc_link *link,
        case DP_TEST_PATTERN_VIDEO_MODE:
        {
                /* restore bitdepth reduction */
-               resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params);
+               resource_build_bit_depth_reduction_params(pipe_ctx->stream, &params,
+                       pipe_ctx->stream->ctx->dc);
                pipe_ctx->stream->bit_depth_params = params;
                if (pipe_ctx->stream_res.tg->funcs->set_test_pattern) {
                        opp->funcs->opp_program_bit_depth_reduction(opp, &params);
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c +2 -1
index 7c09825cd9bd..6433f48e9158 100644
@@ -928,7 +928,8 @@ void dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
                &pipe_ctx->stream_res.pix_clk_params,
                &pipe_ctx->pll_settings);
        resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                       &pipe_ctx->stream->bit_depth_params);
+                       &pipe_ctx->stream->bit_depth_params,
+                       pipe_ctx->stream->ctx->dc);
        pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn10/dcn10_resource.c +2 -1
index 9c1a57a1f989..6cd16b64baae 100644
@@ -1042,7 +1042,8 @@ static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
        pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
        resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                       &pipe_ctx->stream->bit_depth_params);
+                                       &pipe_ctx->stream->bit_depth_params,
+                                       pipe_ctx->stream->ctx->dc);
        build_clamping_params(pipe_ctx->stream);
 }
 
drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c +2 -2
index b28e877fb99d..f2786bfc87c1 100644
@@ -1302,7 +1302,8 @@ static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
        pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
 
        resource_build_bit_depth_reduction_params(pipe_ctx->stream,
-                                       &pipe_ctx->stream->bit_depth_params);
+                                       &pipe_ctx->stream->bit_depth_params,
+                                       pipe_ctx->stream->ctx->dc);
        build_clamping_params(pipe_ctx->stream);
 
        return DC_OK;
--

2.53.0

#8 lore raw

Re: [PATCH] drm/amd/display: Dither when plane bpc is higher than output bpc

In reply to Harry Wentland
Quoted 7 lines · Harry Wentland

We don't want to dither when a 10bpc buffer is output on a 10bpc connection as we'd get off-by-one errors. But we do want to dither if we have planes with a higher bit depth.

In order to solve this, look at all planes, and pick TRUN dither when input bit depth doesn't exceed output bit depth, otherwise pick SPATIAL.

This mixes up the framebuffer format and the bpc of the display HW colour pipeline output, which aren't directly related.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#9 lore raw
In reply to Mario Kleiner
Quoted 9 lines · Mario Kleiner
Quoted 5 lines · On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected]…

There is a reason for the change that is alluded in the commit, but perhaps I should've been clearer.
If you have an ARGB2101010 surface and monitor is 10bpc, one of the HW design goals is that we can output this in a bit-perfect way, i.e., for every surface pixel value K=0..1023, monitor will receive K at its end. It's also one of the things some customers have checked for and complained about historically. This is very hard to see visually or even with a colorimeter but is readily apparent with a HW capture card.

Our HW can accomplish this 10-bit perfect requirement if set up correctly, however, it can only do so if we use rounding, not dithering.
For example, say you have a 10-bit code 200, our pipeline precision and error accumulation may result with 200.15, which in 12bpc before dithering would be 801 and the nature of the spatial dithering is that now and then RNG result will push that to 201 output, it's just the way it works. Rounding is several times less sensitive to this, and without this randomness component, we can verify we're always accurate enough at 10bpc level.

Ok, that makes a lot more sense. I can understand that. My own software and users have the same critical requirement for some use cases, of being able to pass through ARGB8888 surfaces to 8 bpc video sinks. They connect special neuroscience display equipment that parses special binary control information out of false-color coded framebuffer images, or implements very high color precision display up to 16 bpc per color channel on top of 8 bpc framebuffers and some shader magic. Luckily, using a standard 8 bpc framebuffer under the native X-Server, a 8 bpc DVI-D or DP video sink, and loading a specifically crafted gamma table achieved this for our case, despite the spatial dithering-down-to-8bpc being active. DC has some special detection function (__is_lut_linear() in amdgpu_dm_color.c) that detects if a user provided gamma lut is essentially meant to be a linear identity mapping lut, and if so, enables lut bypass or identity mapping iirc, and that does the trick well enough for us atm.

Sounds like passthrough of 10 bpc values should work fine with your patch thanks to this bypass / identity mapping, doesn't it?

Quoted 1 line

I haven't tested this yet under Wayland, as the Wayland eco system is not ready for the more demanding use cases, [...]

Are there issues describing those use cases?

Quoted 3 lines
Quoted 1 line

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 1 line

This workaround, that you also propose, would be the least bad of all bad solutions.

Seems pretty bad to me, mixing up things which aren't directly related.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
maintainer
#10 lore raw
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected] <mailto:[email protected]>> wrote:

snip

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values? They're higher, but that's somewhat irrelevant.

Quoted 5 lines
Quoted 2 lines

This workaround, that you also propose, would be the least bad of all bad solutions.

Seems pretty bad to me, mixing up things which aren't directly related.

I'm not sure I follow. Dither by definition is about relating the input bpc to the output bpc.

Harry

Quoted 1 line
#11 lore raw
Quoted 4 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected] <mailto:[email protected]>> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
maintainer
#12 lore raw
Quoted 12 lines · Michel Dänzer
Quoted 11 lines · Harry Wentland
Quoted 9 lines · Michel Dänzer
Quoted 5 lines · Mario Kleiner
Quoted 1 line · On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected]…

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 8 lines
Quoted 1 line

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

True, but if, for example, the input is 8bpc then the intermediate representation won't be able to add additional precision.

I guess if there are color operations on top of the 8bpc content then the values might be shifted in such a way that outputting or dithered 8pbc will be a better representation than 8bpc rounded values.

Harry

Quoted 1 line
#13 lore raw
Quoted 17 lines · Harry Wentland
Quoted 16 lines · Michel Dänzer
Quoted 4 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected] <mailto:[email protected]>> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

True, but if, for example, the input is 8bpc then the intermediate representation won't be able to add additional precision.

Why not? (See below)

Quoted 4 lines

I guess if there are color operations on top of the 8bpc content then the values might be shifted in such a way that outputting or dithered 8pbc will be a better representation than 8bpc rounded values.

Exactly. The colour pipeline can produce arbitrary output values up to the precision limits of the KMS API / HW internal pipeline, independent from the framebuffer formats. I.e. the output values can have more significant bits than the framebuffer formats.

Therefore, basing the dithering on/off decision on the framebuffer format makes no sense.

A less bad solution would be to disable dithering if the output bpc is >= (or ==) 10.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#14 lore raw
In reply to Michel Dänzer
Quoted 12 lines · Michel Dänzer
Quoted 11 lines · Harry Wentland
Quoted 9 lines · Michel Dänzer
Quoted 5 lines · Mario Kleiner
Quoted 1 line · On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected]…

I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 7 lines
Quoted 1 line

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

Our internal precision is higher than 12, but since we first "trim" to 12bpc and then dither to 10bpc, bypass case is actually ok in practice even with dithering.

Normally for this case where we want 10bpc to go out as-is we would put HW color pipeline blocks to bypass. There are some exceptions however, and unfortunately one of them is not that uncommon. It's the multi-plane case where linear blending is desired, which is the norm for HDR. In this case, we do degamma, blend, regamma. Degamma+regamma can be set in a way that makes them true inverses at 10bpc precision for common EOTFs, but not with dithering.
It's pretty hard to notice difference between dithering and rounding at 10bpc even with a colorimeter, and since we had complaints about 10-bit one-off errors, we went with rounding. I still think it's a preferred option for 10bpc surfaces.

#15 lore raw
Quoted 17 lines · Krunoslav
Quoted 16 lines · Michel Dänzer
Quoted 4 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <[email protected] <mailto:[email protected]>> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

     I believe we don't have surface info in that code, but one way to work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Looking at all callers of resource_build_bit_depth_reduction_params(), they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

That doesn't really make sense, the output of the display HW colour pipeline has more than 10 bpc regardless of framebuffer format.

The output will be determined by the link bandwidth, display-advertised supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

Our internal precision is higher than 12, but since we first "trim" to 12bpc and then dither to 10bpc, bypass case is actually ok in practice even with dithering.

Normally for this case where we want 10bpc to go out as-is we would put HW color pipeline blocks to bypass. There are some exceptions however, and unfortunately one of them is not that uncommon. It's the multi-plane case where linear blending is desired, which is the norm for HDR. In this case, we do degamma, blend, regamma.

That's not "passthrough" by definition, so maybe the expectation that 10 bpc framebuffer values get through the pipeline unmodified just isn't realistic.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#16 lore raw
In reply to Michel Dänzer

To clarify: I do agree with Michel and Kruno that in most typical use cases you'd probably want to get all or as much of the internal HW pipelines precision as possible to the Eyes of the person in front of the display, or at least an approximation of it. My understanding of current AMD hardware is that you can have an up to 16 bpc framebuffer, which gets truncated/rounded down to 12 bpc somewhere in the pipeline (gamma tables, color transformation matrices, etc.) and then retained at 12 bpc until shortly before the actual output, which can be 6, 8, 10 or 12 bpc depending on connection type, bandwidth, "max bpc" etc.

If the final output depth is lower than 12 bpc one would usually still want an approximation of 12 bpc reaching the "eyes" of the person (/animal/retina in some of the use cases of my research users) in front of the display, and spatial dithering down from 12 bpc -> 10/8/6 bpc is the way to go. That's also true for most of my users use cases, and especially for the use cases involving 16 bpc framebuffers/surfaces.

Some more special use cases will require an absolutely perfect identity passthrough of pixel color values, where any kind of transformation in the pipeline, including spatial dithering, would be bad. Some of your customers seem to require this for 10 bpc output. Some of my users require this for 8 bpc output of a 8 bpc framebuffer. Specifically, some neuroscience research requires up to 16 bpc color or luminance precision, but all graphics cards and normal displays max out at 12 bpc. There exist special display devices and converters that can do up to 16 bpc precision (native or via some form of spatial or temporal dithering), e.g., the Bits# or Display++ from Cambridge Research Systems (UK) and Datapixx, ViewPixx and ProPixx devices from VPixx in Canada. These are essentially active DVI-D or DisplayPort 8 bpc to 14 bpc or 16 bpc VGA analog converters with 14 or 16 DAC's, or special purpose LCD panels or DLP video projectors which can do 14/16 bpc precision. Because commercially available gpu's and PHY's do not support true 16 bpc output (the DP and HDMI standards specify such signal formats, but no actual transmitter hardware afaik), these devices encode 16 bpc color content on top of a 8 bpc framebuffer and link: The software renders 16 bpc unorm/fp or 32 bpc float content and then uses GLSL shaders to split up 16 bpc into 8 MSB and 8 LSB and puts the 8 MSB into the 8 bpc red channel and 8 LSB into the 8 bpc blue channel (and 8 bpc color index overlay into the 8 bpc blue channel) to false-color encode a pure grayscale image + some 256 color index palette overlay. Or for true color images, it sacrifices half the horizontal resolution by putting 8 MSB of each color channel into the even pixel columns, and the 8 LSB into the odd pixel columns. So a false color 8 rgb8 framebuffer -> pixel identity passthrough -> 8 bpc link output via DVI-D or DP, and the video sink then decodes and reassembles again into 16 bpc color/luminance content and uses special display hardware to these 16 bpc into the eyes of the being in front of the display. Some medical imaging displays, e.g., for Radiology use (e.g., cancer screening) in hospitals or at eye doctors, also use such special framebuffer encodings to get > 12 bpc content out of the gpu Siemens Medical and similar companies sell these for research and medical use.

Another use case of my users requiring perfect pixel identity passthrough is to encode side-band signals into the scanlines of the vactive area of an image, encoding binary control data and packets as false color pixel values, similar to the various info packets transmitted inside vblank. This for control data that is very custom and not standardized in any Vesa or HDMI standard, e.g., in my case to control special neuroscience hardware, e.g., sound microsecond synchronized to pictures, sending various analog waveforms to electrophysiology equipment or haptic stimulation, or digital trigger signals to transmagnetic stimulators (magnetic pulses to brain regions), or start/stop/synchronize various recording equipment (fMRI and MEG scanners, electrophysiological recordings, video capture etc.)

For the pixel identity passthrough, the difference is that I only need it for 8 bpc framebuffers to 8 bpc (DVI-D or DP) outputs atm., and that works fine under OpenGL with an identity gamma table loaded, despite spatial dithering down to 8 bpc active. Right now, I neither have the need nor the equipment to verify 10 bpc identity passthrough, as my capture hw can only process 8 bpc signals.

I don't think there is an automated way for the driver to guess the proper configuration in all cases. The proper solution would be a drm connector property that can be queried/set to control dithering on/off/method/target depth, and plumb that through. Or maybe something that could be derived from existing connector properties? E.g., if a content property has something standardized that essentially requires identity passthrough? In my case, it is important that such settings still fully work under native X11 via RandR properties. Something that is only realistically accessible via an atomic client or Wayland server is insufficient for me.

So yes, as Michel points out, there is a disconnect between the framebuffer color depth and hw pipeline depth and what dither settings should be used. But Harry's patch, if it worked, would be at least a good enough guess-o-matic or heuristic to make the situation better in the short term, even if it is not optimal. Or at least for my users use cases it would make it better, as for my use cases the framebuffer color depth usually corresponds to what my users need as effective output precision. For me there is also the urgency of wanting to have a not broken situation for Linux 7.0 and upcoming Ubuntu 26.04-LTS / Fedora Core 44. If I have the choice of having the current state, or this patch, I'd gladly have this patch as a step up.

I hoped this patch would be still simple and contained and early enough, to make it into drm-fixes for Linux 7.0, and maybe be backportable to older kernels, as all kernels since late 2023 are impaired from my use cases point of view. But as I said, my testing didn't confirm the patch is actually working - it always ends up enabling dithering. Which, to be sneaky, would also be a step up for me, as that "only" breaks use cases that don't affect my users specifically :/

Quoted 42 lines · Michel Dänzer
Quoted 3 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <

Quoted 2 lines · [email protected] <mailto:[email protected]>> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I believe we don't have surface info in that code, but one way to

work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Looking at all callers of resource_build_bit_depth_reduction_params(),

they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

Quoted 2 lines
Quoted 2 lines

That doesn't really make sense, the output of the display HW colour

pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 3 lines
Quoted 1 line

The output will be determined by the link bandwidth, display-advertised

supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast

#17 lore raw
Quoted 9 lines · Mario Kleiner

To clarify: I do agree with Michel and Kruno that in most typical use cases you'd probably want to get all or as much of the internal HW pipelines precision as possible to the Eyes of the person in front of the display, or at least an approximation of it. My understanding of current AMD hardware is that you can have an up to 16 bpc framebuffer, which gets truncated/rounded down to 12 bpc somewhere in the pipeline (gamma tables, color transformation matrices, etc.) and then retained at 12 bpc until shortly before the actual output, which can be 6, 8, 10 or 12 bpc depending on connection type, bandwidth, "max bpc" etc.

At the start of the pipeline we immediately go into a 19bpc space. Except around 3DLUT, all color processing happens at this precision.
It's near the end of the color pipeline that we go from 19 to 12 in a block called DENORM. Other than some specialized ABM block, we then go into FMT that does 12 -> monitor bpc.

I didn't see any difference with my capture HW for 8bpc->8bpc either, so I left spatial dithering as default. There's enough extra precision that apparently it doesn't matter here.

Maybe your case always has an FP16 plane, say compositing space?

Quoted 135 lines

If the final output depth is lower than 12 bpc one would usually still want an approximation of 12 bpc reaching the "eyes" of the person (/animal/retina in some of the use cases of my research users) in front of the display, and spatial dithering down from 12 bpc -> 10/8/6 bpc is the way to go. That's also true for most of my users use cases, and especially for the use cases involving 16 bpc framebuffers/surfaces.

Some more special use cases will require an absolutely perfect identity passthrough of pixel color values, where any kind of transformation in the pipeline, including spatial dithering, would be bad. Some of your customers seem to require this for 10 bpc output. Some of my users require this for 8 bpc output of a 8 bpc framebuffer. Specifically, some neuroscience research requires up to 16 bpc color or luminance precision, but all graphics cards and normal displays max out at 12 bpc. There exist special display devices and converters that can do up to 16 bpc precision (native or via some form of spatial or temporal dithering), e.g., the Bits# or Display++ from Cambridge Research Systems (UK) and Datapixx, ViewPixx and ProPixx devices from VPixx in Canada. These are essentially active DVI-D or DisplayPort 8 bpc to 14 bpc or 16 bpc VGA analog converters with 14 or 16 DAC's, or special purpose LCD panels or DLP video projectors which can do 14/16 bpc precision. Because commercially available gpu's and PHY's do not support true 16 bpc output (the DP and HDMI standards specify such signal formats, but no actual transmitter hardware afaik), these devices encode 16 bpc color content on top of a 8 bpc framebuffer and link: The software renders 16 bpc unorm/fp or 32 bpc float content and then uses GLSL shaders to split up 16 bpc into 8 MSB and 8 LSB and puts the 8 MSB into the 8 bpc red channel and 8 LSB into the 8 bpc blue channel (and 8 bpc color index overlay into the 8 bpc blue channel) to false-color encode a pure grayscale image + some 256 color index palette overlay. Or for true color images, it sacrifices half the horizontal resolution by putting 8 MSB of each color channel into the even pixel columns, and the 8 LSB into the odd pixel columns. So a false color 8 rgb8 framebuffer -> pixel identity passthrough -> 8 bpc link output via DVI-D or DP, and the video sink then decodes and reassembles again into 16 bpc color/luminance content and uses special display hardware to these 16 bpc into the eyes of the being in front of the display. Some medical imaging displays, e.g., for Radiology use (e.g., cancer screening) in hospitals or at eye doctors, also use such special framebuffer encodings to get > 12 bpc content out of the gpu Siemens Medical and similar companies sell these for research and medical use.

Another use case of my users requiring perfect pixel identity passthrough is to encode side-band signals into the scanlines of the vactive area of an image, encoding binary control data and packets as false color pixel values, similar to the various info packets transmitted inside vblank. This for control data that is very custom and not standardized in any Vesa or HDMI standard, e.g., in my case to control special neuroscience hardware, e.g., sound microsecond synchronized to pictures, sending various analog waveforms to electrophysiology equipment or haptic stimulation, or digital trigger signals to transmagnetic stimulators (magnetic pulses to brain regions), or start/stop/synchronize various recording equipment (fMRI and MEG scanners, electrophysiological recordings, video capture etc.)

For the pixel identity passthrough, the difference is that I only need it for 8 bpc framebuffers to 8 bpc (DVI-D or DP) outputs atm., and that works fine under OpenGL with an identity gamma table loaded, despite spatial dithering down to 8 bpc active. Right now, I neither have the need nor the equipment to verify 10 bpc identity passthrough, as my capture hw can only process 8 bpc signals.

I don't think there is an automated way for the driver to guess the proper configuration in all cases. The proper solution would be a drm connector property that can be queried/set to control dithering on/off/method/target depth, and plumb that through. Or maybe something that could be derived from existing connector properties? E.g., if a content property has something standardized that essentially requires identity passthrough? In my case, it is important that such settings still fully work under native X11 via RandR properties. Something that is only realistically accessible via an atomic client or Wayland server is insufficient for me.

So yes, as Michel points out, there is a disconnect between the framebuffer color depth and hw pipeline depth and what dither settings should be used. But Harry's patch, if it worked, would be at least a good enough guess-o-matic or heuristic to make the situation better in the short term, even if it is not optimal. Or at least for my users use cases it would make it better, as for my use cases the framebuffer color depth usually corresponds to what my users need as effective output precision. For me there is also the urgency of wanting to have a not broken situation for Linux 7.0 and upcoming Ubuntu 26.04-LTS / Fedora Core 44. If I have the choice of having the current state, or this patch, I'd gladly have this patch as a step up.

I hoped this patch would be still simple and contained and early enough, to make it into drm-fixes for Linux 7.0, and maybe be backportable to older kernels, as all kernels since late 2023 are impaired from my use cases point of view. But as I said, my testing didn't confirm the patch is actually working - it always ends up enabling dithering. Which, to be sneaky, would also be a step up for me, as that "only" breaks use cases that don't affect my users specifically :/

Quoted 42 lines · Michel Dänzer
Quoted 3 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <

Quoted 2 lines · [email protected] <mailto:[email protected]>> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I believe we don't have surface info in that code, but one way to

work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the earlier complaints about 10-bit output having one-off bit errors will be coming back.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Looking at all callers of resource_build_bit_depth_reduction_params(),

they all have access to the associated "struct pipe_ctx", which should give access to pipe_ctx ->plane_state->format of an associated display plane. I could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

Quoted 2 lines
Quoted 2 lines

That doesn't really make sense, the output of the display HW colour

pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 3 lines
Quoted 1 line

The output will be determined by the link bandwidth, display-advertised

supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to the internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast

#18 lore raw
Quoted 11 lines · Krunoslav
Quoted 1 line · Mario Kleiner

To clarify: I do agree with Michel and Kruno that in most typical use

cases

Quoted 2 lines

you'd probably want to get all or as much of the internal HW pipelines precision as possible to the Eyes of the person in front of the display,

or

Quoted 5 lines

at least an approximation of it. My understanding of current AMD hardware is that you can have an up to 16 bpc framebuffer, which gets truncated/rounded down to 12 bpc somewhere in the pipeline (gamma tables, color transformation matrices, etc.) and then retained at 12 bpc until shortly before the actual output, which can be 6, 8, 10 or 12 bpc

Quoted 9 lines

depending

Quoted 1 line

on connection type, bandwidth, "max bpc" etc.

At the start of the pipeline we immediately go into a 19bpc space. Except around 3DLUT, all color processing happens at this precision. It's near the end of the color pipeline that we go from 19 to 12 in a block called DENORM. Other than some specialized ABM block, we then go into FMT that does 12 -> monitor bpc.

Interesting new info, good to know.

Quoted 4 lines

I didn't see any difference with my capture HW for 8bpc->8bpc either, so I left spatial dithering as default. There's enough extra precision that apparently it doesn't matter here.

Yes, that satisfies both the high precision and identity passthrough use cases.

Quoted 3 lines

Maybe your case always has an FP16 plane, say compositing space?

It all depends on the application. My software is not a single purpose self-contained app, but a toolkit - a set of extensions for Matlab/Octave/Python with many wildly different use cases and requirements. Think of it as SDL, but tailored to neuroscience research and related bio-medical research, and for scientists with usually only basic programming skills (Matlab scripting language or Python). Can be 8 bpc SDR, 10 bpc SDR or HDR, effective ~11 bpc unorm SDR (hw that can do fp16 surfaces but not rgba16 unorm) 12 bpc (AMD hw with rgba16unorm framebuffer -> native 12 bpc or dithered 12 bpc) SDR/HDR, 14 bpc or 16 bpc SDR on special (and very expensive) neuroscience display equipment. For high precision modes, the software often uses fp32 "framebuffers" and its own composition pipeline with various GLSL shader plugins for post-processing, then outputting to the actual 8/10/fp16/16bpc framebuffer via OpenGL or Vulkan or OpenXR for VR applications. So it's difficult to explain the specific use case, because there isn't a specific use case.

Quoted 176 lines
Quoted 1 line

If the final output depth is lower than 12 bpc one would usually still

want

Quoted 2 lines

an approximation of 12 bpc reaching the "eyes" of the person (/animal/retina in some of the use cases of my research users) in front

of

Quoted 2 lines

the display, and spatial dithering down from 12 bpc -> 10/8/6 bpc is the way to go. That's also true for most of my users use cases, and

especially

Quoted 4 lines

for the use cases involving 16 bpc framebuffers/surfaces.

Some more special use cases will require an absolutely perfect identity passthrough of pixel color values, where any kind of transformation in

the

Quoted 1 line

pipeline, including spatial dithering, would be bad. Some of your

customers

Quoted 1 line

seem to require this for 10 bpc output. Some of my users require this

for 8

Quoted 1 line

bpc output of a 8 bpc framebuffer. Specifically, some neuroscience

research

Quoted 1 line

requires up to 16 bpc color or luminance precision, but all graphics

cards

Quoted 1 line

and normal displays max out at 12 bpc. There exist special display

devices

Quoted 1 line

and converters that can do up to 16 bpc precision (native or via some

form

Quoted 2 lines

of spatial or temporal dithering), e.g., the Bits# or Display++ from Cambridge Research Systems (UK) and Datapixx, ViewPixx and ProPixx

devices

Quoted 5 lines

from VPixx in Canada. These are essentially active DVI-D or DisplayPort 8 bpc to 14 bpc or 16 bpc VGA analog converters with 14 or 16 DAC's, or special purpose LCD panels or DLP video projectors which can do 14/16 bpc precision. Because commercially available gpu's and PHY's do not support true 16 bpc output (the DP and HDMI standards specify such signal

formats,

Quoted 2 lines

but no actual transmitter hardware afaik), these devices encode 16 bpc color content on top of a 8 bpc framebuffer and link: The software

renders

Quoted 1 line

16 bpc unorm/fp or 32 bpc float content and then uses GLSL shaders to

split

Quoted 3 lines

up 16 bpc into 8 MSB and 8 LSB and puts the 8 MSB into the 8 bpc red channel and 8 LSB into the 8 bpc blue channel (and 8 bpc color index overlay into the 8 bpc blue channel) to false-color encode a pure

grayscale

Quoted 1 line

image + some 256 color index palette overlay. Or for true color images,

it

Quoted 3 lines

sacrifices half the horizontal resolution by putting 8 MSB of each color channel into the even pixel columns, and the 8 LSB into the odd pixel columns. So a false color 8 rgb8 framebuffer -> pixel identity

passthrough

Quoted 3 lines

-> 8 bpc link output via DVI-D or DP, and the video sink then decodes and reassembles again into 16 bpc color/luminance content and uses special display hardware to these 16 bpc into the eyes of the being in front of

the

Quoted 7 lines

display. Some medical imaging displays, e.g., for Radiology use (e.g., cancer screening) in hospitals or at eye doctors, also use such special framebuffer encodings to get > 12 bpc content out of the gpu Siemens Medical and similar companies sell these for research and medical use.

Another use case of my users requiring perfect pixel identity passthrough is to encode side-band signals into the scanlines of the vactive area of

an

Quoted 2 lines

image, encoding binary control data and packets as false color pixel values, similar to the various info packets transmitted inside vblank.

This

Quoted 4 lines

for control data that is very custom and not standardized in any Vesa or HDMI standard, e.g., in my case to control special neuroscience hardware, e.g., sound microsecond synchronized to pictures, sending various analog waveforms to electrophysiology equipment or haptic stimulation, or

digital

Quoted 6 lines

trigger signals to transmagnetic stimulators (magnetic pulses to brain regions), or start/stop/synchronize various recording equipment (fMRI and MEG scanners, electrophysiological recordings, video capture etc.)

For the pixel identity passthrough, the difference is that I only need it for 8 bpc framebuffers to 8 bpc (DVI-D or DP) outputs atm., and that

works

Quoted 2 lines

fine under OpenGL with an identity gamma table loaded, despite spatial dithering down to 8 bpc active. Right now, I neither have the need nor

the

Quoted 1 line

equipment to verify 10 bpc identity passthrough, as my capture hw can

only

Quoted 3 lines

process 8 bpc signals.

I don't think there is an automated way for the driver to guess the

proper

Quoted 2 lines

configuration in all cases. The proper solution would be a drm connector property that can be queried/set to control dithering

on/off/method/target

Quoted 8 lines

depth, and plumb that through. Or maybe something that could be derived from existing connector properties? E.g., if a content property has something standardized that essentially requires identity passthrough? In my case, it is important that such settings still fully work under native X11 via RandR properties. Something that is only realistically accessible via an atomic client or Wayland server is insufficient for me.

So yes, as Michel points out, there is a disconnect between the

framebuffer

Quoted 1 line

color depth and hw pipeline depth and what dither settings should be

used.

Quoted 6 lines

But Harry's patch, if it worked, would be at least a good enough guess-o-matic or heuristic to make the situation better in the short term, even if it is not optimal. Or at least for my users use cases it would make it better, as for my use cases the framebuffer color depth usually corresponds to what my users need as effective output precision. For me there is also the urgency of wanting to have a not broken

situation

Quoted 1 line

for Linux 7.0 and upcoming Ubuntu 26.04-LTS / Fedora Core 44. If I have

the

Quoted 4 lines

choice of having the current state, or this patch, I'd gladly have this patch as a step up.

I hoped this patch would be still simple and contained and early enough,

to

Quoted 8 lines

make it into drm-fixes for Linux 7.0, and maybe be backportable to older kernels, as all kernels since late 2023 are impaired from my use cases point of view. But as I said, my testing didn't confirm the patch is actually working - it always ends up enabling dithering. Which, to be sneaky, would also be a step up for me, as that "only" breaks use cases that don't affect my users specifically :/

On Tue, Mar 31, 2026 at 9:16 AM Michel Dänzer <

[email protected]>

Quoted 9 lines
Quoted 7 lines · wrote:
Quoted 3 lines · Harry Wentland
Quoted 2 lines · Michel Dänzer
Quoted 1 line · Mario Kleiner

On Sun, Mar 22, 2026 at 7:11 PM Kovac, Krunoslav <

Quoted 2 lines · [email protected] <mailto:[email protected]>> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I believe we don't have surface info in that code, but one way

to

Quoted 2 lines
Quoted 2 lines

work around it would be to use spatial dithering for FP16/ARGB16 and rounding for 10 bits. But if we just switch to spatial, some of the

earlier

Quoted 4 lines
Quoted 4 lines

complaints about 10-bit output having one-off bit errors will be coming back.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Looking at all callers of

resource_build_bit_depth_reduction_params(),

Quoted 1 line
Quoted 1 line

they all have access to the associated "struct pipe_ctx", which should

give

Quoted 1 line
Quoted 1 line

access to pipe_ctx ->plane_state->format of an associated display

plane. I

Quoted 6 lines
Quoted 6 lines

could prepare a patch that passes the pipe_ctx from each caller into resource_build_bit_depth_reduction_params() and that function could check if a 16 bpc framebuffer is in use and switch to spatial dithering down-to-10-bpc in this case, and leave the rounding/truncation to 10 bpc otherwise.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

That doesn't really make sense, the output of the display HW colour

pipeline has more than 10 bpc regardless of framebuffer format.

Quoted 3 lines
Quoted 1 line

The output will be determined by the link bandwidth, display-advertised

supported bpc, and userspace-selected "max bpc" on a drm_connector. This could very well be 10 bpc, 8 bpc, even 6 bpc. Or are you referring to

the

Quoted 6 lines
Quoted 6 lines

internal DCN HW representation of the values?

I am indeed.

Quoted 1 line

They're higher, but that's somewhat irrelevant.

Quoted 7 lines
Quoted 7 lines

How so? Surely dithering is applied to those values, not to the original values sampled from the framebuffer.

--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software

enthusiast

Quoted 2 lines
Quoted 1 line
maintainer Reviewed-by on v1 1/1
#19 lore raw
In reply to Mario Kleiner
Quoted 52 lines · Mario Kleiner

Commit d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round") degraded display of 12 bpc color precision output to 10 bpc sinks by switching 10 bpc output from dithering to "truncate to 10 bpc".

I don't find the argumentation in that commit convincing, but the consequences highly unfortunate, especially for applications that require effective > 10 bpc precision output of > 10 bpc framebuffers.

The argument wasn't something strong like "there are hardware design defects or limitations which require us to work around broken dithering to 10 bpc", or "there are some special use cases which do require truncation to 10 bpc", but essentially "at some point in the past we used truncation in Polaris/Vega times and it looks like it got inadvertently changed for Navi, so let's do that again". I couldn't find evidence for that in the git commit logs for this. The commit message also acknowledges that using dithering "...makes some sense for FP16... ...but not for ARGB2101010 surfaces..."

The problem with this is that it makes fp16 surfaces, and especially rgba16 fixed point surfaces, less useful. These are now well supported by Mesa 25.3 and later via OpenGL + EGL, Vulkan/WSI, and by OSS AMDVLK Vulkan/WSI/display, and also by GNOME 50 mutter under Wayland, and they used to provide more than 10 bpc effective precision at the output.

Even for 8 or 10 bpc surfaces, the color pipeline behind the framebuffer, e.g., gamma tables, CTM, can be used for color correction and will benefit from an effective > 10 bpc output precision via dithering, retaining some precision that would get lost on the way through the pipeline, e.g., due to non-linear gamma functions.

Scientific apps rely on this for > 10 bpc display precision. Truncating to 10 bpc, instead of dithering the pipeline internal 12 bpc precision down to 10 bpc, causes a serious loss of precision. This also creates the undesirable and slightly absurd situation that using a cheap monitor with only 8 bpc input and display panel will yield roughly 12 bpc precision via dithering from 12 -> 8 bpc, whereas investment into a more expensive monitor with 10 bpc input and native 10 bpc display will only yield 10 bpc, even if a fp16 or rgb16 framebuffer and/or a properly set up color pipeline (gamma tables, CTM's etc. with more than 10 bpc out precision) would allow effective 12 bpc precision output.

Therefore this patch proposes reverting that commit and going back to dithering down to 10 bpc, consistent with the behaviour for 6 bpc or 8 bpc output.

Successfully tested on AMD Polaris DCE 11.2 and Raven Ridge DCN 1.0 with a native 10 bpc capable monitor, outputting a RGBA16 unorm framebuffer and measuring resulting color precision with a photometer. No apparent visual artifacts or problems were observed, and effective precision was measured to be 12 bpc again, as expected.

Quoted 9 lines
Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round")
Cc Aric Cyr <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Krunoslav Kovac <[email protected]>
Cc Alex Deucher <[email protected]>

Kruno and I chatted a bit more about this and the best way forward seems to be to re-enable SPATIAL10 dither and then override that when needed in our Windows driver.

Patches is

Will pull it in today.

Harry

Quoted 17 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +1 -1
index c9fbb64d706a..29db5404c4a0 100644
@@ -5056,7 +5056,7 @@ void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
 			option = DITHER_OPTION_SPATIAL8;
 			break;
 		case COLOR_DEPTH_101010:
-			option = DITHER_OPTION_TRUN10;
+			option = DITHER_OPTION_SPATIAL10;
 			break;
 		default:
 			option = DITHER_OPTION_DISABLE;
#20 lore raw

That's great to hear! Maybe still a happy end for my users and Ubuntu 26.04-LTS.

Thanks Harry!

Quoted 101 lines · Harry Wentland
Quoted 8 lines · Mario Kleiner

Commit d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to round") degraded display of 12 bpc color precision output to 10 bpc sinks by switching 10 bpc output from dithering to "truncate to 10 bpc".

I don't find the argumentation in that commit convincing, but the consequences highly unfortunate, especially for applications that require effective > 10 bpc precision output of > 10 bpc framebuffers.

Quoted 7 lines

The argument wasn't something strong like "there are hardware design defects or limitations which require us to work around broken dithering to 10 bpc", or "there are some special use cases which do require truncation to 10 bpc", but essentially "at some point in the past we used truncation in Polaris/Vega times and it looks like it got inadvertently changed for Navi, so let's do that again". I couldn't find evidence for that in the git commit logs for this. The commit message

also

Quoted 27 lines

acknowledges that using dithering "...makes some sense for FP16... ...but not for ARGB2101010 surfaces..."

The problem with this is that it makes fp16 surfaces, and especially rgba16 fixed point surfaces, less useful. These are now well supported by Mesa 25.3 and later via OpenGL + EGL, Vulkan/WSI, and by OSS AMDVLK Vulkan/WSI/display, and also by GNOME 50 mutter under Wayland, and they used to provide more than 10 bpc effective precision at the output.

Even for 8 or 10 bpc surfaces, the color pipeline behind the framebuffer, e.g., gamma tables, CTM, can be used for color correction and will benefit from an effective > 10 bpc output precision via dithering, retaining some precision that would get lost on the way through the pipeline, e.g., due to non-linear gamma functions.

Scientific apps rely on this for > 10 bpc display precision. Truncating to 10 bpc, instead of dithering the pipeline internal 12 bpc precision down to 10 bpc, causes a serious loss of precision. This also creates the undesirable and slightly absurd situation that using a cheap monitor with only 8 bpc input and display panel will yield roughly 12 bpc precision via dithering from 12 -> 8 bpc, whereas investment into a more expensive monitor with 10 bpc input and native 10 bpc display will only yield 10 bpc, even if a fp16 or rgb16 framebuffer and/or a properly set up color pipeline (gamma tables, CTM's etc. with more than 10 bpc out precision) would allow effective 12 bpc precision output.

Quoted 2 lines

Therefore this patch proposes reverting that commit and going back to dithering down to 10 bpc, consistent with the behaviour for 6 bpc or 8

bpc

Quoted 4 lines

output.

Successfully tested on AMD Polaris DCE 11.2 and Raven Ridge DCN 1.0 with a native 10 bpc capable monitor, outputting a RGBA16 unorm framebuffer

and

Quoted 5 lines

measuring resulting color precision with a photometer. No apparent visual artifacts or problems were observed, and effective precision was measured to be 12 bpc again, as expected.

Fixes d5df648ec830 ("drm/amd/display: Change dither policy for 10bpc to

round")

Quoted 8 lines
Cc Aric Cyr <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Krunoslav Kovac <[email protected]>
Cc Alex Deucher <[email protected]>

Kruno and I chatted a bit more about this and the best way forward seems to be to re-enable SPATIAL10 dither and then override that when needed in our Windows driver.

Patches is

Will pull it in today.

Harry

Review

Quoted 5 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c

drivers/gpu/drm/amd/display/dc/core/dc_resource.c void

Quoted 4 lines

index c9fbb64d706a..29db5404c4a0 100644

drivers/gpu/drm/amd/display/dc/core/dc_resource.c +0 -0
@@ -5056,7 +5056,7 @@ void

resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +1 -1
                      option = DITHER_OPTION_SPATIAL8;
                      break;
              case COLOR_DEPTH_101010:
-                     option = DITHER_OPTION_TRUN10;
+                     option = DITHER_OPTION_SPATIAL10;
                      break;
              default:
                      option = DITHER_OPTION_DISABLE;