[vlc-commits] d3d11: allow selecting RGB and YUV formats separately
Steve Lhomme
git at videolan.org
Mon Dec 16 13:18:49 CET 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Dec 16 11:12:55 2019 +0100| [2726d1e327282cf94dff104b12389332c6df1649] | committer: Steve Lhomme
d3d11: allow selecting RGB and YUV formats separately
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2726d1e327282cf94dff104b12389332c6df1649
---
modules/codec/avcodec/d3d11va.c | 4 ++--
modules/hw/d3d11/d3d11_surface.c | 2 +-
modules/video_chroma/d3d11_fmt.c | 8 ++++----
modules/video_chroma/d3d11_fmt.h | 5 ++++-
modules/video_output/win32/d3d11_swapchain.c | 4 ++--
modules/video_output/win32/direct3d11.c | 16 +++++++++-------
6 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index f0436aeb99..65d99dbed3 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -251,13 +251,13 @@ static const struct vlc_va_operations ops = { Get, Close, };
static const d3d_format_t *GetDirectRenderingFormat(vlc_va_t *vd, vlc_fourcc_t i_src_chroma)
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_DECODER_OUTPUT | D3D11_FORMAT_SUPPORT_SHADER_LOAD;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, true, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, true, supportFlags );
}
static const d3d_format_t *GetDirectDecoderFormat(vlc_va_t *vd, vlc_fourcc_t i_src_chroma)
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_DECODER_OUTPUT;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, true, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, true, supportFlags );
}
static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 8b62663b74..826012b931 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -178,7 +178,7 @@ static int assert_staging(filter_t *p_filter, picture_sys_d3d11_t *p_sys)
/* failed with the this format, try a different one */
UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD | D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
const d3d_format_t *new_fmt =
- FindD3D11Format( p_filter, &d3d_dev, 0, false, 0, 0, 0, false, supportFlags );
+ FindD3D11Format( p_filter, &d3d_dev, 0, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, false, supportFlags );
if (new_fmt && texDesc.Format != new_fmt->formatTexture)
{
DXGI_FORMAT srcFormat = texDesc.Format;
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index 9a79a966cb..026e8908d5 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -529,11 +529,10 @@ done:
return result;
}
-#undef FindD3D11Format
-const d3d_format_t *FindD3D11Format(vlc_object_t *o,
+const d3d_format_t *(FindD3D11Format)(vlc_object_t *o,
d3d11_device_t *d3d_dev,
vlc_fourcc_t i_src_chroma,
- bool rgb_only,
+ int rgb_yuv,
uint8_t bits_per_channel,
uint8_t widthDenominator,
uint8_t heightDenominator,
@@ -550,7 +549,8 @@ const d3d_format_t *FindD3D11Format(vlc_object_t *o,
continue;
if (!allow_opaque && is_d3d11_opaque(output_format->fourcc))
continue;
- if (rgb_only && vlc_fourcc_IsYUV(output_format->fourcc))
+ int format = vlc_fourcc_IsYUV(output_format->fourcc) ? D3D11_YUV_FORMAT : D3D11_RGB_FORMAT;
+ if ((rgb_yuv & format)==0)
continue;
if (widthDenominator && widthDenominator < output_format->widthDenominator)
continue;
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 35878e6b60..fa2e58dabf 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -180,10 +180,13 @@ static inline bool DeviceSupportsFormat(ID3D11Device *d3ddevice,
&& ( i_formatSupport & supportFlags ) == supportFlags;
}
+#define D3D11_RGB_FORMAT 1
+#define D3D11_YUV_FORMAT 2
+
const d3d_format_t *FindD3D11Format(vlc_object_t *,
d3d11_device_t*,
vlc_fourcc_t i_src_chroma,
- bool rgb_only,
+ int rgb_yuv,
uint8_t bits_per_channel,
uint8_t widthDenominator,
uint8_t heightDenominator,
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 5ebe877987..4db4969f39 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -368,12 +368,12 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
}
#else /* !VLC_WINSTORE_APP */
/* favor RGB formats first */
- newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, true,
+ newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_RGB_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
false, D3D11_FORMAT_SUPPORT_DISPLAY );
if (unlikely(newPixelFormat == NULL))
- newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, false,
+ newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_YUV_FORMAT|D3D11_YUV_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
false, D3D11_FORMAT_SUPPORT_DISPLAY );
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 5ec9fbcddf..dc0e39779c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -736,25 +736,25 @@ static const d3d_format_t *GetDirectRenderingFormat(vout_display_t *vd, vlc_four
UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD;
if (is_d3d11_opaque(i_src_chroma))
supportFlags |= D3D11_FORMAT_SUPPORT_DECODER_OUTPUT;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
}
static const d3d_format_t *GetDirectDecoderFormat(vout_display_t *vd, vlc_fourcc_t i_src_chroma)
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_DECODER_OUTPUT;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
}
static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t bit_depth,
uint8_t widthDenominator,
uint8_t heightDenominator,
bool from_processor,
- bool rgb_only)
+ int rgb_yuv)
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD;
if (from_processor)
supportFlags |= D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, 0, rgb_only,
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, 0, rgb_yuv,
bit_depth, widthDenominator, heightDenominator,
false, supportFlags );
}
@@ -762,7 +762,7 @@ static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t b
static const d3d_format_t *GetBlendableFormat(vout_display_t *vd, vlc_fourcc_t i_src_chroma)
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD | D3D11_FORMAT_SUPPORT_BLENDABLE;
- return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, 0, 0, false, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, false, supportFlags );
}
static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
@@ -915,11 +915,13 @@ static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt)
bool is_rgb = !vlc_fourcc_IsYUV(fmt->i_chroma);
sys->picQuad.textureFormat = GetDisplayFormatByDepth(vd, bits_per_channel,
widthDenominator, heightDenominator,
- decoder_format!=NULL, is_rgb);
+ decoder_format!=NULL,
+ is_rgb ? D3D11_RGB_FORMAT : (D3D11_YUV_FORMAT|D3D11_RGB_FORMAT));
if (!sys->picQuad.textureFormat && is_rgb)
sys->picQuad.textureFormat = GetDisplayFormatByDepth(vd, bits_per_channel,
widthDenominator, heightDenominator,
- decoder_format!=NULL, false);
+ decoder_format!=NULL,
+ D3D11_YUV_FORMAT);
}
// look for any pixel format that we can handle
More information about the vlc-commits
mailing list