[vlc-commits] d3d11_fmt: pass an object and a d3d11_device_t to FindD3D11Format()
Steve Lhomme
git at videolan.org
Tue Aug 7 13:43:55 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Aug 7 13:17:40 2018 +0200| [58739768a0bcafeb10791684a90af55ce740fb57] | committer: Steve Lhomme
d3d11_fmt: pass an object and a d3d11_device_t to FindD3D11Format()
So we can test for more errors and log them.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=58739768a0bcafeb10791684a90af55ce740fb57
---
modules/hw/d3d11/d3d11_surface.c | 16 ++++++++--------
modules/video_chroma/d3d11_fmt.c | 6 ++++--
modules/video_chroma/d3d11_fmt.h | 4 +++-
modules/video_output/win32/direct3d11.c | 12 ++++++------
4 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index 1d00ebcf3a..30ed915b52 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -169,10 +169,10 @@ static int assert_staging(filter_t *p_filter, picture_sys_t *p_sys)
texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
texDesc.BindFlags = 0;
- ID3D11Device *p_device;
- ID3D11DeviceContext_GetDevice(p_sys->context, &p_device);
+ d3d11_device_t d3d_dev = { .d3dcontext = p_sys->context };
+ ID3D11DeviceContext_GetDevice(d3d_dev.d3dcontext, &d3d_dev.d3ddevice);
sys->staging = NULL;
- hr = ID3D11Device_CreateTexture2D( p_device, &texDesc, NULL, &sys->staging);
+ hr = ID3D11Device_CreateTexture2D( d3d_dev.d3ddevice, &texDesc, NULL, &sys->staging);
/* test if mapping the texture works ref #18746 */
if (SUCCEEDED(hr) && FAILED(hr = can_map(sys, p_sys->context)))
msg_Dbg(p_filter, "can't map default staging texture (hr=0x%0lx)", hr);
@@ -181,21 +181,21 @@ static int assert_staging(filter_t *p_filter, picture_sys_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_device, 0, false, 0, false, supportFlags );
+ FindD3D11Format( p_filter, &d3d_dev, 0, false, 0, false, supportFlags );
if (new_fmt && texDesc.Format != new_fmt->formatTexture)
{
DXGI_FORMAT srcFormat = texDesc.Format;
texDesc.Format = new_fmt->formatTexture;
- hr = ID3D11Device_CreateTexture2D( p_device, &texDesc, NULL, &sys->staging);
+ hr = ID3D11Device_CreateTexture2D( d3d_dev.d3ddevice, &texDesc, NULL, &sys->staging);
if (SUCCEEDED(hr))
{
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.CPUAccessFlags = 0;
texDesc.BindFlags |= D3D11_BIND_RENDER_TARGET;
- hr = ID3D11Device_CreateTexture2D( p_device, &texDesc, NULL, &sys->procOutTexture);
+ hr = ID3D11Device_CreateTexture2D( d3d_dev.d3ddevice, &texDesc, NULL, &sys->procOutTexture);
if (SUCCEEDED(hr) && SUCCEEDED(hr = can_map(sys, p_sys->context)))
{
- d3d11_device_t d3d_dev = { .d3ddevice = p_device, .d3dcontext = p_sys->context };
+ d3d11_device_t d3d_dev = { .d3ddevice = d3d_dev.d3ddevice, .d3dcontext = p_sys->context };
if (SetupProcessor(p_filter, &d3d_dev, srcFormat, new_fmt->formatTexture))
{
ID3D11Texture2D_Release(sys->procOutTexture);
@@ -216,7 +216,7 @@ static int assert_staging(filter_t *p_filter, picture_sys_t *p_sys)
}
}
#endif
- ID3D11Device_Release(p_device);
+ ID3D11Device_Release(d3d_dev.d3ddevice);
if (FAILED(hr)) {
msg_Err(p_filter, "Failed to create a %s staging texture to extract surface pixels (hr=0x%0lx)", DxgiFormatToStr(texDesc.Format), hr );
return VLC_EGENERIC;
diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index d011cf7381..c00eb6bfae 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -418,7 +418,9 @@ int D3D11CheckDriverVersion(d3d11_device_t *d3d_dev, UINT vendorId, const struct
return VLC_SUCCESS;
}
-const d3d_format_t *FindD3D11Format(ID3D11Device *d3ddevice,
+#undef FindD3D11Format
+const d3d_format_t *FindD3D11Format(vlc_object_t *o,
+ d3d11_device_t *d3d_dev,
vlc_fourcc_t i_src_chroma,
bool rgb_only,
uint8_t bits_per_channel,
@@ -444,7 +446,7 @@ const d3d_format_t *FindD3D11Format(ID3D11Device *d3ddevice,
else
textureFormat = output_format->formatTexture;
- if( DeviceSupportsFormat( d3ddevice, textureFormat, supportFlags ) )
+ if( DeviceSupportsFormat( d3d_dev->d3ddevice, textureFormat, supportFlags ) )
return output_format;
}
return NULL;
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 615cfdde5f..251a81a88d 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -133,12 +133,14 @@ static inline bool DeviceSupportsFormat(ID3D11Device *d3ddevice,
&& ( i_formatSupport & supportFlags ) == supportFlags;
}
-const d3d_format_t *FindD3D11Format(ID3D11Device *d3ddevice,
+const d3d_format_t *FindD3D11Format(vlc_object_t *,
+ d3d11_device_t*,
vlc_fourcc_t i_src_chroma,
bool rgb_only,
uint8_t bits_per_channel,
bool allow_opaque,
UINT supportFlags);
+#define FindD3D11Format(a,b,c,d,e,f,g) FindD3D11Format(VLC_OBJECT(a),b,c,d,e,f,g)
int AllocateTextures(vlc_object_t *, d3d11_device_t *, const d3d_format_t *,
const video_format_t *, unsigned pool_size, ID3D11Texture2D *textures[]);
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 55481b3928..7c26449d05 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1137,13 +1137,13 @@ 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->sys->d3d_dev.d3ddevice, i_src_chroma, false, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 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->sys->d3d_dev.d3ddevice, i_src_chroma, false, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, is_d3d11_opaque(i_src_chroma), supportFlags );
}
static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t bit_depth, bool from_processor, bool rgb_only)
@@ -1151,13 +1151,13 @@ static const d3d_format_t *GetDisplayFormatByDepth(vout_display_t *vd, uint8_t b
UINT supportFlags = D3D11_FORMAT_SUPPORT_SHADER_LOAD;
if (from_processor)
supportFlags |= D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT;
- return FindD3D11Format( vd->sys->d3d_dev.d3ddevice, 0, rgb_only, bit_depth, false, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, 0, rgb_only, bit_depth, false, 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->sys->d3d_dev.d3ddevice, i_src_chroma, false, 0, false, supportFlags );
+ return FindD3D11Format( vd, &vd->sys->d3d_dev, i_src_chroma, false, 0, false, supportFlags );
}
static int Direct3D11Open(vout_display_t *vd)
@@ -1191,11 +1191,11 @@ static int Direct3D11Open(vout_display_t *vd)
return VLC_EGENERIC;
}
- sys->display.pixelFormat = FindD3D11Format( sys->d3d_dev.d3ddevice, 0, true,
+ sys->display.pixelFormat = FindD3D11Format( vd, &sys->d3d_dev, 0, true,
vd->source.i_chroma==VLC_CODEC_D3D11_OPAQUE_10B ? 10 : 8,
false, D3D11_FORMAT_SUPPORT_DISPLAY );
if (unlikely(sys->display.pixelFormat == NULL))
- sys->display.pixelFormat = FindD3D11Format( sys->d3d_dev.d3ddevice, 0, false,
+ sys->display.pixelFormat = FindD3D11Format( vd, &sys->d3d_dev, 0, false,
vd->source.i_chroma==VLC_CODEC_D3D11_OPAQUE_10B ? 10 : 8,
false, D3D11_FORMAT_SUPPORT_DISPLAY );
if (unlikely(sys->display.pixelFormat == NULL)) {
More information about the vlc-commits
mailing list