d3d11window: Don't create swapchain again per caps change

Creating swapchain is relatively heavy operation. If output dxgi format
is not being chagned, we don't need to destroy and create swachain again.
This commit is contained in:
Seungha Yang 2020-01-30 21:12:31 +09:00 committed by GStreamer Merge Bot
parent c1d2d9171d
commit 2aa9f0bd6c
2 changed files with 11 additions and 4 deletions

View file

@ -570,12 +570,15 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
swapchain_flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
}
if (window->swap_chain) {
gst_d3d11_device_lock (window->device);
/* release swapchain if render format is being changed */
gst_d3d11_device_lock (window->device);
if (window->swap_chain &&
window->render_format->dxgi_format != window->dxgi_format) {
gst_d3d11_window_release_resources (window->device, window);
gst_d3d11_device_unlock (window->device);
}
window->dxgi_format = window->render_format->dxgi_format;
window->aspect_ratio_n = aspect_ratio_n;
window->aspect_ratio_d = aspect_ratio_d;
@ -590,14 +593,17 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
window->height = height;
klass = GST_D3D11_WINDOW_GET_CLASS (window);
if (!klass->create_swap_chain (window, window->render_format->dxgi_format,
if (!window->swap_chain &&
!klass->create_swap_chain (window, window->dxgi_format,
width, height, swapchain_flags, &window->swap_chain)) {
GST_ERROR_OBJECT (window, "Cannot create swapchain");
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
"Cannot create swapchain");
gst_d3d11_device_unlock (window->device);
return FALSE;
}
gst_d3d11_device_unlock (window->device);
#if (DXGI_HEADER_VERSION >= 4)
{

View file

@ -105,6 +105,7 @@ struct _GstD3D11Window
IDXGISwapChain *swap_chain;
ID3D11RenderTargetView *rtv;
ID3D11VideoProcessorOutputView *pov;
DXGI_FORMAT dxgi_format;
GstBuffer *cached_buffer;
gboolean first_present;