[vlc-commits] [Git][videolan/vlc][master] 3 commits: d3d11_scaler: fix rendering format selection
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Feb 23 14:38:30 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
abd1616f by Steve Lhomme at 2024-02-23T12:48:40+00:00
d3d11_scaler: fix rendering format selection
We just want a RGB format as that's what VideoProcessor scalers require.
We can select either a format without alpha or one with alpha.
- - - - -
6e47593b by Steve Lhomme at 2024-02-23T12:48:40+00:00
d3d11_scaler: select the output format with D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT
The selected format is used for output, not input.
- - - - -
2ccd91d9 by Steve Lhomme at 2024-02-23T12:48:40+00:00
d3d11_scaler: detect if NVIDIA upscaler is available
We only need to check is super resolution is used.
- - - - -
1 changed file:
- modules/video_output/win32/d3d11_scaler.cpp
Changes:
=====================================
modules/video_output/win32/d3d11_scaler.cpp
=====================================
@@ -62,11 +62,11 @@ struct d3d11_scaler
#endif
};
-static const d3d_format_t *GetDirectRenderingFormat(vlc_object_t *vd, d3d11_device_t *d3d_dev, vlc_fourcc_t i_src_chroma)
+static const d3d_format_t *GetDirectRenderingFormat(vlc_object_t *vd, d3d11_device_t *d3d_dev, uint8_t bits_per_channel, uint8_t alpha_bits)
{
- UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD | D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_INPUT;
- return (FindD3D11Format)( vd, d3d_dev, i_src_chroma, DXGI_RGB_FORMAT|DXGI_YUV_FORMAT, 0, 0, 0, 0,
- DXGI_CHROMA_CPU|DXGI_CHROMA_GPU, supportFlags );
+ UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD | D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
+ return (FindD3D11Format)( vd, d3d_dev, 0, DXGI_RGB_FORMAT, bits_per_channel, 0, 0, alpha_bits,
+ DXGI_CHROMA_GPU, supportFlags );
}
d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vlc_fourcc_t i_chroma,
@@ -83,12 +83,50 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
struct vlc_amf_context amf = {};
amf::AMFComponent *amf_scaler = nullptr;
#endif
+ if (super_res)
+ {
// NVIDIA 530+ driver
if (d3d_dev->adapterDesc.VendorId == GPU_MANUFACTURER_NVIDIA &&
(d3d_dev->WDDM.revision * 10000 + d3d_dev->WDDM.build) > 153000)
{
- // TODO refine which GPU can do it
- canProcess = true;
+ constexpr GUID kNvidiaPPEInterfaceGUID{ 0xd43ce1b3, 0x1f4b, 0x48ac, {0xba, 0xee, 0xc3, 0xc2, 0x53, 0x75, 0xe6, 0xf7} };
+ HRESULT hr;
+ UINT available = 0;
+ D3D11_VIDEO_PROCESSOR_CONTENT_DESC processorDesc{};
+
+ ComPtr<ID3D11VideoContext> d3dvidctx;
+ ComPtr<ID3D11VideoDevice> d3dviddev;
+ ComPtr<ID3D11VideoProcessorEnumerator> enumerator;
+ ComPtr<ID3D11VideoProcessor> processor;
+
+ d3d11_device_lock(d3d_dev);
+ hr = d3d_dev->d3dcontext->QueryInterface(IID_GRAPHICS_PPV_ARGS(&d3dvidctx));
+ if (unlikely(FAILED(hr)))
+ goto checked;
+ hr = d3d_dev->d3ddevice->QueryInterface(IID_GRAPHICS_PPV_ARGS(&d3dviddev));
+ if (unlikely(FAILED(hr)))
+ goto checked;
+
+ processorDesc.InputFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE;
+ processorDesc.InputFrameRate = { 1, 25 };
+ processorDesc.InputWidth = 1280;
+ processorDesc.InputHeight = 720;
+ processorDesc.OutputWidth = 1920;
+ processorDesc.OutputHeight = 1080;
+ processorDesc.OutputFrameRate = { 1, 25 };
+ processorDesc.Usage = D3D11_VIDEO_USAGE_PLAYBACK_NORMAL;
+ hr = d3dviddev->CreateVideoProcessorEnumerator(&processorDesc, &enumerator);
+ if (unlikely(FAILED(hr)))
+ goto checked;
+ hr = d3dviddev->CreateVideoProcessor(enumerator.Get(), 0, &processor);
+ if (unlikely(FAILED(hr)))
+ goto checked;
+
+ hr = d3dvidctx->VideoProcessorGetStreamExtension(processor.Get(),
+ 0, &kNvidiaPPEInterfaceGUID, sizeof(available), &available);
+ d3d11_device_unlock(d3d_dev);
+checked:
+ canProcess = available != 0;
}
else if (d3d_dev->adapterDesc.VendorId == GPU_MANUFACTURER_INTEL)
{
@@ -96,7 +134,7 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
canProcess = true;
}
#ifdef HAVE_AMF_SCALER
- else if (d3d_dev->adapterDesc.VendorId == GPU_MANUFACTURER_AMD && !canProcess)
+ else if (d3d_dev->adapterDesc.VendorId == GPU_MANUFACTURER_AMD)
{
int res = vlc_AMFCreateContext(&amf);
if (res == VLC_SUCCESS)
@@ -110,6 +148,7 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
}
}
#endif
+ }
d3d11_scaler *scaleProc = nullptr;
const d3d_format_t *fmt = nullptr;
@@ -131,14 +170,16 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
fmt = *out_fmt;
}
#endif
+ if (fmt == nullptr)
+ fmt = GetDirectRenderingFormat(vd, d3d_dev, (*out_fmt)->bitsPerChannel, (*out_fmt)->bitsPerChannel);
+ if (fmt == nullptr)
+ fmt = GetDirectRenderingFormat(vd, d3d_dev, (*out_fmt)->bitsPerChannel, 0);
if (fmt == nullptr && (*out_fmt)->bitsPerChannel > 10)
- fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA64);
+ fmt = GetDirectRenderingFormat(vd, d3d_dev, 10, 10);
if (fmt == nullptr && (*out_fmt)->bitsPerChannel > 8)
- fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA10LE);
- if (fmt == nullptr)
- fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA);
+ fmt = GetDirectRenderingFormat(vd, d3d_dev, 8, 8);
if (fmt == nullptr)
- fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_BGRA);
+ fmt = GetDirectRenderingFormat(vd, d3d_dev, 8, 0);
if (fmt == nullptr || fmt->formatTexture == DXGI_FORMAT_UNKNOWN)
{
msg_Warn(vd, "chroma upscale of %4.4s not supported", (char*)&i_chroma);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/18d58433da9a5a6a855bc355fa7da51a94b28d00...2ccd91d9b296e435dcb1b20759071bfdaacca04d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/18d58433da9a5a6a855bc355fa7da51a94b28d00...2ccd91d9b296e435dcb1b20759071bfdaacca04d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list