[vlc-commits] d3d11: allow selecting a GPU/CPU pixel format or both
Steve Lhomme
git at videolan.org
Wed Dec 18 15:12:35 CET 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Dec 18 14:32:42 2019 +0100| [7cd337769ebbee941ea6475c999b2b5f75533b8d] | committer: Steve Lhomme
d3d11: allow selecting a GPU/CPU pixel format or both
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7cd337769ebbee941ea6475c999b2b5f75533b8d
---
modules/codec/avcodec/d3d11va.c | 6 ++++--
modules/hw/d3d11/d3d11_surface.c | 2 +-
modules/video_chroma/d3d11_fmt.c | 5 +++--
modules/video_chroma/d3d11_fmt.h | 5 ++++-
modules/video_output/win32/d3d11_swapchain.c | 4 ++--
modules/video_output/win32/direct3d11.c | 10 ++++++----
6 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 394f5fddf7..4b7d246544 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -252,13 +252,15 @@ static const d3d_format_t *GetDirectRenderingFormat(vlc_va_t *vd, const directx_
{
UINT supportFlags = D3D11_FORMAT_SUPPORT_DECODER_OUTPUT | D3D11_FORMAT_SUPPORT_SHADER_LOAD;
return FindD3D11Format( vd, &vd->sys->d3d_dev, 0, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT,
- mode->bit_depth, mode->log2_chroma_h+1, mode->log2_chroma_w+1, true, supportFlags );
+ mode->bit_depth, mode->log2_chroma_h+1, mode->log2_chroma_w+1,
+ D3D11_CHROMA_GPU | D3D11_CHROMA_CPU, 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, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, true, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0,
+ D3D11_CHROMA_GPU | D3D11_CHROMA_CPU, 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 826012b931..f4e897f477 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, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, false, supportFlags );
+ FindD3D11Format( p_filter, &d3d_dev, 0, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, D3D11_CHROMA_CPU, 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 026e8908d5..5e2f3a6c91 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -536,7 +536,7 @@ const d3d_format_t *(FindD3D11Format)(vlc_object_t *o,
uint8_t bits_per_channel,
uint8_t widthDenominator,
uint8_t heightDenominator,
- bool allow_opaque,
+ int cpu_gpu,
UINT supportFlags)
{
supportFlags |= D3D11_FORMAT_SUPPORT_TEXTURE2D;
@@ -547,7 +547,8 @@ const d3d_format_t *(FindD3D11Format)(vlc_object_t *o,
continue;
if (bits_per_channel && bits_per_channel > output_format->bitsPerChannel)
continue;
- if (!allow_opaque && is_d3d11_opaque(output_format->fourcc))
+ int cpu_gpu_fmt = is_d3d11_opaque(output_format->fourcc) ? D3D11_CHROMA_GPU : D3D11_CHROMA_CPU;
+ if ((cpu_gpu & cpu_gpu_fmt)==0)
continue;
int format = vlc_fourcc_IsYUV(output_format->fourcc) ? D3D11_YUV_FORMAT : D3D11_RGB_FORMAT;
if ((rgb_yuv & format)==0)
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index fa2e58dabf..b32b7a7428 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -183,6 +183,9 @@ static inline bool DeviceSupportsFormat(ID3D11Device *d3ddevice,
#define D3D11_RGB_FORMAT 1
#define D3D11_YUV_FORMAT 2
+#define D3D11_CHROMA_CPU 1
+#define D3D11_CHROMA_GPU 2
+
const d3d_format_t *FindD3D11Format(vlc_object_t *,
d3d11_device_t*,
vlc_fourcc_t i_src_chroma,
@@ -190,7 +193,7 @@ const d3d_format_t *FindD3D11Format(vlc_object_t *,
uint8_t bits_per_channel,
uint8_t widthDenominator,
uint8_t heightDenominator,
- bool allow_opaque,
+ int cpu_gpu,
UINT supportFlags);
#define FindD3D11Format(a,b,c,d,e,f,g,h,i) \
FindD3D11Format(VLC_OBJECT(a),b,c,d,e,f,g,h,i)
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index b74d378497..71112e876b 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -371,12 +371,12 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_RGB_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
- false, D3D11_FORMAT_SUPPORT_DISPLAY );
+ D3D11_CHROMA_CPU, D3D11_FORMAT_SUPPORT_DISPLAY );
if (unlikely(newPixelFormat == NULL))
newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_YUV_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
- false, D3D11_FORMAT_SUPPORT_DISPLAY );
+ D3D11_CHROMA_CPU, D3D11_FORMAT_SUPPORT_DISPLAY );
#endif /* !VLC_WINSTORE_APP */
if (unlikely(newPixelFormat == NULL)) {
msg_Err(display->obj, "Could not get the SwapChain format.");
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 00f9bca696..440dde3216 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -736,13 +736,15 @@ 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, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 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) ? D3D11_CHROMA_GPU : D3D11_CHROMA_CPU, 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, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 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,
+ D3D11_CHROMA_GPU, supportFlags );
}
static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t bit_depth,
@@ -756,13 +758,13 @@ static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t b
supportFlags |= D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
return FindD3D11Format( vd, &vd->sys->d3d_dev, 0, rgb_yuv,
bit_depth, widthDenominator, heightDenominator,
- false, supportFlags );
+ D3D11_CHROMA_CPU, supportFlags );
}
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, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, false, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, D3D11_RGB_FORMAT|D3D11_YUV_FORMAT, 0, 0, 0, D3D11_CHROMA_CPU, supportFlags );
}
static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_context *vctx)
More information about the vlc-commits
mailing list