[vlc-commits] direct3d11: split the format specific allocations and generic allocations
Steve Lhomme
git at videolan.org
Tue Nov 28 12:26:05 CET 2017
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Nov 28 11:19:21 2017 +0100| [63a6b5c36d0ec0073befd69de331f3541c7de638] | committer: Jean-Baptiste Kempf
direct3d11: split the format specific allocations and generic allocations
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=63a6b5c36d0ec0073befd69de331f3541c7de638
---
modules/video_output/win32/direct3d11.c | 97 +++++++++++++++++++--------------
1 file changed, 56 insertions(+), 41 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index d8e94b766c..4e31fca7d5 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -218,7 +218,8 @@ static void Direct3D11Destroy(vout_display_t *);
static int Direct3D11Open (vout_display_t *, video_format_t *);
static void Direct3D11Close(vout_display_t *);
-static int Direct3D11CreateResources (vout_display_t *, video_format_t *);
+static int Direct3D11CreateFormatResources (vout_display_t *, video_format_t *);
+static int Direct3D11CreateGenericResources(vout_display_t *);
static void Direct3D11DestroyResources(vout_display_t *);
static void Direct3D11DestroyPool(vout_display_t *);
@@ -1545,7 +1546,13 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
if (!sys->d3dregion_format)
sys->d3dregion_format = GetBlendableFormat(vd, VLC_CODEC_BGRA);
- if (Direct3D11CreateResources(vd, fmt)) {
+ if (Direct3D11CreateFormatResources(vd, fmt)) {
+ msg_Err(vd, "Failed to allocate format resources");
+ Direct3D11DestroyResources(vd);
+ return VLC_EGENERIC;
+ }
+
+ if (Direct3D11CreateGenericResources(vd)) {
msg_Err(vd, "Failed to allocate resources");
Direct3D11DestroyResources(vd);
return VLC_EGENERIC;
@@ -1976,7 +1983,53 @@ static bool CanUseTextureArray(vout_display_t *vd)
/* TODO : handle errors better
TODO : seperate out into smaller functions like createshaders */
-static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
+static int Direct3D11CreateFormatResources(vout_display_t *vd, video_format_t *fmt)
+{
+ vout_display_sys_t *sys = vd->sys;
+ HRESULT hr;
+
+ sys->legacy_shader = !CanUseTextureArray(vd);
+
+ hr = CompilePixelShader(vd, sys->picQuadConfig, fmt->transfer, fmt->b_color_range_full, &sys->picQuadPixelShader);
+ if (FAILED(hr))
+ {
+#ifdef HAVE_ID3D11VIDEODECODER
+ if (!sys->legacy_shader)
+ {
+ sys->legacy_shader = true;
+ msg_Dbg(vd, "fallback to legacy shader mode");
+ hr = CompilePixelShader(vd, sys->picQuadConfig, fmt->transfer, fmt->b_color_range_full, &sys->picQuadPixelShader);
+ }
+#endif
+ if (FAILED(hr))
+ {
+ msg_Err(vd, "Failed to create the pixel shader. (hr=0x%lX)", hr);
+ return VLC_EGENERIC;
+ }
+ }
+
+ if (!is_d3d11_opaque(fmt->i_chroma) || sys->legacy_shader)
+ {
+ sys->picQuad.i_width = fmt->i_visible_width;
+ sys->picQuad.i_height = fmt->i_visible_height;
+ }
+ else
+ {
+ sys->picQuad.i_width = fmt->i_width;
+ sys->picQuad.i_height = fmt->i_height;
+ }
+ if ( sys->picQuadConfig->formatTexture != DXGI_FORMAT_R8G8B8A8_UNORM &&
+ sys->picQuadConfig->formatTexture != DXGI_FORMAT_B5G6R5_UNORM )
+ {
+ sys->picQuad.i_width = (sys->picQuad.i_width + 0x01) & ~0x01;
+ sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
+ }
+
+ vd->info.is_slow = !is_d3d11_opaque(fmt->i_chroma) && sys->picQuadConfig->formatTexture != DXGI_FORMAT_UNKNOWN;
+ return VLC_SUCCESS;
+}
+
+static int Direct3D11CreateGenericResources(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
HRESULT hr;
@@ -2031,44 +2084,6 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
ID3D11DepthStencilState_Release(pDepthStencilState);
}
- sys->legacy_shader = !CanUseTextureArray(vd);
- vd->info.is_slow = !is_d3d11_opaque(fmt->i_chroma) && sys->picQuadConfig->formatTexture != DXGI_FORMAT_UNKNOWN;
-
- hr = CompilePixelShader(vd, sys->picQuadConfig, fmt->transfer, fmt->b_color_range_full, &sys->picQuadPixelShader);
- if (FAILED(hr))
- {
-#ifdef HAVE_ID3D11VIDEODECODER
- if (!sys->legacy_shader)
- {
- sys->legacy_shader = true;
- msg_Dbg(vd, "fallback to legacy shader mode");
- hr = CompilePixelShader(vd, sys->picQuadConfig, fmt->transfer, fmt->b_color_range_full, &sys->picQuadPixelShader);
- }
-#endif
- if (FAILED(hr))
- {
- msg_Err(vd, "Failed to create the pixel shader. (hr=0x%lX)", hr);
- return VLC_EGENERIC;
- }
- }
-
- if (!is_d3d11_opaque(vd->fmt.i_chroma) || sys->legacy_shader)
- {
- sys->picQuad.i_width = fmt->i_visible_width;
- sys->picQuad.i_height = fmt->i_visible_height;
- }
- else
- {
- sys->picQuad.i_width = fmt->i_width;
- sys->picQuad.i_height = fmt->i_height;
- }
- if ( sys->picQuadConfig->formatTexture != DXGI_FORMAT_R8G8B8A8_UNORM &&
- sys->picQuadConfig->formatTexture != DXGI_FORMAT_B5G6R5_UNORM )
- {
- sys->picQuad.i_width = (sys->picQuad.i_width + 0x01) & ~0x01;
- sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
- }
-
BEFORE_UPDATE_RECTS;
UpdateRects(vd, NULL, true);
AFTER_UPDATE_RECTS;
More information about the vlc-commits
mailing list