d3d11: return minimum bitdepth for display output and swapchain

If the output display reports high bitdepth, 12-bit and 10-bit swapchain
is used the value returned from d3d11_color_depth needs to take it into
account.
This commit is contained in:
Kacper Michajłow 2024-06-14 01:05:53 +02:00
parent 3fa09458da
commit ab0a50874b
1 changed files with 9 additions and 6 deletions

View File

@ -156,8 +156,8 @@ static int d3d11_color_depth(struct ra_swapchain *sw)
struct priv *p = sw->priv; struct priv *p = sw->priv;
DXGI_OUTPUT_DESC1 desc1; DXGI_OUTPUT_DESC1 desc1;
if (mp_get_dxgi_output_desc(p->swapchain, &desc1)) if (!mp_get_dxgi_output_desc(p->swapchain, &desc1))
return desc1.BitsPerColor; desc1.BitsPerColor = 0;
DXGI_SWAP_CHAIN_DESC desc; DXGI_SWAP_CHAIN_DESC desc;
@ -165,15 +165,18 @@ static int d3d11_color_depth(struct ra_swapchain *sw)
if (FAILED(hr)) { if (FAILED(hr)) {
MP_ERR(sw->ctx, "Failed to query swap chain description: %s!\n", MP_ERR(sw->ctx, "Failed to query swap chain description: %s!\n",
mp_HRESULT_to_str(hr)); mp_HRESULT_to_str(hr));
return 0; return desc1.BitsPerColor;
} }
const struct ra_format *ra_fmt = const struct ra_format *ra_fmt =
ra_d3d11_get_ra_format(sw->ctx->ra, desc.BufferDesc.Format); ra_d3d11_get_ra_format(sw->ctx->ra, desc.BufferDesc.Format);
if (!ra_fmt) if (!ra_fmt || !ra_fmt->component_depth[0])
return 0; return desc1.BitsPerColor;
return ra_fmt->component_depth[0]; if (!desc1.BitsPerColor)
return ra_fmt->component_depth[0];
return MPMIN(ra_fmt->component_depth[0], desc1.BitsPerColor);
} }
static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)